Merge "Add $ORIGIN to fuzzer-coverage sanitized .so's."
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/androidmk.go b/android/androidmk.go
index 4893bf4..f3c15e4 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -61,7 +61,7 @@
// Allows modules to customize their Android*.mk output.
type AndroidMkEntriesProvider interface {
- AndroidMkEntries() AndroidMkEntries
+ AndroidMkEntries() []AndroidMkEntries
BaseModuleName() string
}
@@ -510,10 +510,10 @@
return nil
}
- entries := provider.AndroidMkEntries()
- entries.fillInEntries(ctx.Config(), ctx.BlueprintFile(mod), mod)
-
- entries.write(w)
+ for _, entries := range provider.AndroidMkEntries() {
+ entries.fillInEntries(ctx.Config(), ctx.BlueprintFile(mod), mod)
+ entries.write(w)
+ }
return nil
}
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/config.go b/android/config.go
index 271a54a..e1db55d 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1103,6 +1103,10 @@
return Bool(c.productVariables.EnforceProductPartitionInterface)
}
+func (c *config) InstallExtraFlattenedApexes() bool {
+ return Bool(c.productVariables.InstallExtraFlattenedApexes)
+}
+
func (c *config) ProductHiddenAPIStubs() []string {
return c.productVariables.ProductHiddenAPIStubs
}
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/paths.go b/android/paths.go
index 1a37a34..85c861d 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -512,8 +512,12 @@
}
func FilterPathList(list []Path, filter []Path) (remainder []Path, filtered []Path) {
+ return FilterPathListPredicate(list, func(p Path) bool { return inPathList(p, filter) })
+}
+
+func FilterPathListPredicate(list []Path, predicate func(Path) bool) (remainder []Path, filtered []Path) {
for _, l := range list {
- if inPathList(l, filter) {
+ if predicate(l) {
filtered = append(filtered, l)
} else {
remainder = append(remainder, l)
diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go
index 2701185..388d17f 100644
--- a/android/prebuilt_etc.go
+++ b/android/prebuilt_etc.go
@@ -165,12 +165,12 @@
})
}
-func (p *PrebuiltEtc) AndroidMkEntries() AndroidMkEntries {
+func (p *PrebuiltEtc) AndroidMkEntries() []AndroidMkEntries {
nameSuffix := ""
if p.inRecovery() && !p.onlyInRecovery() {
nameSuffix = ".recovery"
}
- return AndroidMkEntries{
+ return []AndroidMkEntries{AndroidMkEntries{
Class: "ETC",
SubName: nameSuffix,
OutputFile: OptionalPathForPath(p.outputFilePath),
@@ -187,7 +187,7 @@
}
},
},
- }
+ }}
}
func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go
index 2c4123f..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,8 +141,8 @@
"LOCAL_TARGET_REQUIRED_MODULES": {"targetModA"},
}
- mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
- entries := AndroidMkEntriesForTest(t, config, "", mod)
+ 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 {
if !reflect.DeepEqual(value, expectedValue) {
@@ -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/android/sh_binary.go b/android/sh_binary.go
index 2b649c4..3293d4f 100644
--- a/android/sh_binary.go
+++ b/android/sh_binary.go
@@ -135,8 +135,8 @@
})
}
-func (s *ShBinary) AndroidMkEntries() AndroidMkEntries {
- return AndroidMkEntries{
+func (s *ShBinary) AndroidMkEntries() []AndroidMkEntries {
+ return []AndroidMkEntries{AndroidMkEntries{
Class: "EXECUTABLES",
OutputFile: OptionalPathForPath(s.outputFilePath),
Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
@@ -145,7 +145,7 @@
s.customAndroidMkEntries(entries)
},
},
- }
+ }}
}
func (s *ShBinary) customAndroidMkEntries(entries *AndroidMkEntries) {
@@ -163,8 +163,8 @@
s.data = PathsForModuleSrc(ctx, s.testProperties.Data)
}
-func (s *ShTest) AndroidMkEntries() AndroidMkEntries {
- return AndroidMkEntries{
+func (s *ShTest) AndroidMkEntries() []AndroidMkEntries {
+ return []AndroidMkEntries{AndroidMkEntries{
Class: "NATIVE_TESTS",
OutputFile: OptionalPathForPath(s.outputFilePath),
Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
@@ -185,7 +185,7 @@
}
},
},
- }
+ }}
}
func InitShBinaryModule(s *ShBinary) {
diff --git a/android/sh_binary_test.go b/android/sh_binary_test.go
index a138754..8488fe4 100644
--- a/android/sh_binary_test.go
+++ b/android/sh_binary_test.go
@@ -42,7 +42,7 @@
mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*ShTest)
- entries := AndroidMkEntriesForTest(t, config, "", mod)
+ entries := AndroidMkEntriesForTest(t, config, "", mod)[0]
expected := []string{":testdata/data1", ":testdata/sub/data2"}
actual := entries.EntryMap["LOCAL_TEST_DATA"]
if !reflect.DeepEqual(expected, actual) {
diff --git a/android/testing.go b/android/testing.go
index 4b55920..26f1e4d 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -403,15 +403,18 @@
}
-func AndroidMkEntriesForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) AndroidMkEntries {
+func AndroidMkEntriesForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) []AndroidMkEntries {
var p AndroidMkEntriesProvider
var ok bool
if p, ok = mod.(AndroidMkEntriesProvider); !ok {
t.Errorf("module does not implement AndroidMkEntriesProvider: " + mod.Name())
}
- entries := p.AndroidMkEntries()
- entries.fillInEntries(config, bpPath, mod)
- return entries
+
+ entriesList := p.AndroidMkEntries()
+ for i, _ := range entriesList {
+ entriesList[i].fillInEntries(config, bpPath, mod)
+ }
+ return entriesList
}
func AndroidMkDataForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) AndroidMkData {
diff --git a/android/variable.go b/android/variable.go
index 25a5dc0..628408e 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -311,6 +311,8 @@
MissingUsesLibraries []string `json:",omitempty"`
EnforceProductPartitionInterface *bool `json:",omitempty"`
+
+ InstallExtraFlattenedApexes *bool `json:",omitempty"`
}
func boolPtr(v bool) *bool {
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 3dde149..3d7b45d 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -339,6 +339,14 @@
// binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
// from PRODUCT_PACKAGES.
Overrides []string
+
+ // 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 {
@@ -451,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 {
@@ -503,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
@@ -731,6 +742,10 @@
return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
}
+func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
+ return proptools.Bool(a.properties.Test_only_no_hashtree)
+}
+
func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
if a.vndkApex {
return cc.VendorVariationPrefix + a.vndkVersion(config)
@@ -779,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
@@ -793,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
@@ -808,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 {
@@ -838,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()
@@ -864,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
@@ -884,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`.
@@ -905,6 +920,10 @@
} else {
a.suffix = ""
a.primaryApexType = true
+
+ if ctx.Config().InstallExtraFlattenedApexes() {
+ a.externalDeps = append(a.externalDeps, a.Name()+flattenedSuffix)
+ }
}
case zipApex:
if proptools.String(a.properties.Payload_type) == "zip" {
@@ -968,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 {
@@ -988,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 {
@@ -996,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 {
@@ -1008,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)
}
@@ -1033,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)
}
@@ -1089,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`
@@ -1125,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 944852d..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) {
@@ -2380,7 +2381,7 @@
p := ctx.ModuleForTests("myapex.prebuilt", "android_common").Module().(*Prebuilt)
expected := []string{"myapex"}
- actual := android.AndroidMkEntriesForTest(t, config, "", p).EntryMap["LOCAL_OVERRIDES_MODULES"]
+ actual := android.AndroidMkEntriesForTest(t, config, "", p)[0].EntryMap["LOCAL_OVERRIDES_MODULES"]
if !reflect.DeepEqual(actual, expected) {
t.Errorf("Incorrect LOCAL_OVERRIDES_MODULES value '%s', expected '%s'", actual, expected)
}
@@ -2452,11 +2453,34 @@
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")
}
+func TestInstallExtraFlattenedApexes(t *testing.T) {
+ ctx, config := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `, func(fs map[string][]byte, config android.Config) {
+ config.TestProductVariables.InstallExtraFlattenedApexes = proptools.BoolPtr(true)
+ })
+ ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
+ ensureListContains(t, ab.externalDeps, "myapex.flattened")
+ mk := android.AndroidMkDataForTest(t, config, "", ab)
+ var builder strings.Builder
+ mk.Custom(&builder, ab.Name(), "TARGET_", "", mk)
+ androidMk := builder.String()
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += myapex.flattened")
+}
+
func TestApexUsesOtherApex(t *testing.T) {
ctx, _ := testApex(t, `
apex {
@@ -2503,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")
@@ -2670,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") {
@@ -2882,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 {
@@ -2907,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 {
@@ -2934,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) {
@@ -3011,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 7fe0af3..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{
@@ -141,6 +138,8 @@
Command: `${zip2zip} -i $in -o $out ` +
`apex_payload.img:apex/${abi}.img ` +
`apex_manifest.json:root/apex_manifest.json ` +
+ `apex_pubkey:root/apex_pubkey ` +
+ `apex_manifest.pb:root/apex_manifest.pb ` +
`AndroidManifest.xml:manifest/AndroidManifest.xml ` +
`assets/NOTICE.html.gz:assets/NOTICE.html.gz`,
CommandDeps: []string{"${zip2zip}"},
@@ -169,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)
@@ -184,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, " "),
@@ -192,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,
})
}
@@ -254,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())
@@ -269,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{
@@ -375,7 +379,11 @@
optFlags = append(optFlags, "--assets_dir "+filepath.Dir(noticeFile.String()))
}
- if !ctx.Config().UnbundledBuild() && a.installable() {
+ if ctx.ModuleDir() != "system/apex/apexd/apexd_testdata" && a.testOnlyShouldSkipHashtreeGeneration() {
+ ctx.PropertyErrorf("test_only_no_hashtree", "not available")
+ return
+ }
+ if (!ctx.Config().UnbundledBuild() && a.installable()) || a.testOnlyShouldSkipHashtreeGeneration() {
// Apexes which are supposed to be installed in builtin dirs(/system, etc)
// don't need hashtree for activation. Therefore, by removing hashtree from
// apex bundle (filesystem image in it, to be specific), we can save storage.
@@ -388,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, " "),
},
})
@@ -434,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(),
},
})
}
@@ -499,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")
@@ -511,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/apex/prebuilt.go b/apex/prebuilt.go
index db3b5ef..ba5a466 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -181,8 +181,8 @@
// TODO(b/143192278): Add compat symlinks for prebuilt_apex
}
-func (p *Prebuilt) AndroidMkEntries() android.AndroidMkEntries {
- return android.AndroidMkEntries{
+func (p *Prebuilt) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "ETC",
OutputFile: android.OptionalPathForPath(p.inputApex),
Include: "$(BUILD_PREBUILT)",
@@ -194,5 +194,5 @@
entries.AddStrings("LOCAL_OVERRIDES_MODULES", p.properties.Overrides...)
},
},
- }
+ }}
}
diff --git a/cc/androidmk.go b/cc/androidmk.go
index ff181d8..c1225bc 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -317,6 +317,11 @@
filepath.Dir(fuzz.corpusIntermediateDir.String())+":corpus/"+d.Base())
}
+ for _, d := range fuzz.data {
+ fuzzFiles = append(fuzzFiles,
+ filepath.Dir(fuzz.dataIntermediateDir.String())+":data/"+d.Rel())
+ }
+
if fuzz.dictionary != nil {
fuzzFiles = append(fuzzFiles,
filepath.Dir(fuzz.dictionary.String())+":"+fuzz.dictionary.Base())
diff --git a/cc/cc.go b/cc/cc.go
index a56978d..512fe8e 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -38,7 +38,7 @@
android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("vndk", VndkMutator).Parallel()
ctx.BottomUp("link", LinkageMutator).Parallel()
- ctx.BottomUp("ndk_api", ndkApiMutator).Parallel()
+ ctx.BottomUp("ndk_api", NdkApiMutator).Parallel()
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
ctx.BottomUp("version", VersionMutator).Parallel()
ctx.BottomUp("begin", BeginMutator).Parallel()
@@ -286,6 +286,7 @@
isPgoCompile() bool
isNDKStubLibrary() bool
useClangLld(actx ModuleContext) bool
+ isForPlatform() bool
apexName() string
hasStubsVariants() bool
isStubs() bool
@@ -1056,10 +1057,6 @@
// Host modules do not need ABI dumps.
return false
}
- if !ctx.mod.IsForPlatform() {
- // APEX variants do not need ABI dumps.
- return false
- }
if ctx.isStubs() {
// Stubs do not need ABI dumps.
return false
@@ -1086,6 +1083,10 @@
return ctx.mod.getVndkExtendsModuleName()
}
+func (ctx *moduleContextImpl) isForPlatform() bool {
+ return ctx.mod.IsForPlatform()
+}
+
func (ctx *moduleContextImpl) apexName() string {
return ctx.mod.ApexName()
}
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 0cbdd52..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"
)
@@ -421,7 +421,7 @@
}`, config)
module := ctx.ModuleForTests("llndk.libraries.txt", "")
- entries := android.AndroidMkEntriesForTest(t, config, "", module.Module())
+ entries := android.AndroidMkEntriesForTest(t, config, "", module.Module())[0]
assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.VER.txt"})
}
@@ -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/config/clang.go b/cc/config/clang.go
index eddc341..8618d09 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -132,6 +132,10 @@
// Disable -Winconsistent-missing-override until we can clean up the existing
// codebase for it.
"-Wno-inconsistent-missing-override",
+
+ // Warnings from clang-10
+ // Nested and array designated initialization is nice to have.
+ "-Wno-c99-designator",
}, " "))
pctx.StaticVariable("ClangExtraCppflags", strings.Join([]string{
@@ -161,6 +165,10 @@
// new warnings are fixed.
"-Wno-tautological-constant-compare",
"-Wno-tautological-type-limit-compare",
+ // http://b/145210666
+ "-Wno-reorder-init-list",
+ // http://b/145211066
+ "-Wno-implicit-int-float-conversion",
}, " "))
// Extra cflags for external third-party projects to disable warnings that
@@ -176,6 +184,13 @@
// Bug: http://b/29823425 Disable -Wnull-dereference until the
// new instances detected by this warning are fixed.
"-Wno-null-dereference",
+
+ // http://b/145211477
+ "-Wno-pointer-compare",
+ // http://b/145211022
+ "-Wno-xor-used-as-pow",
+ // http://b/145211022
+ "-Wno-final-dtor-non-final-class",
}, " "))
}
diff --git a/cc/config/global.go b/cc/config/global.go
index 0a09fa4..bae5555 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -126,8 +126,8 @@
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
- ClangDefaultVersion = "clang-r365631b"
- ClangDefaultShortVersion = "9.0.7"
+ ClangDefaultVersion = "clang-r370808"
+ ClangDefaultShortVersion = "10.0.1"
// Directories with warnings from Android.bp files.
WarningAllowedProjects = []string{
diff --git a/cc/fuzz.go b/cc/fuzz.go
index c2b0ff4..0d3cc74 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -49,6 +49,9 @@
// Optional list of seed files to be installed to the fuzz target's output
// directory.
Corpus []string `android:"path"`
+ // Optional list of data files to be installed to the fuzz target's output
+ // directory. Directory structure relative to the module is preserved.
+ Data []string `android:"path"`
// Optional dictionary to be installed to the fuzz target's output directory.
Dictionary *string `android:"path"`
// Config for running the target on fuzzing infrastructure.
@@ -81,6 +84,8 @@
corpus android.Paths
corpusIntermediateDir android.Path
config android.Path
+ data android.Paths
+ dataIntermediateDir android.Path
installedSharedDeps []string
}
@@ -210,6 +215,17 @@
builder.Build(pctx, ctx, "copy_corpus", "copy corpus")
fuzz.corpusIntermediateDir = intermediateDir
+ fuzz.data = android.PathsForModuleSrc(ctx, fuzz.Properties.Data)
+ builder = android.NewRuleBuilder()
+ intermediateDir = android.PathForModuleOut(ctx, "data")
+ for _, entry := range fuzz.data {
+ builder.Command().Text("cp").
+ Input(entry).
+ Output(intermediateDir.Join(ctx, entry.Rel()))
+ }
+ builder.Build(pctx, ctx, "copy_data", "copy data")
+ fuzz.dataIntermediateDir = intermediateDir
+
if fuzz.Properties.Dictionary != nil {
fuzz.dictionary = android.PathForModuleSrc(ctx, *fuzz.Properties.Dictionary)
if fuzz.dictionary.Ext() != ".dict" {
@@ -377,6 +393,19 @@
files = append(files, fileToZip{corpusZip, ""})
}
+ // Package the data into a zipfile.
+ if fuzzModule.data != nil {
+ dataZip := archDir.Join(ctx, module.Name()+"_data.zip")
+ command := builder.Command().BuiltTool(ctx, "soong_zip").
+ FlagWithOutput("-o ", dataZip)
+ for _, f := range fuzzModule.data {
+ intermediateDir := strings.TrimSuffix(f.String(), f.Rel())
+ command.FlagWithArg("-C ", intermediateDir)
+ command.FlagWithInput("-f ", f)
+ }
+ files = append(files, fileToZip{dataZip, ""})
+ }
+
// Find and mark all the transiently-dependent shared libraries for
// packaging.
for _, library := range sharedLibraries {
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 4b8e052..04130c4 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -24,7 +24,6 @@
"strings"
"sync"
- "github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
"android/soong/android"
@@ -522,6 +521,19 @@
if !ctx.shouldCreateSourceAbiDump() {
return false
}
+ if !ctx.isForPlatform() {
+ if !ctx.hasStubsVariants() {
+ // Skip ABI checks if this library is for APEX but isn't exported.
+ return false
+ }
+ if !Bool(library.Properties.Header_abi_checker.Enabled) {
+ // Skip ABI checks if this library is for APEX and did not explicitly enable
+ // ABI checks.
+ // TODO(b/145608479): ABI checks should be enabled by default. Remove this
+ // after evaluating the extra build time.
+ return false
+ }
+ }
return library.classifySourceAbiDump(ctx) != ""
}
@@ -1424,230 +1436,3 @@
return outputFile
}
-
-var LibrarySdkMemberType = &librarySdkMemberType{}
-
-type librarySdkMemberType struct {
-}
-
-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)
- }
- mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: android.CoreVariation},
- {Mutator: "link", Variation: "shared"},
- {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 := organizeVariants(member)
- buildSharedNativeLibSnapshot(sdkModuleContext, info, builder, member)
-}
-
-func buildSharedNativeLibSnapshot(sdkModuleContext android.ModuleContext, info *nativeLibInfo, builder android.SnapshotBuilder, member android.SdkMember) {
- // a function for emitting include dirs
- printExportedDirCopyCommandsForNativeLibs := func(lib archSpecificNativeLibInfo) {
- includeDirs := lib.exportedIncludeDirs
- includeDirs = append(includeDirs, lib.exportedSystemIncludeDirs...)
- if len(includeDirs) == 0 {
- return
- }
- for _, dir := range includeDirs {
- if _, gen := dir.(android.WritablePath); gen {
- // generated headers are copied via exportedGeneratedHeaders. See below.
- continue
- }
- targetDir := nativeIncludeDir
- if info.hasArchSpecificFlags {
- targetDir = filepath.Join(lib.archType, targetDir)
- }
-
- // 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 {
- targetDir := nativeGeneratedIncludeDir
- if info.hasArchSpecificFlags {
- targetDir = filepath.Join(lib.archType, targetDir)
- }
- dest := filepath.Join(targetDir, lib.name, file.Rel())
- builder.CopyToSnapshot(file, dest)
- }
- }
-
- if !info.hasArchSpecificFlags {
- printExportedDirCopyCommandsForNativeLibs(info.archVariants[0])
- }
-
- // for each architecture
- for _, av := range info.archVariants {
- builder.CopyToSnapshot(av.outputFile, nativeStubFilePathFor(av))
-
- if info.hasArchSpecificFlags {
- printExportedDirCopyCommandsForNativeLibs(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 archSpecificNativeLibInfo, properties android.BpPropertySet, systemInclude bool) {
- includeDirs := nativeIncludeDirPathsFor(lib, systemInclude, info.hasArchSpecificFlags)
- 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, "cc_prebuilt_library_shared")
-
- if !info.hasArchSpecificFlags {
- addExportedDirsForNativeLibs(info.archVariants[0], pbm, false /*systemInclude*/)
- addExportedDirsForNativeLibs(info.archVariants[0], pbm, true /*systemInclude*/)
- }
-
- archProperties := pbm.AddPropertySet("arch")
- for _, av := range info.archVariants {
- archTypeProperties := archProperties.AddPropertySet(av.archType)
- archTypeProperties.AddProperty("srcs", []string{nativeStubFilePathFor(av)})
- if info.hasArchSpecificFlags {
- // 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"
- nativeStubFileSuffix = ".so"
-)
-
-// path to the stub file of a native shared library. Relative to <sdk_root>/<api_dir>
-func nativeStubFilePathFor(lib archSpecificNativeLibInfo) string {
- return filepath.Join(lib.archType,
- nativeStubDir, lib.name+nativeStubFileSuffix)
-}
-
-// paths to the include dirs of a native shared library. Relative to <sdk_root>/<api_dir>
-func nativeIncludeDirPathsFor(lib archSpecificNativeLibInfo, systemInclude bool, archSpecific bool) []string {
- var result []string
- var includeDirs []android.Path
- if !systemInclude {
- includeDirs = lib.exportedIncludeDirs
- } else {
- includeDirs = lib.exportedSystemIncludeDirs
- }
- for _, dir := range includeDirs {
- var path string
- if _, gen := dir.(android.WritablePath); gen {
- path = filepath.Join(nativeGeneratedIncludeDir, lib.name)
- } else {
- path = filepath.Join(nativeIncludeDir, dir.String())
- }
- if archSpecific {
- path = filepath.Join(lib.archType, path)
- }
- result = append(result, path)
- }
- return result
-}
-
-// archSpecificNativeLibInfo represents an arch-specific variant of a native lib
-type archSpecificNativeLibInfo struct {
- name string
- archType string
- exportedIncludeDirs android.Paths
- exportedSystemIncludeDirs android.Paths
- exportedFlags []string
- exportedGeneratedHeaders android.Paths
- outputFile android.Path
-}
-
-func (lib *archSpecificNativeLibInfo) signature() string {
- return fmt.Sprintf("%v %v %v %v",
- lib.name,
- lib.exportedIncludeDirs.Strings(),
- lib.exportedSystemIncludeDirs.Strings(),
- lib.exportedFlags)
-}
-
-// nativeLibInfo represents a collection of arch-specific modules having the same name
-type nativeLibInfo struct {
- name string
- archVariants []archSpecificNativeLibInfo
- // hasArchSpecificFlags is set to true if modules for each architecture all have the same
- // include dirs, flags, etc, in which case only those of the first arch is selected.
- hasArchSpecificFlags bool
-}
-
-// Organize the variants by architecture.
-func organizeVariants(member android.SdkMember) *nativeLibInfo {
- info := &nativeLibInfo{name: member.Name()}
-
- for _, variant := range member.Variants() {
- ccModule := variant.(*Module)
-
- info.archVariants = append(info.archVariants, archSpecificNativeLibInfo{
- name: ccModule.BaseModuleName(),
- archType: ccModule.Target().Arch.ArchType.String(),
- exportedIncludeDirs: ccModule.ExportedIncludeDirs(),
- exportedSystemIncludeDirs: ccModule.ExportedSystemIncludeDirs(),
- exportedFlags: ccModule.ExportedFlags(),
- exportedGeneratedHeaders: ccModule.ExportedGeneratedHeaders(),
- outputFile: ccModule.OutputFile().Path(),
- })
- }
-
- // Determine if include dirs and flags for each variant are different across arch-specific
- // variants or not. And set hasArchSpecificFlags accordingly
- // by default, include paths and flags are assumed to be the same across arches
- info.hasArchSpecificFlags = false
- oldSignature := ""
- for _, av := range info.archVariants {
- newSignature := av.signature()
- if oldSignature == "" {
- oldSignature = newSignature
- }
- if oldSignature != newSignature {
- info.hasArchSpecificFlags = true
- break
- }
- }
-
- return info
-}
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/ndk_library.go b/cc/ndk_library.go
index c47cbf0..00338b9 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -228,7 +228,7 @@
}
}
-func ndkApiMutator(mctx android.BottomUpMutatorContext) {
+func NdkApiMutator(mctx android.BottomUpMutatorContext) {
if m, ok := mctx.Module().(*Module); ok {
if m.Enabled() {
if compiler, ok := m.compiler.(*stubDecorator); ok {
@@ -261,6 +261,7 @@
// We're knowingly doing some otherwise unsightly things with builtin
// functions here. We're just generating stub libraries, so ignore it.
"-Wno-incompatible-library-redeclaration",
+ "-Wno-incomplete-setjmp-declaration",
"-Wno-builtin-requires-header",
"-Wno-invalid-noreturn",
"-Wall",
@@ -389,7 +390,7 @@
// ndk_library creates a stub library that exposes dummy implementation
// of functions and variables for use at build time only.
-func ndkLibraryFactory() android.Module {
+func NdkLibraryFactory() android.Module {
module := newStubLibrary()
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
module.ModuleBase.EnableNativeBridgeSupportByDefault()
diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go
index 4356732..e849aee 100644
--- a/cc/ndk_prebuilt.go
+++ b/cc/ndk_prebuilt.go
@@ -23,8 +23,8 @@
)
func init() {
- android.RegisterModuleType("ndk_prebuilt_object", ndkPrebuiltObjectFactory)
- android.RegisterModuleType("ndk_prebuilt_static_stl", ndkPrebuiltStaticStlFactory)
+ android.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
+ android.RegisterModuleType("ndk_prebuilt_static_stl", NdkPrebuiltStaticStlFactory)
android.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
}
@@ -68,7 +68,7 @@
// operations. Soong's module name format is ndk_<NAME>.o.<sdk_version> where
// the object is located under
// ./prebuilts/ndk/current/platforms/android-<sdk_version>/arch-$(HOST_ARCH)/usr/lib/<NAME>.o.
-func ndkPrebuiltObjectFactory() android.Module {
+func NdkPrebuiltObjectFactory() android.Module {
module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
module.ModuleBase.EnableNativeBridgeSupportByDefault()
module.linker = &ndkPrebuiltObjectLinker{
@@ -126,7 +126,7 @@
// library (stl) library for linking operation. The soong's module name format
// is ndk_<NAME>.a where the library is located under
// ./prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs/$(HOST_ARCH)/<NAME>.a.
-func ndkPrebuiltStaticStlFactory() android.Module {
+func NdkPrebuiltStaticStlFactory() android.Module {
module, library := NewLibrary(android.DeviceSupported)
library.BuildOnlyStatic()
module.compiler = nil
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index f6de4ef..56fd54b 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -58,7 +58,7 @@
func init() {
android.RegisterModuleType("ndk_headers", ndkHeadersFactory)
- android.RegisterModuleType("ndk_library", ndkLibraryFactory)
+ android.RegisterModuleType("ndk_library", NdkLibraryFactory)
android.RegisterModuleType("versioned_ndk_headers", versionedNdkHeadersFactory)
android.RegisterModuleType("preprocessed_ndk_headers", preprocessedNdkHeadersFactory)
android.RegisterSingletonType("ndk", NdkSingleton)
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 32676d6..f20616f 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -130,16 +130,8 @@
p.properties.Srcs = nil
}
-// cc_prebuilt_library_shared installs a precompiled shared library that are
-// listed in the srcs property in the device's directory.
-func PrebuiltSharedLibraryFactory() android.Module {
- module, _ := NewPrebuiltSharedLibrary(android.HostAndDeviceSupported)
- return module.Init()
-}
-
-func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
+func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
module, library := NewLibrary(hod)
- library.BuildOnlyShared()
module.compiler = nil
prebuilt := &prebuiltLibraryLinker{
@@ -151,9 +143,24 @@
android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
- // Prebuilt libraries can be included in APEXes
- android.InitApexModule(module)
+ // Prebuilt libraries can be used in SDKs.
android.InitSdkAwareModule(module)
+ return module, library
+}
+
+// cc_prebuilt_library_shared installs a precompiled shared library that are
+// listed in the srcs property in the device's directory.
+func PrebuiltSharedLibraryFactory() android.Module {
+ module, _ := NewPrebuiltSharedLibrary(android.HostAndDeviceSupported)
+ return module.Init()
+}
+
+func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
+ module, library := NewPrebuiltLibrary(hod)
+ library.BuildOnlyShared()
+
+ // Prebuilt shared libraries can be included in APEXes
+ android.InitApexModule(module)
return module, library
}
@@ -166,19 +173,8 @@
}
func NewPrebuiltStaticLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
- module, library := NewLibrary(hod)
+ module, library := NewPrebuiltLibrary(hod)
library.BuildOnlyStatic()
- module.compiler = nil
-
- prebuilt := &prebuiltLibraryLinker{
- libraryDecorator: library,
- }
- module.linker = prebuilt
-
- module.AddProperties(&prebuilt.properties)
-
- android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
- android.InitSdkAwareModule(module)
return module, library
}
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/cc/testing.go b/cc/testing.go
index 18cc83f..417ea4a 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -265,6 +265,7 @@
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
+ ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
ctx.RegisterModuleType("cc_object", ObjectFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
diff --git a/cc/vndk.go b/cc/vndk.go
index 5aeb2e6..f531af3 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -460,8 +460,8 @@
ctx.InstallFile(installPath, filename, txt.outputFile)
}
-func (txt *vndkLibrariesTxt) AndroidMkEntries() android.AndroidMkEntries {
- return android.AndroidMkEntries{
+func (txt *vndkLibrariesTxt) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "ETC",
OutputFile: android.OptionalPathForPath(txt.outputFile),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
@@ -469,7 +469,7 @@
entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base())
},
},
- }
+ }}
}
func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath {
diff --git a/cc/xom.go b/cc/xom.go
index e1cac53..ce817aa 100644
--- a/cc/xom.go
+++ b/cc/xom.go
@@ -68,7 +68,10 @@
if !disableXom || (xom.Properties.Xom != nil && *xom.Properties.Xom) {
// XOM is only supported on AArch64 when using lld.
if ctx.Arch().ArchType == android.Arm64 && ctx.useClangLld(ctx) {
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-execute-only")
+ flags.Local.LdFlags = append(flags.Local.LdFlags,
+ "-Wl,--execute-only",
+ "-Wl,-z,separate-code",
+ )
}
}
diff --git a/java/androidmk.go b/java/androidmk.go
index c973739..f4e3c34 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -17,101 +17,103 @@
import (
"fmt"
"io"
- "strings"
"android/soong/android"
)
-// TODO(jungjw): We'll probably want AndroidMkEntriesProvider.AndroidMkEntries to return multiple
-// entries so that this can be more error-proof.
-func (library *Library) AndroidMkHostDex(w io.Writer, name string, entries *android.AndroidMkEntries) {
- if Bool(library.deviceProperties.Hostdex) && !library.Host() {
- fmt.Fprintln(w, "include $(CLEAR_VARS)")
- fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
- fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
- fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
- if library.dexJarFile != nil {
- fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.dexJarFile.String())
- } else {
- fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.implementationAndResourcesJar.String())
- }
- if library.dexJarFile != nil {
- fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
- }
- fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
- fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
- if len(entries.Required) > 0 {
- fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(entries.Required, " "))
- }
- if len(entries.Host_required) > 0 {
- fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", strings.Join(entries.Host_required, " "))
- }
- if len(entries.Target_required) > 0 {
- fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", strings.Join(entries.Target_required, " "))
- }
- if r := library.deviceProperties.Target.Hostdex.Required; len(r) > 0 {
- fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(r, " "))
- }
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", library.Stem()+"-hostdex")
- fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
+func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
+ hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
+ if !library.IsForPlatform() {
+ // If the platform variant is available, don't emit hostdex modules from the APEX variants
+ hostDexNeeded = false
}
+
+ if hostDexNeeded {
+ var output android.Path
+ if library.dexJarFile != nil {
+ output = library.dexJarFile
+ } else {
+ output = library.implementationAndResourcesJar
+ }
+ return android.AndroidMkEntries{
+ Class: "JAVA_LIBRARIES",
+ SubName: "-hostdex",
+ OutputFile: android.OptionalPathForPath(output),
+ Required: library.deviceProperties.Target.Hostdex.Required,
+ Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
+ entries.SetBool("LOCAL_IS_HOST_MODULE", true)
+ entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
+ if library.dexJarFile != nil {
+ entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
+ }
+ entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
+ entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
+ entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
+ },
+ },
+ }
+ }
+ return android.AndroidMkEntries{Disabled: true}
}
-func (library *Library) AndroidMkEntries() android.AndroidMkEntries {
- if !library.IsForPlatform() {
- return android.AndroidMkEntries{
- Disabled: true,
+func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
+ var entriesList []android.AndroidMkEntries
+
+ mainEntries := android.AndroidMkEntries{Disabled: true}
+ // For a java library built for an APEX, we don't need Make module
+ if library.IsForPlatform() {
+ mainEntries = android.AndroidMkEntries{
+ Class: "JAVA_LIBRARIES",
+ OutputFile: android.OptionalPathForPath(library.outputFile),
+ Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(entries *android.AndroidMkEntries) {
+ if len(library.logtagsSrcs) > 0 {
+ var logtags []string
+ for _, l := range library.logtagsSrcs {
+ logtags = append(logtags, l.Rel())
+ }
+ entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
+ }
+
+ if library.installFile == nil {
+ entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
+ }
+ if library.dexJarFile != nil {
+ entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
+ }
+ if len(library.dexpreopter.builtInstalled) > 0 {
+ entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
+ }
+ entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion())
+ entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
+ entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
+
+ if library.jacocoReportClassesFile != nil {
+ entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
+ }
+
+ entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
+
+ if len(library.additionalCheckedModules) != 0 {
+ entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
+ }
+
+ if library.proguardDictionary != nil {
+ entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
+ }
+ entries.SetString("LOCAL_MODULE_STEM", library.Stem())
+ },
+ },
}
}
- return android.AndroidMkEntries{
- Class: "JAVA_LIBRARIES",
- OutputFile: android.OptionalPathForPath(library.outputFile),
- Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
- ExtraEntries: []android.AndroidMkExtraEntriesFunc{
- func(entries *android.AndroidMkEntries) {
- if len(library.logtagsSrcs) > 0 {
- var logtags []string
- for _, l := range library.logtagsSrcs {
- logtags = append(logtags, l.Rel())
- }
- entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
- }
- if library.installFile == nil {
- entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
- }
- if library.dexJarFile != nil {
- entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
- }
- if len(library.dexpreopter.builtInstalled) > 0 {
- entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
- }
- entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion())
- entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
- entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
+ hostDexEntries := library.AndroidMkEntriesHostDex()
- if library.jacocoReportClassesFile != nil {
- entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
- }
-
- entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
-
- if len(library.additionalCheckedModules) != 0 {
- entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
- }
-
- if library.proguardDictionary != nil {
- entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
- }
- entries.SetString("LOCAL_MODULE_STEM", library.Stem())
- },
- },
- ExtraFooters: []android.AndroidMkExtraFootersFunc{
- func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
- library.AndroidMkHostDex(w, name, entries)
- },
- },
- }
+ entriesList = append(entriesList, mainEntries, hostDexEntries)
+ return entriesList
}
// Called for modules that are a component of a test suite.
@@ -124,8 +126,9 @@
}
}
-func (j *Test) AndroidMkEntries() android.AndroidMkEntries {
- entries := j.Library.AndroidMkEntries()
+func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
+ entriesList := j.Library.AndroidMkEntries()
+ entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, j.testProperties.Test_suites)
if j.testConfig != nil {
@@ -134,25 +137,26 @@
androidMkWriteTestData(j.data, entries)
})
- return entries
+ return entriesList
}
-func (j *TestHelperLibrary) AndroidMkEntries() android.AndroidMkEntries {
- entries := j.Library.AndroidMkEntries()
+func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
+ entriesList := j.Library.AndroidMkEntries()
+ entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
})
- return entries
+ return entriesList
}
-func (prebuilt *Import) AndroidMkEntries() android.AndroidMkEntries {
+func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() {
- return android.AndroidMkEntries{
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true,
- }
+ }}
}
- return android.AndroidMkEntries{
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
@@ -165,16 +169,16 @@
entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
},
},
- }
+ }}
}
-func (prebuilt *DexImport) AndroidMkEntries() android.AndroidMkEntries {
+func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
if !prebuilt.IsForPlatform() {
- return android.AndroidMkEntries{
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true,
- }
+ }}
}
- return android.AndroidMkEntries{
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
@@ -193,11 +197,11 @@
entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
},
},
- }
+ }}
}
-func (prebuilt *AARImport) AndroidMkEntries() android.AndroidMkEntries {
- return android.AndroidMkEntries{
+func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
@@ -213,13 +217,13 @@
entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion())
},
},
- }
+ }}
}
-func (binary *Binary) AndroidMkEntries() android.AndroidMkEntries {
+func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
if !binary.isWrapperVariant {
- return android.AndroidMkEntries{
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(binary.outputFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
@@ -240,9 +244,9 @@
fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
},
},
- }
+ }}
} else {
- return android.AndroidMkEntries{
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "EXECUTABLES",
OutputFile: android.OptionalPathForPath(binary.wrapperFile),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
@@ -257,17 +261,17 @@
fmt.Fprintln(w, "jar_installed_module :=")
},
},
- }
+ }}
}
}
-func (app *AndroidApp) AndroidMkEntries() android.AndroidMkEntries {
+func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
if !app.IsForPlatform() {
- return android.AndroidMkEntries{
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true,
- }
+ }}
}
- return android.AndroidMkEntries{
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "APPS",
OutputFile: android.OptionalPathForPath(app.outputFile),
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
@@ -359,7 +363,7 @@
}
},
},
- }
+ }}
}
func (a *AndroidApp) getOverriddenPackages() []string {
@@ -373,8 +377,9 @@
return overridden
}
-func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries {
- entries := a.AndroidApp.AndroidMkEntries()
+func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
+ entriesList := a.AndroidApp.AndroidMkEntries()
+ entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, a.testProperties.Test_suites)
if a.testConfig != nil {
@@ -383,20 +388,22 @@
androidMkWriteTestData(a.data, entries)
})
- return entries
+ return entriesList
}
-func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries {
- entries := a.AndroidApp.AndroidMkEntries()
+func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
+ entriesList := a.AndroidApp.AndroidMkEntries()
+ entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
})
- return entries
+ return entriesList
}
-func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries {
- entries := a.Library.AndroidMkEntries()
+func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
+ entriesList := a.Library.AndroidMkEntries()
+ entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
if a.aarFile != nil {
@@ -417,11 +424,11 @@
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
})
- return entries
+ return entriesList
}
-func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries {
- return android.AndroidMkEntries{
+func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
@@ -435,11 +442,11 @@
}
},
},
- }
+ }}
}
-func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries {
- return android.AndroidMkEntries{
+func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
@@ -520,11 +527,11 @@
}
},
},
- }
+ }}
}
-func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries {
- return android.AndroidMkEntries{
+func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
@@ -636,11 +643,11 @@
}
},
},
- }
+ }}
}
-func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
- return android.AndroidMkEntries{
+func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "APPS",
OutputFile: android.OptionalPathForPath(a.outputFile),
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
@@ -659,16 +666,17 @@
entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
},
},
- }
+ }}
}
-func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries {
- entries := a.AndroidAppImport.AndroidMkEntries()
+func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
+ entriesList := a.AndroidAppImport.AndroidMkEntries()
+ entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, a.testProperties.Test_suites)
androidMkWriteTestData(a.data, entries)
})
- return entries
+ return entriesList
}
func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
diff --git a/java/androidmk_test.go b/java/androidmk_test.go
index 438b66a..acc6bf0 100644
--- a/java/androidmk_test.go
+++ b/java/androidmk_test.go
@@ -31,7 +31,7 @@
`)
mod := ctx.ModuleForTests("foo", "android_common").Module()
- entries := android.AndroidMkEntriesForTest(t, config, "", mod)
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
expected := []string{"libfoo"}
actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"]
@@ -50,17 +50,23 @@
`)
mod := ctx.ModuleForTests("foo", "android_common").Module()
- entries := android.AndroidMkEntriesForTest(t, config, "", mod)
+ entriesList := android.AndroidMkEntriesForTest(t, config, "", mod)
+ if len(entriesList) != 2 {
+ t.Errorf("two entries are expected, but got %d", len(entriesList))
+ }
+ mainEntries := &entriesList[0]
expected := []string{"foo"}
- actual := entries.EntryMap["LOCAL_MODULE"]
+ actual := mainEntries.EntryMap["LOCAL_MODULE"]
if !reflect.DeepEqual(expected, actual) {
t.Errorf("Unexpected module name - expected: %q, actual: %q", expected, actual)
}
- footerLines := entries.FooterLinesForTests()
- if !android.InList("LOCAL_MODULE := foo-hostdex", footerLines) {
- t.Errorf("foo-hostdex is not found in the footers: %q", footerLines)
+ subEntries := &entriesList[1]
+ expected = []string{"foo-hostdex"}
+ actual = subEntries.EntryMap["LOCAL_MODULE"]
+ if !reflect.DeepEqual(expected, actual) {
+ t.Errorf("Unexpected module name - expected: %q, actual: %q", expected, actual)
}
}
@@ -75,17 +81,23 @@
`)
mod := ctx.ModuleForTests("foo", "android_common").Module()
- entries := android.AndroidMkEntriesForTest(t, config, "", mod)
+ entriesList := android.AndroidMkEntriesForTest(t, config, "", mod)
+ if len(entriesList) != 2 {
+ t.Errorf("two entries are expected, but got %d", len(entriesList))
+ }
+ mainEntries := &entriesList[0]
expected := []string{"libfoo"}
- actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"]
+ actual := mainEntries.EntryMap["LOCAL_REQUIRED_MODULES"]
if !reflect.DeepEqual(expected, actual) {
t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
}
- footerLines := entries.FooterLinesForTests()
- if !android.InList("LOCAL_REQUIRED_MODULES := libfoo", footerLines) {
- t.Errorf("Wrong or missing required line for foo-hostdex in the footers: %q", footerLines)
+ subEntries := &entriesList[1]
+ expected = []string{"libfoo"}
+ actual = subEntries.EntryMap["LOCAL_REQUIRED_MODULES"]
+ if !reflect.DeepEqual(expected, actual) {
+ t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
}
}
@@ -104,14 +116,20 @@
`)
mod := ctx.ModuleForTests("foo", "android_common").Module()
- entries := android.AndroidMkEntriesForTest(t, config, "", mod)
+ entriesList := android.AndroidMkEntriesForTest(t, config, "", mod)
+ if len(entriesList) != 2 {
+ t.Errorf("two entries are expected, but got %d", len(entriesList))
+ }
- if r, ok := entries.EntryMap["LOCAL_REQUIRED_MODULES"]; ok {
+ mainEntries := &entriesList[0]
+ if r, ok := mainEntries.EntryMap["LOCAL_REQUIRED_MODULES"]; ok {
t.Errorf("Unexpected required modules: %q", r)
}
- footerLines := entries.FooterLinesForTests()
- if !android.InList("LOCAL_REQUIRED_MODULES += libfoo", footerLines) {
- t.Errorf("Wrong or missing required line for foo-hostdex in the footers: %q", footerLines)
+ subEntries := &entriesList[1]
+ expected := []string{"libfoo"}
+ actual := subEntries.EntryMap["LOCAL_REQUIRED_MODULES"]
+ if !reflect.DeepEqual(expected, actual) {
+ t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual)
}
}
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/app_test.go b/java/app_test.go
index c7ed49b..1800bb7 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -1529,7 +1529,7 @@
a := variant.Module().(*AndroidAppImport)
expectedValues := []string{test.expected}
actualValues := android.AndroidMkEntriesForTest(
- t, config, "", a).EntryMap["LOCAL_INSTALLED_MODULE_STEM"]
+ t, config, "", a)[0].EntryMap["LOCAL_INSTALLED_MODULE_STEM"]
if !reflect.DeepEqual(actualValues, expectedValues) {
t.Errorf("Incorrect LOCAL_INSTALLED_MODULE_STEM value '%s', expected '%s'",
actualValues, expectedValues)
@@ -1615,7 +1615,7 @@
test := ctx.ModuleForTests("foo", "android_common").Module().(*AndroidTestImport)
// Check android mks.
- entries := android.AndroidMkEntriesForTest(t, config, "", test)
+ entries := android.AndroidMkEntriesForTest(t, config, "", test)[0]
expected := []string{"tests"}
actual := entries.EntryMap["LOCAL_MODULE_TAGS"]
if !reflect.DeepEqual(expected, actual) {
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 88e3bc2..1d363c9 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -178,6 +178,12 @@
return false
}
+func skipDexpreoptArtBootJars(ctx android.BuilderContext) bool {
+ // with EMMA_INSTRUMENT_FRAMEWORK=true ART boot class path libraries have dependencies on framework,
+ // therefore dexpreopt ART libraries cannot be dexpreopted in isolation => no ART boot image
+ return ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK")
+}
+
type dexpreoptBootJars struct {
defaultBootImage *bootImage
otherImages []*bootImage
@@ -187,7 +193,7 @@
// Accessor function for the apex package. Returns nil if dexpreopt is disabled.
func DexpreoptedArtApexJars(ctx android.BuilderContext) map[android.ArchType]android.OutputPaths {
- if skipDexpreoptBootJars(ctx) {
+ if skipDexpreoptBootJars(ctx) || skipDexpreoptArtBootJars(ctx) {
return nil
}
return artBootImageConfig(ctx).imagesDeps
@@ -216,8 +222,10 @@
// Always create the default boot image first, to get a unique profile rule for all images.
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
- // Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
- d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx)))
+ if !skipDexpreoptArtBootJars(ctx) {
+ // Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
+ d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx)))
+ }
if global.GenerateApexImage {
// Create boot images for the JIT-zygote experiment.
d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx)))
diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go
index 87d5e30..29a5abe 100644
--- a/java/dexpreopt_bootjars_test.go
+++ b/java/dexpreopt_bootjars_test.go
@@ -48,7 +48,7 @@
pathCtx := android.PathContextForTesting(config, nil)
dexpreoptConfig := dexpreopt.GlobalConfigForTests(pathCtx)
- dexpreoptConfig.BootJars = []string{"foo", "bar", "baz"}
+ dexpreoptConfig.ArtApexJars = []string{"foo", "bar", "baz"}
setDexpreoptTestGlobalConfig(config, dexpreoptConfig)
ctx := testContext(bp, nil)
@@ -59,10 +59,9 @@
dexpreoptBootJars := ctx.SingletonForTests("dex_bootjars")
- bootArt := dexpreoptBootJars.Output("boot-foo.art")
+ bootArt := dexpreoptBootJars.Output("boot.art")
expectedInputs := []string{
- "dex_artjars/apex/com.android.art/javalib/arm64/boot.art",
"dex_bootjars_input/foo.jar",
"dex_bootjars_input/bar.jar",
"dex_bootjars_input/baz.jar",
@@ -83,19 +82,19 @@
expectedOutputs := []string{
"dex_bootjars/system/framework/arm64/boot.invocation",
- "dex_bootjars/system/framework/arm64/boot-foo.art",
+ "dex_bootjars/system/framework/arm64/boot.art",
"dex_bootjars/system/framework/arm64/boot-bar.art",
"dex_bootjars/system/framework/arm64/boot-baz.art",
- "dex_bootjars/system/framework/arm64/boot-foo.oat",
+ "dex_bootjars/system/framework/arm64/boot.oat",
"dex_bootjars/system/framework/arm64/boot-bar.oat",
"dex_bootjars/system/framework/arm64/boot-baz.oat",
- "dex_bootjars/system/framework/arm64/boot-foo.vdex",
+ "dex_bootjars/system/framework/arm64/boot.vdex",
"dex_bootjars/system/framework/arm64/boot-bar.vdex",
"dex_bootjars/system/framework/arm64/boot-baz.vdex",
- "dex_bootjars_unstripped/system/framework/arm64/boot-foo.oat",
+ "dex_bootjars_unstripped/system/framework/arm64/boot.oat",
"dex_bootjars_unstripped/system/framework/arm64/boot-bar.oat",
"dex_bootjars_unstripped/system/framework/arm64/boot-baz.oat",
}
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index fd1cfd4..91e0dfb 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -135,10 +135,6 @@
deviceDir := android.PathForOutput(ctx, ctx.Config().DeviceName())
artModules := global.ArtApexJars
- // In coverage builds ART boot class path jars are instrumented and have additional dependencies.
- if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
- artModules = append(artModules, "jacocoagent")
- }
frameworkModules := android.RemoveListFromList(global.BootJars,
concat(artModules, getJarsFromApexJarPairs(global.UpdatableBootJars)))
@@ -166,15 +162,15 @@
}
// Framework config for the boot image extension.
- // It includes framework libraries and depends on the ART config.
+ // It includes both the Core libraries and framework.
frameworkCfg := bootImageConfig{
- extension: true,
+ extension: false,
name: frameworkBootImageName,
stem: "boot",
installSubdir: frameworkSubdir,
- modules: frameworkModules,
- dexLocations: frameworkLocations,
- dexLocationsDeps: append(artLocations, frameworkLocations...),
+ modules: concat(artModules, frameworkModules),
+ dexLocations: concat(artLocations, frameworkLocations),
+ dexLocationsDeps: concat(artLocations, frameworkLocations),
}
// Apex config for the boot image used in the JIT-zygote experiment.
@@ -230,10 +226,6 @@
c.zip = c.dir.Join(ctx, c.name+".zip")
}
- // specific to the framework config
- frameworkCfg.dexPathsDeps = append(artCfg.dexPathsDeps, frameworkCfg.dexPathsDeps...)
- frameworkCfg.imageLocations = append(artCfg.imageLocations, frameworkCfg.imageLocations...)
-
return configs
}).(map[string]*bootImageConfig)
}
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/java/platform_compat_config.go b/java/platform_compat_config.go
index 23ba2b0..7801634 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -71,8 +71,8 @@
}
-func (p *platformCompatConfig) AndroidMkEntries() android.AndroidMkEntries {
- return android.AndroidMkEntries{
+func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "ETC",
OutputFile: android.OptionalPathForPath(p.configFile),
Include: "$(BUILD_PREBUILT)",
@@ -82,7 +82,7 @@
entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.configFile.Base())
},
},
- }
+ }}
}
func platformCompatConfigFactory() android.Module {
diff --git a/java/robolectric.go b/java/robolectric.go
index b7646eb..3195615 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -158,8 +158,9 @@
TransformResourcesToJar(ctx, outputFile, srcJarArgs, srcJarDeps)
}
-func (r *robolectricTest) AndroidMkEntries() android.AndroidMkEntries {
- entries := r.Library.AndroidMkEntries()
+func (r *robolectricTest) AndroidMkEntries() []android.AndroidMkEntries {
+ entriesList := r.Library.AndroidMkEntries()
+ entries := &entriesList[0]
entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
@@ -185,7 +186,7 @@
},
}
- return entries
+ return entriesList
}
func (r *robolectricTest) writeTestRunner(w io.Writer, module, name string, tests []string) {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index a7956fa..e204659 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -194,13 +194,13 @@
})
}
-func (module *SdkLibrary) AndroidMkEntries() android.AndroidMkEntries {
- entries := module.Library.AndroidMkEntries()
+func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
+ entriesList := module.Library.AndroidMkEntries()
+ entries := &entriesList[0]
entries.Required = append(entries.Required, module.xmlFileName())
entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
- module.Library.AndroidMkHostDex(w, name, entries)
if !Bool(module.sdkLibraryProperties.No_dist) {
// Create a phony module that installs the impl library, for the case when this lib is
// in PRODUCT_PACKAGES.
@@ -252,7 +252,7 @@
}
},
}
- return entries
+ return entriesList
}
// Module name of the stubs library
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/arm64_device.go b/rust/config/arm64_device.go
index 0264052..60796d8 100644
--- a/rust/config/arm64_device.go
+++ b/rust/config/arm64_device.go
@@ -27,7 +27,8 @@
"-Wl,--icf=safe",
"-Wl,-z,max-page-size=4096",
- "-Wl,-execute-only",
+ "-Wl,--execute-only",
+ "-Wl,-z,separate-code",
}
Arm64ArchVariantRustFlags = map[string][]string{
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 7620ec1..08751e4 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -24,10 +24,11 @@
t.Helper()
fs := map[string][]byte{
- "Test.cpp": nil,
- "include/Test.h": nil,
- "libfoo.so": nil,
- "aidl/foo/bar/Test.aidl": nil,
+ "Test.cpp": nil,
+ "include/Test.h": nil,
+ "arm64/include/Arm64Test.h": nil,
+ "libfoo.so": nil,
+ "aidl/foo/bar/Test.aidl": nil,
}
return testSdkWithFs(t, bp, fs)
}
@@ -49,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()
@@ -131,18 +132,134 @@
}
`)
- 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())
ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
}
-func TestSnapshotWithCcShared(t *testing.T) {
+func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_shared_libs: ["mynativelib1", "mynativelib2"],
+ }
+
+ cc_library_shared {
+ name: "mynativelib1",
+ srcs: [
+ "Test.cpp",
+ ],
+ export_include_dirs: ["include"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library_shared {
+ name: "mynativelib2",
+ srcs: [
+ "Test.cpp",
+ ],
+ export_include_dirs: ["include"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "android_common", "",
+ checkAllCopyRules(`
+include/Test.h -> include/include/Test.h
+.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
+`),
+ )
+}
+
+// Verify that when the shared library has some common and some arch specific properties that the generated
+// snapshot is optimized properly.
+func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_shared_libs: ["mynativelib"],
+ }
+
+ cc_library_shared {
+ name: "mynativelib",
+ srcs: [
+ "Test.cpp",
+ "aidl/foo/bar/Test.aidl",
+ ],
+ export_include_dirs: ["include"],
+ arch: {
+ arm64: {
+ export_system_include_dirs: ["arm64/include"],
+ },
+ },
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "android_common", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_shared {
+ name: "mysdk_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ export_include_dirs: ["include/include"],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/mynativelib.so"],
+ export_system_include_dirs: ["arm64/include/arm64/include"],
+ },
+ arm: {
+ srcs: ["arm/lib/mynativelib.so"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+cc_prebuilt_library_shared {
+ name: "mynativelib",
+ prefer: false,
+ export_include_dirs: ["include/include"],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/mynativelib.so"],
+ export_system_include_dirs: ["arm64/include/arm64/include"],
+ },
+ arm: {
+ srcs: ["arm/lib/mynativelib.so"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ native_shared_libs: ["mysdk_mynativelib@current"],
+}
+`),
+ checkAllCopyRules(`
+include/Test.h -> include/include/Test.h
+.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_shared/mynativelib.so -> arm/lib/mynativelib.so`),
+ )
+}
+
+func TestSnapshotWithCcSharedLibrary(t *testing.T) {
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -171,20 +288,15 @@
cc_prebuilt_library_shared {
name: "mysdk_mynativelib@current",
sdk_member_name: "mynativelib",
+ export_include_dirs: ["include/include"],
arch: {
arm64: {
srcs: ["arm64/lib/mynativelib.so"],
- export_include_dirs: [
- "arm64/include/include",
- "arm64/include_gen/mynativelib",
- ],
+ export_include_dirs: ["arm64/include_gen/mynativelib"],
},
arm: {
srcs: ["arm/lib/mynativelib.so"],
- export_include_dirs: [
- "arm/include/include",
- "arm/include_gen/mynativelib",
- ],
+ export_include_dirs: ["arm/include_gen/mynativelib"],
},
},
stl: "none",
@@ -194,20 +306,15 @@
cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
+ export_include_dirs: ["include/include"],
arch: {
arm64: {
srcs: ["arm64/lib/mynativelib.so"],
- export_include_dirs: [
- "arm64/include/include",
- "arm64/include_gen/mynativelib",
- ],
+ export_include_dirs: ["arm64/include_gen/mynativelib"],
},
arm: {
srcs: ["arm/lib/mynativelib.so"],
- export_include_dirs: [
- "arm/include/include",
- "arm/include_gen/mynativelib",
- ],
+ export_include_dirs: ["arm/include_gen/mynativelib"],
},
},
stl: "none",
@@ -220,21 +327,20 @@
}
`),
checkAllCopyRules(`
-.intermediates/mynativelib/android_arm64_armv8-a_core_shared/mynativelib.so -> arm64/lib/mynativelib.so
-include/Test.h -> arm64/include/include/Test.h
-.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
-include/Test.h -> arm/include/include/Test.h
-.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
+include/Test.h -> include/include/Test.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
`),
)
}
-func TestHostSnapshotWithCcShared(t *testing.T) {
+func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
SkipIfNotLinux(t)
@@ -272,20 +378,15 @@
sdk_member_name: "mynativelib",
device_supported: false,
host_supported: true,
+ export_include_dirs: ["include/include"],
arch: {
x86_64: {
srcs: ["x86_64/lib/mynativelib.so"],
- export_include_dirs: [
- "x86_64/include/include",
- "x86_64/include_gen/mynativelib",
- ],
+ export_include_dirs: ["x86_64/include_gen/mynativelib"],
},
x86: {
srcs: ["x86/lib/mynativelib.so"],
- export_include_dirs: [
- "x86/include/include",
- "x86/include_gen/mynativelib",
- ],
+ export_include_dirs: ["x86/include_gen/mynativelib"],
},
},
stl: "none",
@@ -297,20 +398,15 @@
prefer: false,
device_supported: false,
host_supported: true,
+ export_include_dirs: ["include/include"],
arch: {
x86_64: {
srcs: ["x86_64/lib/mynativelib.so"],
- export_include_dirs: [
- "x86_64/include/include",
- "x86_64/include_gen/mynativelib",
- ],
+ export_include_dirs: ["x86_64/include_gen/mynativelib"],
},
x86: {
srcs: ["x86/lib/mynativelib.so"],
- export_include_dirs: [
- "x86/include/include",
- "x86/include_gen/mynativelib",
- ],
+ export_include_dirs: ["x86/include_gen/mynativelib"],
},
},
stl: "none",
@@ -325,16 +421,190 @@
}
`),
checkAllCopyRules(`
+include/Test.h -> include/include/Test.h
.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
-include/Test.h -> x86_64/include/include/Test.h
.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
.intermediates/mynativelib/linux_glibc_x86_64_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> x86/lib/mynativelib.so
-include/Test.h -> x86/include/include/Test.h
.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
.intermediates/mynativelib/linux_glibc_x86_shared/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
`),
)
}
+
+func TestSnapshotWithCcStaticLibrary(t *testing.T) {
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ native_static_libs: ["mynativelib"],
+ }
+
+ cc_library_static {
+ name: "mynativelib",
+ srcs: [
+ "Test.cpp",
+ "aidl/foo/bar/Test.aidl",
+ ],
+ export_include_dirs: ["include"],
+ aidl: {
+ export_aidl_headers: true,
+ },
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "android_common", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_static {
+ name: "mysdk_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ export_include_dirs: ["include/include"],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/mynativelib.a"],
+ export_include_dirs: ["arm64/include_gen/mynativelib"],
+ },
+ arm: {
+ srcs: ["arm/lib/mynativelib.a"],
+ export_include_dirs: ["arm/include_gen/mynativelib"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+cc_prebuilt_library_static {
+ name: "mynativelib",
+ prefer: false,
+ export_include_dirs: ["include/include"],
+ arch: {
+ arm64: {
+ srcs: ["arm64/lib/mynativelib.a"],
+ export_include_dirs: ["arm64/include_gen/mynativelib"],
+ },
+ arm: {
+ srcs: ["arm/lib/mynativelib.a"],
+ export_include_dirs: ["arm/include_gen/mynativelib"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ native_static_libs: ["mysdk_mynativelib@current"],
+}
+`),
+ checkAllCopyRules(`
+include/Test.h -> include/include/Test.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
+`),
+ )
+}
+
+func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
+ // b/145598135 - Generating host snapshots for anything other than linux is not supported.
+ SkipIfNotLinux(t)
+
+ result := testSdkWithCc(t, `
+ sdk {
+ name: "mysdk",
+ device_supported: false,
+ host_supported: true,
+ native_static_libs: ["mynativelib"],
+ }
+
+ cc_library_static {
+ name: "mynativelib",
+ device_supported: false,
+ host_supported: true,
+ srcs: [
+ "Test.cpp",
+ "aidl/foo/bar/Test.aidl",
+ ],
+ export_include_dirs: ["include"],
+ aidl: {
+ export_aidl_headers: true,
+ },
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "linux_glibc_common", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_static {
+ name: "mysdk_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ device_supported: false,
+ host_supported: true,
+ export_include_dirs: ["include/include"],
+ arch: {
+ x86_64: {
+ srcs: ["x86_64/lib/mynativelib.a"],
+ export_include_dirs: ["x86_64/include_gen/mynativelib"],
+ },
+ x86: {
+ srcs: ["x86/lib/mynativelib.a"],
+ export_include_dirs: ["x86/include_gen/mynativelib"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+cc_prebuilt_library_static {
+ name: "mynativelib",
+ prefer: false,
+ device_supported: false,
+ host_supported: true,
+ export_include_dirs: ["include/include"],
+ arch: {
+ x86_64: {
+ srcs: ["x86_64/lib/mynativelib.a"],
+ export_include_dirs: ["x86_64/include_gen/mynativelib"],
+ },
+ x86: {
+ srcs: ["x86/lib/mynativelib.a"],
+ export_include_dirs: ["x86/include_gen/mynativelib"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ device_supported: false,
+ host_supported: true,
+ native_static_libs: ["mysdk_mynativelib@current"],
+}
+`),
+ checkAllCopyRules(`
+include/Test.h -> include/include/Test.h
+.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
+.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> x86/lib/mynativelib.a
+.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/Test.h -> x86/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/linux_glibc_x86_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+`),
+ )
+}
diff --git a/sdk/sdk.go b/sdk/sdk.go
index c7e12b9..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,77 +59,141 @@
}
type sdkProperties struct {
- // 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 native libraries in this SDK
- Native_shared_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.LibrarySdkMemberType,
- },
- // 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) {
@@ -163,12 +225,12 @@
}
}
-func (s *sdk) AndroidMkEntries() android.AndroidMkEntries {
+func (s *sdk) AndroidMkEntries() []android.AndroidMkEntries {
if !s.snapshotFile.Valid() {
- return android.AndroidMkEntries{}
+ return []android.AndroidMkEntries{}
}
- return android.AndroidMkEntries{
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "FAKE",
OutputFile: s.snapshotFile,
DistFile: s.snapshotFile,
@@ -180,7 +242,7 @@
fmt.Fprintln(w, s.Name()+":", s.snapshotFile.String())
},
},
- }
+ }}
}
// RegisterPreDepsMutators registers pre-deps mutators to support modules implementing SdkAware
@@ -220,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/testing.go b/sdk/testing.go
index bd929a4..5082ab4 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -59,6 +59,7 @@
// from cc package
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
+ ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
ctx.RegisterModuleType("cc_object", cc.ObjectFactory)
ctx.RegisterModuleType("cc_prebuilt_library_shared", cc.PrebuiltSharedLibraryFactory)
ctx.RegisterModuleType("cc_prebuilt_library_static", cc.PrebuiltStaticLibraryFactory)
diff --git a/sdk/update.go b/sdk/update.go
index 7fad5c7..d31fa30 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -30,7 +30,7 @@
var (
repackageZip = pctx.AndroidStaticRule("SnapshotRepackageZip",
blueprint.RuleParams{
- Command: `${config.Zip2ZipCmd} -i $in -o $out "**/*:$destdir"`,
+ Command: `${config.Zip2ZipCmd} -i $in -o $out -x META-INF/**/* "**/*:$destdir"`,
CommandDeps: []string{
"${config.Zip2ZipCmd}",
},
@@ -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...)
}
@@ -184,13 +183,14 @@
sdk: s,
version: "current",
snapshotDir: snapshotDir.OutputPath,
+ copies: make(map[string]string),
filesToZip: []android.Path{bp.path},
bpFile: bpFile,
prebuiltModules: make(map[string]*bpModule),
}
s.builderForTests = builder
- for _, member := range collectMembers(ctx) {
+ for _, member := range s.collectMembers(ctx) {
member.memberType.BuildSnapshot(ctx, builder, member)
}
@@ -219,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)
@@ -337,6 +337,11 @@
version string
snapshotDir android.OutputPath
bpFile *bpFile
+
+ // Map from destination to source of each copy - used to eliminate duplicates and
+ // detect conflicts.
+ copies map[string]string
+
filesToZip android.Paths
zipsToMerge android.Paths
@@ -345,13 +350,22 @@
}
func (s *snapshotBuilder) CopyToSnapshot(src android.Path, dest string) {
- path := s.snapshotDir.Join(s.ctx, dest)
- s.ctx.Build(pctx, android.BuildParams{
- Rule: android.Cp,
- Input: src,
- Output: path,
- })
- s.filesToZip = append(s.filesToZip, path)
+ if existing, ok := s.copies[dest]; ok {
+ if existing != src.String() {
+ s.ctx.ModuleErrorf("conflicting copy, %s copied from both %s and %s", dest, existing, src)
+ return
+ }
+ } else {
+ path := s.snapshotDir.Join(s.ctx, dest)
+ s.ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cp,
+ Input: src,
+ Output: path,
+ })
+ s.filesToZip = append(s.filesToZip, path)
+
+ s.copies[dest] = src.String()
+ }
}
func (s *snapshotBuilder) UnzipToSnapshot(zipPath android.Path, destDir string) {
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 909d93c..90ff706 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -75,7 +75,6 @@
var Configuration = map[string]PathConfig{
"bash": Allowed,
- "bc": Allowed,
"dd": Allowed,
"diff": Allowed,
"dlv": Allowed,
@@ -120,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())
}