Merge "Declare ConfiguredJarList in specific fragment implementations."
diff --git a/android/license.go b/android/license.go
index 3bc6199..cb375a2 100644
--- a/android/license.go
+++ b/android/license.go
@@ -51,6 +51,7 @@
type licenseModule struct {
ModuleBase
DefaultableModuleBase
+ SdkBase
properties licenseProperties
}
@@ -75,6 +76,7 @@
// The visibility property needs to be checked and parsed by the visibility module.
setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)
+ InitSdkAwareModule(module)
initAndroidModuleBase(module)
InitDefaultableModule(module)
diff --git a/android/paths.go b/android/paths.go
index b934687..5d458cb 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -24,6 +24,7 @@
"strings"
"github.com/google/blueprint"
+ "github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/pathtools"
)
@@ -449,6 +450,12 @@
return outputFiles, nil
} else if tag != "" {
return nil, fmt.Errorf("path dependency %q is not an output file producing module", path)
+ } else if goBinary, ok := module.(bootstrap.GoBinaryTool); ok {
+ if rel, err := filepath.Rel(PathForOutput(ctx).String(), goBinary.InstallPath()); err == nil {
+ return Paths{PathForOutput(ctx, rel).WithoutRel()}, nil
+ } else {
+ return nil, fmt.Errorf("cannot find output path for %q: %w", goBinary.InstallPath(), err)
+ }
} else if srcProducer, ok := module.(SourceFileProducer); ok {
return srcProducer.Srcs(), nil
} else {
diff --git a/android/sdk.go b/android/sdk.go
index 6fc1910..0adfd89 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -41,6 +41,11 @@
sdkBase() *SdkBase
MakeMemberOf(sdk SdkRef)
IsInAnySdk() bool
+
+ // IsVersioned determines whether the module is versioned, i.e. has a name of the form
+ // <name>@<version>
+ IsVersioned() bool
+
ContainingSdk() SdkRef
MemberName() string
BuildWithSdks(sdks SdkRefs)
@@ -82,7 +87,7 @@
func ParseSdkRef(ctx BaseModuleContext, str string, property string) SdkRef {
tokens := strings.Split(str, string(SdkVersionSeparator))
if len(tokens) < 1 || len(tokens) > 2 {
- ctx.PropertyErrorf(property, "%q does not follow name#version syntax", str)
+ ctx.PropertyErrorf(property, "%q does not follow name@version syntax", str)
return SdkRef{Name: "invalid sdk name", Version: "invalid sdk version"}
}
@@ -140,6 +145,11 @@
return s.properties.ContainingSdk != nil
}
+// IsVersioned returns true if this module is versioned.
+func (s *SdkBase) IsVersioned() bool {
+ return strings.Contains(s.module.Name(), "@")
+}
+
// ContainingSdk returns the SDK that this module is a member of
func (s *SdkBase) ContainingSdk() SdkRef {
if s.properties.ContainingSdk != nil {
@@ -292,9 +302,7 @@
}
// SdkMemberTypeDependencyTag is the interface that a tag must implement in order to allow the
-// dependent module to be automatically added to the sdk. In order for this to work the
-// SdkMemberType of the depending module must return true from
-// SdkMemberType.HasTransitiveSdkMembers.
+// dependent module to be automatically added to the sdk.
type SdkMemberTypeDependencyTag interface {
blueprint.DependencyTag
@@ -375,13 +383,6 @@
// True if the member type supports the sdk/sdk_snapshot, false otherwise.
UsableWithSdkAndSdkSnapshot() bool
- // Return true if modules of this type can have dependencies which should be
- // treated as if they are sdk members.
- //
- // Any dependency that is to be treated as a member of the sdk needs to implement
- // SdkAware and be added with an SdkMemberTypeDependencyTag tag.
- HasTransitiveSdkMembers() bool
-
// Return true if prebuilt host artifacts may be specific to the host OS. Only
// applicable to modules where HostSupported() is true. If this is true,
// snapshots will list each host OS variant explicitly and disable all other
@@ -447,10 +448,9 @@
// Base type for SdkMemberType implementations.
type SdkMemberTypeBase struct {
- PropertyName string
- SupportsSdk bool
- TransitiveSdkMembers bool
- HostOsDependent bool
+ PropertyName string
+ SupportsSdk bool
+ HostOsDependent bool
}
func (b *SdkMemberTypeBase) SdkPropertyName() string {
@@ -461,10 +461,6 @@
return b.SupportsSdk
}
-func (b *SdkMemberTypeBase) HasTransitiveSdkMembers() bool {
- return b.TransitiveSdkMembers
-}
-
func (b *SdkMemberTypeBase) IsHostOsDependent() bool {
return b.HostOsDependent
}
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 7830f95..8996352 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -110,6 +110,13 @@
}
}
+// Implements android.DepInInSameApex
+func (p *prebuiltCommon) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
+ tag := ctx.OtherModuleDependencyTag(dep)
+ _, ok := tag.(exportedDependencyTag)
+ return ok
+}
+
// apexInfoMutator marks any modules for which this apex exports a file as requiring an apex
// specific variant and checks that they are supported.
//
@@ -142,34 +149,43 @@
// Collect the list of dependencies.
var dependencies []android.ApexModule
- mctx.VisitDirectDeps(func(m android.Module) {
- tag := mctx.OtherModuleDependencyTag(m)
+ mctx.WalkDeps(func(child, parent android.Module) bool {
+ // If the child is not in the same apex as the parent then exit immediately and do not visit
+ // any of the child's dependencies.
+ if !android.IsDepInSameApex(mctx, parent, child) {
+ return false
+ }
+
+ tag := mctx.OtherModuleDependencyTag(child)
+ depName := mctx.OtherModuleName(child)
if exportedTag, ok := tag.(exportedDependencyTag); ok {
propertyName := exportedTag.name
- depName := mctx.OtherModuleName(m)
// It is an error if the other module is not a prebuilt.
- if _, ok := m.(android.PrebuiltInterface); !ok {
+ if !android.IsModulePrebuilt(child) {
mctx.PropertyErrorf(propertyName, "%q is not a prebuilt module", depName)
- return
+ return false
}
// It is an error if the other module is not an ApexModule.
- if _, ok := m.(android.ApexModule); !ok {
+ if _, ok := child.(android.ApexModule); !ok {
mctx.PropertyErrorf(propertyName, "%q is not usable within an apex", depName)
- return
+ return false
}
-
- // Strip off the prebuilt_ prefix if present before storing content to ensure consistent
- // behavior whether there is a corresponding source module present or not.
- depName = android.RemoveOptionalPrebuiltPrefix(depName)
-
- // Remember that this module was added as a direct dependency.
- contents[depName] = contents[depName].Add(true)
-
- // Add the module to the list of dependencies that need to have an APEX variant.
- dependencies = append(dependencies, m.(android.ApexModule))
}
+
+ // Strip off the prebuilt_ prefix if present before storing content to ensure consistent
+ // behavior whether there is a corresponding source module present or not.
+ depName = android.RemoveOptionalPrebuiltPrefix(depName)
+
+ // Remember if this module was added as a direct dependency.
+ direct := parent == mctx.Module()
+ contents[depName] = contents[depName].Add(direct)
+
+ // Add the module to the list of dependencies that need to have an APEX variant.
+ dependencies = append(dependencies, child.(android.ApexModule))
+
+ return true
})
// Create contents for the prebuilt_apex and store it away for later use.
diff --git a/cc/builder.go b/cc/builder.go
index 0542015..29cde9d 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -143,7 +143,7 @@
}(),
Pool: darwinStripPool,
},
- "args", "crossCompile")
+ "args")
// Rule to invoke `strip` (to discard symbols and data from object files) on darwin architecture.
darwinStrip = pctx.AndroidStaticRule("darwinStrip",
@@ -993,7 +993,6 @@
func transformStrip(ctx android.ModuleContext, inputFile android.Path,
outputFile android.WritablePath, flags StripFlags) {
- crossCompile := gccCmd(flags.Toolchain, "")
args := ""
if flags.StripAddGnuDebuglink {
args += " --add-gnu-debuglink"
@@ -1010,9 +1009,6 @@
if flags.StripKeepSymbolsAndDebugFrame {
args += " --keep-symbols-and-debug-frame"
}
- if flags.StripUseGnuStrip {
- args += " --use-gnu-strip"
- }
ctx.Build(pctx, android.BuildParams{
Rule: strip,
@@ -1020,8 +1016,7 @@
Output: outputFile,
Input: inputFile,
Args: map[string]string{
- "crossCompile": crossCompile,
- "args": args,
+ "args": args,
},
})
}
diff --git a/cc/makevars.go b/cc/makevars.go
index 2b7bb9b..da5f1fd 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -285,11 +285,14 @@
}
if target.Os.Class == android.Device {
- ctx.Strict(makePrefix+"OBJCOPY", gccCmd(toolchain, "objcopy"))
- ctx.Strict(makePrefix+"LD", gccCmd(toolchain, "ld"))
- ctx.Strict(makePrefix+"GCC_VERSION", toolchain.GccVersion())
+ ctx.Strict(makePrefix+"OBJCOPY", "${config.ClangBin}/llvm-objcopy")
+ ctx.Strict(makePrefix+"LD", "${config.ClangBin}/lld")
ctx.Strict(makePrefix+"NDK_TRIPLE", config.NDKTriple(toolchain))
+ // TODO: work out whether to make this "${config.ClangBin}/llvm-", which
+ // should mostly work, or remove it.
ctx.Strict(makePrefix+"TOOLS_PREFIX", gccCmd(toolchain, ""))
+ // TODO: GCC version is obsolete now that GCC has been removed.
+ ctx.Strict(makePrefix+"GCC_VERSION", toolchain.GccVersion())
}
if target.Os.Class == android.Host {
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index de9dc45..4dd383d 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -55,6 +55,8 @@
ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
+
+ ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
}
var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
@@ -124,6 +126,7 @@
type PrebuiltEtc struct {
android.ModuleBase
+ android.DefaultableModuleBase
properties prebuiltEtcProperties
subdirProperties prebuiltSubdirProperties
@@ -139,6 +142,11 @@
additionalDependencies *android.Paths
}
+type Defaults struct {
+ android.ModuleBase
+ android.DefaultsModuleBase
+}
+
func (p *PrebuiltEtc) inRamdisk() bool {
return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
}
@@ -378,6 +386,25 @@
InitPrebuiltEtcModule(module, "etc")
// This module is device-only
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
+ android.InitDefaultableModule(module)
+ return module
+}
+
+func defaultsFactory() android.Module {
+ return DefaultsFactory()
+}
+
+func DefaultsFactory(props ...interface{}) android.Module {
+ module := &Defaults{}
+
+ module.AddProperties(props...)
+ module.AddProperties(
+ &prebuiltEtcProperties{},
+ &prebuiltSubdirProperties{},
+ )
+
+ android.InitDefaultsModule(module)
+
return module
}
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index 8fe362a..6270b5b 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -32,9 +32,8 @@
android.RegisterSdkMemberType(&bootclasspathFragmentMemberType{
SdkMemberTypeBase: android.SdkMemberTypeBase{
- PropertyName: "bootclasspath_fragments",
- SupportsSdk: true,
- TransitiveSdkMembers: true,
+ PropertyName: "bootclasspath_fragments",
+ SupportsSdk: true,
},
})
}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index ce5155f..06326ac 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -790,7 +790,7 @@
rule.Build("bootJarsProfile", "profile boot jars")
- image.profileInstalls = rule.Installs()
+ image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
return profile
}
diff --git a/java/java.go b/java/java.go
index 7258dce..d74bf68 100644
--- a/java/java.go
+++ b/java/java.go
@@ -669,6 +669,7 @@
module.Module.properties.Installable = proptools.BoolPtr(true)
android.InitApexModule(module)
+ android.InitSdkAwareModule(module)
InitJavaModule(module, android.HostSupported)
return module
}
@@ -923,6 +924,7 @@
module.Module.dexpreopter.isTest = true
module.Module.linter.test = true
+ android.InitSdkAwareModule(module)
InitJavaModule(module, android.HostAndDeviceSupported)
return module
}
@@ -1296,9 +1298,10 @@
if ai.ForPrebuiltApex {
if deapexerModule == nil {
// This should never happen as a variant for a prebuilt_apex is only created if the
- // deapxer module has been configured to export the dex implementation jar for this module.
+ // deapexer module has been configured to export the dex implementation jar for this module.
ctx.ModuleErrorf("internal error: module %q does not depend on a `deapexer` module for prebuilt_apex %q",
j.Name(), ai.ApexVariationName)
+ return
}
// Get the path of the dex implementation jar from the `deapexer` module.
diff --git a/java/sdk_library.go b/java/sdk_library.go
index fcc105d..aff4539 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1756,6 +1756,7 @@
module.InitSdkLibraryProperties()
android.InitApexModule(module)
+ android.InitSdkAwareModule(module)
InitJavaModule(module, android.HostAndDeviceSupported)
// Initialize the map from scope to scope specific properties.
@@ -2385,9 +2386,6 @@
// Scope to per scope properties.
Scopes map[*apiScope]scopeProperties
- // Additional libraries that the exported stubs libraries depend upon.
- Libs []string
-
// The Java stubs source files.
Stub_srcs []string
@@ -2439,7 +2437,6 @@
}
}
- s.Libs = sdk.properties.Libs
s.Naming_scheme = sdk.commonSdkLibraryProperties.Naming_scheme
s.Shared_library = proptools.BoolPtr(sdk.sharedLibrary())
s.Compile_dex = sdk.dexProperties.Compile_dex
@@ -2504,8 +2501,4 @@
}
propertySet.AddProperty("doctag_files", dests)
}
-
- if len(s.Libs) > 0 {
- propertySet.AddPropertyWithTag("libs", s.Libs, ctx.SnapshotBuilder().SdkMemberReferencePropertyTag(false))
- }
}
diff --git a/java/system_modules.go b/java/system_modules.go
index a09778c..d0dc74a 100644
--- a/java/system_modules.go
+++ b/java/system_modules.go
@@ -35,9 +35,8 @@
// Register sdk member types.
android.RegisterSdkMemberType(&systemModulesSdkMemberType{
android.SdkMemberTypeBase{
- PropertyName: "java_system_modules",
- SupportsSdk: true,
- TransitiveSdkMembers: true,
+ PropertyName: "java_system_modules",
+ SupportsSdk: true,
},
})
}
@@ -115,6 +114,7 @@
module.AddProperties(&module.properties)
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
+ android.InitSdkAwareModule(module)
return module
}
diff --git a/python/python.go b/python/python.go
index 4444a70..0f5b788 100644
--- a/python/python.go
+++ b/python/python.go
@@ -444,11 +444,10 @@
var sharedLibs []string
// if embedded launcher is enabled, we need to collect the shared library depenendencies of the
// launcher
- ctx.VisitDirectDeps(func(dep android.Module) {
- if ctx.OtherModuleDependencyTag(dep) == launcherSharedLibTag {
- sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
- }
- })
+ for _, dep := range ctx.GetDirectDepsWithTag(launcherSharedLibTag) {
+ sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
+ }
+
p.installer.setAndroidMkSharedLibs(sharedLibs)
// Install the par file from installSource
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index a4f985b..31555c0 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -191,12 +191,12 @@
sdk_snapshot {
name: "mysdk@1",
- native_shared_libs: ["sdkmember_mysdk_1"],
+ native_shared_libs: ["sdkmember_mysdk@1"],
}
sdk_snapshot {
name: "mysdk@2",
- native_shared_libs: ["sdkmember_mysdk_2"],
+ native_shared_libs: ["sdkmember_mysdk@2"],
}
cc_prebuilt_library_shared {
@@ -208,7 +208,7 @@
}
cc_prebuilt_library_shared {
- name: "sdkmember_mysdk_1",
+ name: "sdkmember_mysdk@1",
sdk_member_name: "sdkmember",
srcs: ["libfoo.so"],
system_shared_libs: [],
@@ -221,7 +221,7 @@
}
cc_prebuilt_library_shared {
- name: "sdkmember_mysdk_2",
+ name: "sdkmember_mysdk@2",
sdk_member_name: "sdkmember",
srcs: ["libfoo.so"],
system_shared_libs: [],
@@ -272,8 +272,8 @@
}
`)
- sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
- sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
+ sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk@1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output
+ sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk@2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output
cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1")
cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2")
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 6016981..dc58d93 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -83,12 +83,12 @@
sdk_snapshot {
name: "mysdk@1",
- java_header_libs: ["sdkmember_mysdk_1"],
+ java_header_libs: ["sdkmember_mysdk@1"],
}
sdk_snapshot {
name: "mysdk@2",
- java_header_libs: ["sdkmember_mysdk_2"],
+ java_header_libs: ["sdkmember_mysdk@2"],
}
java_library {
@@ -100,13 +100,13 @@
}
java_import {
- name: "sdkmember_mysdk_1",
+ name: "sdkmember_mysdk@1",
sdk_member_name: "sdkmember",
host_supported: true,
}
java_import {
- name: "sdkmember_mysdk_2",
+ name: "sdkmember_mysdk@2",
sdk_member_name: "sdkmember",
host_supported: true,
}
@@ -144,8 +144,8 @@
}
`)
- sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_common").Rule("combineJar").Output
- sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_common").Rule("combineJar").Output
+ sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk@1", "android_common").Rule("combineJar").Output
+ sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk@2", "android_common").Rule("combineJar").Output
javalibForMyApex := result.ModuleForTests("myjavalib", "android_common_apex10000_mysdk_1")
javalibForMyApex2 := result.ModuleForTests("myjavalib", "android_common_apex10000_mysdk_2")
diff --git a/sdk/sdk.go b/sdk/sdk.go
index 2f56de6..624c0fa 100644
--- a/sdk/sdk.go
+++ b/sdk/sdk.go
@@ -444,7 +444,7 @@
// built with libfoo.mysdk.11 and libfoo.mysdk.12, respectively depending on which sdk they are
// using.
func memberInterVersionMutator(mctx android.BottomUpMutatorContext) {
- if m, ok := mctx.Module().(android.SdkAware); ok && m.IsInAnySdk() {
+ if m, ok := mctx.Module().(android.SdkAware); ok && m.IsInAnySdk() && m.IsVersioned() {
if !m.ContainingSdk().Unversioned() {
memberName := m.MemberName()
tag := sdkMemberVersionedDepTag{member: memberName, version: m.ContainingSdk().Version}
@@ -483,7 +483,7 @@
// Step 5: if libfoo.mysdk.11 is in the context where version 11 of mysdk is requested, the
// versioned module is used instead of the un-versioned (in-development) module libfoo
func sdkDepsReplaceMutator(mctx android.BottomUpMutatorContext) {
- if versionedSdkMember, ok := mctx.Module().(android.SdkAware); ok && versionedSdkMember.IsInAnySdk() {
+ if versionedSdkMember, ok := mctx.Module().(android.SdkAware); ok && versionedSdkMember.IsInAnySdk() && versionedSdkMember.IsVersioned() {
if sdk := versionedSdkMember.ContainingSdk(); !sdk.Unversioned() {
// Only replace dependencies to <sdkmember> with <sdkmember@required-version>
// if the depending module requires it. e.g.
@@ -499,7 +499,7 @@
// TODO(b/183204176): Remove this after fixing.
defer func() {
if r := recover(); r != nil {
- mctx.ModuleErrorf("%s", r)
+ mctx.ModuleErrorf("sdkDepsReplaceMutator %s", r)
}
}()
diff --git a/sdk/update.go b/sdk/update.go
index 72b02e8..457cbd9 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -133,9 +133,9 @@
export := memberTag.ExportMember()
s.memberVariantDeps = append(s.memberVariantDeps, sdkMemberVariantDep{s, memberType, child.(android.SdkAware), export})
- // If the member type supports transitive sdk members then recurse down into
- // its dependencies, otherwise exit traversal.
- return memberType.HasTransitiveSdkMembers()
+ // Recurse down into the member's dependencies as it may have dependencies that need to be
+ // automatically added to the sdk.
+ return true
}
return false