Merge "Propagate headers from bazel to mixed builds" am: 92d4188c2b
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1912212 Change-Id: I80abd9375d5acc7b5b0a18de975227df239075fd
This commit is contained in:
@@ -461,11 +461,9 @@ var (
|
||||
"libprotobuf-cpp-full", "libprotobuf-cpp-lite", // Unsupported product&vendor suffix. b/204811222 and b/204810610.
|
||||
|
||||
// Depends on libprotobuf-cpp-*
|
||||
"libadb_crypto", "libadb_crypto_static", "libadb_pairing_connection",
|
||||
"libadb_pairing_connection",
|
||||
"libadb_pairing_connection_static",
|
||||
"libadb_pairing_server", "libadb_pairing_server_static",
|
||||
"libadb_protos_static", "libadb_protos",
|
||||
"libapp_processes_protos_lite",
|
||||
}
|
||||
|
||||
// Used for quicker lookups
|
||||
|
@@ -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 {
|
||||
|
@@ -257,12 +257,14 @@ cc_library {
|
||||
CcObjectFiles: []string{"foo.o"},
|
||||
Includes: []string{"include"},
|
||||
SystemIncludes: []string{"system_include"},
|
||||
Headers: []string{"foo.h"},
|
||||
RootDynamicLibraries: []string{"foo.so"},
|
||||
},
|
||||
"//foo/bar:bar_bp2build_cc_library_static": cquery.CcInfo{
|
||||
CcObjectFiles: []string{"foo.o"},
|
||||
Includes: []string{"include"},
|
||||
SystemIncludes: []string{"system_include"},
|
||||
Headers: []string{"foo.h"},
|
||||
RootStaticArchives: []string{"foo.a"},
|
||||
},
|
||||
},
|
||||
@@ -278,18 +280,25 @@ cc_library {
|
||||
expectedOutputFiles := []string{"outputbase/execroot/__main__/foo.a"}
|
||||
android.AssertDeepEquals(t, "output files", expectedOutputFiles, outputFiles.Strings())
|
||||
|
||||
flagExporter := ctx.ModuleProvider(staticFoo, FlagExporterInfoProvider).(FlagExporterInfo)
|
||||
android.AssertPathsRelativeToTopEquals(t, "exported include dirs", []string{"outputbase/execroot/__main__/include"}, flagExporter.IncludeDirs)
|
||||
android.AssertPathsRelativeToTopEquals(t, "exported system include dirs", []string{"outputbase/execroot/__main__/system_include"}, flagExporter.SystemIncludeDirs)
|
||||
android.AssertPathsRelativeToTopEquals(t, "exported headers", []string{"outputbase/execroot/__main__/foo.h"}, flagExporter.GeneratedHeaders)
|
||||
android.AssertPathsRelativeToTopEquals(t, "deps", []string{"outputbase/execroot/__main__/foo.h"}, flagExporter.Deps)
|
||||
|
||||
sharedFoo := ctx.ModuleForTests("foo", "android_arm_armv7-a-neon_shared").Module()
|
||||
outputFiles, err = sharedFoo.(android.OutputFileProducer).OutputFiles("")
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error getting cc_object outputfiles %s", err)
|
||||
t.Errorf("Unexpected error getting cc_library outputfiles %s", err)
|
||||
}
|
||||
expectedOutputFiles = []string{"outputbase/execroot/__main__/foo.so"}
|
||||
android.AssertDeepEquals(t, "output files", expectedOutputFiles, outputFiles.Strings())
|
||||
|
||||
entries := android.AndroidMkEntriesForTest(t, ctx, sharedFoo)[0]
|
||||
expectedFlags := []string{"-Ioutputbase/execroot/__main__/include", "-isystem outputbase/execroot/__main__/system_include"}
|
||||
gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
|
||||
android.AssertDeepEquals(t, "androidmk exported cflags", expectedFlags, gotFlags)
|
||||
flagExporter = ctx.ModuleProvider(sharedFoo, FlagExporterInfoProvider).(FlagExporterInfo)
|
||||
android.AssertPathsRelativeToTopEquals(t, "exported include dirs", []string{"outputbase/execroot/__main__/include"}, flagExporter.IncludeDirs)
|
||||
android.AssertPathsRelativeToTopEquals(t, "exported system include dirs", []string{"outputbase/execroot/__main__/system_include"}, flagExporter.SystemIncludeDirs)
|
||||
android.AssertPathsRelativeToTopEquals(t, "exported headers", []string{"outputbase/execroot/__main__/foo.h"}, flagExporter.GeneratedHeaders)
|
||||
android.AssertPathsRelativeToTopEquals(t, "deps", []string{"outputbase/execroot/__main__/foo.h"}, flagExporter.Deps)
|
||||
}
|
||||
|
||||
func TestLibraryVersionScript(t *testing.T) {
|
||||
|
@@ -384,9 +384,13 @@ func flagExporterInfoFromCcInfo(ctx android.ModuleContext, ccInfo cquery.CcInfo)
|
||||
|
||||
includes := android.PathsForBazelOut(ctx, ccInfo.Includes)
|
||||
systemIncludes := android.PathsForBazelOut(ctx, ccInfo.SystemIncludes)
|
||||
headers := android.PathsForBazelOut(ctx, ccInfo.Headers)
|
||||
|
||||
return FlagExporterInfo{
|
||||
IncludeDirs: android.FirstUniquePaths(includes),
|
||||
SystemIncludeDirs: android.FirstUniquePaths(systemIncludes),
|
||||
GeneratedHeaders: headers,
|
||||
// necessary to ensure generated headers are considered implicit deps of dependent actions
|
||||
Deps: headers,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user