Loading apex/apex_test.go +0 −168 Original line number Diff line number Diff line Loading @@ -3905,174 +3905,6 @@ func TestVndkApexWithBinder32(t *testing.T) { }) } func TestVendorApexWithVndkPrebuilts(t *testing.T) { ctx := testApex(t, "", android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.DeviceVndkVersion = proptools.StringPtr("27") }), android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { cc.RegisterVendorSnapshotModules(ctx) }), withFiles(map[string][]byte{ "vendor/foo/Android.bp": []byte(` apex { name: "myapex", binaries: ["foo"], key: "myapex.key", min_sdk_version: "27", vendor: true, } cc_binary { name: "foo", vendor: true, srcs: ["abc.cpp"], shared_libs: [ "libllndk", "libvndk", ], nocrt: true, system_shared_libs: [], min_sdk_version: "27", } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } `), // Simulate VNDK prebuilts with vendor_snapshot "prebuilts/vndk/Android.bp": []byte(` vndk_prebuilt_shared { name: "libllndk", version: "27", vendor_available: true, product_available: true, target_arch: "arm64", arch: { arm64: { srcs: ["libllndk.so"], }, }, } vndk_prebuilt_shared { name: "libvndk", version: "27", vendor_available: true, product_available: true, target_arch: "arm64", arch: { arm64: { srcs: ["libvndk.so"], }, }, vndk: { enabled: true, }, min_sdk_version: "27", } vndk_prebuilt_shared { name: "libc++", version: "27", target_arch: "arm64", vendor_available: true, product_available: true, vndk: { enabled: true, support_system_process: true, }, arch: { arm64: { srcs: ["libc++.so"], }, }, min_sdk_version: "apex_inherit", } vendor_snapshot { name: "vendor_snapshot", version: "27", arch: { arm64: { vndk_libs: [ "libc++", "libllndk", "libvndk", ], static_libs: [ "libc++demangle", "libclang_rt.builtins", "libunwind", ], }, } } vendor_snapshot_static { name: "libclang_rt.builtins", version: "27", target_arch: "arm64", vendor: true, arch: { arm64: { src: "libclang_rt.builtins-aarch64-android.a", }, }, } vendor_snapshot_static { name: "libc++demangle", version: "27", target_arch: "arm64", compile_multilib: "64", vendor: true, arch: { arm64: { src: "libc++demangle.a", }, }, min_sdk_version: "apex_inherit", } vendor_snapshot_static { name: "libunwind", version: "27", target_arch: "arm64", compile_multilib: "64", vendor: true, arch: { arm64: { src: "libunwind.a", }, }, min_sdk_version: "apex_inherit", } `), })) // Should embed the prebuilt VNDK libraries in the apex ensureExactContents(t, ctx, "myapex", "android_common_myapex", []string{ "bin/foo", "prebuilts/vndk/libc++.so:lib64/libc++.so", "prebuilts/vndk/libvndk.so:lib64/libvndk.so", }) // Should link foo with prebuilt libraries (shared/static) ldRule := ctx.ModuleForTests("foo", "android_vendor.27_arm64_armv8-a_myapex").Rule("ld") android.AssertStringDoesContain(t, "should link to prebuilt llndk", ldRule.Args["libFlags"], "prebuilts/vndk/libllndk.so") android.AssertStringDoesContain(t, "should link to prebuilt vndk", ldRule.Args["libFlags"], "prebuilts/vndk/libvndk.so") android.AssertStringDoesContain(t, "should link to prebuilt libc++demangle", ldRule.Args["libFlags"], "prebuilts/vndk/libc++demangle.a") android.AssertStringDoesContain(t, "should link to prebuilt libunwind", ldRule.Args["libFlags"], "prebuilts/vndk/libunwind.a") // Should declare the LLNDK library as a "required" external dependency manifestRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexManifestRule") requireNativeLibs := names(manifestRule.Args["requireNativeLibs"]) ensureListContains(t, requireNativeLibs, "libllndk.so") } func TestDependenciesInApexManifest(t *testing.T) { ctx := testApex(t, ` apex { Loading cc/Android.bp +0 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ bootstrap_go_package { "soong-fuzz", "soong-genrule", "soong-multitree", "soong-snapshot", "soong-testing", "soong-tradefed", ], Loading Loading @@ -45,12 +44,10 @@ bootstrap_go_package { "sabi.go", "sdk.go", "snapshot_prebuilt.go", "snapshot_utils.go", "stl.go", "strip.go", "tidy.go", "util.go", "vendor_snapshot.go", "vndk.go", "vndk_prebuilt.go", Loading cc/androidmk.go +0 −75 Original line number Diff line number Diff line Loading @@ -15,8 +15,6 @@ package cc import ( "github.com/google/blueprint/proptools" "fmt" "io" "path/filepath" Loading Loading @@ -478,79 +476,6 @@ func (c *vndkPrebuiltLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, en }) } func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { // Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current // and the version of the prebuilt is same as BOARD_VNDK_VERSION. if c.shared() { entries.Class = "SHARED_LIBRARIES" } else if c.static() { entries.Class = "STATIC_LIBRARIES" } else if c.header() { entries.Class = "HEADER_LIBRARIES" } entries.SubName = "" if c.IsSanitizerEnabled(cfi) { entries.SubName += ".cfi" } else if c.IsSanitizerEnabled(Hwasan) { entries.SubName += ".hwasan" } entries.SubName += c.baseProperties.Androidmk_suffix entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { c.libraryDecorator.androidMkWriteExportedFlags(entries) if c.shared() || c.static() { src := c.path.String() // For static libraries which aren't installed, directly use Src to extract filename. // This is safe: generated snapshot modules have a real path as Src, not a module if c.static() { src = proptools.String(c.properties.Src) } path, file := filepath.Split(src) stem, suffix, ext := android.SplitFileExt(file) entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) entries.SetString("LOCAL_MODULE_SUFFIX", suffix) entries.SetString("LOCAL_MODULE_STEM", stem) if c.shared() { entries.SetString("LOCAL_MODULE_PATH", path) } if c.tocFile.Valid() { entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String()) } if c.shared() && len(c.Properties.Overrides) > 0 { entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, c.Properties.Overrides), " ")) } } if !c.shared() { // static or header entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) } }) } func (c *snapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { entries.Class = "EXECUTABLES" entries.SubName = c.baseProperties.Androidmk_suffix } func (c *snapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { entries.Class = "STATIC_LIBRARIES" entries.SubName = c.baseProperties.Androidmk_suffix entries.ExtraFooters = append(entries.ExtraFooters, func(w io.Writer, name, prefix, moduleDir string) { out := entries.OutputFile.Path() varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName) fmt.Fprintf(w, "\n%s := %s\n", varname, out.String()) fmt.Fprintln(w, ".KATI_READONLY: "+varname) }) } func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { entries.Class = "SHARED_LIBRARIES" } Loading cc/cc.go +23 −106 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import ( "android/soong/fuzz" "android/soong/genrule" "android/soong/multitree" "android/soong/snapshot" ) func init() { Loading Loading @@ -347,11 +346,6 @@ type BaseProperties struct { // see soong/cc/config/vndk.go MustUseVendorVariant bool `blueprint:"mutated"` // Used by vendor snapshot to record dependencies from snapshot modules. SnapshotSharedLibs []string `blueprint:"mutated"` SnapshotStaticLibs []string `blueprint:"mutated"` SnapshotRuntimeLibs []string `blueprint:"mutated"` Installable *bool `android:"arch_variant"` // Set by factories of module types that can only be referenced from variants compiled against Loading @@ -364,20 +358,6 @@ type BaseProperties struct { // variant to have a ".sdk" suffix. SdkAndPlatformVariantVisibleToMake bool `blueprint:"mutated"` // Normally Soong uses the directory structure to decide which modules // should be included (framework) or excluded (non-framework) from the // different snapshots (vendor, recovery, etc.), but this property // allows a partner to exclude a module normally thought of as a // framework module from the vendor snapshot. Exclude_from_vendor_snapshot *bool // Normally Soong uses the directory structure to decide which modules // should be included (framework) or excluded (non-framework) from the // different snapshots (vendor, recovery, etc.), but this property // allows a partner to exclude a module normally thought of as a // framework module from the recovery snapshot. Exclude_from_recovery_snapshot *bool // List of APEXes that this module has private access to for testing purpose. The module // can depend on libraries that are not exported by the APEXes and use private symbols // from the exported libraries. Loading Loading @@ -960,8 +940,6 @@ func (c *Module) AddJSONData(d *map[string]interface{}) { "IsVndkSp": c.IsVndkSp(), "IsLlndk": c.IsLlndk(), "IsLlndkPublic": c.IsLlndkPublic(), "IsSnapshotLibrary": c.IsSnapshotLibrary(), "IsSnapshotPrebuilt": c.IsSnapshotPrebuilt(), "IsVendorPublicLibrary": c.IsVendorPublicLibrary(), "ApexSdkVersion": c.apexSdkVersion, "TestFor": c.TestFor(), Loading Loading @@ -1513,14 +1491,6 @@ func (c *Module) IsSnapshotPrebuilt() bool { return false } func (c *Module) ExcludeFromVendorSnapshot() bool { return Bool(c.Properties.Exclude_from_vendor_snapshot) } func (c *Module) ExcludeFromRecoverySnapshot() bool { return Bool(c.Properties.Exclude_from_recovery_snapshot) } func isBionic(name string) bool { switch name { case "libc", "libm", "libdl", "libdl_android", "linker": Loading Loading @@ -2152,14 +2122,6 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { c.outputFile = android.OptionalPathForPath(outputFile) c.maybeUnhideFromMake() // glob exported headers for snapshot, if BOARD_VNDK_VERSION is current or // RECOVERY_SNAPSHOT_VERSION is current. if i, ok := c.linker.(snapshotLibraryInterface); ok { if ShouldCollectHeadersForSnapshot(ctx, c, apexInfo) { i.collectHeadersForSnapshot(ctx) } } } if c.testModule { android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{}) Loading Loading @@ -2438,31 +2400,6 @@ func GetApiImports(c LinkableInterface, actx android.BottomUpMutatorContext) mul return apiImportInfo } func GetSnapshot(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext) SnapshotInfo { // Only device modules with BOARD_VNDK_VERSION uses snapshot. Others use the zero value of // SnapshotInfo, which provides no mappings. if *snapshotInfo == nil && c.Device() { // Only retrieve the snapshot on demand in order to avoid circular dependencies // between the modules in the snapshot and the snapshot itself. var snapshotModule []blueprint.Module if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() && actx.OtherModuleExists("vendor_snapshot") { snapshotModule = actx.AddVariationDependencies(nil, nil, "vendor_snapshot") } else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() && actx.OtherModuleExists("recovery_snapshot") { snapshotModule = actx.AddVariationDependencies(nil, nil, "recovery_snapshot") } if len(snapshotModule) > 0 && snapshotModule[0] != nil { snapshot, _ := android.OtherModuleProvider(actx, snapshotModule[0], SnapshotInfoProvider) *snapshotInfo = &snapshot // republish the snapshot for use in later mutators on this module android.SetProvider(actx, SnapshotInfoProvider, snapshot) } } if *snapshotInfo == nil { *snapshotInfo = &SnapshotInfo{} } return **snapshotInfo } func GetReplaceModuleName(lib string, replaceMap map[string]string) string { if snapshot, ok := replaceMap[lib]; ok { return snapshot Loading @@ -2471,44 +2408,35 @@ func GetReplaceModuleName(lib string, replaceMap map[string]string) string { return lib } // RewriteLibs takes a list of names of shared libraries and scans it for three types // FilterNdkLibs takes a list of names of shared libraries and scans it for two types // of names: // // 1. Name of an NDK library that refers to a prebuilt module. // // For each of these, it adds the name of the prebuilt module (which will be in // prebuilts/ndk) to the list of nonvariant libs. // // 2. Name of an NDK library that refers to an ndk_library module. // 1. Name of an NDK library that refers to an ndk_library module. // // For each of these, it adds the name of the ndk_library module to the list of // variant libs. // // 3. Anything else (so anything that isn't an NDK library). // 2. Anything else (so anything that isn't an NDK library). // // It adds these to the nonvariantLibs list. // // The caller can then know to add the variantLibs dependencies differently from the // nonvariantLibs func RewriteLibs(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext, config android.Config, list []string) (nonvariantLibs []string, variantLibs []string) { func FilterNdkLibs(c LinkableInterface, config android.Config, list []string) (nonvariantLibs []string, variantLibs []string) { variantLibs = []string{} nonvariantLibs = []string{} for _, entry := range list { // strip #version suffix out name, _ := StubsLibNameAndVersion(entry) if c.InRecovery() { nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs)) } else if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) { if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) { variantLibs = append(variantLibs, name+ndkLibrarySuffix) } else if c.UseVndk() { nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs)) } else { // put name#version back nonvariantLibs = append(nonvariantLibs, entry) } } return nonvariantLibs, variantLibs } func rewriteLibsForApiImports(c LinkableInterface, libs []string, replaceList map[string]string, config android.Config) ([]string, []string) { Loading Loading @@ -2580,18 +2508,12 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { c.Properties.AndroidMkSystemSharedLibs = deps.SystemSharedLibs var snapshotInfo *SnapshotInfo variantNdkLibs := []string{} variantLateNdkLibs := []string{} if ctx.Os() == android.Android { deps.SharedLibs, variantNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.SharedLibs) deps.LateSharedLibs, variantLateNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.LateSharedLibs) deps.ReexportSharedLibHeaders, _ = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.ReexportSharedLibHeaders) for idx, lib := range deps.RuntimeLibs { deps.RuntimeLibs[idx] = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).SharedLibs) } deps.SharedLibs, variantNdkLibs = FilterNdkLibs(c, ctx.Config(), deps.SharedLibs) deps.LateSharedLibs, variantLateNdkLibs = FilterNdkLibs(c, ctx.Config(), deps.LateSharedLibs) deps.ReexportSharedLibHeaders, _ = FilterNdkLibs(c, ctx.Config(), deps.ReexportSharedLibHeaders) } for _, lib := range deps.HeaderLibs { Loading @@ -2604,7 +2526,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { if c.shouldUseApiSurface() { lib = GetReplaceModuleName(lib, apiImportInfo.HeaderLibs) } lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).HeaderLibs) if c.isNDKStubLibrary() { // ndk_headers do not have any variations Loading @@ -2630,8 +2551,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { for _, lib := range deps.WholeStaticLibs { depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true} lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs) actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, lib) Loading @@ -2646,8 +2565,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { depTag.excludeInApex = true } lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs) actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, lib) Loading @@ -2660,7 +2577,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true} actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, GetReplaceModuleName(staticUnwinder(actx), GetSnapshot(c, &snapshotInfo, actx).StaticLibs)) }, depTag, staticUnwinder(actx)) } // shared lib names without the #version suffix Loading Loading @@ -2701,14 +2618,14 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency} actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)) }, depTag, lib) } for _, lib := range deps.UnexportedStaticLibs { depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency, unexportedSymbols: true} actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)) }, depTag, lib) } for _, lib := range deps.LateSharedLibs { Loading Loading @@ -2749,11 +2666,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...) for _, crt := range deps.CrtBegin { actx.AddVariationDependencies(crtVariations, CrtBeginDepTag, GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects)) crt) } for _, crt := range deps.CrtEnd { actx.AddVariationDependencies(crtVariations, CrtEndDepTag, GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects)) crt) } if deps.DynamicLinker != "" { actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker) Loading Loading @@ -2786,7 +2703,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { actx.AddVariationDependencies([]blueprint.Variation{ c.ImageVariation(), {Mutator: "link", Variation: "shared"}, }, vndkExtDepTag, GetReplaceModuleName(vndkdep.getVndkExtendsModuleName(), GetSnapshot(c, &snapshotInfo, actx).SharedLibs)) }, vndkExtDepTag, vndkdep.getVndkExtendsModuleName()) } } Loading Loading @@ -3394,8 +3311,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // they merely serve as Make dependencies and do not affect this lib itself. c.Properties.AndroidMkSharedLibs = append( c.Properties.AndroidMkSharedLibs, makeLibName) // Record BaseLibName for snapshots. c.Properties.SnapshotSharedLibs = append(c.Properties.SnapshotSharedLibs, BaseLibName(depName)) case libDepTag.static(): if libDepTag.wholeStatic { c.Properties.AndroidMkWholeStaticLibs = append( Loading @@ -3404,8 +3319,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { c.Properties.AndroidMkStaticLibs = append( c.Properties.AndroidMkStaticLibs, makeLibName) } // Record BaseLibName for snapshots. c.Properties.SnapshotStaticLibs = append(c.Properties.SnapshotStaticLibs, BaseLibName(depName)) } } else if !c.IsStubs() { // Stubs lib doesn't link to the runtime lib, object, crt, etc. dependencies. Loading @@ -3414,8 +3327,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { case runtimeDepTag: c.Properties.AndroidMkRuntimeLibs = append( c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName())+libDepTag.makeSuffix) // Record BaseLibName for snapshots. c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, BaseLibName(depName)) case objDepTag: depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path()) case CrtBeginDepTag: Loading Loading @@ -3799,6 +3710,14 @@ func (c *Module) Object() bool { return false } func (m *Module) Dylib() bool { return false } func (m *Module) Rlib() bool { return false } func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string { if c.InVendorOrProduct() { if c.IsLlndk() { Loading Loading @@ -4030,8 +3949,6 @@ func (c *Module) overriddenModules() []string { return nil } var _ snapshot.RelativeInstallPath = (*Module)(nil) type moduleType int const ( Loading cc/genrule.go +1 −8 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ import ( "android/soong/android" "android/soong/genrule" "android/soong/snapshot" ) func init() { Loading Loading @@ -97,14 +96,8 @@ func (g *GenruleExtraProperties) DebugRamdiskVariantNeeded(ctx android.BaseModul func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { // If the build is using a snapshot, the recovery variant under AOSP directories // is not needed. recoverySnapshotVersion := ctx.DeviceConfig().RecoverySnapshotVersion() if recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && !snapshot.IsRecoveryProprietaryModule(ctx) { return false } else { return Bool(g.Recovery_available) } } func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string { var variants []string Loading Loading
apex/apex_test.go +0 −168 Original line number Diff line number Diff line Loading @@ -3905,174 +3905,6 @@ func TestVndkApexWithBinder32(t *testing.T) { }) } func TestVendorApexWithVndkPrebuilts(t *testing.T) { ctx := testApex(t, "", android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.DeviceVndkVersion = proptools.StringPtr("27") }), android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { cc.RegisterVendorSnapshotModules(ctx) }), withFiles(map[string][]byte{ "vendor/foo/Android.bp": []byte(` apex { name: "myapex", binaries: ["foo"], key: "myapex.key", min_sdk_version: "27", vendor: true, } cc_binary { name: "foo", vendor: true, srcs: ["abc.cpp"], shared_libs: [ "libllndk", "libvndk", ], nocrt: true, system_shared_libs: [], min_sdk_version: "27", } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } `), // Simulate VNDK prebuilts with vendor_snapshot "prebuilts/vndk/Android.bp": []byte(` vndk_prebuilt_shared { name: "libllndk", version: "27", vendor_available: true, product_available: true, target_arch: "arm64", arch: { arm64: { srcs: ["libllndk.so"], }, }, } vndk_prebuilt_shared { name: "libvndk", version: "27", vendor_available: true, product_available: true, target_arch: "arm64", arch: { arm64: { srcs: ["libvndk.so"], }, }, vndk: { enabled: true, }, min_sdk_version: "27", } vndk_prebuilt_shared { name: "libc++", version: "27", target_arch: "arm64", vendor_available: true, product_available: true, vndk: { enabled: true, support_system_process: true, }, arch: { arm64: { srcs: ["libc++.so"], }, }, min_sdk_version: "apex_inherit", } vendor_snapshot { name: "vendor_snapshot", version: "27", arch: { arm64: { vndk_libs: [ "libc++", "libllndk", "libvndk", ], static_libs: [ "libc++demangle", "libclang_rt.builtins", "libunwind", ], }, } } vendor_snapshot_static { name: "libclang_rt.builtins", version: "27", target_arch: "arm64", vendor: true, arch: { arm64: { src: "libclang_rt.builtins-aarch64-android.a", }, }, } vendor_snapshot_static { name: "libc++demangle", version: "27", target_arch: "arm64", compile_multilib: "64", vendor: true, arch: { arm64: { src: "libc++demangle.a", }, }, min_sdk_version: "apex_inherit", } vendor_snapshot_static { name: "libunwind", version: "27", target_arch: "arm64", compile_multilib: "64", vendor: true, arch: { arm64: { src: "libunwind.a", }, }, min_sdk_version: "apex_inherit", } `), })) // Should embed the prebuilt VNDK libraries in the apex ensureExactContents(t, ctx, "myapex", "android_common_myapex", []string{ "bin/foo", "prebuilts/vndk/libc++.so:lib64/libc++.so", "prebuilts/vndk/libvndk.so:lib64/libvndk.so", }) // Should link foo with prebuilt libraries (shared/static) ldRule := ctx.ModuleForTests("foo", "android_vendor.27_arm64_armv8-a_myapex").Rule("ld") android.AssertStringDoesContain(t, "should link to prebuilt llndk", ldRule.Args["libFlags"], "prebuilts/vndk/libllndk.so") android.AssertStringDoesContain(t, "should link to prebuilt vndk", ldRule.Args["libFlags"], "prebuilts/vndk/libvndk.so") android.AssertStringDoesContain(t, "should link to prebuilt libc++demangle", ldRule.Args["libFlags"], "prebuilts/vndk/libc++demangle.a") android.AssertStringDoesContain(t, "should link to prebuilt libunwind", ldRule.Args["libFlags"], "prebuilts/vndk/libunwind.a") // Should declare the LLNDK library as a "required" external dependency manifestRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexManifestRule") requireNativeLibs := names(manifestRule.Args["requireNativeLibs"]) ensureListContains(t, requireNativeLibs, "libllndk.so") } func TestDependenciesInApexManifest(t *testing.T) { ctx := testApex(t, ` apex { Loading
cc/Android.bp +0 −3 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ bootstrap_go_package { "soong-fuzz", "soong-genrule", "soong-multitree", "soong-snapshot", "soong-testing", "soong-tradefed", ], Loading Loading @@ -45,12 +44,10 @@ bootstrap_go_package { "sabi.go", "sdk.go", "snapshot_prebuilt.go", "snapshot_utils.go", "stl.go", "strip.go", "tidy.go", "util.go", "vendor_snapshot.go", "vndk.go", "vndk_prebuilt.go", Loading
cc/androidmk.go +0 −75 Original line number Diff line number Diff line Loading @@ -15,8 +15,6 @@ package cc import ( "github.com/google/blueprint/proptools" "fmt" "io" "path/filepath" Loading Loading @@ -478,79 +476,6 @@ func (c *vndkPrebuiltLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, en }) } func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { // Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current // and the version of the prebuilt is same as BOARD_VNDK_VERSION. if c.shared() { entries.Class = "SHARED_LIBRARIES" } else if c.static() { entries.Class = "STATIC_LIBRARIES" } else if c.header() { entries.Class = "HEADER_LIBRARIES" } entries.SubName = "" if c.IsSanitizerEnabled(cfi) { entries.SubName += ".cfi" } else if c.IsSanitizerEnabled(Hwasan) { entries.SubName += ".hwasan" } entries.SubName += c.baseProperties.Androidmk_suffix entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { c.libraryDecorator.androidMkWriteExportedFlags(entries) if c.shared() || c.static() { src := c.path.String() // For static libraries which aren't installed, directly use Src to extract filename. // This is safe: generated snapshot modules have a real path as Src, not a module if c.static() { src = proptools.String(c.properties.Src) } path, file := filepath.Split(src) stem, suffix, ext := android.SplitFileExt(file) entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) entries.SetString("LOCAL_MODULE_SUFFIX", suffix) entries.SetString("LOCAL_MODULE_STEM", stem) if c.shared() { entries.SetString("LOCAL_MODULE_PATH", path) } if c.tocFile.Valid() { entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String()) } if c.shared() && len(c.Properties.Overrides) > 0 { entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, c.Properties.Overrides), " ")) } } if !c.shared() { // static or header entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) } }) } func (c *snapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { entries.Class = "EXECUTABLES" entries.SubName = c.baseProperties.Androidmk_suffix } func (c *snapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { entries.Class = "STATIC_LIBRARIES" entries.SubName = c.baseProperties.Androidmk_suffix entries.ExtraFooters = append(entries.ExtraFooters, func(w io.Writer, name, prefix, moduleDir string) { out := entries.OutputFile.Path() varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName) fmt.Fprintf(w, "\n%s := %s\n", varname, out.String()) fmt.Fprintln(w, ".KATI_READONLY: "+varname) }) } func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { entries.Class = "SHARED_LIBRARIES" } Loading
cc/cc.go +23 −106 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import ( "android/soong/fuzz" "android/soong/genrule" "android/soong/multitree" "android/soong/snapshot" ) func init() { Loading Loading @@ -347,11 +346,6 @@ type BaseProperties struct { // see soong/cc/config/vndk.go MustUseVendorVariant bool `blueprint:"mutated"` // Used by vendor snapshot to record dependencies from snapshot modules. SnapshotSharedLibs []string `blueprint:"mutated"` SnapshotStaticLibs []string `blueprint:"mutated"` SnapshotRuntimeLibs []string `blueprint:"mutated"` Installable *bool `android:"arch_variant"` // Set by factories of module types that can only be referenced from variants compiled against Loading @@ -364,20 +358,6 @@ type BaseProperties struct { // variant to have a ".sdk" suffix. SdkAndPlatformVariantVisibleToMake bool `blueprint:"mutated"` // Normally Soong uses the directory structure to decide which modules // should be included (framework) or excluded (non-framework) from the // different snapshots (vendor, recovery, etc.), but this property // allows a partner to exclude a module normally thought of as a // framework module from the vendor snapshot. Exclude_from_vendor_snapshot *bool // Normally Soong uses the directory structure to decide which modules // should be included (framework) or excluded (non-framework) from the // different snapshots (vendor, recovery, etc.), but this property // allows a partner to exclude a module normally thought of as a // framework module from the recovery snapshot. Exclude_from_recovery_snapshot *bool // List of APEXes that this module has private access to for testing purpose. The module // can depend on libraries that are not exported by the APEXes and use private symbols // from the exported libraries. Loading Loading @@ -960,8 +940,6 @@ func (c *Module) AddJSONData(d *map[string]interface{}) { "IsVndkSp": c.IsVndkSp(), "IsLlndk": c.IsLlndk(), "IsLlndkPublic": c.IsLlndkPublic(), "IsSnapshotLibrary": c.IsSnapshotLibrary(), "IsSnapshotPrebuilt": c.IsSnapshotPrebuilt(), "IsVendorPublicLibrary": c.IsVendorPublicLibrary(), "ApexSdkVersion": c.apexSdkVersion, "TestFor": c.TestFor(), Loading Loading @@ -1513,14 +1491,6 @@ func (c *Module) IsSnapshotPrebuilt() bool { return false } func (c *Module) ExcludeFromVendorSnapshot() bool { return Bool(c.Properties.Exclude_from_vendor_snapshot) } func (c *Module) ExcludeFromRecoverySnapshot() bool { return Bool(c.Properties.Exclude_from_recovery_snapshot) } func isBionic(name string) bool { switch name { case "libc", "libm", "libdl", "libdl_android", "linker": Loading Loading @@ -2152,14 +2122,6 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { c.outputFile = android.OptionalPathForPath(outputFile) c.maybeUnhideFromMake() // glob exported headers for snapshot, if BOARD_VNDK_VERSION is current or // RECOVERY_SNAPSHOT_VERSION is current. if i, ok := c.linker.(snapshotLibraryInterface); ok { if ShouldCollectHeadersForSnapshot(ctx, c, apexInfo) { i.collectHeadersForSnapshot(ctx) } } } if c.testModule { android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{}) Loading Loading @@ -2438,31 +2400,6 @@ func GetApiImports(c LinkableInterface, actx android.BottomUpMutatorContext) mul return apiImportInfo } func GetSnapshot(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext) SnapshotInfo { // Only device modules with BOARD_VNDK_VERSION uses snapshot. Others use the zero value of // SnapshotInfo, which provides no mappings. if *snapshotInfo == nil && c.Device() { // Only retrieve the snapshot on demand in order to avoid circular dependencies // between the modules in the snapshot and the snapshot itself. var snapshotModule []blueprint.Module if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() && actx.OtherModuleExists("vendor_snapshot") { snapshotModule = actx.AddVariationDependencies(nil, nil, "vendor_snapshot") } else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() && actx.OtherModuleExists("recovery_snapshot") { snapshotModule = actx.AddVariationDependencies(nil, nil, "recovery_snapshot") } if len(snapshotModule) > 0 && snapshotModule[0] != nil { snapshot, _ := android.OtherModuleProvider(actx, snapshotModule[0], SnapshotInfoProvider) *snapshotInfo = &snapshot // republish the snapshot for use in later mutators on this module android.SetProvider(actx, SnapshotInfoProvider, snapshot) } } if *snapshotInfo == nil { *snapshotInfo = &SnapshotInfo{} } return **snapshotInfo } func GetReplaceModuleName(lib string, replaceMap map[string]string) string { if snapshot, ok := replaceMap[lib]; ok { return snapshot Loading @@ -2471,44 +2408,35 @@ func GetReplaceModuleName(lib string, replaceMap map[string]string) string { return lib } // RewriteLibs takes a list of names of shared libraries and scans it for three types // FilterNdkLibs takes a list of names of shared libraries and scans it for two types // of names: // // 1. Name of an NDK library that refers to a prebuilt module. // // For each of these, it adds the name of the prebuilt module (which will be in // prebuilts/ndk) to the list of nonvariant libs. // // 2. Name of an NDK library that refers to an ndk_library module. // 1. Name of an NDK library that refers to an ndk_library module. // // For each of these, it adds the name of the ndk_library module to the list of // variant libs. // // 3. Anything else (so anything that isn't an NDK library). // 2. Anything else (so anything that isn't an NDK library). // // It adds these to the nonvariantLibs list. // // The caller can then know to add the variantLibs dependencies differently from the // nonvariantLibs func RewriteLibs(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.BottomUpMutatorContext, config android.Config, list []string) (nonvariantLibs []string, variantLibs []string) { func FilterNdkLibs(c LinkableInterface, config android.Config, list []string) (nonvariantLibs []string, variantLibs []string) { variantLibs = []string{} nonvariantLibs = []string{} for _, entry := range list { // strip #version suffix out name, _ := StubsLibNameAndVersion(entry) if c.InRecovery() { nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs)) } else if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) { if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) { variantLibs = append(variantLibs, name+ndkLibrarySuffix) } else if c.UseVndk() { nonvariantLibs = append(nonvariantLibs, GetReplaceModuleName(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs)) } else { // put name#version back nonvariantLibs = append(nonvariantLibs, entry) } } return nonvariantLibs, variantLibs } func rewriteLibsForApiImports(c LinkableInterface, libs []string, replaceList map[string]string, config android.Config) ([]string, []string) { Loading Loading @@ -2580,18 +2508,12 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { c.Properties.AndroidMkSystemSharedLibs = deps.SystemSharedLibs var snapshotInfo *SnapshotInfo variantNdkLibs := []string{} variantLateNdkLibs := []string{} if ctx.Os() == android.Android { deps.SharedLibs, variantNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.SharedLibs) deps.LateSharedLibs, variantLateNdkLibs = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.LateSharedLibs) deps.ReexportSharedLibHeaders, _ = RewriteLibs(c, &snapshotInfo, actx, ctx.Config(), deps.ReexportSharedLibHeaders) for idx, lib := range deps.RuntimeLibs { deps.RuntimeLibs[idx] = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).SharedLibs) } deps.SharedLibs, variantNdkLibs = FilterNdkLibs(c, ctx.Config(), deps.SharedLibs) deps.LateSharedLibs, variantLateNdkLibs = FilterNdkLibs(c, ctx.Config(), deps.LateSharedLibs) deps.ReexportSharedLibHeaders, _ = FilterNdkLibs(c, ctx.Config(), deps.ReexportSharedLibHeaders) } for _, lib := range deps.HeaderLibs { Loading @@ -2604,7 +2526,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { if c.shouldUseApiSurface() { lib = GetReplaceModuleName(lib, apiImportInfo.HeaderLibs) } lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).HeaderLibs) if c.isNDKStubLibrary() { // ndk_headers do not have any variations Loading @@ -2630,8 +2551,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { for _, lib := range deps.WholeStaticLibs { depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true} lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs) actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, lib) Loading @@ -2646,8 +2565,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { depTag.excludeInApex = true } lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs) actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, lib) Loading @@ -2660,7 +2577,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true} actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, GetReplaceModuleName(staticUnwinder(actx), GetSnapshot(c, &snapshotInfo, actx).StaticLibs)) }, depTag, staticUnwinder(actx)) } // shared lib names without the #version suffix Loading Loading @@ -2701,14 +2618,14 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency} actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)) }, depTag, lib) } for _, lib := range deps.UnexportedStaticLibs { depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency, unexportedSymbols: true} actx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, depTag, GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)) }, depTag, lib) } for _, lib := range deps.LateSharedLibs { Loading Loading @@ -2749,11 +2666,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...) for _, crt := range deps.CrtBegin { actx.AddVariationDependencies(crtVariations, CrtBeginDepTag, GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects)) crt) } for _, crt := range deps.CrtEnd { actx.AddVariationDependencies(crtVariations, CrtEndDepTag, GetReplaceModuleName(crt, GetSnapshot(c, &snapshotInfo, actx).Objects)) crt) } if deps.DynamicLinker != "" { actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker) Loading Loading @@ -2786,7 +2703,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { actx.AddVariationDependencies([]blueprint.Variation{ c.ImageVariation(), {Mutator: "link", Variation: "shared"}, }, vndkExtDepTag, GetReplaceModuleName(vndkdep.getVndkExtendsModuleName(), GetSnapshot(c, &snapshotInfo, actx).SharedLibs)) }, vndkExtDepTag, vndkdep.getVndkExtendsModuleName()) } } Loading Loading @@ -3394,8 +3311,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // they merely serve as Make dependencies and do not affect this lib itself. c.Properties.AndroidMkSharedLibs = append( c.Properties.AndroidMkSharedLibs, makeLibName) // Record BaseLibName for snapshots. c.Properties.SnapshotSharedLibs = append(c.Properties.SnapshotSharedLibs, BaseLibName(depName)) case libDepTag.static(): if libDepTag.wholeStatic { c.Properties.AndroidMkWholeStaticLibs = append( Loading @@ -3404,8 +3319,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { c.Properties.AndroidMkStaticLibs = append( c.Properties.AndroidMkStaticLibs, makeLibName) } // Record BaseLibName for snapshots. c.Properties.SnapshotStaticLibs = append(c.Properties.SnapshotStaticLibs, BaseLibName(depName)) } } else if !c.IsStubs() { // Stubs lib doesn't link to the runtime lib, object, crt, etc. dependencies. Loading @@ -3414,8 +3327,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { case runtimeDepTag: c.Properties.AndroidMkRuntimeLibs = append( c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName())+libDepTag.makeSuffix) // Record BaseLibName for snapshots. c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, BaseLibName(depName)) case objDepTag: depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path()) case CrtBeginDepTag: Loading Loading @@ -3799,6 +3710,14 @@ func (c *Module) Object() bool { return false } func (m *Module) Dylib() bool { return false } func (m *Module) Rlib() bool { return false } func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string { if c.InVendorOrProduct() { if c.IsLlndk() { Loading Loading @@ -4030,8 +3949,6 @@ func (c *Module) overriddenModules() []string { return nil } var _ snapshot.RelativeInstallPath = (*Module)(nil) type moduleType int const ( Loading
cc/genrule.go +1 −8 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ import ( "android/soong/android" "android/soong/genrule" "android/soong/snapshot" ) func init() { Loading Loading @@ -97,14 +96,8 @@ func (g *GenruleExtraProperties) DebugRamdiskVariantNeeded(ctx android.BaseModul func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { // If the build is using a snapshot, the recovery variant under AOSP directories // is not needed. recoverySnapshotVersion := ctx.DeviceConfig().RecoverySnapshotVersion() if recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && !snapshot.IsRecoveryProprietaryModule(ctx) { return false } else { return Bool(g.Recovery_available) } } func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string { var variants []string Loading