Incorporate cc_library_headers into mixed builds
Test: go soong tests Test: bp2build generate & sync; mixed build libc; mixed build su (su is an Android.mk target that relies on converted a cc_library_headers) Bug: 181552740 Change-Id: I9efd587970551fd41f642a208f0aa0a80e8694e0
This commit is contained in:
@@ -14,6 +14,8 @@ type CcInfo struct {
|
||||
OutputFiles []string
|
||||
CcObjectFiles []string
|
||||
CcStaticLibraryFiles []string
|
||||
Includes []string
|
||||
SystemIncludes []string
|
||||
}
|
||||
|
||||
type getOutputFilesRequestType struct{}
|
||||
@@ -63,6 +65,9 @@ func (g getCcInfoType) StarlarkFunctionBody() string {
|
||||
return `
|
||||
outputFiles = [f.path for f in target.files.to_list()]
|
||||
|
||||
includes = providers(target)["CcInfo"].compilation_context.includes.to_list()
|
||||
system_includes = providers(target)["CcInfo"].compilation_context.system_includes.to_list()
|
||||
|
||||
ccObjectFiles = []
|
||||
staticLibraries = []
|
||||
linker_inputs = providers(target)["CcInfo"].linking_context.linker_inputs.to_list()
|
||||
@@ -78,6 +83,8 @@ returns = [
|
||||
outputFiles,
|
||||
staticLibraries,
|
||||
ccObjectFiles,
|
||||
includes,
|
||||
system_includes,
|
||||
]
|
||||
|
||||
return "|".join([", ".join(r) for r in returns])`
|
||||
@@ -91,7 +98,7 @@ func (g getCcInfoType) ParseResult(rawString string) (CcInfo, error) {
|
||||
var ccObjects []string
|
||||
|
||||
splitString := strings.Split(rawString, "|")
|
||||
if expectedLen := 3; len(splitString) != expectedLen {
|
||||
if expectedLen := 5; len(splitString) != expectedLen {
|
||||
return CcInfo{}, fmt.Errorf("Expected %d items, got %q", expectedLen, splitString)
|
||||
}
|
||||
outputFilesString := splitString[0]
|
||||
@@ -100,10 +107,14 @@ func (g getCcInfoType) ParseResult(rawString string) (CcInfo, error) {
|
||||
outputFiles = splitOrEmpty(outputFilesString, ", ")
|
||||
ccStaticLibraries := splitOrEmpty(ccStaticLibrariesString, ", ")
|
||||
ccObjects = splitOrEmpty(ccObjectsString, ", ")
|
||||
includes := splitOrEmpty(splitString[3], ", ")
|
||||
systemIncludes := splitOrEmpty(splitString[4], ", ")
|
||||
return CcInfo{
|
||||
OutputFiles: outputFiles,
|
||||
CcObjectFiles: ccObjects,
|
||||
CcStaticLibraryFiles: ccStaticLibraries,
|
||||
Includes: includes,
|
||||
SystemIncludes: systemIncludes,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package cquery
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -45,42 +46,48 @@ func TestGetCcInfoParseResults(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
description: "no result",
|
||||
input: "||",
|
||||
input: "||||",
|
||||
expectedOutput: CcInfo{
|
||||
OutputFiles: []string{},
|
||||
CcObjectFiles: []string{},
|
||||
CcStaticLibraryFiles: []string{},
|
||||
Includes: []string{},
|
||||
SystemIncludes: []string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "only output",
|
||||
input: "test||",
|
||||
input: "test||||",
|
||||
expectedOutput: CcInfo{
|
||||
OutputFiles: []string{"test"},
|
||||
CcObjectFiles: []string{},
|
||||
CcStaticLibraryFiles: []string{},
|
||||
Includes: []string{},
|
||||
SystemIncludes: []string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "all items set",
|
||||
input: "out1, out2|static_lib1, static_lib2|object1, object2",
|
||||
input: "out1, out2|static_lib1, static_lib2|object1, object2|., dir/subdir|system/dir, system/other/dir",
|
||||
expectedOutput: CcInfo{
|
||||
OutputFiles: []string{"out1", "out2"},
|
||||
CcObjectFiles: []string{"object1", "object2"},
|
||||
CcStaticLibraryFiles: []string{"static_lib1", "static_lib2"},
|
||||
Includes: []string{".", "dir/subdir"},
|
||||
SystemIncludes: []string{"system/dir", "system/other/dir"},
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "too few result splits",
|
||||
input: "|",
|
||||
expectedOutput: CcInfo{},
|
||||
expectedErrorMessage: fmt.Sprintf("Expected %d items, got %q", 3, []string{"", ""}),
|
||||
expectedErrorMessage: fmt.Sprintf("Expected %d items, got %q", 5, []string{"", ""}),
|
||||
},
|
||||
{
|
||||
description: "too many result splits",
|
||||
input: "|||",
|
||||
input: strings.Repeat("|", 8),
|
||||
expectedOutput: CcInfo{},
|
||||
expectedErrorMessage: fmt.Sprintf("Expected %d items, got %q", 3, []string{"", "", "", ""}),
|
||||
expectedErrorMessage: fmt.Sprintf("Expected %d items, got %q", 5, make([]string, 9)),
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
|
Reference in New Issue
Block a user