Merge changes from topic "separate_code"
* changes:
soong: use -Wl,-z,separate-code w/ -Wl,--execute-only
Revert "Revert "soong: upgrade Android platform to clang-r370808""
diff --git a/Android.bp b/Android.bp
index f72d624..d469f41 100644
--- a/Android.bp
+++ b/Android.bp
@@ -186,6 +186,7 @@
"cc/binary.go",
"cc/fuzz.go",
"cc/library.go",
+ "cc/library_sdk_member.go",
"cc/object.go",
"cc/test.go",
"cc/toolchain_library.go",
@@ -346,6 +347,7 @@
"rust/config/whitelist.go",
"rust/config/x86_darwin_host.go",
"rust/config/x86_linux_host.go",
+ "rust/config/x86_device.go",
"rust/config/x86_64_device.go",
],
}
diff --git a/android/apex.go b/android/apex.go
index 44387cd..3da4828 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -179,7 +179,7 @@
m.checkApexAvailableProperty(mctx)
sort.Strings(m.apexVariations)
variations := []string{}
- availableForPlatform := mctx.Module().(ApexModule).AvailableFor(availableToPlatform)
+ availableForPlatform := mctx.Module().(ApexModule).AvailableFor(availableToPlatform) || mctx.Host()
if availableForPlatform {
variations = append(variations, "") // Original variation for platform
}
diff --git a/android/image.go b/android/image.go
index 8424cf8..5291ce3 100644
--- a/android/image.go
+++ b/android/image.go
@@ -42,7 +42,7 @@
// CoreVariation is the variant used for framework-private libraries, or
// SDK libraries. (which framework-private libraries can use), which
// will be installed to the system image.
- CoreVariation string = "core"
+ CoreVariation string = ""
// RecoveryVariation means a module to be installed to recovery image.
RecoveryVariation string = "recovery"
diff --git a/android/module.go b/android/module.go
index b4f8f1a..b858564 100644
--- a/android/module.go
+++ b/android/module.go
@@ -302,9 +302,6 @@
// If a module does not specify the `visibility` property then it uses the
// `default_visibility` property of the `package` module in the module's package.
//
- // If a module does not specify the `visibility` property then it uses the
- // `default_visibility` property of the `package` module in the module's package.
- //
// If the `default_visibility` property is not set for the module's package then
// it will use the `default_visibility` of its closest ancestor package for which
// a `default_visibility` property is specified.
diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go
index 6bb3ccf..3c466a1 100644
--- a/android/prebuilt_etc_test.go
+++ b/android/prebuilt_etc_test.go
@@ -88,7 +88,7 @@
}
`)
- p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
+ p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc)
if p.outputFilePath.Base() != "foo.installed.conf" {
t.Errorf("expected foo.installed.conf, got %q", p.outputFilePath.Base())
}
@@ -107,12 +107,12 @@
}
`)
- p := ctx.ModuleForTests("my_foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
+ p := ctx.ModuleForTests("my_foo", "android_arm64_armv8-a").Module().(*PrebuiltEtc)
if p.outputFilePath.Base() != "my_foo" {
t.Errorf("expected my_foo, got %q", p.outputFilePath.Base())
}
- p = ctx.ModuleForTests("my_bar", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
+ p = ctx.ModuleForTests("my_bar", "android_arm64_armv8-a").Module().(*PrebuiltEtc)
if p.outputFilePath.Base() != "bar.conf" {
t.Errorf("expected bar.conf, got %q", p.outputFilePath.Base())
}
@@ -141,7 +141,7 @@
"LOCAL_TARGET_REQUIRED_MODULES": {"targetModA"},
}
- mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
+ mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*PrebuiltEtc)
entries := AndroidMkEntriesForTest(t, config, "", mod)[0]
for k, expectedValue := range expected {
if value, ok := entries.EntryMap[k]; ok {
@@ -178,7 +178,7 @@
}
`)
- p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
+ p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc)
expected := buildDir + "/target/product/test_device/system/usr/share/bar"
if p.installDirPath.String() != expected {
t.Errorf("expected %q, got %q", expected, p.installDirPath.String())
@@ -210,7 +210,7 @@
}
`)
- p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
+ p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc)
expected := buildDir + "/target/product/test_device/system/fonts"
if p.installDirPath.String() != expected {
t.Errorf("expected %q, got %q", expected, p.installDirPath.String())
@@ -245,7 +245,7 @@
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
ctx, _ := testPrebuiltEtc(t, tt.config)
- p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
+ p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc)
if p.installDirPath.String() != tt.expectedPath {
t.Errorf("expected %q, got %q", tt.expectedPath, p.installDirPath)
}
diff --git a/android/sdk.go b/android/sdk.go
index 533bd0e..7956434 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -15,6 +15,7 @@
package android
import (
+ "sort"
"strings"
"github.com/google/blueprint"
@@ -218,18 +219,24 @@
// The basic implementation should look something like this, where ModuleType is
// the name of the module type being supported.
//
-// var ModuleTypeSdkMemberType = newModuleTypeSdkMemberType()
-//
-// func newModuleTypeSdkMemberType() android.SdkMemberType {
-// return &moduleTypeSdkMemberType{}
+// type moduleTypeSdkMemberType struct {
+// android.SdkMemberTypeBase
// }
//
-// type moduleTypeSdkMemberType struct {
+// func init() {
+// android.RegisterSdkMemberType(&moduleTypeSdkMemberType{
+// SdkMemberTypeBase: android.SdkMemberTypeBase{
+// PropertyName: "module_types",
+// },
+// }
// }
//
// ...methods...
//
type SdkMemberType interface {
+ // The name of the member type property on an sdk module.
+ SdkPropertyName() string
+
// 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
@@ -254,3 +261,66 @@
// IsInstance(Module) method returned true.
BuildSnapshot(sdkModuleContext ModuleContext, builder SnapshotBuilder, member SdkMember)
}
+
+type SdkMemberTypeBase struct {
+ PropertyName string
+}
+
+func (b *SdkMemberTypeBase) SdkPropertyName() string {
+ return b.PropertyName
+}
+
+// Encapsulates the information about registered SdkMemberTypes.
+type SdkMemberTypesRegistry struct {
+ // The list of types sorted by property name.
+ list []SdkMemberType
+
+ // The key that uniquely identifies this registry instance.
+ key OnceKey
+}
+
+func (r *SdkMemberTypesRegistry) RegisteredTypes() []SdkMemberType {
+ return r.list
+}
+
+func (r *SdkMemberTypesRegistry) UniqueOnceKey() OnceKey {
+ // Use the pointer to the registry as the unique key.
+ return NewCustomOnceKey(r)
+}
+
+// The set of registered SdkMemberTypes.
+var SdkMemberTypes = &SdkMemberTypesRegistry{}
+
+// Register an SdkMemberType object to allow them to be used in the sdk and sdk_snapshot module
+// types.
+func RegisterSdkMemberType(memberType SdkMemberType) {
+ oldList := SdkMemberTypes.list
+
+ // Copy the slice just in case this is being read while being modified, e.g. when testing.
+ list := make([]SdkMemberType, 0, len(oldList)+1)
+ list = append(list, oldList...)
+ list = append(list, memberType)
+
+ // Sort the member types by their property name to ensure that registry order has no effect
+ // on behavior.
+ sort.Slice(list, func(i1, i2 int) bool {
+ t1 := list[i1]
+ t2 := list[i2]
+
+ return t1.SdkPropertyName() < t2.SdkPropertyName()
+ })
+
+ // Generate a key that identifies the slice of SdkMemberTypes by joining the property names
+ // from all the SdkMemberType .
+ var properties []string
+ for _, t := range list {
+ properties = append(properties, t.SdkPropertyName())
+ }
+ key := NewOnceKey(strings.Join(properties, "|"))
+
+ // Create a new registry so the pointer uniquely identifies the set of registered types.
+ SdkMemberTypes = &SdkMemberTypesRegistry{
+ list: list,
+ key: key,
+ }
+}
diff --git a/apex/androidmk.go b/apex/androidmk.go
index 35622f0..a231a90 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -63,7 +63,11 @@
}
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
- fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
+ if fi.moduleDir != "" {
+ fmt.Fprintln(w, "LOCAL_PATH :=", fi.moduleDir)
+ } else {
+ fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
+ }
fmt.Fprintln(w, "LOCAL_MODULE :=", fi.moduleName)
// /apex/<apex_name>/{lib|framework|...}
pathWhenActivated := filepath.Join("$(PRODUCT_OUT)", "apex", apexName, fi.installDir)
diff --git a/apex/apex.go b/apex/apex.go
index 16bac94..3d7b45d 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -343,6 +343,10 @@
// Whenever apex_payload.img of the APEX should include dm-verity hashtree.
// Should be only used in tests#.
Test_only_no_hashtree *bool
+
+ // Whether this APEX should support Android10. Default is false. If this is set true, then apex_manifest.json is bundled as well
+ // because Android10 requires legacy apex_manifest.json instead of apex_manifest.pb
+ Legacy_android10_support *bool
}
type apexTargetBundleProperties struct {
@@ -455,20 +459,25 @@
// list of symlinks that will be created in installDir that point to this apexFile
symlinks []string
transitiveDep bool
+ moduleDir string
}
-func newApexFile(builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
- return apexFile{
+func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, moduleName string, installDir string, class apexFileClass, module android.Module) apexFile {
+ ret := apexFile{
builtFile: builtFile,
moduleName: moduleName,
installDir: installDir,
class: class,
module: module,
}
+ if module != nil {
+ ret.moduleDir = ctx.OtherModuleDir(module)
+ }
+ return ret
}
func (af *apexFile) Ok() bool {
- return af.builtFile != nil || af.builtFile.String() == ""
+ return af.builtFile != nil && af.builtFile.String() != ""
}
type apexBundle struct {
@@ -507,10 +516,8 @@
artApex bool
primaryApexType bool
- // intermediate path for apex_manifest.json
- manifestJsonOut android.WritablePath
- manifestJsonFullOut android.WritablePath
- manifestPbOut android.WritablePath
+ manifestJsonOut android.WritablePath
+ manifestPbOut android.WritablePath
// list of commands to create symlinks for backward compatibility
// these commands will be attached as LOCAL_POST_INSTALL_CMD to
@@ -787,7 +794,7 @@
}
// TODO(jiyong) move apexFileFor* close to the apexFile type definition
-func apexFileForNativeLibrary(ccMod *cc.Module, config android.Config, handleSpecialLibs bool) apexFile {
+func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
// Decide the APEX-local directory by the multilib of the library
// In the future, we may query this to the module.
var dirInApex string
@@ -801,7 +808,7 @@
if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
}
- if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), config) {
+ if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
// Special case for Bionic libs and other libs installed with them. This is
// to prevent those libs from being included in the search path
// /apex/com.android.runtime/${LIB}. This exclusion is required because
@@ -816,26 +823,26 @@
}
fileToCopy := ccMod.OutputFile().Path()
- return newApexFile(fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
+ return newApexFile(ctx, fileToCopy, ccMod.Name(), dirInApex, nativeSharedLib, ccMod)
}
-func apexFileForExecutable(cc *cc.Module) apexFile {
+func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
dirInApex := filepath.Join("bin", cc.RelativeInstallPath())
if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
}
fileToCopy := cc.OutputFile().Path()
- af := newApexFile(fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
+ af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
af.symlinks = cc.Symlinks()
return af
}
-func apexFileForPyBinary(py *python.Module) apexFile {
+func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
dirInApex := "bin"
fileToCopy := py.HostToolPath().Path()
- return newApexFile(fileToCopy, py.Name(), dirInApex, pyBinary, py)
+ return newApexFile(ctx, fileToCopy, py.Name(), dirInApex, pyBinary, py)
}
-func apexFileForGoBinary(ctx android.ModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
+func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
dirInApex := "bin"
s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
if err != nil {
@@ -846,24 +853,24 @@
// NB: Since go binaries are static we don't need the module for anything here, which is
// good since the go tool is a blueprint.Module not an android.Module like we would
// normally use.
- return newApexFile(fileToCopy, depName, dirInApex, goBinary, nil)
+ return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
}
-func apexFileForShBinary(sh *android.ShBinary) apexFile {
+func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
dirInApex := filepath.Join("bin", sh.SubDir())
fileToCopy := sh.OutputFile()
- af := newApexFile(fileToCopy, sh.Name(), dirInApex, shBinary, sh)
+ af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
af.symlinks = sh.Symlinks()
return af
}
-func apexFileForJavaLibrary(java *java.Library) apexFile {
+func apexFileForJavaLibrary(ctx android.BaseModuleContext, java *java.Library) apexFile {
dirInApex := "javalib"
fileToCopy := java.DexJarFile()
- return newApexFile(fileToCopy, java.Name(), dirInApex, javaSharedLib, java)
+ return newApexFile(ctx, fileToCopy, java.Name(), dirInApex, javaSharedLib, java)
}
-func apexFileForPrebuiltJavaLibrary(java *java.Import) apexFile {
+func apexFileForPrebuiltJavaLibrary(ctx android.BaseModuleContext, java *java.Import) apexFile {
dirInApex := "javalib"
// The output is only one, but for some reason, ImplementationJars returns Paths, not Path
implJars := java.ImplementationJars()
@@ -872,16 +879,16 @@
strings.Join(implJars.Strings(), ", ")))
}
fileToCopy := implJars[0]
- return newApexFile(fileToCopy, java.Name(), dirInApex, javaSharedLib, java)
+ return newApexFile(ctx, fileToCopy, java.Name(), dirInApex, javaSharedLib, java)
}
-func apexFileForPrebuiltEtc(prebuilt android.PrebuiltEtcModule, depName string) apexFile {
+func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
dirInApex := filepath.Join("etc", prebuilt.SubDir())
fileToCopy := prebuilt.OutputFile()
- return newApexFile(fileToCopy, depName, dirInApex, etc, prebuilt)
+ return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
}
-func apexFileForAndroidApp(aapp interface {
+func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
android.Module
Privileged() bool
OutputFile() android.Path
@@ -892,7 +899,7 @@
}
dirInApex := filepath.Join(appDir, pkgName)
fileToCopy := aapp.OutputFile()
- return newApexFile(fileToCopy, aapp.Name(), dirInApex, app, aapp)
+ return newApexFile(ctx, fileToCopy, aapp.Name(), dirInApex, app, aapp)
}
// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
@@ -980,19 +987,19 @@
if cc.HasStubsVariants() {
provideNativeLibs = append(provideNativeLibs, cc.OutputFile().Path().Base())
}
- filesInfo = append(filesInfo, apexFileForNativeLibrary(cc, ctx.Config(), handleSpecialLibs))
+ filesInfo = append(filesInfo, apexFileForNativeLibrary(ctx, cc, handleSpecialLibs))
return true // track transitive dependencies
} else {
ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
}
case executableTag:
if cc, ok := child.(*cc.Module); ok {
- filesInfo = append(filesInfo, apexFileForExecutable(cc))
+ filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
return true // track transitive dependencies
} else if sh, ok := child.(*android.ShBinary); ok {
- filesInfo = append(filesInfo, apexFileForShBinary(sh))
+ filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
} else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
- filesInfo = append(filesInfo, apexFileForPyBinary(py))
+ filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
} else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
} else {
@@ -1000,7 +1007,7 @@
}
case javaLibTag:
if javaLib, ok := child.(*java.Library); ok {
- af := apexFileForJavaLibrary(javaLib)
+ af := apexFileForJavaLibrary(ctx, javaLib)
if !af.Ok() {
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
} else {
@@ -1008,7 +1015,7 @@
return true // track transitive dependencies
}
} else if javaLib, ok := child.(*java.Import); ok {
- af := apexFileForPrebuiltJavaLibrary(javaLib)
+ af := apexFileForPrebuiltJavaLibrary(ctx, javaLib)
if !af.Ok() {
ctx.PropertyErrorf("java_libs", "%q does not have a jar output", depName)
} else {
@@ -1020,16 +1027,16 @@
case androidAppTag:
pkgName := ctx.DeviceConfig().OverridePackageNameFor(depName)
if ap, ok := child.(*java.AndroidApp); ok {
- filesInfo = append(filesInfo, apexFileForAndroidApp(ap, pkgName))
+ filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
return true // track transitive dependencies
} else if ap, ok := child.(*java.AndroidAppImport); ok {
- filesInfo = append(filesInfo, apexFileForAndroidApp(ap, pkgName))
+ filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap, pkgName))
} else {
ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
}
case prebuiltTag:
if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
- filesInfo = append(filesInfo, apexFileForPrebuiltEtc(prebuilt, depName))
+ filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
} else {
ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
}
@@ -1045,7 +1052,7 @@
return true
} else {
// Single-output test module (where `test_per_src: false`).
- af := apexFileForExecutable(ccTest)
+ af := apexFileForExecutable(ctx, ccTest)
af.class = nativeTest
filesInfo = append(filesInfo, af)
}
@@ -1101,14 +1108,14 @@
// Don't track further
return false
}
- af := apexFileForNativeLibrary(cc, ctx.Config(), handleSpecialLibs)
+ af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
af.transitiveDep = true
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
}
} else if cc.IsTestPerSrcDepTag(depTag) {
if cc, ok := child.(*cc.Module); ok {
- af := apexFileForExecutable(cc)
+ af := apexFileForExecutable(ctx, cc)
// Handle modules created as `test_per_src` variations of a single test module:
// use the name of the generated test binary (`fileToCopy`) instead of the name
// of the original test module (`depName`, shared by all `test_per_src`
@@ -1137,7 +1144,7 @@
dirInApex := filepath.Join("javalib", arch.String())
for _, f := range files {
localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
- af := newApexFile(f, localModule, dirInApex, etc, nil)
+ af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
filesInfo = append(filesInfo, af)
}
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index a5ccc1b..4f0ab3a 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -140,8 +140,8 @@
ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
})
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.BottomUp("link", cc.LinkageMutator).Parallel()
ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
+ ctx.BottomUp("link", cc.LinkageMutator).Parallel()
ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()
ctx.BottomUp("version", cc.VersionMutator).Parallel()
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
@@ -483,12 +483,12 @@
ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
// Ensure that apex variant is created for the direct dep
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_myapex")
ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common_myapex")
ensureListContains(t, ctx.ModuleVariantsForTests("myprebuiltjar"), "android_common_myapex")
// Ensure that apex variant is created for the indirect dep
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_myapex")
ensureListContains(t, ctx.ModuleVariantsForTests("myotherjar"), "android_common_myapex")
// Ensure that both direct and indirect deps are copied into apex
@@ -499,9 +499,9 @@
// .. but not for java libs
ensureNotContains(t, copyCmds, "image.apex/javalib/myotherjar.jar")
- // Ensure that the platform variant ends with _core_shared or _common
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared")
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared")
+ // Ensure that the platform variant ends with _shared or _common
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared")
ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common")
ensureListContains(t, ctx.ModuleVariantsForTests("myotherjar"), "android_common")
ensureListContains(t, ctx.ModuleVariantsForTests("myprebuiltjar"), "android_common")
@@ -547,9 +547,10 @@
`)
module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
- module.Output("apex_manifest.pb")
- module.Output("apex_manifest.json")
- module.Output("apex_manifest_full.json")
+ args := module.Rule("apexRule").Args
+ if manifest := args["manifest"]; manifest != module.Output("apex_manifest.pb").Output.String() {
+ t.Error("manifest should be apex_manifest.pb, but " + manifest)
+ }
}
func TestBasicZipApex(t *testing.T) {
@@ -590,10 +591,10 @@
ensureContains(t, zipApexRule.Output.String(), "myapex.zipapex.unsigned")
// Ensure that APEX variant is created for the direct dep
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_myapex")
// Ensure that APEX variant is created for the indirect dep
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_myapex")
// Ensure that both direct and indirect deps are copied into apex
ensureContains(t, copyCmds, "image.zipapex/lib64/mylib.so")
@@ -664,24 +665,24 @@
// Ensure that direct stubs dep is included
ensureContains(t, copyCmds, "image.apex/lib64/mylib3.so")
- mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"]
+ mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_myapex").Rule("ld").Args["libFlags"]
// Ensure that mylib is linking with the latest version of stubs for mylib2
- ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_core_shared_3_myapex/mylib2.so")
+ ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared_3_myapex/mylib2.so")
// ... and not linking to the non-stub (impl) variant of mylib2
- ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_core_shared_myapex/mylib2.so")
+ ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared_myapex/mylib2.so")
// Ensure that mylib is linking with the non-stub (impl) of mylib3 (because mylib3 is in the same apex)
- ensureContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_core_shared_myapex/mylib3.so")
+ ensureContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_myapex/mylib3.so")
// .. and not linking to the stubs variant of mylib3
- ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_core_shared_12_myapex/mylib3.so")
+ ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_12_myapex/mylib3.so")
// Ensure that stubs libs are built without -include flags
- mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"]
+ mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylib2Cflags, "-include ")
// Ensure that genstub is invoked with --apex
- ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_core_static_3_myapex").Rule("genStubSrc").Args["flags"])
+ ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_3_myapex").Rule("genStubSrc").Args["flags"])
}
func TestApexWithExplicitStubsDependency(t *testing.T) {
@@ -738,14 +739,14 @@
// Ensure that dependency of stubs is not included
ensureNotContains(t, copyCmds, "image.apex/lib64/libbar.so")
- mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"]
+ mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_myapex").Rule("ld").Args["libFlags"]
// Ensure that mylib is linking with version 10 of libfoo
- ensureContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_core_shared_10_myapex/libfoo.so")
+ ensureContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_shared_10_myapex/libfoo.so")
// ... and not linking to the non-stub (impl) variant of libfoo
- ensureNotContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_core_shared_myapex/libfoo.so")
+ ensureNotContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_shared_myapex/libfoo.so")
- libFooStubsLdFlags := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_core_shared_10_myapex").Rule("ld").Args["libFlags"]
+ libFooStubsLdFlags := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared_10_myapex").Rule("ld").Args["libFlags"]
// Ensure that libfoo stubs is not linking to libbar (since it is a stubs)
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
@@ -951,45 +952,45 @@
// Ensure that libc is not included (since it has stubs and not listed in native_shared_libs)
ensureNotContains(t, copyCmds, "image.apex/lib64/bionic/libc.so")
- mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"]
- mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"]
- mylibSharedCFlags := ctx.ModuleForTests("mylib_shared", "android_arm64_armv8-a_core_shared_myapex").Rule("cc").Args["cFlags"]
+ mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_myapex").Rule("ld").Args["libFlags"]
+ mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"]
+ mylibSharedCFlags := ctx.ModuleForTests("mylib_shared", "android_arm64_armv8-a_shared_myapex").Rule("cc").Args["cFlags"]
// For dependency to libc
// Ensure that mylib is linking with the latest version of stubs
- ensureContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_core_shared_29_myapex/libc.so")
+ ensureContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_shared_29_myapex/libc.so")
// ... and not linking to the non-stub (impl) variant
- ensureNotContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_core_shared_myapex/libc.so")
+ ensureNotContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_shared_myapex/libc.so")
// ... Cflags from stub is correctly exported to mylib
ensureContains(t, mylibCFlags, "__LIBC_API__=29")
ensureContains(t, mylibSharedCFlags, "__LIBC_API__=29")
// For dependency to libm
// Ensure that mylib is linking with the non-stub (impl) variant
- ensureContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_core_shared_myapex/libm.so")
+ ensureContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_shared_myapex/libm.so")
// ... and not linking to the stub variant
- ensureNotContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_core_shared_29_myapex/libm.so")
+ ensureNotContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_shared_29_myapex/libm.so")
// ... and is not compiling with the stub
ensureNotContains(t, mylibCFlags, "__LIBM_API__=29")
ensureNotContains(t, mylibSharedCFlags, "__LIBM_API__=29")
// For dependency to libdl
// Ensure that mylib is linking with the specified version of stubs
- ensureContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_27_myapex/libdl.so")
+ ensureContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_shared_27_myapex/libdl.so")
// ... and not linking to the other versions of stubs
- ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_28_myapex/libdl.so")
- ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_29_myapex/libdl.so")
+ ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_shared_28_myapex/libdl.so")
+ ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_shared_29_myapex/libdl.so")
// ... and not linking to the non-stub (impl) variant
- ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_myapex/libdl.so")
+ ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_shared_myapex/libdl.so")
// ... Cflags from stub is correctly exported to mylib
ensureContains(t, mylibCFlags, "__LIBDL_API__=27")
ensureContains(t, mylibSharedCFlags, "__LIBDL_API__=27")
// Ensure that libBootstrap is depending on the platform variant of bionic libs
- libFlags := ctx.ModuleForTests("libBootstrap", "android_arm64_armv8-a_core_shared").Rule("ld").Args["libFlags"]
- ensureContains(t, libFlags, "libc/android_arm64_armv8-a_core_shared/libc.so")
- ensureContains(t, libFlags, "libm/android_arm64_armv8-a_core_shared/libm.so")
- ensureContains(t, libFlags, "libdl/android_arm64_armv8-a_core_shared/libdl.so")
+ libFlags := ctx.ModuleForTests("libBootstrap", "android_arm64_armv8-a_shared").Rule("ld").Args["libFlags"]
+ ensureContains(t, libFlags, "libc/android_arm64_armv8-a_shared/libc.so")
+ ensureContains(t, libFlags, "libm/android_arm64_armv8-a_shared/libm.so")
+ ensureContains(t, libFlags, "libdl/android_arm64_armv8-a_shared/libdl.so")
}
func TestFilesInSubDir(t *testing.T) {
@@ -1100,8 +1101,8 @@
ensureContains(t, inputsString, "android_arm64_armv8-a_vendor.VER_shared_myapex/mylib2.so")
// ensure that the apex does not include core variants
- ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib.so")
- ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib2.so")
+ ensureNotContains(t, inputsString, "android_arm64_armv8-a_shared_myapex/mylib.so")
+ ensureNotContains(t, inputsString, "android_arm64_armv8-a_shared_myapex/mylib2.so")
}
func TestUseVendorRestriction(t *testing.T) {
@@ -1194,10 +1195,10 @@
}
`)
- ldFlags := ctx.ModuleForTests("not_in_apex", "android_arm64_armv8-a_core").Rule("ld").Args["libFlags"]
+ ldFlags := ctx.ModuleForTests("not_in_apex", "android_arm64_armv8-a").Rule("ld").Args["libFlags"]
// Ensure that not_in_apex is linking with the static variant of mylib
- ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_core_static/mylib.a")
+ ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_static/mylib.a")
}
func TestKeys(t *testing.T) {
@@ -1284,19 +1285,19 @@
`)
// non-APEX variant does not have __ANDROID_APEX(_NAME)__ defined
- mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"]
+ mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
// APEX variant has __ANDROID_APEX(_NAME)__ defined
- mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"]
+ mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"]
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
// APEX variant has __ANDROID_APEX(_NAME)__ defined
- mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_otherapex").Rule("cc").Args["cFlags"]
+ mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_otherapex").Rule("cc").Args["cFlags"]
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
@@ -1344,7 +1345,7 @@
}
`)
- cFlags := ctx.ModuleForTests("otherlib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"]
+ cFlags := ctx.ModuleForTests("otherlib", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
// Ensure that the include path of the header lib is exported to 'otherlib'
ensureContains(t, cFlags, "-Imy_include")
@@ -1970,13 +1971,13 @@
ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
// Ensure that apex variant is created for the direct dep
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_shared_myapex")
// Ensure that both direct and indirect deps are copied into apex
ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so")
- // Ensure that the platform variant ends with _core_shared
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared")
+ // Ensure that the platform variant ends with _shared
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_shared")
if !android.InAnyApex("mylib_common") {
t.Log("Found mylib_common not in any apex!")
@@ -2021,13 +2022,13 @@
ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
// Ensure that apex variant is created for the direct dep
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_core_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_shared_myapex")
// Ensure that both direct and indirect deps are copied into apex
ensureContains(t, copyCmds, "image.apex/lib64/mylib_common_test.so")
- // Ensure that the platform variant ends with _core_shared
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_core_shared")
+ // Ensure that the platform variant ends with _shared
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_shared")
if android.InAnyApex("mylib_common_test") {
t.Log("Found mylib_common_test in some apex!")
@@ -2100,19 +2101,19 @@
ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
// Ensure that apex variant is created for the direct dep
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex")
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared_myapex")
- ensureListNotContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_shared_myapex")
+ ensureListNotContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_myapex")
// Ensure that both direct and indirect deps are copied into apex
ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so")
ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so")
- // Ensure that the platform variant ends with _core_shared
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared")
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared")
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared")
+ // Ensure that the platform variant ends with _shared
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_shared")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared")
}
func TestApexWithShBinary(t *testing.T) {
@@ -2452,7 +2453,7 @@
ensureContains(t, androidMk, "LOCAL_MODULE := mytest1.myapex\n")
ensureContains(t, androidMk, "LOCAL_MODULE := mytest2.myapex\n")
ensureContains(t, androidMk, "LOCAL_MODULE := mytest3.myapex\n")
- ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.json.myapex\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.myapex\n")
ensureContains(t, androidMk, "LOCAL_MODULE := apex_pubkey.myapex\n")
ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
}
@@ -2526,8 +2527,8 @@
apexRule2 := module2.Rule("apexRule")
copyCmds2 := apexRule2.Args["copy_commands"]
- ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex")
- ensureListContains(t, ctx.ModuleVariantsForTests("libcommon"), "android_arm64_armv8-a_core_shared_commonapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("libcommon"), "android_arm64_armv8-a_shared_commonapex")
ensureContains(t, copyCmds1, "image.apex/lib64/mylib.so")
ensureContains(t, copyCmds2, "image.apex/lib64/libcommon.so")
ensureNotContains(t, copyCmds1, "image.apex/lib64/libcommon.so")
@@ -2693,7 +2694,7 @@
// JNI libraries are embedded inside APK
appZipRule := ctx.ModuleForTests("AppFoo", "android_common_myapex").Rule("zip")
- libjniOutput := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_core_shared_myapex").Module().(*cc.Module).OutputFile()
+ libjniOutput := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_shared_myapex").Module().(*cc.Module).OutputFile()
ensureListContains(t, appZipRule.Implicits.Strings(), libjniOutput.String())
// ... uncompressed
if args := appZipRule.Args["jarArgs"]; !strings.Contains(args, "-L 0") {
@@ -2905,10 +2906,10 @@
}`)
// check that libfoo and libbar are created only for myapex, but not for the platform
- ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared_myapex")
- ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared")
- ensureListContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_core_shared_myapex")
- ensureListNotContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_core_shared")
+ ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex")
+ ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared")
+ ensureListContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared_myapex")
+ ensureListNotContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared")
ctx, _ = testApex(t, `
apex {
@@ -2930,8 +2931,8 @@
}`)
// check that libfoo is created only for the platform
- ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared_myapex")
- ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared")
+ ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared")
ctx, _ = testApex(t, `
apex {
@@ -2957,11 +2958,11 @@
}`)
// shared variant of libfoo is only available to myapex
- ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared_myapex")
- ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_shared")
+ ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex")
+ ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared")
// but the static variant is available to both myapex and the platform
- ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_static_myapex")
- ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_core_static")
+ ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static_myapex")
+ ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static")
}
func TestOverrideApex(t *testing.T) {
@@ -3034,6 +3035,49 @@
ensureNotContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.apex")
}
+func TestLegacyAndroid10Support(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ legacy_android10_support: true,
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `)
+
+ module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
+ args := module.Rule("apexRule").Args
+ ensureContains(t, args["opt_flags"], "--manifest_json "+module.Output("apex_manifest.json").Output.String())
+}
+
+func TestRejectNonInstallableJavaLibrary(t *testing.T) {
+ testApexError(t, `"myjar" is not configured to be compiled into dex`, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ java_libs: ["myjar"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ java_library {
+ name: "myjar",
+ srcs: ["foo/bar/MyClass.java"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ `)
+}
+
func TestMain(m *testing.M) {
run := func() int {
setUp()
diff --git a/apex/builder.go b/apex/builder.go
index 3455ec7..a90918d 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -103,7 +103,6 @@
`(. ${out}.copy_commands) && ` +
`APEXER_TOOL_PATH=${tool_path} ` +
`${apexer} --force --manifest ${manifest} ` +
- `--manifest_json ${manifest_json} --manifest_json_full ${manifest_json_full} ` +
`--file_contexts ${file_contexts} ` +
`--canned_fs_config ${canned_fs_config} ` +
`--payload_type image ` +
@@ -114,22 +113,20 @@
Rspfile: "${out}.copy_commands",
RspfileContent: "${copy_commands}",
Description: "APEX ${image_dir} => ${out}",
- }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags",
- "manifest", "manifest_json", "manifest_json_full",
- )
+ }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags", "manifest")
zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{
Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
`(. ${out}.copy_commands) && ` +
`APEXER_TOOL_PATH=${tool_path} ` +
- `${apexer} --force --manifest ${manifest} --manifest_json_full ${manifest_json_full} ` +
+ `${apexer} --force --manifest ${manifest} ` +
`--payload_type zip ` +
`${image_dir} ${out} `,
CommandDeps: []string{"${apexer}", "${merge_zips}", "${soong_zip}", "${zipalign}", "${aapt2}"},
Rspfile: "${out}.copy_commands",
RspfileContent: "${copy_commands}",
Description: "ZipAPEX ${image_dir} => ${out}",
- }, "tool_path", "image_dir", "copy_commands", "manifest", "manifest_json_full")
+ }, "tool_path", "image_dir", "copy_commands", "manifest")
apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule",
blueprint.RuleParams{
@@ -171,7 +168,7 @@
func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, requireNativeLibs []string) {
manifestSrc := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
- a.manifestJsonFullOut = android.PathForModuleOut(ctx, "apex_manifest_full.json")
+ manifestJsonFullOut := android.PathForModuleOut(ctx, "apex_manifest_full.json")
// put dependency({provide|require}NativeLibs) in apex_manifest.json
provideNativeLibs = android.SortedUniqueStrings(provideNativeLibs)
@@ -186,7 +183,7 @@
ctx.Build(pctx, android.BuildParams{
Rule: apexManifestRule,
Input: manifestSrc,
- Output: a.manifestJsonFullOut,
+ Output: manifestJsonFullOut,
Args: map[string]string{
"provideNativeLibs": strings.Join(provideNativeLibs, " "),
"requireNativeLibs": strings.Join(requireNativeLibs, " "),
@@ -194,20 +191,22 @@
},
})
- // b/143654022 Q apexd can't understand newly added keys in apex_manifest.json
- // prepare stripped-down version so that APEX modules built from R+ can be installed to Q
- a.manifestJsonOut = android.PathForModuleOut(ctx, "apex_manifest.json")
- ctx.Build(pctx, android.BuildParams{
- Rule: stripApexManifestRule,
- Input: a.manifestJsonFullOut,
- Output: a.manifestJsonOut,
- })
+ if proptools.Bool(a.properties.Legacy_android10_support) {
+ // b/143654022 Q apexd can't understand newly added keys in apex_manifest.json
+ // prepare stripped-down version so that APEX modules built from R+ can be installed to Q
+ a.manifestJsonOut = android.PathForModuleOut(ctx, "apex_manifest.json")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: stripApexManifestRule,
+ Input: manifestJsonFullOut,
+ Output: a.manifestJsonOut,
+ })
+ }
// from R+, protobuf binary format (.pb) is the standard format for apex_manifest
a.manifestPbOut = android.PathForModuleOut(ctx, "apex_manifest.pb")
ctx.Build(pctx, android.BuildParams{
Rule: pbApexManifestRule,
- Input: a.manifestJsonFullOut,
+ Input: manifestJsonFullOut,
Output: a.manifestPbOut,
})
}
@@ -256,7 +255,10 @@
copyCommands := []string{}
emitCommands := []string{}
imageContentFile := android.PathForModuleOut(ctx, a.Name()+"-content.txt")
- emitCommands = append(emitCommands, "echo ./apex_manifest.json >> "+imageContentFile.String())
+ emitCommands = append(emitCommands, "echo ./apex_manifest.pb >> "+imageContentFile.String())
+ if proptools.Bool(a.properties.Legacy_android10_support) {
+ emitCommands = append(emitCommands, "echo ./apex_manifest.json >> "+imageContentFile.String())
+ }
for i, src := range filesToCopy {
dest := filepath.Join(a.filesInfo[i].installDir, src.Base())
emitCommands = append(emitCommands, "echo './"+dest+"' >> "+imageContentFile.String())
@@ -271,7 +273,7 @@
emitCommands = append(emitCommands, "sort -o "+imageContentFile.String()+" "+imageContentFile.String())
implicitInputs := append(android.Paths(nil), filesToCopy...)
- implicitInputs = append(implicitInputs, a.manifestPbOut, a.manifestJsonFullOut, a.manifestJsonOut)
+ implicitInputs = append(implicitInputs, a.manifestPbOut)
if a.properties.Whitelisted_files != nil {
ctx.Build(pctx, android.BuildParams{
@@ -394,22 +396,25 @@
optFlags = append(optFlags, "--do_not_check_keyname")
}
+ if proptools.Bool(a.properties.Legacy_android10_support) {
+ implicitInputs = append(implicitInputs, a.manifestJsonOut)
+ optFlags = append(optFlags, "--manifest_json "+a.manifestJsonOut.String())
+ }
+
ctx.Build(pctx, android.BuildParams{
Rule: apexRule,
Implicits: implicitInputs,
Output: unsignedOutputFile,
Description: "apex (" + apexType.name() + ")",
Args: map[string]string{
- "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
- "image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
- "copy_commands": strings.Join(copyCommands, " && "),
- "manifest_json_full": a.manifestJsonFullOut.String(),
- "manifest_json": a.manifestJsonOut.String(),
- "manifest": a.manifestPbOut.String(),
- "file_contexts": a.fileContexts.String(),
- "canned_fs_config": cannedFsConfig.String(),
- "key": a.private_key_file.String(),
- "opt_flags": strings.Join(optFlags, " "),
+ "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
+ "image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
+ "copy_commands": strings.Join(copyCommands, " && "),
+ "manifest": a.manifestPbOut.String(),
+ "file_contexts": a.fileContexts.String(),
+ "canned_fs_config": cannedFsConfig.String(),
+ "key": a.private_key_file.String(),
+ "opt_flags": strings.Join(optFlags, " "),
},
})
@@ -440,11 +445,10 @@
Output: unsignedOutputFile,
Description: "apex (" + apexType.name() + ")",
Args: map[string]string{
- "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
- "image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
- "copy_commands": strings.Join(copyCommands, " && "),
- "manifest": a.manifestPbOut.String(),
- "manifest_json_full": a.manifestJsonFullOut.String(),
+ "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
+ "image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
+ "copy_commands": strings.Join(copyCommands, " && "),
+ "manifest": a.manifestPbOut.String(),
},
})
}
@@ -505,10 +509,9 @@
func (a *apexBundle) buildFilesInfo(ctx android.ModuleContext) {
if a.installable() {
- // For flattened APEX, do nothing but make sure that apex_manifest.json and apex_pubkey are also copied along
+ // For flattened APEX, do nothing but make sure that APEX manifest and apex_pubkey are also copied along
// with other ordinary files.
- a.filesInfo = append(a.filesInfo, newApexFile(a.manifestJsonOut, "apex_manifest.json."+a.Name()+a.suffix, ".", etc, nil))
- a.filesInfo = append(a.filesInfo, newApexFile(a.manifestPbOut, "apex_manifest.pb."+a.Name()+a.suffix, ".", etc, nil))
+ a.filesInfo = append(a.filesInfo, newApexFile(ctx, a.manifestPbOut, "apex_manifest.pb."+a.Name()+a.suffix, ".", etc, nil))
// rename to apex_pubkey
copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
@@ -517,7 +520,7 @@
Input: a.public_key_file,
Output: copiedPubkey,
})
- a.filesInfo = append(a.filesInfo, newApexFile(copiedPubkey, "apex_pubkey."+a.Name()+a.suffix, ".", etc, nil))
+ a.filesInfo = append(a.filesInfo, newApexFile(ctx, copiedPubkey, "apex_pubkey."+a.Name()+a.suffix, ".", etc, nil))
if a.properties.ApexType == flattenedApex {
apexName := proptools.StringDefault(a.properties.Apex_name, a.Name())
diff --git a/cc/cc_test.go b/cc/cc_test.go
index f378f71..92c1e3b 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -112,7 +112,7 @@
}
const (
- coreVariant = "android_arm64_armv8-a_core_shared"
+ coreVariant = "android_arm64_armv8-a_shared"
vendorVariant = "android_arm64_armv8-a_vendor.VER_shared"
recoveryVariant = "android_arm64_armv8-a_recovery_shared"
)
@@ -1906,7 +1906,7 @@
`)
- variant := "android_arm64_armv8-a_core_static"
+ variant := "android_arm64_armv8-a_static"
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
actual := moduleA.depsInLinkOrder
expected := getOutputPaths(ctx, variant, []string{"c", "b", "d"})
@@ -1940,7 +1940,7 @@
`)
- variant := "android_arm64_armv8-a_core_static"
+ variant := "android_arm64_armv8-a_static"
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
actual := moduleA.depsInLinkOrder
expected := getOutputPaths(ctx, variant, []string{"c", "b"})
@@ -2052,7 +2052,7 @@
ctx := testCc(t, runtimeLibAndroidBp)
// runtime_libs for core variants use the module names without suffixes.
- variant := "android_arm64_armv8-a_core_shared"
+ variant := "android_arm64_armv8-a_shared"
module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
@@ -2074,7 +2074,7 @@
func TestExcludeRuntimeLibs(t *testing.T) {
ctx := testCc(t, runtimeLibAndroidBp)
- variant := "android_arm64_armv8-a_core_shared"
+ variant := "android_arm64_armv8-a_shared"
module := ctx.ModuleForTests("libvendor_available3", variant).Module().(*Module)
checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
@@ -2088,7 +2088,7 @@
// If DeviceVndkVersion is not defined, then runtime_libs are copied as-is.
- variant := "android_arm64_armv8-a_core_shared"
+ variant := "android_arm64_armv8-a_shared"
module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
@@ -2123,12 +2123,12 @@
ctx := testCc(t, staticLibAndroidBp)
// Check the shared version of lib2.
- variant := "android_arm64_armv8-a_core_shared"
+ variant := "android_arm64_armv8-a_shared"
module := ctx.ModuleForTests("lib2", variant).Module().(*Module)
checkStaticLibs(t, []string{"lib1", "libc++demangle", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc_stripped"}, module)
// Check the static version of lib2.
- variant = "android_arm64_armv8-a_core_static"
+ variant = "android_arm64_armv8-a_static"
module = ctx.ModuleForTests("lib2", variant).Module().(*Module)
// libc++_static is linked additionally.
checkStaticLibs(t, []string{"lib1", "libc++_static", "libc++demangle", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc_stripped"}, module)
@@ -2256,28 +2256,29 @@
}
`)
- variant := "android_arm64_armv8-a_core_shared"
+ coreVariant := "android_arm64_armv8-a_shared"
+ vendorVariant := "android_arm64_armv8-a_vendor.VER_shared"
// test if header search paths are correctly added
// _static variant is used since _shared reuses *.o from the static variant
- cc := ctx.ModuleForTests("libsystem", strings.Replace(variant, "_shared", "_static", 1)).Rule("cc")
+ cc := ctx.ModuleForTests("libsystem", strings.Replace(coreVariant, "_shared", "_static", 1)).Rule("cc")
cflags := cc.Args["cFlags"]
if !strings.Contains(cflags, "-Imy_include") {
t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
}
// test if libsystem is linked to the stub
- ld := ctx.ModuleForTests("libsystem", variant).Rule("ld")
+ ld := ctx.ModuleForTests("libsystem", coreVariant).Rule("ld")
libflags := ld.Args["libFlags"]
- stubPaths := getOutputPaths(ctx, variant, []string{"libvendorpublic" + vendorPublicLibrarySuffix})
+ stubPaths := getOutputPaths(ctx, coreVariant, []string{"libvendorpublic" + vendorPublicLibrarySuffix})
if !strings.Contains(libflags, stubPaths[0].String()) {
t.Errorf("libflags for libsystem must contain %#v, but was %#v", stubPaths[0], libflags)
}
// test if libvendor is linked to the real shared lib
- ld = ctx.ModuleForTests("libvendor", strings.Replace(variant, "_core", "_vendor.VER", 1)).Rule("ld")
+ ld = ctx.ModuleForTests("libvendor", vendorVariant).Rule("ld")
libflags = ld.Args["libFlags"]
- stubPaths = getOutputPaths(ctx, strings.Replace(variant, "_core", "_vendor.VER", 1), []string{"libvendorpublic"})
+ stubPaths = getOutputPaths(ctx, vendorVariant, []string{"libvendorpublic"})
if !strings.Contains(libflags, stubPaths[0].String()) {
t.Errorf("libflags for libvendor must contain %#v, but was %#v", stubPaths[0], libflags)
}
@@ -2338,14 +2339,14 @@
variants := ctx.ModuleVariantsForTests("libFoo")
expectedVariants := []string{
- "android_arm64_armv8-a_core_shared",
- "android_arm64_armv8-a_core_shared_1",
- "android_arm64_armv8-a_core_shared_2",
- "android_arm64_armv8-a_core_shared_3",
- "android_arm_armv7-a-neon_core_shared",
- "android_arm_armv7-a-neon_core_shared_1",
- "android_arm_armv7-a-neon_core_shared_2",
- "android_arm_armv7-a-neon_core_shared_3",
+ "android_arm64_armv8-a_shared",
+ "android_arm64_armv8-a_shared_1",
+ "android_arm64_armv8-a_shared_2",
+ "android_arm64_armv8-a_shared_3",
+ "android_arm_armv7-a-neon_shared",
+ "android_arm_armv7-a-neon_shared_1",
+ "android_arm_armv7-a-neon_shared_2",
+ "android_arm_armv7-a-neon_shared_3",
}
variantsMismatch := false
if len(variants) != len(expectedVariants) {
@@ -2368,14 +2369,14 @@
}
}
- libBarLinkRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_core_shared").Rule("ld")
+ libBarLinkRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_shared").Rule("ld")
libFlags := libBarLinkRule.Args["libFlags"]
- libFoo1StubPath := "libFoo/android_arm64_armv8-a_core_shared_1/libFoo.so"
+ libFoo1StubPath := "libFoo/android_arm64_armv8-a_shared_1/libFoo.so"
if !strings.Contains(libFlags, libFoo1StubPath) {
t.Errorf("%q is not found in %q", libFoo1StubPath, libFlags)
}
- libBarCompileRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_core_shared").Rule("cc")
+ libBarCompileRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_shared").Rule("cc")
cFlags := libBarCompileRule.Args["cFlags"]
libFoo1VersioningMacro := "-D__LIBFOO_API__=1"
if !strings.Contains(cFlags, libFoo1VersioningMacro) {
@@ -2391,7 +2392,7 @@
static_executable: true,
}`)
- variant := "android_arm64_armv8-a_core"
+ variant := "android_arm64_armv8-a"
binModuleRule := ctx.ModuleForTests("static_test", variant).Rule("ld")
libFlags := binModuleRule.Args["libFlags"]
systemStaticLibs := []string{"libc.a", "libm.a"}
@@ -2434,9 +2435,9 @@
},
}`)
- mybin := ctx.ModuleForTests("mybin", "android_arm64_armv8-a_core").Module().(*Module)
+ mybin := ctx.ModuleForTests("mybin", "android_arm64_armv8-a").Module().(*Module)
actual := mybin.depsInLinkOrder
- expected := getOutputPaths(ctx, "android_arm64_armv8-a_core_static", []string{"libB", "libC"})
+ expected := getOutputPaths(ctx, "android_arm64_armv8-a_static", []string{"libB", "libC"})
if !reflect.DeepEqual(actual, expected) {
t.Errorf("staticDeps orderings were not propagated correctly"+
@@ -2475,7 +2476,7 @@
srcs: ["foo.c"],
}`)
- variant := "android_arm64_armv8-a_core"
+ variant := "android_arm64_armv8-a"
ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc")
}
@@ -2550,24 +2551,24 @@
return ret
}
- shared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_core_shared").Rule("ld")
+ shared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_shared").Rule("ld")
if g, w := pathsToBase(shared.Inputs), []string{"foo.o", "baz.o"}; !reflect.DeepEqual(w, g) {
t.Errorf("libshared ld rule wanted %q, got %q", w, g)
}
- bothShared := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_core_shared").Rule("ld")
+ bothShared := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_shared").Rule("ld")
if g, w := pathsToBase(bothShared.Inputs), []string{"foo.o", "baz.o"}; !reflect.DeepEqual(w, g) {
t.Errorf("libboth ld rule wanted %q, got %q", w, g)
}
- binary := ctx.ModuleForTests("binary", "android_arm64_armv8-a_core").Rule("ld")
+ binary := ctx.ModuleForTests("binary", "android_arm64_armv8-a").Rule("ld")
if g, w := pathsToBase(binary.Inputs), []string{"foo.o"}; !reflect.DeepEqual(w, g) {
t.Errorf("binary ld rule wanted %q, got %q", w, g)
}
- static := ctx.ModuleForTests("libstatic", "android_arm64_armv8-a_core_static").Rule("ar")
+ static := ctx.ModuleForTests("libstatic", "android_arm64_armv8-a_static").Rule("ar")
if g, w := pathsToBase(static.Inputs), []string{"foo.o", "bar.o"}; !reflect.DeepEqual(w, g) {
t.Errorf("libstatic ar rule wanted %q, got %q", w, g)
}
- bothStatic := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_core_static").Rule("ar")
+ bothStatic := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_static").Rule("ar")
if g, w := pathsToBase(bothStatic.Inputs), []string{"foo.o", "bar.o"}; !reflect.DeepEqual(w, g) {
t.Errorf("libboth ar rule wanted %q, got %q", w, g)
}
diff --git a/cc/gen_test.go b/cc/gen_test.go
index ceecf1c..4b9a36e 100644
--- a/cc/gen_test.go
+++ b/cc/gen_test.go
@@ -31,8 +31,8 @@
],
}`)
- aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl")
- libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module)
+ aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("aidl")
+ libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Module().(*Module)
if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.Local.CommonFlags) {
t.Errorf("missing aidl includes in global flags")
@@ -55,8 +55,8 @@
],
}`)
- aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl")
- libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module)
+ aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("aidl")
+ libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Module().(*Module)
if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.Local.CommonFlags) {
t.Errorf("missing aidl includes in global flags")
diff --git a/cc/genrule_test.go b/cc/genrule_test.go
index 9f159e5..785e3e1 100644
--- a/cc/genrule_test.go
+++ b/cc/genrule_test.go
@@ -74,13 +74,13 @@
t.Fatal(errs)
}
- gen := ctx.ModuleForTests("gen", "android_arm_armv7-a-neon_core").Output("out_arm")
+ gen := ctx.ModuleForTests("gen", "android_arm_armv7-a-neon").Output("out_arm")
expected := []string{"foo"}
if !reflect.DeepEqual(expected, gen.Inputs.Strings()) {
t.Errorf(`want arm inputs %v, got %v`, expected, gen.Inputs.Strings())
}
- gen = ctx.ModuleForTests("gen", "android_arm64_armv8-a_core").Output("out_arm64")
+ gen = ctx.ModuleForTests("gen", "android_arm64_armv8-a").Output("out_arm64")
expected = []string{"bar"}
if !reflect.DeepEqual(expected, gen.Inputs.Strings()) {
t.Errorf(`want arm64 inputs %v, got %v`, expected, gen.Inputs.Strings())
diff --git a/cc/library.go b/cc/library.go
index 85533a9..04130c4 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -18,14 +18,12 @@
"fmt"
"io"
"path/filepath"
- "reflect"
"regexp"
"sort"
"strconv"
"strings"
"sync"
- "github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
"android/soong/android"
@@ -1438,298 +1436,3 @@
return outputFile
}
-
-var SharedLibrarySdkMemberType = &librarySdkMemberType{
- prebuiltModuleType: "cc_prebuilt_library_shared",
- linkTypes: []string{"shared"},
-}
-
-var StaticLibrarySdkMemberType = &librarySdkMemberType{
- prebuiltModuleType: "cc_prebuilt_library_static",
- linkTypes: []string{"static"},
-}
-
-type librarySdkMemberType struct {
- prebuiltModuleType string
-
- // The set of link types supported, set of "static", "shared".
- linkTypes []string
-}
-
-func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
- targets := mctx.MultiTargets()
- for _, lib := range names {
- for _, target := range targets {
- name, version := StubsLibNameAndVersion(lib)
- if version == "" {
- version = LatestStubsVersionFor(mctx.Config(), name)
- }
- for _, linkType := range mt.linkTypes {
- mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: android.CoreVariation},
- {Mutator: "link", Variation: linkType},
- {Mutator: "version", Variation: version},
- }...), dependencyTag, name)
- }
- }
- }
-}
-
-func (mt *librarySdkMemberType) IsInstance(module android.Module) bool {
- _, ok := module.(*Module)
- return ok
-}
-
-// copy exported header files and stub *.so files
-func (mt *librarySdkMemberType) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
- info := mt.organizeVariants(member)
- buildSharedNativeLibSnapshot(sdkModuleContext, info, builder, member)
-}
-
-// Organize the variants by architecture.
-func (mt *librarySdkMemberType) organizeVariants(member android.SdkMember) *nativeLibInfo {
- memberName := member.Name()
- info := &nativeLibInfo{
- name: memberName,
- memberType: mt,
- }
-
- for _, variant := range member.Variants() {
- ccModule := variant.(*Module)
-
- // Separate out the generated include dirs (which are arch specific) from the
- // include dirs (which may not be).
- exportedIncludeDirs, exportedGeneratedIncludeDirs := android.FilterPathListPredicate(
- ccModule.ExportedIncludeDirs(), isGeneratedHeaderDirectory)
-
- info.archVariantProperties = append(info.archVariantProperties, nativeLibInfoProperties{
- name: memberName,
- archType: ccModule.Target().Arch.ArchType.String(),
- ExportedIncludeDirs: exportedIncludeDirs,
- ExportedGeneratedIncludeDirs: exportedGeneratedIncludeDirs,
- ExportedSystemIncludeDirs: ccModule.ExportedSystemIncludeDirs(),
- ExportedFlags: ccModule.ExportedFlags(),
- exportedGeneratedHeaders: ccModule.ExportedGeneratedHeaders(),
- outputFile: ccModule.OutputFile().Path(),
- })
- }
-
- // Initialize the unexported properties that will not be set during the
- // extraction process.
- info.commonProperties.name = memberName
-
- // Extract common properties from the arch specific properties.
- extractCommonProperties(&info.commonProperties, info.archVariantProperties)
-
- return info
-}
-
-func isGeneratedHeaderDirectory(p android.Path) bool {
- _, gen := p.(android.WritablePath)
- return gen
-}
-
-// Extract common properties from a slice of property structures of the same type.
-//
-// All the property structures must be of the same type.
-// commonProperties - must be a pointer to the structure into which common properties will be added.
-// inputPropertiesSlice - must be a slice of input properties structures.
-//
-// Iterates over each exported field (capitalized name) and checks to see whether they
-// have the same value (using DeepEquals) across all the input properties. If it does not then no
-// change is made. Otherwise, the common value is stored in the field in the commonProperties
-// and the field in each of the input properties structure is set to its default value.
-func extractCommonProperties(commonProperties interface{}, inputPropertiesSlice interface{}) {
- commonStructValue := reflect.ValueOf(commonProperties).Elem()
- propertiesStructType := commonStructValue.Type()
-
- // Create an empty structure from which default values for the field can be copied.
- emptyStructValue := reflect.New(propertiesStructType).Elem()
-
- for f := 0; f < propertiesStructType.NumField(); f++ {
- // Check to see if all the structures have the same value for the field. The commonValue
- // is nil on entry to the loop and if it is nil on exit then there is no common value,
- // otherwise it points to the common value.
- var commonValue *reflect.Value
- sliceValue := reflect.ValueOf(inputPropertiesSlice)
-
- for i := 0; i < sliceValue.Len(); i++ {
- structValue := sliceValue.Index(i)
- fieldValue := structValue.Field(f)
- if !fieldValue.CanInterface() {
- // The field is not exported so ignore it.
- continue
- }
-
- if commonValue == nil {
- // Use the first value as the commonProperties value.
- commonValue = &fieldValue
- } else {
- // If the value does not match the current common value then there is
- // no value in common so break out.
- if !reflect.DeepEqual(fieldValue.Interface(), commonValue.Interface()) {
- commonValue = nil
- break
- }
- }
- }
-
- // If the fields all have a common value then store it in the common struct field
- // and set the input struct's field to the empty value.
- if commonValue != nil {
- emptyValue := emptyStructValue.Field(f)
- commonStructValue.Field(f).Set(*commonValue)
- for i := 0; i < sliceValue.Len(); i++ {
- structValue := sliceValue.Index(i)
- fieldValue := structValue.Field(f)
- fieldValue.Set(emptyValue)
- }
- }
- }
-}
-
-func buildSharedNativeLibSnapshot(sdkModuleContext android.ModuleContext, info *nativeLibInfo, builder android.SnapshotBuilder, member android.SdkMember) {
- // a function for emitting include dirs
- addExportedDirCopyCommandsForNativeLibs := func(lib nativeLibInfoProperties) {
- // Do not include ExportedGeneratedIncludeDirs in the list of directories whose
- // contents are copied as they are copied from exportedGeneratedHeaders below.
- includeDirs := lib.ExportedIncludeDirs
- includeDirs = append(includeDirs, lib.ExportedSystemIncludeDirs...)
- for _, dir := range includeDirs {
- // lib.ArchType is "" for common properties.
- targetDir := filepath.Join(lib.archType, nativeIncludeDir)
-
- // TODO(jiyong) copy headers having other suffixes
- headers, _ := sdkModuleContext.GlobWithDeps(dir.String()+"/**/*.h", nil)
- for _, file := range headers {
- src := android.PathForSource(sdkModuleContext, file)
- dest := filepath.Join(targetDir, file)
- builder.CopyToSnapshot(src, dest)
- }
- }
-
- genHeaders := lib.exportedGeneratedHeaders
- for _, file := range genHeaders {
- // lib.ArchType is "" for common properties.
- targetDir := filepath.Join(lib.archType, nativeGeneratedIncludeDir)
-
- dest := filepath.Join(targetDir, lib.name, file.Rel())
- builder.CopyToSnapshot(file, dest)
- }
- }
-
- addExportedDirCopyCommandsForNativeLibs(info.commonProperties)
-
- // for each architecture
- for _, av := range info.archVariantProperties {
- builder.CopyToSnapshot(av.outputFile, nativeLibraryPathFor(av))
-
- addExportedDirCopyCommandsForNativeLibs(av)
- }
-
- info.generatePrebuiltLibrary(sdkModuleContext, builder, member)
-}
-
-func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
-
- // a function for emitting include dirs
- addExportedDirsForNativeLibs := func(lib nativeLibInfoProperties, properties android.BpPropertySet, systemInclude bool) {
- includeDirs := nativeIncludeDirPathsFor(lib, systemInclude)
- if len(includeDirs) == 0 {
- return
- }
- var propertyName string
- if !systemInclude {
- propertyName = "export_include_dirs"
- } else {
- propertyName = "export_system_include_dirs"
- }
- properties.AddProperty(propertyName, includeDirs)
- }
-
- pbm := builder.AddPrebuiltModule(member, info.memberType.prebuiltModuleType)
-
- addExportedDirsForNativeLibs(info.commonProperties, pbm, false /*systemInclude*/)
- addExportedDirsForNativeLibs(info.commonProperties, pbm, true /*systemInclude*/)
-
- archProperties := pbm.AddPropertySet("arch")
- for _, av := range info.archVariantProperties {
- archTypeProperties := archProperties.AddPropertySet(av.archType)
- archTypeProperties.AddProperty("srcs", []string{nativeLibraryPathFor(av)})
-
- // export_* properties are added inside the arch: {<arch>: {...}} block
- addExportedDirsForNativeLibs(av, archTypeProperties, false /*systemInclude*/)
- addExportedDirsForNativeLibs(av, archTypeProperties, true /*systemInclude*/)
- }
- pbm.AddProperty("stl", "none")
- pbm.AddProperty("system_shared_libs", []string{})
-}
-
-const (
- nativeIncludeDir = "include"
- nativeGeneratedIncludeDir = "include_gen"
- nativeStubDir = "lib"
-)
-
-// path to the native library. Relative to <sdk_root>/<api_dir>
-func nativeLibraryPathFor(lib nativeLibInfoProperties) string {
- return filepath.Join(lib.archType,
- nativeStubDir, lib.outputFile.Base())
-}
-
-// paths to the include dirs of a native shared library. Relative to <sdk_root>/<api_dir>
-func nativeIncludeDirPathsFor(lib nativeLibInfoProperties, systemInclude bool) []string {
- var result []string
- var includeDirs []android.Path
- if !systemInclude {
- // Include the generated include dirs in the exported include dirs.
- includeDirs = append(lib.ExportedIncludeDirs, lib.ExportedGeneratedIncludeDirs...)
- } else {
- includeDirs = lib.ExportedSystemIncludeDirs
- }
- for _, dir := range includeDirs {
- var path string
- if isGeneratedHeaderDirectory(dir) {
- path = filepath.Join(nativeGeneratedIncludeDir, lib.name)
- } else {
- path = filepath.Join(nativeIncludeDir, dir.String())
- }
-
- // lib.ArchType is "" for common properties.
- path = filepath.Join(lib.archType, path)
- result = append(result, path)
- }
- return result
-}
-
-// nativeLibInfoProperties represents properties of a native lib
-//
-// The exported (capitalized) fields will be examined and may be changed during common value extraction.
-// The unexported fields will be left untouched.
-type nativeLibInfoProperties struct {
- // The name of the library, is not exported as this must not be changed during optimization.
- name string
-
- // archType is not exported as if set (to a non default value) it is always arch specific.
- // This is "" for common properties.
- archType string
-
- ExportedIncludeDirs android.Paths
- ExportedGeneratedIncludeDirs android.Paths
- ExportedSystemIncludeDirs android.Paths
- ExportedFlags []string
-
- // exportedGeneratedHeaders is not exported as if set it is always arch specific.
- exportedGeneratedHeaders android.Paths
-
- // outputFile is not exported as it is always arch specific.
- outputFile android.Path
-}
-
-// nativeLibInfo represents a collection of arch-specific modules having the same name
-type nativeLibInfo struct {
- name string
- memberType *librarySdkMemberType
- archVariantProperties []nativeLibInfoProperties
- commonProperties nativeLibInfoProperties
-}
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
new file mode 100644
index 0000000..9319070
--- /dev/null
+++ b/cc/library_sdk_member.go
@@ -0,0 +1,331 @@
+// Copyright 2019 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package cc
+
+import (
+ "path/filepath"
+ "reflect"
+
+ "android/soong/android"
+ "github.com/google/blueprint"
+)
+
+// This file contains support for using cc library modules within an sdk.
+
+func init() {
+ // Register sdk member types.
+ android.RegisterSdkMemberType(&librarySdkMemberType{
+ SdkMemberTypeBase: android.SdkMemberTypeBase{
+ PropertyName: "native_shared_libs",
+ },
+ prebuiltModuleType: "cc_prebuilt_library_shared",
+ linkTypes: []string{"shared"},
+ })
+
+ android.RegisterSdkMemberType(&librarySdkMemberType{
+ SdkMemberTypeBase: android.SdkMemberTypeBase{
+ PropertyName: "native_static_libs",
+ },
+ prebuiltModuleType: "cc_prebuilt_library_static",
+ linkTypes: []string{"static"},
+ })
+}
+
+type librarySdkMemberType struct {
+ android.SdkMemberTypeBase
+
+ prebuiltModuleType string
+
+ // The set of link types supported, set of "static", "shared".
+ linkTypes []string
+}
+
+func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
+ targets := mctx.MultiTargets()
+ for _, lib := range names {
+ for _, target := range targets {
+ name, version := StubsLibNameAndVersion(lib)
+ if version == "" {
+ version = LatestStubsVersionFor(mctx.Config(), name)
+ }
+ for _, linkType := range mt.linkTypes {
+ mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
+ {Mutator: "image", Variation: android.CoreVariation},
+ {Mutator: "link", Variation: linkType},
+ {Mutator: "version", Variation: version},
+ }...), dependencyTag, name)
+ }
+ }
+ }
+}
+
+func (mt *librarySdkMemberType) IsInstance(module android.Module) bool {
+ _, ok := module.(*Module)
+ return ok
+}
+
+// copy exported header files and stub *.so files
+func (mt *librarySdkMemberType) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
+ info := mt.organizeVariants(member)
+ buildSharedNativeLibSnapshot(sdkModuleContext, info, builder, member)
+}
+
+// Organize the variants by architecture.
+func (mt *librarySdkMemberType) organizeVariants(member android.SdkMember) *nativeLibInfo {
+ memberName := member.Name()
+ info := &nativeLibInfo{
+ name: memberName,
+ memberType: mt,
+ }
+
+ for _, variant := range member.Variants() {
+ ccModule := variant.(*Module)
+
+ // Separate out the generated include dirs (which are arch specific) from the
+ // include dirs (which may not be).
+ exportedIncludeDirs, exportedGeneratedIncludeDirs := android.FilterPathListPredicate(
+ ccModule.ExportedIncludeDirs(), isGeneratedHeaderDirectory)
+
+ info.archVariantProperties = append(info.archVariantProperties, nativeLibInfoProperties{
+ name: memberName,
+ archType: ccModule.Target().Arch.ArchType.String(),
+ ExportedIncludeDirs: exportedIncludeDirs,
+ ExportedGeneratedIncludeDirs: exportedGeneratedIncludeDirs,
+ ExportedSystemIncludeDirs: ccModule.ExportedSystemIncludeDirs(),
+ ExportedFlags: ccModule.ExportedFlags(),
+ exportedGeneratedHeaders: ccModule.ExportedGeneratedHeaders(),
+ outputFile: ccModule.OutputFile().Path(),
+ })
+ }
+
+ // Initialize the unexported properties that will not be set during the
+ // extraction process.
+ info.commonProperties.name = memberName
+
+ // Extract common properties from the arch specific properties.
+ extractCommonProperties(&info.commonProperties, info.archVariantProperties)
+
+ return info
+}
+
+func isGeneratedHeaderDirectory(p android.Path) bool {
+ _, gen := p.(android.WritablePath)
+ return gen
+}
+
+// Extract common properties from a slice of property structures of the same type.
+//
+// All the property structures must be of the same type.
+// commonProperties - must be a pointer to the structure into which common properties will be added.
+// inputPropertiesSlice - must be a slice of input properties structures.
+//
+// Iterates over each exported field (capitalized name) and checks to see whether they
+// have the same value (using DeepEquals) across all the input properties. If it does not then no
+// change is made. Otherwise, the common value is stored in the field in the commonProperties
+// and the field in each of the input properties structure is set to its default value.
+func extractCommonProperties(commonProperties interface{}, inputPropertiesSlice interface{}) {
+ commonStructValue := reflect.ValueOf(commonProperties).Elem()
+ propertiesStructType := commonStructValue.Type()
+
+ // Create an empty structure from which default values for the field can be copied.
+ emptyStructValue := reflect.New(propertiesStructType).Elem()
+
+ for f := 0; f < propertiesStructType.NumField(); f++ {
+ // Check to see if all the structures have the same value for the field. The commonValue
+ // is nil on entry to the loop and if it is nil on exit then there is no common value,
+ // otherwise it points to the common value.
+ var commonValue *reflect.Value
+ sliceValue := reflect.ValueOf(inputPropertiesSlice)
+
+ for i := 0; i < sliceValue.Len(); i++ {
+ structValue := sliceValue.Index(i)
+ fieldValue := structValue.Field(f)
+ if !fieldValue.CanInterface() {
+ // The field is not exported so ignore it.
+ continue
+ }
+
+ if commonValue == nil {
+ // Use the first value as the commonProperties value.
+ commonValue = &fieldValue
+ } else {
+ // If the value does not match the current common value then there is
+ // no value in common so break out.
+ if !reflect.DeepEqual(fieldValue.Interface(), commonValue.Interface()) {
+ commonValue = nil
+ break
+ }
+ }
+ }
+
+ // If the fields all have a common value then store it in the common struct field
+ // and set the input struct's field to the empty value.
+ if commonValue != nil {
+ emptyValue := emptyStructValue.Field(f)
+ commonStructValue.Field(f).Set(*commonValue)
+ for i := 0; i < sliceValue.Len(); i++ {
+ structValue := sliceValue.Index(i)
+ fieldValue := structValue.Field(f)
+ fieldValue.Set(emptyValue)
+ }
+ }
+ }
+}
+
+func buildSharedNativeLibSnapshot(sdkModuleContext android.ModuleContext, info *nativeLibInfo, builder android.SnapshotBuilder, member android.SdkMember) {
+ // a function for emitting include dirs
+ addExportedDirCopyCommandsForNativeLibs := func(lib nativeLibInfoProperties) {
+ // Do not include ExportedGeneratedIncludeDirs in the list of directories whose
+ // contents are copied as they are copied from exportedGeneratedHeaders below.
+ includeDirs := lib.ExportedIncludeDirs
+ includeDirs = append(includeDirs, lib.ExportedSystemIncludeDirs...)
+ for _, dir := range includeDirs {
+ // lib.ArchType is "" for common properties.
+ targetDir := filepath.Join(lib.archType, nativeIncludeDir)
+
+ // TODO(jiyong) copy headers having other suffixes
+ headers, _ := sdkModuleContext.GlobWithDeps(dir.String()+"/**/*.h", nil)
+ for _, file := range headers {
+ src := android.PathForSource(sdkModuleContext, file)
+ dest := filepath.Join(targetDir, file)
+ builder.CopyToSnapshot(src, dest)
+ }
+ }
+
+ genHeaders := lib.exportedGeneratedHeaders
+ for _, file := range genHeaders {
+ // lib.ArchType is "" for common properties.
+ targetDir := filepath.Join(lib.archType, nativeGeneratedIncludeDir)
+
+ dest := filepath.Join(targetDir, lib.name, file.Rel())
+ builder.CopyToSnapshot(file, dest)
+ }
+ }
+
+ addExportedDirCopyCommandsForNativeLibs(info.commonProperties)
+
+ // for each architecture
+ for _, av := range info.archVariantProperties {
+ builder.CopyToSnapshot(av.outputFile, nativeLibraryPathFor(av))
+
+ addExportedDirCopyCommandsForNativeLibs(av)
+ }
+
+ info.generatePrebuiltLibrary(sdkModuleContext, builder, member)
+}
+
+func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
+
+ // a function for emitting include dirs
+ addExportedDirsForNativeLibs := func(lib nativeLibInfoProperties, properties android.BpPropertySet, systemInclude bool) {
+ includeDirs := nativeIncludeDirPathsFor(lib, systemInclude)
+ if len(includeDirs) == 0 {
+ return
+ }
+ var propertyName string
+ if !systemInclude {
+ propertyName = "export_include_dirs"
+ } else {
+ propertyName = "export_system_include_dirs"
+ }
+ properties.AddProperty(propertyName, includeDirs)
+ }
+
+ pbm := builder.AddPrebuiltModule(member, info.memberType.prebuiltModuleType)
+
+ addExportedDirsForNativeLibs(info.commonProperties, pbm, false /*systemInclude*/)
+ addExportedDirsForNativeLibs(info.commonProperties, pbm, true /*systemInclude*/)
+
+ archProperties := pbm.AddPropertySet("arch")
+ for _, av := range info.archVariantProperties {
+ archTypeProperties := archProperties.AddPropertySet(av.archType)
+ archTypeProperties.AddProperty("srcs", []string{nativeLibraryPathFor(av)})
+
+ // export_* properties are added inside the arch: {<arch>: {...}} block
+ addExportedDirsForNativeLibs(av, archTypeProperties, false /*systemInclude*/)
+ addExportedDirsForNativeLibs(av, archTypeProperties, true /*systemInclude*/)
+ }
+ pbm.AddProperty("stl", "none")
+ pbm.AddProperty("system_shared_libs", []string{})
+}
+
+const (
+ nativeIncludeDir = "include"
+ nativeGeneratedIncludeDir = "include_gen"
+ nativeStubDir = "lib"
+)
+
+// path to the native library. Relative to <sdk_root>/<api_dir>
+func nativeLibraryPathFor(lib nativeLibInfoProperties) string {
+ return filepath.Join(lib.archType,
+ nativeStubDir, lib.outputFile.Base())
+}
+
+// paths to the include dirs of a native shared library. Relative to <sdk_root>/<api_dir>
+func nativeIncludeDirPathsFor(lib nativeLibInfoProperties, systemInclude bool) []string {
+ var result []string
+ var includeDirs []android.Path
+ if !systemInclude {
+ // Include the generated include dirs in the exported include dirs.
+ includeDirs = append(lib.ExportedIncludeDirs, lib.ExportedGeneratedIncludeDirs...)
+ } else {
+ includeDirs = lib.ExportedSystemIncludeDirs
+ }
+ for _, dir := range includeDirs {
+ var path string
+ if isGeneratedHeaderDirectory(dir) {
+ path = filepath.Join(nativeGeneratedIncludeDir, lib.name)
+ } else {
+ path = filepath.Join(nativeIncludeDir, dir.String())
+ }
+
+ // lib.ArchType is "" for common properties.
+ path = filepath.Join(lib.archType, path)
+ result = append(result, path)
+ }
+ return result
+}
+
+// nativeLibInfoProperties represents properties of a native lib
+//
+// The exported (capitalized) fields will be examined and may be changed during common value extraction.
+// The unexported fields will be left untouched.
+type nativeLibInfoProperties struct {
+ // The name of the library, is not exported as this must not be changed during optimization.
+ name string
+
+ // archType is not exported as if set (to a non default value) it is always arch specific.
+ // This is "" for common properties.
+ archType string
+
+ ExportedIncludeDirs android.Paths
+ ExportedGeneratedIncludeDirs android.Paths
+ ExportedSystemIncludeDirs android.Paths
+ ExportedFlags []string
+
+ // exportedGeneratedHeaders is not exported as if set it is always arch specific.
+ exportedGeneratedHeaders android.Paths
+
+ // outputFile is not exported as it is always arch specific.
+ outputFile android.Path
+}
+
+// nativeLibInfo represents a collection of arch-specific modules having the same name
+type nativeLibInfo struct {
+ name string
+ memberType *librarySdkMemberType
+ archVariantProperties []nativeLibInfoProperties
+ commonProperties nativeLibInfoProperties
+}
diff --git a/cc/library_test.go b/cc/library_test.go
index f8d8934..b8d8895 100644
--- a/cc/library_test.go
+++ b/cc/library_test.go
@@ -27,8 +27,8 @@
srcs: ["foo.c", "baz.o"],
}`)
- libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("ld")
- libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_static").Output("libfoo.a")
+ libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("ld")
+ libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_static").Output("libfoo.a")
if len(libfooShared.Inputs) != 2 {
t.Fatalf("unexpected inputs to libfoo shared: %#v", libfooShared.Inputs.Strings())
@@ -56,8 +56,8 @@
},
}`)
- libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("ld")
- libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_static").Output("libfoo.a")
+ libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("ld")
+ libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_static").Output("libfoo.a")
if len(libfooShared.Inputs) != 1 {
t.Fatalf("unexpected inputs to libfoo shared: %#v", libfooShared.Inputs.Strings())
@@ -82,8 +82,8 @@
},
}`)
- libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("ld")
- libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_static").Output("libfoo.a")
+ libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("ld")
+ libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_static").Output("libfoo.a")
if len(libfooShared.Inputs) != 2 {
t.Fatalf("unexpected inputs to libfoo shared: %#v", libfooShared.Inputs.Strings())
@@ -108,8 +108,8 @@
},
}`)
- libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("ld")
- libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_static").Output("libfoo.a")
+ libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("ld")
+ libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_static").Output("libfoo.a")
if len(libfooShared.Inputs) != 1 {
t.Fatalf("unexpected inputs to libfoo shared: %#v", libfooShared.Inputs.Strings())
@@ -134,8 +134,8 @@
},
}`)
- libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("ld")
- libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_static").Output("libfoo.a")
+ libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("ld")
+ libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_static").Output("libfoo.a")
if len(libfooShared.Inputs) != 1 {
t.Fatalf("unexpected inputs to libfoo shared: %#v", libfooShared.Inputs.Strings())
@@ -165,8 +165,8 @@
},
}`)
- libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("ld")
- libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_static").Output("libfoo.a")
+ libfooShared := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("ld")
+ libfooStatic := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_static").Output("libfoo.a")
if len(libfooShared.Inputs) != 3 {
t.Fatalf("unexpected inputs to libfoo shared: %#v", libfooShared.Inputs.Strings())
@@ -180,7 +180,7 @@
t.Errorf("static objects not reused for shared library")
}
- libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module)
+ libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Module().(*Module)
if !inList("-DGOOGLE_PROTOBUF_NO_RTTI", libfoo.flags.Local.CFlags) {
t.Errorf("missing protobuf cflags")
}
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 72f9f4a..7ddf6eb 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -87,15 +87,15 @@
android.FailIfErrored(t, errs)
// Verify that all the modules exist and that their dependencies were connected correctly
- liba := ctx.ModuleForTests("liba", "android_arm64_armv8-a_core_shared").Module()
- libb := ctx.ModuleForTests("libb", "android_arm64_armv8-a_core_static").Module()
- libd := ctx.ModuleForTests("libd", "android_arm64_armv8-a_core_shared").Module()
- libe := ctx.ModuleForTests("libe", "android_arm64_armv8-a_core_static").Module()
+ liba := ctx.ModuleForTests("liba", "android_arm64_armv8-a_shared").Module()
+ libb := ctx.ModuleForTests("libb", "android_arm64_armv8-a_static").Module()
+ libd := ctx.ModuleForTests("libd", "android_arm64_armv8-a_shared").Module()
+ libe := ctx.ModuleForTests("libe", "android_arm64_armv8-a_static").Module()
- prebuiltLiba := ctx.ModuleForTests("prebuilt_liba", "android_arm64_armv8-a_core_shared").Module()
- prebuiltLibb := ctx.ModuleForTests("prebuilt_libb", "android_arm64_armv8-a_core_static").Module()
- prebuiltLibd := ctx.ModuleForTests("prebuilt_libd", "android_arm64_armv8-a_core_shared").Module()
- prebuiltLibe := ctx.ModuleForTests("prebuilt_libe", "android_arm64_armv8-a_core_static").Module()
+ prebuiltLiba := ctx.ModuleForTests("prebuilt_liba", "android_arm64_armv8-a_shared").Module()
+ prebuiltLibb := ctx.ModuleForTests("prebuilt_libb", "android_arm64_armv8-a_static").Module()
+ prebuiltLibd := ctx.ModuleForTests("prebuilt_libd", "android_arm64_armv8-a_shared").Module()
+ prebuiltLibe := ctx.ModuleForTests("prebuilt_libe", "android_arm64_armv8-a_static").Module()
hasDep := func(m android.Module, wantDep android.Module) bool {
t.Helper()
diff --git a/cc/proto_test.go b/cc/proto_test.go
index 4f0de78..f8bbd26 100644
--- a/cc/proto_test.go
+++ b/cc/proto_test.go
@@ -29,7 +29,7 @@
srcs: ["a.proto"],
}`)
- proto := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Output("proto/a.pb.cc")
+ proto := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Output("proto/a.pb.cc")
if cmd := proto.RuleParams.Command; !strings.Contains(cmd, "--cpp_out=") {
t.Errorf("expected '--cpp_out' in %q", cmd)
@@ -53,7 +53,7 @@
buildOS := android.BuildOs.String()
- proto := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Output("proto/a.pb.cc")
+ proto := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Output("proto/a.pb.cc")
foobar := ctx.ModuleForTests("protoc-gen-foobar", buildOS+"_x86_64")
cmd := proto.RuleParams.Command
diff --git a/java/app.go b/java/app.go
index c772e47..7595e36 100755
--- a/java/app.go
+++ b/java/app.go
@@ -632,6 +632,17 @@
a.testConfig = tradefed.AutoGenInstrumentationTestConfig(ctx, a.testProperties.Test_config,
a.testProperties.Test_config_template, a.manifestPath, a.testProperties.Test_suites, a.testProperties.Auto_gen_config)
+ if a.overridableAppProperties.Package_name != nil {
+ fixedConfig := android.PathForModuleOut(ctx, "test_config_fixer", "AndroidTest.xml")
+ rule := android.NewRuleBuilder()
+ rule.Command().BuiltTool(ctx, "test_config_fixer").
+ FlagWithArg("--manifest ", a.manifestPath.String()).
+ FlagWithArg("--package-name ", *a.overridableAppProperties.Package_name).
+ Input(a.testConfig).
+ Output(fixedConfig)
+ rule.Build(pctx, ctx, "fix_test_config", "fix test config")
+ a.testConfig = fixedConfig
+ }
a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
}
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 76cdaea..92f9246 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -40,6 +40,13 @@
android.RegisterModuleType("droidstubs_host", DroidstubsHostFactory)
android.RegisterModuleType("prebuilt_stubs_sources", PrebuiltStubsSourcesFactory)
+
+ // Register sdk member type.
+ android.RegisterSdkMemberType(&droidStubsSdkMemberType{
+ SdkMemberTypeBase: android.SdkMemberTypeBase{
+ PropertyName: "stubs_sources",
+ },
+ })
}
var (
@@ -1974,9 +1981,8 @@
return module
}
-var DroidStubsSdkMemberType = &droidStubsSdkMemberType{}
-
type droidStubsSdkMemberType struct {
+ android.SdkMemberTypeBase
}
func (mt *droidStubsSdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
diff --git a/java/java.go b/java/java.go
index f58e5ba..d8db5f8 100644
--- a/java/java.go
+++ b/java/java.go
@@ -52,6 +52,23 @@
android.RegisterSingletonType("logtags", LogtagsSingleton)
android.RegisterSingletonType("kythe_java_extract", kytheExtractJavaFactory)
+
+ // Register sdk member types.
+ android.RegisterSdkMemberType(&headerLibrarySdkMemberType{
+ librarySdkMemberType{
+ android.SdkMemberTypeBase{
+ PropertyName: "java_header_libs",
+ },
+ },
+ })
+
+ android.RegisterSdkMemberType(&implLibrarySdkMemberType{
+ librarySdkMemberType{
+ android.SdkMemberTypeBase{
+ PropertyName: "java_libs",
+ },
+ },
+ })
}
func (j *Module) checkSdkVersion(ctx android.ModuleContext) {
@@ -1721,6 +1738,7 @@
}
type librarySdkMemberType struct {
+ android.SdkMemberTypeBase
}
func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
@@ -1764,8 +1782,6 @@
module.AddProperty("jars", []string{snapshotRelativeJavaLibPath})
}
-var HeaderLibrarySdkMemberType = &headerLibrarySdkMemberType{}
-
type headerLibrarySdkMemberType struct {
librarySdkMemberType
}
@@ -1781,8 +1797,6 @@
})
}
-var ImplLibrarySdkMemberType = &implLibrarySdkMemberType{}
-
type implLibrarySdkMemberType struct {
librarySdkMemberType
}
diff --git a/java/java_test.go b/java/java_test.go
index f4b92e3..4a549e6 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1177,7 +1177,7 @@
ctx.ModuleForTests("foo"+sdkDocsSuffix, "android_common")
ctx.ModuleForTests("foo"+sdkDocsSuffix+sdkSystemApiSuffix, "android_common")
ctx.ModuleForTests("foo"+sdkDocsSuffix+sdkTestApiSuffix, "android_common")
- ctx.ModuleForTests("foo"+sdkXmlFileSuffix, "android_arm64_armv8-a_core")
+ ctx.ModuleForTests("foo"+sdkXmlFileSuffix, "android_arm64_armv8-a")
ctx.ModuleForTests("foo.api.public.28", "")
ctx.ModuleForTests("foo.api.system.28", "")
ctx.ModuleForTests("foo.api.test.28", "")
diff --git a/rust/binary.go b/rust/binary.go
index d4b6614..fda056e 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -57,7 +57,7 @@
module := newModule(hod, android.MultilibFirst)
binary := &binaryDecorator{
- baseCompiler: NewBaseCompiler("bin", ""),
+ baseCompiler: NewBaseCompiler("bin", "", InstallInSystem),
}
module.compiler = binary
diff --git a/rust/compiler.go b/rust/compiler.go
index 88e3fb2..4593165 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -36,14 +36,22 @@
compiler.Properties.No_stdlibs = proptools.BoolPtr(true)
}
-func NewBaseCompiler(dir, dir64 string) *baseCompiler {
+func NewBaseCompiler(dir, dir64 string, location installLocation) *baseCompiler {
return &baseCompiler{
Properties: BaseCompilerProperties{},
dir: dir,
dir64: dir64,
+ location: location,
}
}
+type installLocation int
+
+const (
+ InstallInSystem installLocation = 0
+ InstallInData = iota
+)
+
type BaseCompilerProperties struct {
// whether to pass "-D warnings" to rustc. Defaults to true.
Deny_warnings *bool
@@ -109,10 +117,15 @@
subDir string
relative string
path android.InstallPath
+ location installLocation
}
var _ compiler = (*baseCompiler)(nil)
+func (compiler *baseCompiler) inData() bool {
+ return compiler.location == InstallInData
+}
+
func (compiler *baseCompiler) compilerProps() []interface{} {
return []interface{}{&compiler.Properties}
}
diff --git a/rust/config/x86_device.go b/rust/config/x86_device.go
new file mode 100644
index 0000000..ec19b3c
--- /dev/null
+++ b/rust/config/x86_device.go
@@ -0,0 +1,97 @@
+// Copyright 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package config
+
+import (
+ "strings"
+
+ "android/soong/android"
+)
+
+var (
+ x86RustFlags = []string{}
+ x86ArchFeatureRustFlags = map[string][]string{}
+ x86LinkFlags = []string{}
+
+ x86ArchVariantRustFlags = map[string][]string{
+ "": []string{},
+ "atom": []string{"-C target-cpu=atom"},
+ "broadwell": []string{"-C target-cpu=broadwell"},
+ "haswell": []string{"-C target-cpu=haswell"},
+ "ivybridge": []string{"-C target-cpu=ivybridge"},
+ "sandybridge": []string{"-C target-cpu=sandybridge"},
+ "silvermont": []string{"-C target-cpu=silvermont"},
+ "skylake": []string{"-C target-cpu=skylake"},
+ //TODO: Add target-cpu=stoneyridge when rustc supports it.
+ "stoneyridge": []string{""},
+ // use prescott for x86_64, like cc/config/x86_device.go
+ "x86_64": []string{"-C target-cpu=prescott"},
+ }
+)
+
+func init() {
+ registerToolchainFactory(android.Android, android.X86, x86ToolchainFactory)
+
+ pctx.StaticVariable("X86ToolchainRustFlags", strings.Join(x86RustFlags, " "))
+ pctx.StaticVariable("X86ToolchainLinkFlags", strings.Join(x86LinkFlags, " "))
+
+ for variant, rustFlags := range x86ArchVariantRustFlags {
+ pctx.StaticVariable("X86"+variant+"VariantRustFlags",
+ strings.Join(rustFlags, " "))
+ }
+
+}
+
+type toolchainX86 struct {
+ toolchain32Bit
+ toolchainRustFlags string
+}
+
+func (t *toolchainX86) RustTriple() string {
+ return "i686-linux-android"
+}
+
+func (t *toolchainX86) ToolchainLinkFlags() string {
+ return "${config.DeviceGlobalLinkFlags} ${config.X86ToolchainLinkFlags}"
+}
+
+func (t *toolchainX86) ToolchainRustFlags() string {
+ return t.toolchainRustFlags
+}
+
+func (t *toolchainX86) RustFlags() string {
+ return "${config.X86ToolchainRustFlags}"
+}
+
+func (t *toolchainX86) Supported() bool {
+ return true
+}
+
+func x86ToolchainFactory(arch android.Arch) Toolchain {
+ toolchainRustFlags := []string{
+ "${config.X86ToolchainRustFlags}",
+ "${config.X86" + arch.ArchVariant + "VariantRustFlags}",
+ }
+
+ toolchainRustFlags = append(toolchainRustFlags, deviceGlobalRustFlags...)
+
+ for _, feature := range arch.ArchFeatures {
+ toolchainRustFlags = append(toolchainRustFlags, x86ArchFeatureRustFlags[feature]...)
+ }
+
+ return &toolchainX86{
+ toolchainRustFlags: strings.Join(toolchainRustFlags, " "),
+ }
+}
diff --git a/rust/library.go b/rust/library.go
index ba47541..43819ce 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -290,7 +290,7 @@
BuildShared: true,
BuildStatic: true,
},
- baseCompiler: NewBaseCompiler("lib", "lib64"),
+ baseCompiler: NewBaseCompiler("lib", "lib64", InstallInSystem),
}
module.compiler = library
diff --git a/rust/proc_macro.go b/rust/proc_macro.go
index 0da87da..10ea1e3 100644
--- a/rust/proc_macro.go
+++ b/rust/proc_macro.go
@@ -53,7 +53,7 @@
module := newModule(hod, android.MultilibFirst)
procMacro := &procMacroDecorator{
- baseCompiler: NewBaseCompiler("lib", "lib64"),
+ baseCompiler: NewBaseCompiler("lib", "lib64", InstallInSystem),
}
module.compiler = procMacro
diff --git a/rust/rust.go b/rust/rust.go
index a3266f7..0eab8d2 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -226,6 +226,7 @@
compilerDeps(ctx DepsContext, deps Deps) Deps
crateName() string
+ inData() bool
install(ctx ModuleContext, path android.Path)
relativeInstallPath() string
}
@@ -681,6 +682,13 @@
return depPaths
}
+func (mod *Module) InstallInData() bool {
+ if mod.compiler == nil {
+ return false
+ }
+ return mod.compiler.inData()
+}
+
func linkPathFromFilePath(filepath android.Path) string {
return strings.Split(filepath.String(), filepath.Base())[0]
}
diff --git a/rust/rust_test.go b/rust/rust_test.go
index 91c2f09..01b89db 100644
--- a/rust/rust_test.go
+++ b/rust/rust_test.go
@@ -245,7 +245,7 @@
srcs: ["foo.rs"],
no_stdlibs: true,
}`)
- module := ctx.ModuleForTests("fizz-buzz", "android_arm64_armv8-a_core").Module().(*Module)
+ module := ctx.ModuleForTests("fizz-buzz", "android_arm64_armv8-a").Module().(*Module)
if android.InList("libstd", module.Properties.AndroidMkDylibs) {
t.Errorf("no_stdlibs did not suppress dependency on libstd")
diff --git a/rust/test.go b/rust/test.go
index b391103..04f844c 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -55,8 +55,7 @@
test := &testDecorator{
binaryDecorator: &binaryDecorator{
- // TODO(chh): set up dir64?
- baseCompiler: NewBaseCompiler("testcases", ""),
+ baseCompiler: NewBaseCompiler("nativetest", "nativetest64", InstallInData),
},
}
@@ -79,22 +78,26 @@
}
func (test *testDecorator) install(ctx ModuleContext, file android.Path) {
- name := ctx.ModuleName() // default executable name
- if ctx.Device() { // on device, use mutated module name
- name = name + test.getMutatedModuleSubName(name)
- } else { // on host, use stem name in relative_install_path
- if stem := String(test.baseCompiler.Properties.Stem); stem != "" {
- name = stem
+ name := ctx.ModuleName()
+ path := test.baseCompiler.relativeInstallPath()
+ // on device, use mutated module name
+ name = name + test.getMutatedModuleSubName(name)
+ if !ctx.Device() { // on host, use mutated module name + arch type + stem name
+ stem := String(test.baseCompiler.Properties.Stem)
+ if stem == "" {
+ stem = name
}
- if path := test.baseCompiler.relativeInstallPath(); path != "" {
- name = path + "/" + name
- }
+ name = filepath.Join(name, ctx.Arch().ArchType.String(), stem)
}
test.testConfig = tradefed.AutoGenRustTestConfig(ctx, name,
test.Properties.Test_config,
test.Properties.Test_config_template,
test.Properties.Test_suites,
test.Properties.Auto_gen_config)
+ // default relative install path is module name
+ if path == "" {
+ test.baseCompiler.relative = ctx.ModuleName()
+ }
test.binaryDecorator.install(ctx, file)
}
diff --git a/scripts/Android.bp b/scripts/Android.bp
index 8c59cbc..4aaff9a 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -85,3 +85,39 @@
},
}
}
+
+python_binary_host {
+ name: "test_config_fixer",
+ main: "test_config_fixer.py",
+ srcs: [
+ "test_config_fixer.py",
+ "manifest.py",
+ ],
+ version: {
+ py2: {
+ enabled: true,
+ },
+ py3: {
+ enabled: false,
+ },
+ },
+}
+
+python_test_host {
+ name: "test_config_fixer_test",
+ main: "test_config_fixer_test.py",
+ srcs: [
+ "test_config_fixer_test.py",
+ "test_config_fixer.py",
+ "manifest.py",
+ ],
+ version: {
+ py2: {
+ enabled: true,
+ },
+ py3: {
+ enabled: false,
+ },
+ },
+ test_suites: ["general-tests"],
+}
\ No newline at end of file
diff --git a/scripts/manifest.py b/scripts/manifest.py
index 4c75f8b..04f7405 100755
--- a/scripts/manifest.py
+++ b/scripts/manifest.py
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-"""A tool for inserting values from the build system into a manifest."""
+"""A tool for inserting values from the build system into a manifest or a test config."""
from __future__ import print_function
from xml.dom import minidom
@@ -65,6 +65,15 @@
ns.value)
+def parse_test_config(doc):
+ """ Get the configuration element. """
+
+ test_config = doc.documentElement
+ if test_config.tagName != 'configuration':
+ raise RuntimeError('expected configuration tag at root')
+ return test_config
+
+
def as_int(s):
try:
i = int(s)
diff --git a/scripts/test_config_fixer.py b/scripts/test_config_fixer.py
new file mode 100644
index 0000000..7bb4b52
--- /dev/null
+++ b/scripts/test_config_fixer.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+"""A tool for modifying values in a test config."""
+
+from __future__ import print_function
+
+import argparse
+import sys
+from xml.dom import minidom
+
+
+from manifest import get_children_with_tag
+from manifest import parse_manifest
+from manifest import parse_test_config
+from manifest import write_xml
+
+
+def parse_args():
+ """Parse commandline arguments."""
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--manifest', default='', dest='manifest',
+ help=('AndroidManifest.xml that contains the original package name'))
+ parser.add_argument('--package-name', default='', dest='package_name',
+ help=('overwrite package fields in the test config'))
+ parser.add_argument('input', help='input test config file')
+ parser.add_argument('output', help='output test config file')
+ return parser.parse_args()
+
+
+def overwrite_package_name(test_config_doc, manifest_doc, package_name):
+
+ manifest = parse_manifest(manifest_doc)
+ original_package = manifest.getAttribute('package')
+ print('package: ' + original_package)
+
+ test_config = parse_test_config(test_config_doc)
+ tests = get_children_with_tag(test_config, 'test')
+
+ for test in tests:
+ options = get_children_with_tag(test, 'option')
+ for option in options:
+ if option.getAttribute('name') == "package" and option.getAttribute('value') == original_package:
+ option.setAttribute('value', package_name)
+
+def main():
+ """Program entry point."""
+ try:
+ args = parse_args()
+
+ doc = minidom.parse(args.input)
+
+ if args.package_name:
+ if not args.manifest:
+ raise RuntimeError('--manifest flag required for --package-name')
+ manifest_doc = minidom.parse(args.manifest)
+ overwrite_package_name(doc, manifest_doc, args.package_name)
+
+ with open(args.output, 'wb') as f:
+ write_xml(f, doc)
+
+ # pylint: disable=broad-except
+ except Exception as err:
+ print('error: ' + str(err), file=sys.stderr)
+ sys.exit(-1)
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/test_config_fixer_test.py b/scripts/test_config_fixer_test.py
new file mode 100644
index 0000000..b90582e
--- /dev/null
+++ b/scripts/test_config_fixer_test.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+"""Unit tests for test_config_fixer.py."""
+
+import StringIO
+import sys
+import unittest
+from xml.dom import minidom
+
+import test_config_fixer
+
+sys.dont_write_bytecode = True
+
+
+class OverwritePackageNameTest(unittest.TestCase):
+ """ Unit tests for overwrite_package_name function """
+
+ manifest = (
+ '<?xml version="1.0" encoding="utf-8"?>\n'
+ '<manifest xmlns:android="http://schemas.android.com/apk/res/android"\n'
+ ' package="com.android.foo">\n'
+ ' <application>\n'
+ ' </application>\n'
+ '</manifest>\n')
+
+ test_config = (
+ '<?xml version="1.0" encoding="utf-8"?>\n'
+ '<configuration description="Runs some tests.">\n'
+ ' <option name="test-suite-tag" value="apct"/>\n'
+ ' <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">\n'
+ ' <option name="package" value="%s"/>\n'
+ ' </target_preparer>\n'
+ ' <test class="com.android.tradefed.testtype.AndroidJUnitTest">\n'
+ ' <option name="package" value="%s"/>\n'
+ ' <option name="runtime-hint" value="20s"/>\n'
+ ' </test>\n'
+ ' <test class="com.android.tradefed.testtype.AndroidJUnitTest">\n'
+ ' <option name="package" value="%s"/>\n'
+ ' <option name="runtime-hint" value="15s"/>\n'
+ ' </test>\n'
+ '</configuration>\n')
+
+ def test_all(self):
+ doc = minidom.parseString(self.test_config % ("com.android.foo", "com.android.foo", "com.android.bar"))
+ manifest = minidom.parseString(self.manifest)
+
+ test_config_fixer.overwrite_package_name(doc, manifest, "com.soong.foo")
+ output = StringIO.StringIO()
+ test_config_fixer.write_xml(output, doc)
+
+ # Only the matching package name in a test node should be updated.
+ expected = self.test_config % ("com.android.foo", "com.soong.foo", "com.android.bar")
+ self.assertEqual(expected, output.getvalue())
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 53109ec..08751e4 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -50,8 +50,8 @@
}
`)
- armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_core_shared").(*cc.Module).OutputFile()
- arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_core_shared").(*cc.Module).OutputFile()
+ armOutput := result.Module("sdkmember", "android_arm_armv7-a-neon_shared").(*cc.Module).OutputFile()
+ arm64Output := result.Module("sdkmember", "android_arm64_armv8-a_shared").(*cc.Module).OutputFile()
var inputs []string
buildParams := result.Module("mysdk", "android_common").BuildParamsForTests()
@@ -132,11 +132,11 @@
}
`)
- sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_core_shared_myapex").Rule("toc").Output
- sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_core_shared_myapex2").Rule("toc").Output
+ sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk_1", "android_arm64_armv8-a_shared_myapex").Rule("toc").Output
+ sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk_2", "android_arm64_armv8-a_shared_myapex2").Rule("toc").Output
- cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_core_shared_myapex")
- cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_core_shared_myapex2")
+ cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex")
+ cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_myapex2")
// Depending on the uses_sdks value, different libs are linked
ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String())
@@ -174,10 +174,10 @@
result.CheckSnapshot("mysdk", "android_common", "",
checkAllCopyRules(`
include/Test.h -> include/include/Test.h
-.intermediates/mynativelib1/android_arm64_armv8-a_core_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
-.intermediates/mynativelib1/android_arm_armv7-a-neon_core_shared/mynativelib1.so -> arm/lib/mynativelib1.so
-.intermediates/mynativelib2/android_arm64_armv8-a_core_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
-.intermediates/mynativelib2/android_arm_armv7-a-neon_core_shared/mynativelib2.so -> arm/lib/mynativelib2.so
+.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
+.intermediates/mynativelib1/android_arm_armv7-a-neon_shared/mynativelib1.so -> arm/lib/mynativelib1.so
+.intermediates/mynativelib2/android_arm64_armv8-a_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
+.intermediates/mynativelib2/android_arm_armv7-a-neon_shared/mynativelib2.so -> arm/lib/mynativelib2.so
`),
)
}
@@ -253,9 +253,9 @@
`),
checkAllCopyRules(`
include/Test.h -> include/include/Test.h
-.intermediates/mynativelib/android_arm64_armv8-a_core_shared/mynativelib.so -> arm64/lib/mynativelib.so
+.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/mynativelib.so -> arm/lib/mynativelib.so`),
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so`),
)
}
@@ -328,14 +328,14 @@
`),
checkAllCopyRules(`
include/Test.h -> include/include/Test.h
-.intermediates/mynativelib/android_arm64_armv8-a_core_shared/mynativelib.so -> arm64/lib/mynativelib.so
-.intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/mynativelib.so -> arm/lib/mynativelib.so
-.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_core_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
+.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/android_arm64_armv8-a_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
`),
)
}
@@ -503,14 +503,14 @@
`),
checkAllCopyRules(`
include/Test.h -> include/include/Test.h
-.intermediates/mynativelib/android_arm64_armv8-a_core_static/mynativelib.a -> arm64/lib/mynativelib.a
-.intermediates/mynativelib/android_arm64_armv8-a_core_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/android_arm64_armv8-a_core_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/android_arm64_armv8-a_core_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_core_static/mynativelib.a -> arm/lib/mynativelib.a
-.intermediates/mynativelib/android_arm_armv7-a-neon_core_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_core_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
-.intermediates/mynativelib/android_arm_armv7-a-neon_core_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
+.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/Test.h -> arm64/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/android_arm64_armv8-a_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> arm/lib/mynativelib.a
+.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/Test.h -> arm/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BnTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/android_arm_armv7-a-neon_static/gen/aidl/aidl/foo/bar/BpTest.h -> arm/include_gen/mynativelib/aidl/foo/bar/BpTest.h
`),
)
}
diff --git a/sdk/sdk.go b/sdk/sdk.go
index cd9aafa..62bc06f 100644
--- a/sdk/sdk.go
+++ b/sdk/sdk.go
@@ -17,6 +17,7 @@
import (
"fmt"
"io"
+ "reflect"
"strconv"
"github.com/google/blueprint"
@@ -26,8 +27,6 @@
// This package doesn't depend on the apex package, but import it to make its mutators to be
// registered before mutators in this package. See RegisterPostDepsMutators for more details.
_ "android/soong/apex"
- "android/soong/cc"
- "android/soong/java"
)
func init() {
@@ -38,20 +37,19 @@
android.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory)
android.PreDepsMutators(RegisterPreDepsMutators)
android.PostDepsMutators(RegisterPostDepsMutators)
-
- // Populate the dependency tags for each member list property. This needs to
- // be done here to break an initialization cycle.
- for _, memberListProperty := range sdkMemberListProperties {
- memberListProperty.dependencyTag = &sdkMemberDependencyTag{
- memberListProperty: memberListProperty,
- }
- }
}
type sdk struct {
android.ModuleBase
android.DefaultableModuleBase
+ // The dynamically generated information about the registered SdkMemberType
+ dynamicSdkMemberTypes *dynamicSdkMemberTypes
+
+ // The dynamically created instance of the properties struct containing the sdk member
+ // list properties, e.g. java_libs.
+ dynamicMemberTypeListProperties interface{}
+
properties sdkProperties
snapshotFile android.OptionalPath
@@ -61,92 +59,141 @@
}
type sdkProperties struct {
- // For module types from the cc package
-
- // The list of shared native libraries in this SDK
- Native_shared_libs []string
-
- // The list of static native libraries in this SDK
- Native_static_libs []string
-
- // For module types from the java package
-
- // The list of java header libraries in this SDK
- //
- // This should be used for java libraries that are provided separately at runtime,
- // e.g. through an APEX.
- Java_header_libs []string
-
- // The list of java implementation libraries in this SDK
- Java_libs []string
-
- // The list of stub sources in this SDK
- Stubs_sources []string
-
Snapshot bool `blueprint:"mutated"`
}
type sdkMemberDependencyTag struct {
blueprint.BaseDependencyTag
- memberListProperty *sdkMemberListProperty
+ memberType android.SdkMemberType
}
// Contains information about the sdk properties that list sdk members, e.g.
// Java_header_libs.
type sdkMemberListProperty struct {
- // the name of the property as used in a .bp file
- name string
-
// getter for the list of member names
- getter func(properties *sdkProperties) []string
+ getter func(properties interface{}) []string
// the type of member referenced in the list
memberType android.SdkMemberType
- // the dependency tag used for items in this list.
+ // the dependency tag used for items in this list that can be used to determine the memberType
+ // for a resolved dependency.
dependencyTag *sdkMemberDependencyTag
}
-// Information about how to handle each member list property.
+func (p *sdkMemberListProperty) propertyName() string {
+ return p.memberType.SdkPropertyName()
+}
+
+// Cache of dynamically generated dynamicSdkMemberTypes objects. The key is the pointer
+// to a slice of SdkMemberType instances held in android.SdkMemberTypes.
+var dynamicSdkMemberTypesMap android.OncePer
+
+// A dynamically generated set of member list properties and associated structure type.
+type dynamicSdkMemberTypes struct {
+ // The dynamically generated structure type.
+ //
+ // Contains one []string exported field for each android.SdkMemberTypes. The name of the field
+ // is the exported form of the value returned by SdkMemberType.SdkPropertyName().
+ propertiesStructType reflect.Type
+
+ // Information about each of the member type specific list properties.
+ memberListProperties []*sdkMemberListProperty
+}
+
+func (d *dynamicSdkMemberTypes) createMemberListProperties() interface{} {
+ return reflect.New(d.propertiesStructType).Interface()
+}
+
+func getDynamicSdkMemberTypes(registry *android.SdkMemberTypesRegistry) *dynamicSdkMemberTypes {
+
+ // Get a key that uniquely identifies the registry contents.
+ key := registry.UniqueOnceKey()
+
+ // Get the registered types.
+ registeredTypes := registry.RegisteredTypes()
+
+ // Get the cached value, creating new instance if necessary.
+ return dynamicSdkMemberTypesMap.Once(key, func() interface{} {
+ return createDynamicSdkMemberTypes(registeredTypes)
+ }).(*dynamicSdkMemberTypes)
+}
+
+// Create the dynamicSdkMemberTypes from the list of registered member types.
//
-// It is organized first by package and then by name within the package.
-// Packages are in alphabetical order and properties are in alphabetical order
-// within each package.
-var sdkMemberListProperties = []*sdkMemberListProperty{
- // Members from cc package.
- {
- name: "native_shared_libs",
- getter: func(properties *sdkProperties) []string { return properties.Native_shared_libs },
- memberType: cc.SharedLibrarySdkMemberType,
- },
- {
- name: "native_static_libs",
- getter: func(properties *sdkProperties) []string { return properties.Native_static_libs },
- memberType: cc.StaticLibrarySdkMemberType,
- },
- // Members from java package.
- {
- name: "java_header_libs",
- getter: func(properties *sdkProperties) []string { return properties.Java_header_libs },
- memberType: java.HeaderLibrarySdkMemberType,
- },
- {
- name: "java_libs",
- getter: func(properties *sdkProperties) []string { return properties.Java_libs },
- memberType: java.ImplLibrarySdkMemberType,
- },
- {
- name: "stubs_sources",
- getter: func(properties *sdkProperties) []string { return properties.Stubs_sources },
- memberType: java.DroidStubsSdkMemberType,
- },
+// A struct is created which contains one exported field per member type corresponding to
+// the SdkMemberType.SdkPropertyName() value.
+//
+// A list of sdkMemberListProperty instances is created, one per member type that provides:
+// * a reference to the member type.
+// * a getter for the corresponding field in the properties struct.
+// * a dependency tag that identifies the member type of a resolved dependency.
+//
+func createDynamicSdkMemberTypes(sdkMemberTypes []android.SdkMemberType) *dynamicSdkMemberTypes {
+ var listProperties []*sdkMemberListProperty
+ var fields []reflect.StructField
+
+ // Iterate over the member types creating StructField and sdkMemberListProperty objects.
+ for f, memberType := range sdkMemberTypes {
+ p := memberType.SdkPropertyName()
+
+ // Create a dynamic exported field for the member type's property.
+ fields = append(fields, reflect.StructField{
+ Name: proptools.FieldNameForProperty(p),
+ Type: reflect.TypeOf([]string{}),
+ })
+
+ // Copy the field index for use in the getter func as using the loop variable directly will
+ // cause all funcs to use the last value.
+ fieldIndex := f
+
+ // Create an sdkMemberListProperty for the member type.
+ memberListProperty := &sdkMemberListProperty{
+ getter: func(properties interface{}) []string {
+ // The properties is expected to be of the following form (where
+ // <Module_types> is the name of an SdkMemberType.SdkPropertyName().
+ // properties *struct {<Module_types> []string, ....}
+ //
+ // Although it accesses the field by index the following reflection code is equivalent to:
+ // *properties.<Module_types>
+ //
+ list := reflect.ValueOf(properties).Elem().Field(fieldIndex).Interface().([]string)
+ return list
+ },
+
+ memberType: memberType,
+
+ dependencyTag: &sdkMemberDependencyTag{
+ memberType: memberType,
+ },
+ }
+
+ listProperties = append(listProperties, memberListProperty)
+ }
+
+ // Create a dynamic struct from the collated fields.
+ propertiesStructType := reflect.StructOf(fields)
+
+ return &dynamicSdkMemberTypes{
+ memberListProperties: listProperties,
+ propertiesStructType: propertiesStructType,
+ }
}
// sdk defines an SDK which is a logical group of modules (e.g. native libs, headers, java libs, etc.)
// which Mainline modules like APEX can choose to build with.
func ModuleFactory() android.Module {
s := &sdk{}
- s.AddProperties(&s.properties)
+
+ // Get the dynamic sdk member type data for the currently registered sdk member types.
+ s.dynamicSdkMemberTypes = getDynamicSdkMemberTypes(android.SdkMemberTypes)
+
+ // Create an instance of the dynamically created struct that contains all the
+ // properties for the member type specific list properties.
+ s.dynamicMemberTypeListProperties = s.dynamicSdkMemberTypes.createMemberListProperties()
+
+ s.AddProperties(&s.properties, s.dynamicMemberTypeListProperties)
+
android.InitAndroidMultiTargetsArchModule(s, android.HostAndDeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(s)
android.AddLoadHook(s, func(ctx android.LoadHookContext) {
@@ -235,9 +282,9 @@
// Step 1: create dependencies from an SDK module to its members.
func memberMutator(mctx android.BottomUpMutatorContext) {
- if m, ok := mctx.Module().(*sdk); ok {
- for _, memberListProperty := range sdkMemberListProperties {
- names := memberListProperty.getter(&m.properties)
+ if s, ok := mctx.Module().(*sdk); ok {
+ for _, memberListProperty := range s.dynamicSdkMemberTypes.memberListProperties {
+ names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
tag := memberListProperty.dependencyTag
memberListProperty.memberType.AddDependencies(mctx, tag, names)
}
diff --git a/sdk/update.go b/sdk/update.go
index 52d21ed..d31fa30 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -105,21 +105,20 @@
// Collect all the members.
//
// The members are first grouped by type and then grouped by name. The order of
-// the types is the order they are referenced in sdkMemberListProperties. The
+// the types is the order they are referenced in android.SdkMemberTypes. The
// names are in order in which the dependencies were added.
-func collectMembers(ctx android.ModuleContext) []*sdkMember {
+func (s *sdk) collectMembers(ctx android.ModuleContext) []*sdkMember {
byType := make(map[android.SdkMemberType][]*sdkMember)
byName := make(map[string]*sdkMember)
ctx.VisitDirectDeps(func(m android.Module) {
tag := ctx.OtherModuleDependencyTag(m)
if memberTag, ok := tag.(*sdkMemberDependencyTag); ok {
- memberListProperty := memberTag.memberListProperty
- memberType := memberListProperty.memberType
+ memberType := memberTag.memberType
// Make sure that the resolved module is allowed in the member list property.
if !memberType.IsInstance(m) {
- ctx.ModuleErrorf("module %q is not valid in property %s", ctx.OtherModuleName(m), memberListProperty.name)
+ ctx.ModuleErrorf("module %q is not valid in property %s", ctx.OtherModuleName(m), memberType.SdkPropertyName())
}
name := ctx.OtherModuleName(m)
@@ -136,7 +135,7 @@
})
var members []*sdkMember
- for _, memberListProperty := range sdkMemberListProperties {
+ for _, memberListProperty := range s.dynamicSdkMemberTypes.memberListProperties {
membersOfType := byType[memberListProperty.memberType]
members = append(members, membersOfType...)
}
@@ -191,7 +190,7 @@
}
s.builderForTests = builder
- for _, member := range collectMembers(ctx) {
+ for _, member := range s.collectMembers(ctx) {
member.memberType.BuildSnapshot(ctx, builder, member)
}
@@ -220,10 +219,10 @@
}
addHostDeviceSupportedProperties(&s.ModuleBase, snapshotModule)
- for _, memberListProperty := range sdkMemberListProperties {
- names := memberListProperty.getter(&s.properties)
+ for _, memberListProperty := range s.dynamicSdkMemberTypes.memberListProperties {
+ names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
if len(names) > 0 {
- snapshotModule.AddProperty(memberListProperty.name, builder.versionedSdkMemberNames(names))
+ snapshotModule.AddProperty(memberListProperty.propertyName(), builder.versionedSdkMemberNames(names))
}
}
bpFile.AddModule(snapshotModule)
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index 81f4c53..7b90673 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -295,10 +295,10 @@
}
for _, variant := range []string{
- "android_arm_armv7-a-neon_core_shared",
- "android_arm_armv7-a-neon_core_static",
- "android_arm64_armv8-a_core_shared",
- "android_arm64_armv8-a_core_static",
+ "android_arm_armv7-a-neon_shared",
+ "android_arm_armv7-a-neon_static",
+ "android_arm64_armv8-a_shared",
+ "android_arm64_armv8-a_static",
} {
ctx.ModuleForTests("libsysprop-platform", variant)
@@ -310,17 +310,17 @@
ctx.ModuleForTests("sysprop-vendor", "android_common")
// Check for exported includes
- coreVariant := "android_arm64_armv8-a_core_static"
+ coreVariant := "android_arm64_armv8-a_static"
vendorVariant := "android_arm64_armv8-a_vendor.VER_static"
- platformInternalPath := "libsysprop-platform/android_arm64_armv8-a_core_static/gen/sysprop/include"
- platformPublicCorePath := "libsysprop-platform/android_arm64_armv8-a_core_static/gen/sysprop/public/include"
+ platformInternalPath := "libsysprop-platform/android_arm64_armv8-a_static/gen/sysprop/include"
+ platformPublicCorePath := "libsysprop-platform/android_arm64_armv8-a_static/gen/sysprop/public/include"
platformPublicVendorPath := "libsysprop-platform/android_arm64_armv8-a_vendor.VER_static/gen/sysprop/public/include"
- platformOnProductPath := "libsysprop-platform-on-product/android_arm64_armv8-a_core_static/gen/sysprop/public/include"
+ platformOnProductPath := "libsysprop-platform-on-product/android_arm64_armv8-a_static/gen/sysprop/public/include"
vendorInternalPath := "libsysprop-vendor/android_arm64_armv8-a_vendor.VER_static/gen/sysprop/include"
- vendorPublicPath := "libsysprop-vendor/android_arm64_armv8-a_core_static/gen/sysprop/public/include"
+ vendorPublicPath := "libsysprop-vendor/android_arm64_armv8-a_static/gen/sysprop/public/include"
platformClient := ctx.ModuleForTests("cc-client-platform", coreVariant)
platformFlags := platformClient.Rule("cc").Args["cFlags"]
diff --git a/ui/build/kati.go b/ui/build/kati.go
index 307475a..ac09ce1 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -151,6 +151,45 @@
"KATI_PACKAGE_MK_DIR="+config.KatiPackageMkDir())
runKati(ctx, config, katiBuildSuffix, args, func(env *Environment) {})
+
+ cleanCopyHeaders(ctx, config)
+}
+
+func cleanCopyHeaders(ctx Context, config Config) {
+ ctx.BeginTrace("clean", "clean copy headers")
+ defer ctx.EndTrace()
+
+ data, err := ioutil.ReadFile(filepath.Join(config.ProductOut(), ".copied_headers_list"))
+ if err != nil {
+ if os.IsNotExist(err) {
+ return
+ }
+ ctx.Fatalf("Failed to read copied headers list: %v", err)
+ }
+
+ headers := strings.Fields(string(data))
+ if len(headers) < 1 {
+ ctx.Fatal("Failed to parse copied headers list: %q", string(data))
+ }
+ headerDir := headers[0]
+ headers = headers[1:]
+
+ filepath.Walk(headerDir,
+ func(path string, info os.FileInfo, err error) error {
+ if err != nil {
+ return nil
+ }
+ if info.IsDir() {
+ return nil
+ }
+ if !inList(path, headers) {
+ ctx.Printf("Removing obsolete header %q", path)
+ if err := os.Remove(path); err != nil {
+ ctx.Fatalf("Failed to remove obsolete header %q: %v", path, err)
+ }
+ }
+ return nil
+ })
}
func runKatiPackage(ctx Context, config Config) {
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index f347a11..90ff706 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -119,9 +119,6 @@
"pgrep": LinuxOnlyPrebuilt,
"pkill": LinuxOnlyPrebuilt,
"ps": LinuxOnlyPrebuilt,
-
- // The toybox xargs is currently breaking the mac build.
- "xargs": LinuxOnlyPrebuilt,
}
func init() {
diff --git a/xml/xml_test.go b/xml/xml_test.go
index f42ba77..0a11566 100644
--- a/xml/xml_test.go
+++ b/xml/xml_test.go
@@ -104,7 +104,7 @@
{rule: "xmllint-minimal", input: "baz.xml"},
} {
t.Run(tc.schemaType, func(t *testing.T) {
- rule := ctx.ModuleForTests(tc.input, "android_arm64_armv8-a_core").Rule(tc.rule)
+ rule := ctx.ModuleForTests(tc.input, "android_arm64_armv8-a").Rule(tc.rule)
assertEqual(t, "input", tc.input, rule.Input.String())
if tc.schemaType != "" {
assertEqual(t, "schema", tc.schema, rule.Args[tc.schemaType])
@@ -112,6 +112,6 @@
})
}
- m := ctx.ModuleForTests("foo.xml", "android_arm64_armv8-a_core").Module().(*prebuiltEtcXml)
+ m := ctx.ModuleForTests("foo.xml", "android_arm64_armv8-a").Module().(*prebuiltEtcXml)
assertEqual(t, "installDir", buildDir+"/target/product/test_device/system/etc", m.InstallDirPath().String())
}