Merge "Introduce flat deps info list." into rvc-dev
diff --git a/android/mutator.go b/android/mutator.go
index 10a815a..247eb4d 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -81,11 +81,53 @@
var preArch = []RegisterMutatorFunc{
RegisterNamespaceMutator,
+
// Rename package module types.
+ //
+ // The package module type does not have a name property, instead its name is determined
+ // by the location of the containing .bp file relative to the root of the file structure
+ // being built by Soong. Unfortunately, due to limitations in LoadHook the module has to
+ // be given a synthetic temporary name which is then fixed up by these mutators.
RegisterPackageRenamer,
+
+ // Create an association between prebuilt modules and their corresponding source
+ // modules (if any).
RegisterPrebuiltsPreArchMutators,
+
+ // Check the visibility rules are valid.
+ //
+ // This must run after the package renamer mutators so that any issues found during
+ // validation of the package's default_visibility property are reported using the
+ // correct package name and not the synthetic name.
+ //
+ // This must also be run before defaults mutators as the rules for validation are
+ // different before checking the rules than they are afterwards. e.g.
+ // visibility: ["//visibility:private", "//visibility:public"]
+ // would be invalid if specified in a module definition but is valid if it results
+ // from something like this:
+ //
+ // defaults {
+ // name: "defaults",
+ // // Be inaccessible outside a package by default.
+ // visibility: ["//visibility:private"]
+ // }
+ //
+ // defaultable_module {
+ // name: "defaultable_module",
+ // defaults: ["defaults"],
+ // // Override the default.
+ // visibility: ["//visibility:public"]
+ // }
+ //
RegisterVisibilityRuleChecker,
+
+ // Apply properties from defaults modules to the referencing modules.
RegisterDefaultsPreArchMutators,
+
+ // Gather the visibility rules for all modules for us during visibility enforcement.
+ //
+ // This must come after the defaults mutators to ensure that any visibility supplied
+ // in a defaults module has been successfully applied before the rules are gathered.
RegisterVisibilityRuleGatherer,
}
diff --git a/android/sdk.go b/android/sdk.go
index 2fdaf35..6f62f55 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -313,10 +313,11 @@
// SdkAware and be added with an SdkMemberTypeDependencyTag tag.
HasTransitiveSdkMembers() bool
- // Add dependencies from the SDK module to all the variants the member
- // contributes to the SDK. The exact set of variants required is determined
- // by the SDK and its properties. The dependencies must be added with the
- // supplied tag.
+ // Add dependencies from the SDK module to all the module variants the member
+ // type contributes to the SDK. `names` is the list of module names given in
+ // the member type property (as returned by SdkPropertyName()) in the SDK
+ // module. The exact set of variants required is determined by the SDK and its
+ // properties. The dependencies must be added with the supplied tag.
//
// The BottomUpMutatorContext provided is for the SDK module.
AddDependencies(mctx BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string)
diff --git a/cc/binary_sdk_member.go b/cc/binary_sdk_member.go
index 9b3235c..88ac513 100644
--- a/cc/binary_sdk_member.go
+++ b/cc/binary_sdk_member.go
@@ -18,6 +18,7 @@
"path/filepath"
"android/soong/android"
+
"github.com/google/blueprint"
)
@@ -110,7 +111,7 @@
ccModule := variant.(*Module)
p.archType = ccModule.Target().Arch.ArchType.String()
- p.outputFile = ccModule.OutputFile().Path()
+ p.outputFile = getRequiredMemberOutputFile(ctx, ccModule)
if ccModule.linker != nil {
specifiedDeps := specifiedDeps{}
@@ -137,7 +138,9 @@
propertySet.AddPropertyWithTag("shared_libs", p.SharedLibs, builder.SdkMemberReferencePropertyTag(false))
}
- if len(p.SystemSharedLibs) > 0 {
+ // SystemSharedLibs needs to be propagated if it's a list, even if it's empty,
+ // so check for non-nil instead of nonzero length.
+ if p.SystemSharedLibs != nil {
propertySet.AddPropertyWithTag("system_shared_libs", p.SystemSharedLibs, builder.SdkMemberReferencePropertyTag(false))
}
}
diff --git a/cc/cc.go b/cc/cc.go
index b237935..ec0f1a0 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -396,7 +396,7 @@
type specifiedDeps struct {
sharedLibs []string
- systemSharedLibs []string
+ systemSharedLibs []string // Note nil and [] are semantically distinct.
}
type installer interface {
diff --git a/cc/config/clang.go b/cc/config/clang.go
index d849906..2e0b241 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -48,6 +48,8 @@
"-Wunused-but-set-parameter",
"-Wunused-but-set-variable",
"-fdiagnostics-color",
+ // http://b/153759688
+ "-fuse-init-array",
// arm + arm64 + mips + mips64
"-fgcse-after-reload",
@@ -120,9 +122,6 @@
// color codes if it is not running in a terminal.
"-fcolor-diagnostics",
- // http://b/68236239 Allow 0/NULL instead of using nullptr everywhere.
- "-Wno-zero-as-null-pointer-constant",
-
// Warnings from clang-7.0
"-Wno-sign-compare",
@@ -173,6 +172,17 @@
"-Wno-int-in-bool-context", // http://b/148287349
"-Wno-sizeof-array-div", // http://b/148815709
"-Wno-tautological-overlap-compare", // http://b/148815696
+ // New warnings to be fixed after clang-r383902.
+ "-Wno-deprecated-copy", // http://b/153746672
+ "-Wno-range-loop-construct", // http://b/153747076
+ "-Wno-misleading-indentation", // http://b/153746954
+ "-Wno-zero-as-null-pointer-constant", // http://b/68236239
+ "-Wno-deprecated-anon-enum-enum-conversion", // http://b/153746485
+ "-Wno-deprecated-enum-enum-conversion", // http://b/153746563
+ "-Wno-string-compare", // http://b/153764102
+ "-Wno-enum-enum-conversion", // http://b/154138986
+ "-Wno-enum-float-conversion", // http://b/154255917
+ "-Wno-pessimizing-move", // http://b/154270751
}, " "))
// Extra cflags for external third-party projects to disable warnings that
diff --git a/cc/config/global.go b/cc/config/global.go
index d85ac5f..d5ecf7f 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -128,8 +128,8 @@
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
- ClangDefaultVersion = "clang-r377782d"
- ClangDefaultShortVersion = "10.0.6"
+ ClangDefaultVersion = "clang-r383902"
+ ClangDefaultShortVersion = "11.0.1"
// Directories with warnings from Android.bp files.
WarningAllowedProjects = []string{
diff --git a/cc/library.go b/cc/library.go
index ce814b1..8d4992c 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -376,7 +376,7 @@
useCoreVariant bool
checkSameCoreVariant bool
- // Decorated interafaces
+ // Decorated interfaces
*baseCompiler
*baseLinker
*baseInstaller
@@ -749,10 +749,12 @@
func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
if library.static() {
+ // Compare with nil because an empty list needs to be propagated.
if library.StaticProperties.Static.System_shared_libs != nil {
library.baseLinker.Properties.System_shared_libs = library.StaticProperties.Static.System_shared_libs
}
} else if library.shared() {
+ // Compare with nil because an empty list needs to be propagated.
if library.SharedProperties.Shared.System_shared_libs != nil {
library.baseLinker.Properties.System_shared_libs = library.SharedProperties.Shared.System_shared_libs
}
@@ -828,10 +830,21 @@
}
specifiedDeps.sharedLibs = append(specifiedDeps.sharedLibs, properties.Shared_libs...)
- specifiedDeps.systemSharedLibs = append(specifiedDeps.systemSharedLibs, properties.System_shared_libs...)
+
+ // Must distinguish nil and [] in system_shared_libs - ensure that [] in
+ // either input list doesn't come out as nil.
+ if specifiedDeps.systemSharedLibs == nil {
+ specifiedDeps.systemSharedLibs = properties.System_shared_libs
+ } else {
+ specifiedDeps.systemSharedLibs = append(specifiedDeps.systemSharedLibs, properties.System_shared_libs...)
+ }
specifiedDeps.sharedLibs = android.FirstUniqueStrings(specifiedDeps.sharedLibs)
- specifiedDeps.systemSharedLibs = android.FirstUniqueStrings(specifiedDeps.systemSharedLibs)
+ if len(specifiedDeps.systemSharedLibs) > 0 {
+ // Skip this if systemSharedLibs is either nil or [], to ensure they are
+ // retained.
+ specifiedDeps.systemSharedLibs = android.FirstUniqueStrings(specifiedDeps.systemSharedLibs)
+ }
return specifiedDeps
}
@@ -1384,6 +1397,8 @@
len(sharedCompiler.SharedProperties.Shared.Static_libs) == 0 &&
len(staticCompiler.StaticProperties.Static.Shared_libs) == 0 &&
len(sharedCompiler.SharedProperties.Shared.Shared_libs) == 0 &&
+ // Compare System_shared_libs properties with nil because empty lists are
+ // semantically significant for them.
staticCompiler.StaticProperties.Static.System_shared_libs == nil &&
sharedCompiler.SharedProperties.Shared.System_shared_libs == nil {
diff --git a/cc/library_headers.go b/cc/library_headers.go
index 88cf7af..b7ab390 100644
--- a/cc/library_headers.go
+++ b/cc/library_headers.go
@@ -29,7 +29,7 @@
SupportsSdk: true,
},
prebuiltModuleType: "cc_prebuilt_library_headers",
- linkTypes: nil,
+ noOutputFiles: true,
}
func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) {
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 566bdce..2c8e311 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -18,6 +18,7 @@
"path/filepath"
"android/soong/android"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -63,7 +64,10 @@
prebuiltModuleType string
- // The set of link types supported, set of "static", "shared".
+ noOutputFiles bool // True if there are no srcs files.
+
+ // The set of link types supported. A set of "static", "shared", or nil to
+ // skip link type variations.
linkTypes []string
}
@@ -208,7 +212,9 @@
outputProperties.AddPropertyWithTag("shared_libs", libInfo.SharedLibs, builder.SdkMemberReferencePropertyTag(false))
}
- if len(libInfo.SystemSharedLibs) > 0 {
+ // SystemSharedLibs needs to be propagated if it's a list, even if it's empty,
+ // so check for non-nil instead of nonzero length.
+ if libInfo.SystemSharedLibs != nil {
outputProperties.AddPropertyWithTag("system_shared_libs", libInfo.SystemSharedLibs, builder.SdkMemberReferencePropertyTag(false))
}
@@ -263,6 +269,11 @@
for property, dirs := range includeDirs {
outputProperties.AddProperty(property, dirs)
}
+
+ if len(libInfo.StubsVersion) > 0 {
+ stubsSet := outputProperties.AddPropertySet("stubs")
+ stubsSet.AddProperty("versions", []string{libInfo.StubsVersion})
+ }
}
const (
@@ -323,11 +334,16 @@
// This field is exported as its contents may not be arch specific.
SharedLibs []string
- // The set of system shared libraries
+ // The set of system shared libraries. Note nil and [] are semantically
+ // distinct - see BaseLinkerProperties.System_shared_libs.
//
// This field is exported as its contents may not be arch specific.
SystemSharedLibs []string
+ // The specific stubs version for the lib variant, or empty string if stubs
+ // are not in use.
+ StubsVersion string
+
// outputFile is not exported as it is always arch specific.
outputFile android.Path
}
@@ -337,8 +353,8 @@
// If the library has some link types then it produces an output binary file, otherwise it
// is header only.
- if p.memberType.linkTypes != nil {
- p.outputFile = ccModule.OutputFile().Path()
+ if !p.memberType.noOutputFiles {
+ p.outputFile = getRequiredMemberOutputFile(ctx, ccModule)
}
// Separate out the generated include dirs (which are arch specific) from the
@@ -359,10 +375,28 @@
specifiedDeps := specifiedDeps{}
specifiedDeps = ccModule.linker.linkerSpecifiedDeps(specifiedDeps)
- p.SharedLibs = specifiedDeps.sharedLibs
+ if !ccModule.HasStubsVariants() {
+ // Propagate dynamic dependencies for implementation libs, but not stubs.
+ p.SharedLibs = specifiedDeps.sharedLibs
+ }
p.SystemSharedLibs = specifiedDeps.systemSharedLibs
}
p.exportedGeneratedHeaders = ccModule.ExportedGeneratedHeaders()
+
+ if ccModule.HasStubsVariants() {
+ p.StubsVersion = ccModule.StubsVersion()
+ }
+}
+
+func getRequiredMemberOutputFile(ctx android.SdkMemberContext, ccModule *Module) android.Path {
+ var path android.Path
+ outputFile := ccModule.OutputFile()
+ if outputFile.Valid() {
+ path = outputFile.Path()
+ } else {
+ ctx.SdkModuleContext().ModuleErrorf("member variant %s does not have a valid output file", ccModule)
+ }
+ return path
}
func (p *nativeLibInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
diff --git a/cc/linker.go b/cc/linker.go
index 9b2c1e7..d56c733 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -503,7 +503,15 @@
func (linker *baseLinker) linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps {
specifiedDeps.sharedLibs = append(specifiedDeps.sharedLibs, linker.Properties.Shared_libs...)
- specifiedDeps.systemSharedLibs = append(specifiedDeps.systemSharedLibs, linker.Properties.System_shared_libs...)
+
+ // Must distinguish nil and [] in system_shared_libs - ensure that [] in
+ // either input list doesn't come out as nil.
+ if specifiedDeps.systemSharedLibs == nil {
+ specifiedDeps.systemSharedLibs = linker.Properties.System_shared_libs
+ } else {
+ specifiedDeps.systemSharedLibs = append(specifiedDeps.systemSharedLibs, linker.Properties.System_shared_libs...)
+ }
+
return specifiedDeps
}
diff --git a/cc/object.go b/cc/object.go
index ad31d09..19decec 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -26,6 +26,16 @@
func init() {
android.RegisterModuleType("cc_object", ObjectFactory)
+ android.RegisterSdkMemberType(ccObjectSdkMemberType)
+}
+
+var ccObjectSdkMemberType = &librarySdkMemberType{
+ SdkMemberTypeBase: android.SdkMemberTypeBase{
+ PropertyName: "native_objects",
+ SupportsSdk: true,
+ },
+ prebuiltModuleType: "cc_prebuilt_object",
+ linkTypes: nil,
}
type objectLinker struct {
@@ -47,12 +57,18 @@
Linker_script *string `android:"path,arch_variant"`
}
+func newObject() *Module {
+ module := newBaseModule(android.HostAndDeviceSupported, android.MultilibBoth)
+ module.sanitize = &sanitize{}
+ module.stl = &stl{}
+ return module
+}
+
// cc_object runs the compiler without running the linker. It is rarely
// necessary, but sometimes used to generate .s files from .c files to use as
// input to a cc_genrule module.
func ObjectFactory() android.Module {
- module := newBaseModule(android.HostAndDeviceSupported, android.MultilibBoth)
- module.sanitize = &sanitize{}
+ module := newObject()
module.linker = &objectLinker{
baseLinker: NewBaseLinker(module.sanitize),
}
@@ -61,7 +77,7 @@
// Clang's address-significance tables are incompatible with ld -r.
module.compiler.appendCflags([]string{"-fno-addrsig"})
- module.stl = &stl{}
+ module.sdkMemberTypes = []android.SdkMemberType{ccObjectSdkMemberType}
return module.Init()
}
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 3dbd3e3..2ef3195 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -26,6 +26,7 @@
ctx.RegisterModuleType("cc_prebuilt_library", PrebuiltLibraryFactory)
ctx.RegisterModuleType("cc_prebuilt_library_shared", PrebuiltSharedLibraryFactory)
ctx.RegisterModuleType("cc_prebuilt_library_static", PrebuiltStaticLibraryFactory)
+ ctx.RegisterModuleType("cc_prebuilt_object", prebuiltObjectFactory)
ctx.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
}
@@ -222,6 +223,50 @@
return module, library
}
+type prebuiltObjectProperties struct {
+ Srcs []string `android:"path,arch_variant"`
+}
+
+type prebuiltObjectLinker struct {
+ android.Prebuilt
+ objectLinker
+
+ properties prebuiltObjectProperties
+}
+
+func (p *prebuiltObjectLinker) prebuilt() *android.Prebuilt {
+ return &p.Prebuilt
+}
+
+var _ prebuiltLinkerInterface = (*prebuiltObjectLinker)(nil)
+
+func (p *prebuiltObjectLinker) link(ctx ModuleContext,
+ flags Flags, deps PathDeps, objs Objects) android.Path {
+ if len(p.properties.Srcs) > 0 {
+ return p.Prebuilt.SingleSourcePath(ctx)
+ }
+ return nil
+}
+
+func newPrebuiltObject() *Module {
+ module := newObject()
+ prebuilt := &prebuiltObjectLinker{
+ objectLinker: objectLinker{
+ baseLinker: NewBaseLinker(nil),
+ },
+ }
+ module.linker = prebuilt
+ module.AddProperties(&prebuilt.properties)
+ android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
+ android.InitSdkAwareModule(module)
+ return module
+}
+
+func prebuiltObjectFactory() android.Module {
+ module := newPrebuiltObject()
+ return module.Init()
+}
+
type prebuiltBinaryLinker struct {
*binaryDecorator
prebuiltLinker
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 0eca97f..242d835 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -73,6 +73,15 @@
srcs: ["libf.so"],
},
}
+
+ cc_object {
+ name: "crtx",
+ }
+
+ cc_prebuilt_object {
+ name: "crtx",
+ srcs: ["crtx.o"],
+ }
`
ctx := testPrebuilt(t, bp)
@@ -84,6 +93,7 @@
libe := ctx.ModuleForTests("libe", "android_arm64_armv8-a_static").Module()
libfStatic := ctx.ModuleForTests("libf", "android_arm64_armv8-a_static").Module()
libfShared := ctx.ModuleForTests("libf", "android_arm64_armv8-a_shared").Module()
+ crtx := ctx.ModuleForTests("crtx", "android_arm64_armv8-a").Module()
prebuiltLiba := ctx.ModuleForTests("prebuilt_liba", "android_arm64_armv8-a_shared").Module()
prebuiltLibb := ctx.ModuleForTests("prebuilt_libb", "android_arm64_armv8-a_static").Module()
@@ -91,6 +101,7 @@
prebuiltLibe := ctx.ModuleForTests("prebuilt_libe", "android_arm64_armv8-a_static").Module()
prebuiltLibfStatic := ctx.ModuleForTests("prebuilt_libf", "android_arm64_armv8-a_static").Module()
prebuiltLibfShared := ctx.ModuleForTests("prebuilt_libf", "android_arm64_armv8-a_shared").Module()
+ prebuiltCrtx := ctx.ModuleForTests("prebuilt_crtx", "android_arm64_armv8-a").Module()
hasDep := func(m android.Module, wantDep android.Module) bool {
t.Helper()
@@ -126,9 +137,14 @@
if !hasDep(libfShared, prebuiltLibfShared) {
t.Errorf("libf shared missing dependency on prebuilt_libf")
}
+
+ if !hasDep(crtx, prebuiltCrtx) {
+ t.Errorf("crtx missing dependency on prebuilt_crtx")
+ }
}
func testPrebuilt(t *testing.T, bp string) *android.TestContext {
+
fs := map[string][]byte{
"liba.so": nil,
"libb.a": nil,
@@ -136,6 +152,7 @@
"libe.a": nil,
"libf.a": nil,
"libf.so": nil,
+ "crtx.o": nil,
}
config := TestConfig(buildDir, android.Android, nil, bp, fs)
ctx := CreateTestContext()
diff --git a/cc/tidy.go b/cc/tidy.go
index cfb5b68..364e56c 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -121,6 +121,12 @@
// many local projects enable cert-* checks, which
// trigger bugprone-reserved-identifier.
tidyChecks = tidyChecks + ",-bugprone-reserved-identifier*,-cert-dcl51-cpp,-cert-dcl37-c"
+ // http://b/153757728
+ tidyChecks = tidyChecks + ",-readability-qualified-auto"
+ // http://b/155034563
+ tidyChecks = tidyChecks + ",-bugprone-signed-char-misuse"
+ // http://b/155034972
+ tidyChecks = tidyChecks + ",-bugprone-branch-clone"
flags.TidyFlags = append(flags.TidyFlags, tidyChecks)
if len(tidy.Properties.Tidy_checks_as_errors) > 0 {
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 0a4e16d..733f7ac 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -32,6 +32,7 @@
"arm64/include/Arm64Test.h": nil,
"libfoo.so": nil,
"aidl/foo/bar/Test.aidl": nil,
+ "some/where/stubslib.map.txt": nil,
}
return testSdkWithFs(t, bp, fs)
}
@@ -48,7 +49,6 @@
cc_library_shared {
name: "sdkmember",
srcs: ["Test.cpp"],
- system_shared_libs: [],
stl: "none",
}
`)
@@ -178,13 +178,11 @@
cc_library_host_shared {
name: "sdkshared",
- system_shared_libs: [],
stl: "none",
}
cc_library_host_static {
name: "sdkstatic",
- system_shared_libs: [],
stl: "none",
}
`)
@@ -201,30 +199,83 @@
cc_library_shared {
name: "sdkshared",
- system_shared_libs: [],
stl: "none",
}
cc_library_static {
name: "sdkstatic",
- system_shared_libs: [],
stl: "none",
}
cc_library {
name: "sdkboth1",
- system_shared_libs: [],
stl: "none",
}
cc_library {
name: "sdkboth2",
- system_shared_libs: [],
stl: "none",
}
`)
}
+func TestSnapshotWithObject(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_objects: ["crtobj"],
+ }
+
+ cc_object {
+ name: "crtobj",
+ stl: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_object {
+ name: "mysdk_crtobj@current",
+ sdk_member_name: "crtobj",
+ stl: "none",
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/crtobj.o"],
+ },
+ arm: {
+ srcs: ["arm/lib/crtobj.o"],
+ },
+ },
+}
+
+cc_prebuilt_object {
+ name: "crtobj",
+ prefer: false,
+ stl: "none",
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/crtobj.o"],
+ },
+ arm: {
+ srcs: ["arm/lib/crtobj.o"],
+ },
+ },
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ native_objects: ["mysdk_crtobj@current"],
+}
+`),
+ checkAllCopyRules(`
+.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
+.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
+`),
+ )
+}
+
func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
result := testSdkWithCc(t, `
sdk {
@@ -238,7 +289,6 @@
"Test.cpp",
],
export_include_dirs: ["include"],
- system_shared_libs: [],
stl: "none",
}
@@ -248,7 +298,6 @@
"Test.cpp",
],
export_include_dirs: ["include"],
- system_shared_libs: [],
stl: "none",
}
`)
@@ -285,7 +334,6 @@
export_system_include_dirs: ["arm64/include"],
},
},
- system_shared_libs: [],
stl: "none",
}
`)
@@ -353,7 +401,6 @@
"Test.cpp",
],
compile_multilib: "both",
- system_shared_libs: [],
stl: "none",
}
`)
@@ -428,7 +475,6 @@
"Test.cpp",
],
compile_multilib: "both",
- system_shared_libs: [],
stl: "none",
target: {
windows: {
@@ -529,7 +575,6 @@
aidl: {
export_aidl_headers: true,
},
- system_shared_libs: [],
stl: "none",
}
`)
@@ -616,7 +661,6 @@
srcs: [
"Test.cpp",
],
- system_shared_libs: [],
stl: "none",
}
@@ -657,7 +701,6 @@
},
},
},
- system_shared_libs: [],
stl: "none",
}
`)
@@ -807,7 +850,6 @@
aidl: {
export_aidl_headers: true,
},
- system_shared_libs: [],
stl: "none",
sdk_version: "minimum",
}
@@ -903,7 +945,6 @@
srcs: [
"Test.cpp",
],
- system_shared_libs: [],
stl: "none",
target: {
windows: {
@@ -993,7 +1034,6 @@
aidl: {
export_aidl_headers: true,
},
- system_shared_libs: [],
stl: "none",
}
`)
@@ -1080,7 +1120,6 @@
aidl: {
export_aidl_headers: true,
},
- system_shared_libs: [],
stl: "none",
}
`)
@@ -1162,7 +1201,6 @@
"Test.cpp",
],
export_include_dirs: ["include"],
- system_shared_libs: [],
stl: "none",
}
`)
@@ -1265,7 +1303,6 @@
aidl: {
export_aidl_headers: true,
},
- system_shared_libs: [],
stl: "none",
}
`)
@@ -1336,7 +1373,6 @@
cc_library_headers {
name: "mynativeheaders",
export_include_dirs: ["include"],
- system_shared_libs: [],
stl: "none",
}
`)
@@ -1387,7 +1423,6 @@
device_supported: false,
host_supported: true,
export_include_dirs: ["include"],
- system_shared_libs: [],
stl: "none",
}
`)
@@ -1441,7 +1476,6 @@
cc_library_headers {
name: "mynativeheaders",
host_supported: true,
- system_shared_libs: [],
stl: "none",
export_system_include_dirs: ["include"],
target: {
@@ -1504,3 +1538,270 @@
`),
)
}
+
+func TestSystemSharedLibPropagation(t *testing.T) {
+ // b/145598135 - Generating host snapshots for anything other than linux is not supported.
+ SkipIfNotLinux(t)
+
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_shared_libs: ["sslnil", "sslempty", "sslnonempty"],
+ }
+
+ cc_library {
+ name: "sslnil",
+ host_supported: true,
+ }
+
+ cc_library {
+ name: "sslempty",
+ system_shared_libs: [],
+ }
+
+ cc_library {
+ name: "sslnonempty",
+ system_shared_libs: ["sslnil"],
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mysdk_sslnil@current",
+ sdk_member_name: "sslnil",
+ installable: false,
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/sslnil.so"],
+ },
+ arm: {
+ srcs: ["arm/lib/sslnil.so"],
+ },
+ },
+}
+
+cc_prebuilt_library_shared {
+ name: "sslnil",
+ prefer: false,
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/sslnil.so"],
+ },
+ arm: {
+ srcs: ["arm/lib/sslnil.so"],
+ },
+ },
+}
+
+cc_prebuilt_library_shared {
+ name: "mysdk_sslempty@current",
+ sdk_member_name: "sslempty",
+ installable: false,
+ system_shared_libs: [],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/sslempty.so"],
+ },
+ arm: {
+ srcs: ["arm/lib/sslempty.so"],
+ },
+ },
+}
+
+cc_prebuilt_library_shared {
+ name: "sslempty",
+ prefer: false,
+ system_shared_libs: [],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/sslempty.so"],
+ },
+ arm: {
+ srcs: ["arm/lib/sslempty.so"],
+ },
+ },
+}
+
+cc_prebuilt_library_shared {
+ name: "mysdk_sslnonempty@current",
+ sdk_member_name: "sslnonempty",
+ installable: false,
+ system_shared_libs: ["mysdk_sslnil@current"],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/sslnonempty.so"],
+ },
+ arm: {
+ srcs: ["arm/lib/sslnonempty.so"],
+ },
+ },
+}
+
+cc_prebuilt_library_shared {
+ name: "sslnonempty",
+ prefer: false,
+ system_shared_libs: ["sslnil"],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/sslnonempty.so"],
+ },
+ arm: {
+ srcs: ["arm/lib/sslnonempty.so"],
+ },
+ },
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ native_shared_libs: [
+ "mysdk_sslnil@current",
+ "mysdk_sslempty@current",
+ "mysdk_sslnonempty@current",
+ ],
+}
+`))
+
+ result = testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ host_supported: true,
+ native_shared_libs: ["sslvariants"],
+ }
+
+ cc_library {
+ name: "sslvariants",
+ host_supported: true,
+ target: {
+ android: {
+ system_shared_libs: [],
+ },
+ },
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mysdk_sslvariants@current",
+ sdk_member_name: "sslvariants",
+ host_supported: true,
+ installable: false,
+ target: {
+ android: {
+ system_shared_libs: [],
+ },
+ android_arm64: {
+ srcs: ["android/arm64/lib/sslvariants.so"],
+ },
+ android_arm: {
+ srcs: ["android/arm/lib/sslvariants.so"],
+ },
+ linux_glibc_x86_64: {
+ srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
+ },
+ linux_glibc_x86: {
+ srcs: ["linux_glibc/x86/lib/sslvariants.so"],
+ },
+ },
+}
+
+cc_prebuilt_library_shared {
+ name: "sslvariants",
+ prefer: false,
+ host_supported: true,
+ target: {
+ android: {
+ system_shared_libs: [],
+ },
+ android_arm64: {
+ srcs: ["android/arm64/lib/sslvariants.so"],
+ },
+ android_arm: {
+ srcs: ["android/arm/lib/sslvariants.so"],
+ },
+ linux_glibc_x86_64: {
+ srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
+ },
+ linux_glibc_x86: {
+ srcs: ["linux_glibc/x86/lib/sslvariants.so"],
+ },
+ },
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ host_supported: true,
+ native_shared_libs: ["mysdk_sslvariants@current"],
+}
+`))
+}
+
+func TestStubsLibrary(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_shared_libs: ["stubslib"],
+ }
+
+ cc_library {
+ name: "internaldep",
+ }
+
+ cc_library {
+ name: "stubslib",
+ shared_libs: ["internaldep"],
+ stubs: {
+ symbol_file: "some/where/stubslib.map.txt",
+ versions: ["1", "2", "3"],
+ },
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mysdk_stubslib@current",
+ sdk_member_name: "stubslib",
+ installable: false,
+ stubs: {
+ versions: ["3"],
+ },
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/stubslib.so"],
+ },
+ arm: {
+ srcs: ["arm/lib/stubslib.so"],
+ },
+ },
+}
+
+cc_prebuilt_library_shared {
+ name: "stubslib",
+ prefer: false,
+ stubs: {
+ versions: ["3"],
+ },
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/stubslib.so"],
+ },
+ arm: {
+ srcs: ["arm/lib/stubslib.so"],
+ },
+ },
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ native_shared_libs: ["mysdk_stubslib@current"],
+}
+`))
+}