diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/androidmk.go | 9 | ||||
-rw-r--r-- | cc/binary.go | 4 | ||||
-rw-r--r-- | cc/cc.go | 65 | ||||
-rw-r--r-- | cc/library.go | 9 | ||||
-rw-r--r-- | cc/llndk_library.go | 7 | ||||
-rw-r--r-- | cc/snapshot_utils.go | 6 | ||||
-rw-r--r-- | cc/vendor_snapshot.go | 7 | ||||
-rw-r--r-- | cc/vndk.go | 32 |
8 files changed, 93 insertions, 46 deletions
diff --git a/cc/androidmk.go b/cc/androidmk.go index d92fabc0d..a2549b8e7 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -33,7 +33,6 @@ var ( ) type AndroidMkContext interface { - BaseModuleName() string Target() android.Target subAndroidMk(*android.AndroidMkEntries, interface{}) Arch() android.Arch @@ -44,6 +43,7 @@ type AndroidMkContext interface { static() bool InRamdisk() bool InRecovery() bool + AnyVariantDirectlyInAnyApex() bool } type subAndroidMkProvider interface { @@ -63,7 +63,7 @@ func (c *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{} } func (c *Module) AndroidMkEntries() []android.AndroidMkEntries { - if c.Properties.HideFromMake || !c.IsForPlatform() { + if c.hideApexVariantFromMake || c.Properties.HideFromMake { return []android.AndroidMkEntries{{ Disabled: true, }} @@ -277,9 +277,8 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries } }) } - if len(library.Properties.Stubs.Versions) > 0 && - android.DirectlyInAnyApex(ctx, ctx.BaseModuleName()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && - !ctx.static() { + if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.AnyVariantDirectlyInAnyApex() && + !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && !ctx.static() { if library.buildStubs() && library.isLatestStubVersion() { // reference the latest version via its name without suffix when it is provided by apex entries.SubName = "" diff --git a/cc/binary.go b/cc/binary.go index b3ce5ff1c..7f7b619d5 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -445,7 +445,9 @@ func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) { // The original path becomes a symlink to the corresponding file in the // runtime APEX. translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled - if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !translatedArch && ctx.apexVariationName() == "" && !ctx.inRamdisk() && !ctx.inRecovery() { + if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !ctx.Host() && ctx.directlyInAnyApex() && + !translatedArch && ctx.apexVariationName() == "" && !ctx.inRamdisk() && !ctx.inRecovery() { + if ctx.Device() && isBionic(ctx.baseModuleName()) { binary.installSymlinkToRuntimeApex(ctx, file) } @@ -366,6 +366,7 @@ type ModuleContextIntf interface { bootstrap() bool mustUseVendorVariant() bool nativeCoverage() bool + directlyInAnyApex() bool } type ModuleContext interface { @@ -545,8 +546,17 @@ var ( dataLibDepTag = dependencyTag{name: "data lib"} runtimeDepTag = dependencyTag{name: "runtime lib"} testPerSrcDepTag = dependencyTag{name: "test_per_src"} + testForDepTag = dependencyTag{name: "test for apex"} + + stubImplDepTag = copyDirectlyInAnyApexDependencyTag{name: "stub_impl"} ) +type copyDirectlyInAnyApexDependencyTag dependencyTag + +func (copyDirectlyInAnyApexDependencyTag) CopyDirectlyInAnyApex() {} + +var _ android.CopyDirectlyInAnyApexTag = copyDirectlyInAnyApexDependencyTag{} + func IsSharedDepTag(depTag blueprint.DependencyTag) bool { ccLibDepTag, ok := depTag.(libraryDependencyTag) return ok && ccLibDepTag.shared() @@ -622,6 +632,8 @@ type Module struct { // For apex variants, this is set as apex.min_sdk_version apexSdkVersion android.ApiLevel + + hideApexVariantFromMake bool } func (c *Module) Toc() android.OptionalPath { @@ -1363,11 +1375,11 @@ func (ctx *moduleContextImpl) getVndkExtendsModuleName() string { } func (ctx *moduleContextImpl) isForPlatform() bool { - return ctx.mod.IsForPlatform() + return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() } func (ctx *moduleContextImpl) apexVariationName() string { - return ctx.mod.ApexVariationName() + return ctx.ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).ApexVariationName } func (ctx *moduleContextImpl) apexSdkVersion() android.ApiLevel { @@ -1390,6 +1402,10 @@ func (ctx *moduleContextImpl) nativeCoverage() bool { return ctx.mod.nativeCoverage() } +func (ctx *moduleContextImpl) directlyInAnyApex() bool { + return ctx.mod.DirectlyInAnyApex() +} + func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module { return &Module{ hod: hod, @@ -1545,6 +1561,11 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { return } + apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo) + if !apexInfo.IsForPlatform() { + c.hideApexVariantFromMake = true + } + c.makeLinkType = c.getMakeLinkType(actx) c.Properties.SubName = "" @@ -1676,8 +1697,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { // force anything in the make world to link against the stubs library. // (unless it is explicitly referenced via .bootstrap suffix or the // module is marked with 'bootstrap: true'). - if c.HasStubsVariants() && - android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) && !c.InRamdisk() && + if c.HasStubsVariants() && c.AnyVariantDirectlyInAnyApex() && !c.InRamdisk() && !c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() && c.IsStubs() { c.Properties.HideFromMake = false // unhide @@ -1686,13 +1706,13 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { // glob exported headers for snapshot, if BOARD_VNDK_VERSION is current. if i, ok := c.linker.(snapshotLibraryInterface); ok && ctx.DeviceConfig().VndkVersion() == "current" { - if isSnapshotAware(ctx, c) { + if isSnapshotAware(ctx, c, apexInfo) { i.collectHeadersForSnapshot(ctx) } } } - if c.installable() { + if c.installable(apexInfo) { c.installer.install(ctx, c.outputFile.Path()) if ctx.Failed() { return @@ -2381,8 +2401,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // For the dependency from platform to apex, use the latest stubs c.apexSdkVersion = android.FutureApiLevel - if !c.IsForPlatform() { - c.apexSdkVersion = c.ApexProperties.Info.MinSdkVersion(ctx) + apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) + if !apexInfo.IsForPlatform() { + c.apexSdkVersion = apexInfo.MinSdkVersion(ctx) } if android.InList("hwaddress", ctx.Config().SanitizeDevice()) { @@ -2493,8 +2514,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { if ccDep.CcLibrary() && !libDepTag.static() { depIsStubs := ccDep.BuildStubs() depHasStubs := CanBeOrLinkAgainstVersionVariants(c) && ccDep.HasStubsVariants() - depInSameApexes := android.DirectlyInAllApexes(c.InApexes(), depName) - depInPlatform := !android.DirectlyInAnyApex(ctx, depName) + depInSameApexes := android.DirectlyInAllApexes(apexInfo, depName) + depInPlatform := !dep.(android.ApexModule).AnyVariantDirectlyInAnyApex() var useThisDep bool if depIsStubs && libDepTag.explicitlyVersioned { @@ -2504,7 +2525,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // Use non-stub variant if that is the only choice // (i.e. depending on a lib without stubs.version property) useThisDep = true - } else if c.IsForPlatform() { + } else if apexInfo.IsForPlatform() { // If not building for APEX, use stubs only when it is from // an APEX (and not from platform) useThisDep = (depInPlatform != depIsStubs) @@ -2513,11 +2534,12 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // always link to non-stub variant useThisDep = !depIsStubs } - for _, testFor := range c.TestFor() { - // Another exception: if this module is bundled with an APEX, then - // it is linked with the non-stub variant of a module in the APEX - // as if this is part of the APEX. - if android.DirectlyInApex(testFor, depName) { + // Another exception: if this module is bundled with an APEX, then + // it is linked with the non-stub variant of a module in the APEX + // as if this is part of the APEX. + testFor := ctx.Provider(android.ApexTestForInfoProvider).(android.ApexTestForInfo) + for _, apexContents := range testFor.ApexContents { + if apexContents.DirectlyInApex(depName) { useThisDep = !depIsStubs break } @@ -2549,7 +2571,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // by default, use current version of LLNDK versionToUse := "" versions := m.AllStubsVersions() - if c.ApexVariationName() != "" && len(versions) > 0 { + if apexInfo.ApexVariationName != "" && len(versions) > 0 { // if this is for use_vendor apex && dep has stubsVersions // apply the same rule of apex sdk enforcement to choose right version var err error @@ -2711,10 +2733,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { c.Properties.AndroidMkHeaderLibs, makeLibName) case libDepTag.shared(): if ccDep.CcLibrary() { - if ccDep.BuildStubs() && android.InAnyApex(depName) { + if ccDep.BuildStubs() && dep.(android.ApexModule).InAnyApex() { // Add the dependency to the APEX(es) providing the library so that // m <module> can trigger building the APEXes as well. - for _, an := range android.GetApexesForModule(depName) { + depApexInfo := ctx.OtherModuleProvider(dep, android.ApexInfoProvider).(android.ApexInfo) + for _, an := range depApexInfo.InApexes { c.Properties.ApexesProvidingSharedLibs = append( c.Properties.ApexesProvidingSharedLibs, an) } @@ -3018,7 +3041,7 @@ func (c *Module) EverInstallable() bool { c.installer.everInstallable() } -func (c *Module) installable() bool { +func (c *Module) installable(apexInfo android.ApexInfo) bool { ret := c.EverInstallable() && // Check to see whether the module has been configured to not be installed. proptools.BoolDefault(c.Properties.Installable, true) && @@ -3027,7 +3050,7 @@ func (c *Module) installable() bool { // The platform variant doesn't need further condition. Apex variants however might not // be installable because it will likely to be included in the APEX and won't appear // in the system partition. - if c.IsForPlatform() { + if apexInfo.IsForPlatform() { return ret } diff --git a/cc/library.go b/cc/library.go index b5bec952a..35828aa71 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1231,18 +1231,19 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) { library.baseInstaller.subDir += "-" + vndkVersion } } - } else if len(library.Properties.Stubs.Versions) > 0 && android.DirectlyInAnyApex(ctx, ctx.ModuleName()) { + } else if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.directlyInAnyApex() { // Bionic libraries (e.g. libc.so) is installed to the bootstrap subdirectory. // The original path becomes a symlink to the corresponding file in the // runtime APEX. translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled - if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() && !translatedArch && !ctx.inRamdisk() && !ctx.inRecovery() { + if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() && + !translatedArch && !ctx.inRamdisk() && !ctx.inRecovery() { if ctx.Device() { library.installSymlinkToRuntimeApex(ctx, file) } library.baseInstaller.subDir = "bootstrap" } - } else if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && ctx.isLlndk(ctx.Config()) && !isBionic(ctx.baseModuleName()) { + } else if ctx.directlyInAnyApex() && ctx.isLlndk(ctx.Config()) && !isBionic(ctx.baseModuleName()) { // Skip installing LLNDK (non-bionic) libraries moved to APEX. ctx.Module().SkipInstall() } @@ -1531,6 +1532,8 @@ func createVersionVariations(mctx android.BottomUpMutatorContext, versions []str if variants[i] != "" { m.(LinkableInterface).SetBuildStubs() m.(LinkableInterface).SetStubsVersion(variants[i]) + // The stubs depend on the implementation + mctx.AddInterVariantDependency(stubImplDepTag, modules[i], modules[0]) } } mctx.AliasVariation("") diff --git a/cc/llndk_library.go b/cc/llndk_library.go index b3f9d6177..a42906323 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -74,6 +74,8 @@ type llndkStubDecorator struct { exportHeadersTimestamp android.OptionalPath versionScriptPath android.ModuleGenPath + + movedToApex bool } func (stub *llndkStubDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags { @@ -135,6 +137,11 @@ func (stub *llndkStubDecorator) processHeaders(ctx ModuleContext, srcHeaderDir s func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { + impl := ctx.GetDirectDepWithTag(ctx.baseModuleName(), llndkImplDep) + if implApexModule, ok := impl.(android.ApexModule); ok { + stub.movedToApex = implApexModule.DirectlyInAnyApex() + } + if !Bool(stub.Properties.Unversioned) { linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String() flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag) diff --git a/cc/snapshot_utils.go b/cc/snapshot_utils.go index f27d166f4..b72af4405 100644 --- a/cc/snapshot_utils.go +++ b/cc/snapshot_utils.go @@ -58,10 +58,10 @@ func (s *snapshotMap) get(name string, arch android.ArchType) (snapshot string, return snapshot, found } -func isSnapshotAware(ctx android.ModuleContext, m *Module) bool { - if _, _, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m); ok { +func isSnapshotAware(ctx android.ModuleContext, m *Module, apexInfo android.ApexInfo) bool { + if _, _, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m, apexInfo); ok { return ctx.Config().VndkSnapshotBuildArtifacts() - } else if isVendorSnapshotModule(m, isVendorProprietaryPath(ctx.ModuleDir())) { + } else if isVendorSnapshotModule(m, isVendorProprietaryPath(ctx.ModuleDir()), apexInfo) { return true } return false diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go index 2819f4958..529ed600e 100644 --- a/cc/vendor_snapshot.go +++ b/cc/vendor_snapshot.go @@ -537,7 +537,7 @@ func isVendorProprietaryModule(ctx android.BaseModuleContext) bool { // AOSP. They are not guaranteed to be compatible with older vendor images. (e.g. might // depend on newer VNDK) So they are captured as vendor snapshot To build older vendor // image and newer system image altogether. -func isVendorSnapshotModule(m *Module, inVendorProprietaryPath bool) bool { +func isVendorSnapshotModule(m *Module, inVendorProprietaryPath bool, apexInfo android.ApexInfo) bool { if !m.Enabled() || m.Properties.HideFromMake { return false } @@ -562,7 +562,7 @@ func isVendorSnapshotModule(m *Module, inVendorProprietaryPath bool) bool { return false } // the module must be installed in /vendor - if !m.IsForPlatform() || m.isSnapshotPrebuilt() || !m.inVendor() { + if !apexInfo.IsForPlatform() || m.isSnapshotPrebuilt() || !m.inVendor() { return false } // skip kernel_headers which always depend on vendor @@ -825,6 +825,7 @@ func (c *vendorSnapshotSingleton) GenerateBuildActions(ctx android.SingletonCont moduleDir := ctx.ModuleDir(module) inVendorProprietaryPath := isVendorProprietaryPath(moduleDir) + apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo) if m.ExcludeFromVendorSnapshot() { if inVendorProprietaryPath { @@ -842,7 +843,7 @@ func (c *vendorSnapshotSingleton) GenerateBuildActions(ctx android.SingletonCont } } - if !isVendorSnapshotModule(m, inVendorProprietaryPath) { + if !isVendorSnapshotModule(m, inVendorProprietaryPath, apexInfo) { return } diff --git a/cc/vndk.go b/cc/vndk.go index 9a2fa09d4..4169e2129 100644 --- a/cc/vndk.go +++ b/cc/vndk.go @@ -300,6 +300,7 @@ func processLlndkLibrary(mctx android.BottomUpMutatorContext, m *Module) { if !Bool(lib.Properties.Vendor_available) { vndkPrivateLibraries(mctx.Config())[name] = filename } + if mctx.OtherModuleExists(name) { mctx.AddFarVariationDependencies(m.Target().Variations(), llndkImplDep, name) } @@ -533,11 +534,13 @@ type vndkSnapshotSingleton struct { vndkSnapshotZipFile android.OptionalPath } -func isVndkSnapshotLibrary(config android.DeviceConfig, m *Module) (i snapshotLibraryInterface, vndkType string, isVndkSnapshotLib bool) { +func isVndkSnapshotLibrary(config android.DeviceConfig, m *Module, + apexInfo android.ApexInfo) (i snapshotLibraryInterface, vndkType string, isVndkSnapshotLib bool) { + if m.Target().NativeBridge == android.NativeBridgeEnabled { return nil, "", false } - if !m.inVendor() || !m.installable() || m.isSnapshotPrebuilt() { + if !m.inVendor() || !m.installable(apexInfo) || m.isSnapshotPrebuilt() { return nil, "", false } l, ok := m.linker.(snapshotLibraryInterface) @@ -659,7 +662,9 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex return } - l, vndkType, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m) + apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo) + + l, vndkType, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m, apexInfo) if !ok { return } @@ -823,14 +828,21 @@ func (c *vndkSnapshotSingleton) buildVndkLibrariesTxtFiles(ctx android.Singleton func (c *vndkSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) { // Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to avoid installing libraries on /system if // they been moved to an apex. - movedToApexLlndkLibraries := []string{} - for lib := range llndkLibraries(ctx.Config()) { - // Skip bionic libs, they are handled in different manner - if android.DirectlyInAnyApex(¬OnHostContext{}, lib) && !isBionic(lib) { - movedToApexLlndkLibraries = append(movedToApexLlndkLibraries, lib) + movedToApexLlndkLibraries := make(map[string]bool) + ctx.VisitAllModules(func(module android.Module) { + if m, ok := module.(*Module); ok { + if llndk, ok := m.linker.(*llndkStubDecorator); ok { + // Skip bionic libs, they are handled in different manner + name := m.BaseModuleName() + if llndk.movedToApex && !isBionic(m.BaseModuleName()) { + movedToApexLlndkLibraries[name] = true + } + } } - } - ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES", strings.Join(movedToApexLlndkLibraries, " ")) + }) + + ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES", + strings.Join(android.SortedStringKeys(movedToApexLlndkLibraries), " ")) // Make uses LLNDK_LIBRARIES to determine which libraries to install. // HWASAN is only part of the LL-NDK in builds in which libc depends on HWASAN. |