Propagate headers from bazel to mixed builds
Bug: 208503274 Test: mixed_libc.sh Change-Id: I0be57f2a22f48be3a919208db4034d2bd03c18c0
This commit is contained in:
@@ -17,6 +17,7 @@ type CcInfo struct {
|
||||
CcStaticLibraryFiles []string
|
||||
Includes []string
|
||||
SystemIncludes []string
|
||||
Headers []string
|
||||
// Archives owned by the current target (not by its dependencies). These will
|
||||
// be a subset of OutputFiles. (or static libraries, this will be equal to OutputFiles,
|
||||
// but general cc_library will also have dynamic libraries in output files).
|
||||
@@ -105,6 +106,7 @@ cc_info = providers(target)["CcInfo"]
|
||||
|
||||
includes = cc_info.compilation_context.includes.to_list()
|
||||
system_includes = cc_info.compilation_context.system_includes.to_list()
|
||||
headers = [f.path for f in cc_info.compilation_context.headers.to_list()]
|
||||
|
||||
ccObjectFiles = []
|
||||
staticLibraries = []
|
||||
@@ -145,6 +147,7 @@ returns = [
|
||||
ccObjectFiles,
|
||||
includes,
|
||||
system_includes,
|
||||
headers,
|
||||
rootStaticArchives,
|
||||
rootDynamicLibraries,
|
||||
[toc_file]
|
||||
@@ -161,7 +164,7 @@ func (g getCcInfoType) ParseResult(rawString string) (CcInfo, error) {
|
||||
var ccObjects []string
|
||||
|
||||
splitString := strings.Split(rawString, "|")
|
||||
if expectedLen := 8; len(splitString) != expectedLen {
|
||||
if expectedLen := 9; len(splitString) != expectedLen {
|
||||
return CcInfo{}, fmt.Errorf("Expected %d items, got %q", expectedLen, splitString)
|
||||
}
|
||||
outputFilesString := splitString[0]
|
||||
@@ -172,15 +175,17 @@ func (g getCcInfoType) ParseResult(rawString string) (CcInfo, error) {
|
||||
ccObjects = splitOrEmpty(ccObjectsString, ", ")
|
||||
includes := splitOrEmpty(splitString[3], ", ")
|
||||
systemIncludes := splitOrEmpty(splitString[4], ", ")
|
||||
rootStaticArchives := splitOrEmpty(splitString[5], ", ")
|
||||
rootDynamicLibraries := splitOrEmpty(splitString[6], ", ")
|
||||
tocFile := splitString[7] // NOTE: Will be the empty string if there wasn't
|
||||
headers := splitOrEmpty(splitString[5], ", ")
|
||||
rootStaticArchives := splitOrEmpty(splitString[6], ", ")
|
||||
rootDynamicLibraries := splitOrEmpty(splitString[7], ", ")
|
||||
tocFile := splitString[8] // NOTE: Will be the empty string if there wasn't
|
||||
return CcInfo{
|
||||
OutputFiles: outputFiles,
|
||||
CcObjectFiles: ccObjects,
|
||||
CcStaticLibraryFiles: ccStaticLibraries,
|
||||
Includes: includes,
|
||||
SystemIncludes: systemIncludes,
|
||||
Headers: headers,
|
||||
RootStaticArchives: rootStaticArchives,
|
||||
RootDynamicLibraries: rootDynamicLibraries,
|
||||
TocFile: tocFile,
|
||||
|
@@ -71,13 +71,14 @@ func TestGetCcInfoParseResults(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
description: "no result",
|
||||
input: "|||||||",
|
||||
input: "||||||||",
|
||||
expectedOutput: CcInfo{
|
||||
OutputFiles: []string{},
|
||||
CcObjectFiles: []string{},
|
||||
CcStaticLibraryFiles: []string{},
|
||||
Includes: []string{},
|
||||
SystemIncludes: []string{},
|
||||
Headers: []string{},
|
||||
RootStaticArchives: []string{},
|
||||
RootDynamicLibraries: []string{},
|
||||
TocFile: "",
|
||||
@@ -85,13 +86,14 @@ func TestGetCcInfoParseResults(t *testing.T) {
|
||||
},
|
||||
{
|
||||
description: "only output",
|
||||
input: "test|||||||",
|
||||
input: "test||||||||",
|
||||
expectedOutput: CcInfo{
|
||||
OutputFiles: []string{"test"},
|
||||
CcObjectFiles: []string{},
|
||||
CcStaticLibraryFiles: []string{},
|
||||
Includes: []string{},
|
||||
SystemIncludes: []string{},
|
||||
Headers: []string{},
|
||||
RootStaticArchives: []string{},
|
||||
RootDynamicLibraries: []string{},
|
||||
TocFile: "",
|
||||
@@ -99,13 +101,14 @@ func TestGetCcInfoParseResults(t *testing.T) {
|
||||
},
|
||||
{
|
||||
description: "all items set",
|
||||
input: "out1, out2|static_lib1, static_lib2|object1, object2|., dir/subdir|system/dir, system/other/dir|rootstaticarchive1|rootdynamiclibrary1|lib.so.toc",
|
||||
input: "out1, out2|static_lib1, static_lib2|object1, object2|., dir/subdir|system/dir, system/other/dir|dir/subdir/hdr.h|rootstaticarchive1|rootdynamiclibrary1|lib.so.toc",
|
||||
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"},
|
||||
Headers: []string{"dir/subdir/hdr.h"},
|
||||
RootStaticArchives: []string{"rootstaticarchive1"},
|
||||
RootDynamicLibraries: []string{"rootdynamiclibrary1"},
|
||||
TocFile: "lib.so.toc",
|
||||
@@ -115,13 +118,13 @@ func TestGetCcInfoParseResults(t *testing.T) {
|
||||
description: "too few result splits",
|
||||
input: "|",
|
||||
expectedOutput: CcInfo{},
|
||||
expectedErrorMessage: fmt.Sprintf("Expected %d items, got %q", 8, []string{"", ""}),
|
||||
expectedErrorMessage: fmt.Sprintf("Expected %d items, got %q", 9, []string{"", ""}),
|
||||
},
|
||||
{
|
||||
description: "too many result splits",
|
||||
input: strings.Repeat("|", 8),
|
||||
input: strings.Repeat("|", 50),
|
||||
expectedOutput: CcInfo{},
|
||||
expectedErrorMessage: fmt.Sprintf("Expected %d items, got %q", 8, make([]string, 9)),
|
||||
expectedErrorMessage: fmt.Sprintf("Expected %d items, got %q", 9, make([]string, 51)),
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
|
Reference in New Issue
Block a user