Merge "Soong: Add synopsis to cc_library_* modules"
diff --git a/android/namespace.go b/android/namespace.go
index dca2b8c..50bdcba 100644
--- a/android/namespace.go
+++ b/android/namespace.go
@@ -355,15 +355,19 @@
var _ blueprint.Namespace = (*Namespace)(nil)
+type namespaceProperties struct {
+ // a list of namespaces that contain modules that will be referenced
+ // by modules in this namespace.
+ Imports []string `android:"path"`
+}
+
type NamespaceModule struct {
ModuleBase
namespace *Namespace
resolver *NameResolver
- properties struct {
- Imports []string
- }
+ properties namespaceProperties
}
func (n *NamespaceModule) GenerateAndroidBuildActions(ctx ModuleContext) {
@@ -376,6 +380,16 @@
return *n.nameProperties.Name
}
+// soong_namespace provides a scope to modules in an Android.bp file to prevent
+// module name conflicts with other defined modules in different Android.bp
+// files. Once soong_namespace has been defined in an Android.bp file, the
+// namespacing is applied to all modules that follow the soong_namespace in
+// the current Android.bp file, as well as modules defined in Android.bp files
+// in subdirectories. An Android.bp file in a subdirectory can define its own
+// soong_namespace which is applied to all its modules and as well as modules
+// defined in subdirectories Android.bp files. Modules in a soong_namespace are
+// visible to Make by listing the namespace path in PRODUCT_SOONG_NAMESPACES
+// make variable in a makefile.
func NamespaceFactory() Module {
module := &NamespaceModule{}
diff --git a/android/override_module.go b/android/override_module.go
index 02db359..119bca1 100644
--- a/android/override_module.go
+++ b/android/override_module.go
@@ -134,10 +134,15 @@
// Overrides a base module with the given OverrideModule.
func (b *OverridableModuleBase) override(ctx BaseModuleContext, o OverrideModule) {
+ // Adds the base module to the overrides property, if exists, of the overriding module. See the
+ // comment on OverridableModuleBase.overridesProperty for details.
+ if b.overridesProperty != nil {
+ *b.overridesProperty = append(*b.overridesProperty, b.Name())
+ }
for _, p := range b.overridableProperties {
for _, op := range o.getOverridingProperties() {
if proptools.TypeEqual(p, op) {
- err := proptools.PrependProperties(p, op, nil)
+ err := proptools.AppendProperties(p, op, nil)
if err != nil {
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
@@ -148,13 +153,6 @@
}
}
}
- // Adds the base module to the overrides property, if exists, of the overriding module. See the
- // comment on OverridableModuleBase.overridesProperty for details.
- if b.overridesProperty != nil {
- *b.overridesProperty = append(*b.overridesProperty, b.Name())
- }
- // The base module name property has to be updated separately for Name() to work as intended.
- b.module.base().nameProperties.Name = proptools.StringPtr(o.Name())
}
// Mutators for override/overridable modules. All the fun happens in these functions. It is critical
diff --git a/android/prebuilt.go b/android/prebuilt.go
index 5bd0e2d..df25a89 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -18,6 +18,7 @@
"fmt"
"github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
)
// This file implements common functionality for handling modules that may exist as prebuilts,
@@ -42,6 +43,7 @@
properties PrebuiltProperties
module Module
srcs *[]string
+ src *string
}
func (p *Prebuilt) Name(name string) string {
@@ -49,19 +51,27 @@
}
func (p *Prebuilt) SingleSourcePath(ctx ModuleContext) Path {
- if len(*p.srcs) == 0 {
- ctx.PropertyErrorf("srcs", "missing prebuilt source file")
- return nil
- }
+ if p.srcs != nil {
+ if len(*p.srcs) == 0 {
+ ctx.PropertyErrorf("srcs", "missing prebuilt source file")
+ return nil
+ }
- if len(*p.srcs) > 1 {
- ctx.PropertyErrorf("srcs", "multiple prebuilt source files")
- return nil
- }
+ if len(*p.srcs) > 1 {
+ ctx.PropertyErrorf("srcs", "multiple prebuilt source files")
+ return nil
+ }
- // Return the singleton source after expanding any filegroup in the
- // sources.
- return PathForModuleSrc(ctx, (*p.srcs)[0])
+ // Return the singleton source after expanding any filegroup in the
+ // sources.
+ return PathForModuleSrc(ctx, (*p.srcs)[0])
+ } else {
+ if proptools.String(p.src) == "" {
+ ctx.PropertyErrorf("src", "missing prebuilt source file")
+ return nil
+ }
+ return PathForModuleSrc(ctx, *p.src)
+ }
}
func InitPrebuiltModule(module PrebuiltInterface, srcs *[]string) {
@@ -70,13 +80,19 @@
p.srcs = srcs
}
+func InitSingleSourcePrebuiltModule(module PrebuiltInterface, src *string) {
+ p := module.Prebuilt()
+ module.AddProperties(&p.properties)
+ p.src = src
+}
+
type PrebuiltInterface interface {
Module
Prebuilt() *Prebuilt
}
func RegisterPrebuiltsPreArchMutators(ctx RegisterMutatorsContext) {
- ctx.BottomUp("prebuilts", prebuiltMutator).Parallel()
+ ctx.BottomUp("prebuilts", PrebuiltMutator).Parallel()
}
func RegisterPrebuiltsPostDepsMutators(ctx RegisterMutatorsContext) {
@@ -84,9 +100,9 @@
ctx.BottomUp("prebuilt_postdeps", PrebuiltPostDepsMutator).Parallel()
}
-// prebuiltMutator ensures that there is always a module with an undecorated name, and marks
+// PrebuiltMutator ensures that there is always a module with an undecorated name, and marks
// prebuilt modules that have both a prebuilt and a source module.
-func prebuiltMutator(ctx BottomUpMutatorContext) {
+func PrebuiltMutator(ctx BottomUpMutatorContext) {
if m, ok := ctx.Module().(PrebuiltInterface); ok && m.Prebuilt() != nil {
p := m.Prebuilt()
name := m.base().BaseModuleName()
@@ -104,7 +120,7 @@
func PrebuiltSelectModuleMutator(ctx TopDownMutatorContext) {
if m, ok := ctx.Module().(PrebuiltInterface); ok && m.Prebuilt() != nil {
p := m.Prebuilt()
- if p.srcs == nil {
+ if p.srcs == nil && p.src == nil {
panic(fmt.Errorf("prebuilt module did not have InitPrebuiltModule called on it"))
}
if !p.properties.SourceExists {
@@ -143,7 +159,11 @@
// usePrebuilt returns true if a prebuilt should be used instead of the source module. The prebuilt
// will be used if it is marked "prefer" or if the source module is disabled.
func (p *Prebuilt) usePrebuilt(ctx TopDownMutatorContext, source Module) bool {
- if len(*p.srcs) == 0 {
+ if p.srcs != nil && len(*p.srcs) == 0 {
+ return false
+ }
+
+ if p.src != nil && *p.src == "" {
return false
}
diff --git a/apex/apex.go b/apex/apex.go
index c1f52a6..685a774 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -149,6 +149,7 @@
android.RegisterModuleType("apex", apexBundleFactory)
android.RegisterModuleType("apex_test", testApexBundleFactory)
android.RegisterModuleType("apex_defaults", defaultsFactory)
+ android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.TopDown("apex_deps", apexDepsMutator)
@@ -1283,3 +1284,71 @@
android.InitDefaultsModule(module)
return module
}
+
+//
+// Prebuilt APEX
+//
+type Prebuilt struct {
+ android.ModuleBase
+ prebuilt android.Prebuilt
+
+ properties PrebuiltProperties
+
+ inputApex android.Path
+ installDir android.OutputPath
+}
+
+type PrebuiltProperties struct {
+ // the path to the prebuilt .apex file to import.
+ Src string `android:"arch_variant"`
+
+ // the name of the apex_key module that contains the matching public key to be installed.
+ Key *string
+}
+
+func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
+ if String(p.properties.Key) == "" {
+ ctx.ModuleErrorf("key is missing")
+ return
+ }
+ ctx.AddDependency(ctx.Module(), keyTag, *p.properties.Key)
+}
+
+func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ // TODO(jungjw): Check the key validity.
+ p.inputApex = p.prebuilt.SingleSourcePath(ctx)
+ p.installDir = android.PathForModuleInstall(ctx, "apex")
+ ctx.InstallFile(p.installDir, ctx.ModuleName()+imageApexSuffix, p.inputApex)
+}
+
+func (p *Prebuilt) Prebuilt() *android.Prebuilt {
+ return &p.prebuilt
+}
+
+func (p *Prebuilt) Name() string {
+ return p.prebuilt.Name(p.ModuleBase.Name())
+}
+
+func (p *Prebuilt) AndroidMk() android.AndroidMkData {
+ return android.AndroidMkData{
+ Class: "ETC",
+ OutputFile: android.OptionalPathForPath(p.inputApex),
+ Include: "$(BUILD_PREBUILT)",
+ Extra: []android.AndroidMkExtraFunc{
+ func(w io.Writer, outputFile android.Path) {
+ fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", p.installDir.RelPathString()))
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", p.BaseModuleName()+imageApexSuffix)
+ fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(p.properties.Key))
+ },
+ },
+ }
+}
+
+// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
+func PrebuiltFactory() android.Module {
+ module := &Prebuilt{}
+ module.AddProperties(&module.properties)
+ android.InitSingleSourcePrebuiltModule(module, &module.properties.Src)
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ return module
+}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 8a2e55a..2d9cca6 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -15,6 +15,8 @@
package apex
import (
+ "bufio"
+ "bytes"
"io/ioutil"
"os"
"strings"
@@ -36,11 +38,14 @@
ctx.RegisterModuleType("apex_test", android.ModuleFactoryAdaptor(testApexBundleFactory))
ctx.RegisterModuleType("apex_key", android.ModuleFactoryAdaptor(apexKeyFactory))
ctx.RegisterModuleType("apex_defaults", android.ModuleFactoryAdaptor(defaultsFactory))
+ ctx.RegisterModuleType("prebuilt_apex", android.ModuleFactoryAdaptor(PrebuiltFactory))
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.TopDown("apex_deps", apexDepsMutator)
ctx.BottomUp("apex", apexMutator)
+ ctx.TopDown("prebuilt_select", android.PrebuiltSelectModuleMutator).Parallel()
+ ctx.BottomUp("prebuilt_postdeps", android.PrebuiltPostDepsMutator).Parallel()
})
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
@@ -54,6 +59,9 @@
ctx.RegisterModuleType("sh_binary", android.ModuleFactoryAdaptor(android.ShBinaryFactory))
ctx.RegisterModuleType("android_app_certificate", android.ModuleFactoryAdaptor(java.AndroidAppCertificateFactory))
ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory))
+ ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) {
+ ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
+ })
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("image", cc.ImageMutator).Parallel()
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
@@ -163,6 +171,7 @@
"custom_notice": nil,
"testkey2.avbpubkey": nil,
"testkey2.pem": nil,
+ "myapex.apex": nil,
})
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
@@ -1229,3 +1238,42 @@
t.Errorf("wrong private key path. expected %q. actual %q", expected_privkey, actual_privkey)
}
}
+
+func TestPrebuilt(t *testing.T) {
+ ctx := testApex(t, `
+ prebuilt_apex {
+ name: "myapex",
+ src: "myapex.apex",
+ key: "myapex.key"
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ product_specific: true,
+ }
+ `)
+
+ prebuilt := ctx.ModuleForTests("myapex", "android_common").Module().(*Prebuilt)
+
+ // Check if the key module is added as a required module.
+ buf := &bytes.Buffer{}
+ prebuilt.AndroidMk().Extra[0](buf, nil)
+ found := false
+ scanner := bufio.NewScanner(bytes.NewReader(buf.Bytes()))
+ expected := "myapex.key"
+ for scanner.Scan() {
+ line := scanner.Text()
+ tok := strings.Split(line, " := ")
+ if tok[0] == "LOCAL_REQUIRED_MODULES" {
+ found = true
+ if tok[1] != "myapex.key" {
+ t.Errorf("Unexpected LOCAL_REQUIRED_MODULES '%s', expected '%s'", tok[1], expected)
+ }
+ }
+ }
+ if !found {
+ t.Errorf("Couldn't find a LOCAL_REQUIRED_MODULES entry")
+ }
+}
diff --git a/apex/key.go b/apex/key.go
index 848e8ce..fbd29bc 100644
--- a/apex/key.go
+++ b/apex/key.go
@@ -93,7 +93,7 @@
pubKeyName := m.public_key_file.Base()[0 : len(m.public_key_file.Base())-len(m.public_key_file.Ext())]
privKeyName := m.private_key_file.Base()[0 : len(m.private_key_file.Base())-len(m.private_key_file.Ext())]
- if pubKeyName != privKeyName {
+ if m.properties.Public_key != nil && m.properties.Private_key != nil && pubKeyName != privKeyName {
ctx.ModuleErrorf("public_key %q (keyname:%q) and private_key %q (keyname:%q) do not have same keyname",
m.public_key_file.String(), pubKeyName, m.private_key_file, privKeyName)
return
diff --git a/cc/compiler.go b/cc/compiler.go
index 0ab1f01..fe46a3c 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -226,7 +226,8 @@
}
if compiler.hasSrcExt(".sysprop") {
- deps.SharedLibs = append(deps.SharedLibs, "libbase")
+ deps.HeaderLibs = append(deps.HeaderLibs, "libbase_headers")
+ deps.SharedLibs = append(deps.SharedLibs, "liblog")
}
if Bool(compiler.Properties.Openmp) {
diff --git a/cc/config/clang.go b/cc/config/clang.go
index 81439f3..347bfab 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -132,13 +132,13 @@
// Warnings from clang-8.0
"-Wno-defaulted-function-deleted",
- }, " "))
- pctx.StaticVariable("ClangExtraCppflags", strings.Join([]string{
// Disable -Winconsistent-missing-override until we can clean up the existing
// codebase for it.
"-Wno-inconsistent-missing-override",
+ }, " "))
+ pctx.StaticVariable("ClangExtraCppflags", strings.Join([]string{
// Enable clang's thread-safety annotations in libcxx.
// Turn off -Wthread-safety-negative, to avoid breaking projects that use -Weverything.
"-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
diff --git a/cc/config/global.go b/cc/config/global.go
index e3fab0c..372ffc4 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -120,8 +120,8 @@
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
- ClangDefaultVersion = "clang-r353983"
- ClangDefaultShortVersion = "9.0.1"
+ ClangDefaultVersion = "clang-r353983b"
+ ClangDefaultShortVersion = "9.0.2"
// Directories with warnings from Android.bp files.
WarningAllowedProjects = []string{
diff --git a/cc/object.go b/cc/object.go
index b9c5742..c9ca07a 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -33,6 +33,9 @@
Properties ObjectLinkerProperties
}
+// cc_object runs the compiler without running the linker. It is rarely
+// necessary, but sometimes used to generate .s files from .c files to use as
+// input to a cc_genrule module.
func ObjectFactory() android.Module {
module := newBaseModule(android.HostAndDeviceSupported, android.MultilibBoth)
module.linker = &objectLinker{
diff --git a/cc/pgo.go b/cc/pgo.go
index 9363916..7334ea2 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -27,8 +27,11 @@
var (
// Add flags to ignore warnings that profiles are old or missing for
- // some functions
- profileUseOtherFlags = []string{"-Wno-backend-plugin"}
+ // some functions, and turn on the experimental new pass manager.
+ profileUseOtherFlags = []string{
+ "-Wno-backend-plugin",
+ "-fexperimental-new-pass-manager",
+ }
globalPgoProfileProjects = []string{
"toolchain/pgo-profiles",
diff --git a/cc/testing.go b/cc/testing.go
index b3b2756..2f41de1 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -70,16 +70,6 @@
}
cc_library {
- name: "libbase",
- no_libgcc: true,
- nocrt: true,
- vendor_available: true,
- vndk: {
- enabled: true,
- support_system_process: true,
- }
- }
- cc_library {
name: "libc",
no_libgcc: true,
nocrt: true,
diff --git a/cc/tidy.go b/cc/tidy.go
index 0b78d6f..5455392 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -31,6 +31,9 @@
// Extra checks to enable or disable in clang-tidy
Tidy_checks []string
+
+ // Checks that should be treated as errors.
+ Tidy_checks_as_errors []string
}
type tidyFeature struct {
@@ -116,5 +119,9 @@
}
flags.TidyFlags = append(flags.TidyFlags, tidyChecks)
+ if len(tidy.Properties.Tidy_checks_as_errors) > 0 {
+ tidyChecksAsErrors := "-warnings-as-errors=" + strings.Join(esc(tidy.Properties.Tidy_checks_as_errors), ",")
+ flags.TidyFlags = append(flags.TidyFlags, tidyChecksAsErrors)
+ }
return flags
}
diff --git a/java/app.go b/java/app.go
index b31f232..ab623e2 100644
--- a/java/app.go
+++ b/java/app.go
@@ -74,6 +74,11 @@
// Store dex files uncompressed in the APK and set the android:useEmbeddedDex="true" manifest attribute so that
// they are used from inside the APK at runtime.
Use_embedded_dex *bool
+
+ // Forces native libraries to always be packaged into the APK,
+ // Use_embedded_native_libs still selects whether they are stored uncompressed and aligned or compressed.
+ // True for android_test* modules.
+ AlwaysPackageNativeLibs bool `blueprint:"mutated"`
}
// android_app properties that can be overridden by override_android_app
@@ -81,6 +86,9 @@
// The name of a certificate in the default certificate directory, blank to use the default product certificate,
// or an android_app_certificate module name in the form ":module".
Certificate *string
+
+ // the package name of this app. The package name in the manifest file is used if one was not given.
+ Package_name *string
}
type AndroidApp struct {
@@ -223,11 +231,12 @@
}
}
- // TODO: LOCAL_PACKAGE_OVERRIDES
- // $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
-
manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(ctx.ModuleName())
- if overridden {
+ if overridden || a.overridableAppProperties.Package_name != nil {
+ // The product override variable has a priority over the package_name property.
+ if !overridden {
+ manifestPackageName = *a.overridableAppProperties.Package_name
+ }
aaptLinkFlags = append(aaptLinkFlags, "--rename-manifest-package "+manifestPackageName)
}
@@ -281,7 +290,8 @@
func (a *AndroidApp) jniBuildActions(jniLibs []jniLib, ctx android.ModuleContext) android.WritablePath {
var jniJarFile android.WritablePath
if len(jniLibs) > 0 {
- embedJni := ctx.Config().UnbundledBuild() || Bool(a.appProperties.Use_embedded_native_libs)
+ embedJni := ctx.Config().UnbundledBuild() || Bool(a.appProperties.Use_embedded_native_libs) ||
+ a.appProperties.AlwaysPackageNativeLibs
if embedJni {
jniJarFile = android.PathForModuleOut(ctx, "jnilibs.zip")
TransformJniLibsToJar(ctx, jniJarFile, jniLibs, a.shouldUncompressJNI(ctx))
@@ -503,6 +513,7 @@
module.Module.properties.Instrument = true
module.Module.properties.Installable = proptools.BoolPtr(true)
module.appProperties.Use_embedded_native_libs = proptools.BoolPtr(true)
+ module.appProperties.AlwaysPackageNativeLibs = true
module.Module.dexpreopter.isTest = true
module.AddProperties(
@@ -543,6 +554,7 @@
module.Module.properties.Installable = proptools.BoolPtr(true)
module.appProperties.Use_embedded_native_libs = proptools.BoolPtr(true)
+ module.appProperties.AlwaysPackageNativeLibs = true
module.Module.dexpreopter.isTest = true
module.AddProperties(
diff --git a/java/app_test.go b/java/app_test.go
index cf57c80..1f6297c 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -16,6 +16,8 @@
import (
"android/soong/android"
+ "android/soong/cc"
+
"fmt"
"path/filepath"
"reflect"
@@ -537,43 +539,8 @@
}
}
-func TestJNI(t *testing.T) {
- ctx := testJava(t, `
- toolchain_library {
- name: "libcompiler_rt-extras",
- src: "",
- }
-
- toolchain_library {
- name: "libatomic",
- src: "",
- }
-
- toolchain_library {
- name: "libgcc",
- src: "",
- }
-
- toolchain_library {
- name: "libclang_rt.builtins-aarch64-android",
- src: "",
- }
-
- toolchain_library {
- name: "libclang_rt.builtins-arm-android",
- src: "",
- }
-
- cc_object {
- name: "crtbegin_so",
- stl: "none",
- }
-
- cc_object {
- name: "crtend_so",
- stl: "none",
- }
-
+func TestJNIABI(t *testing.T) {
+ ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
name: "libjni",
system_shared_libs: [],
@@ -615,13 +582,6 @@
}
`)
- // check the existence of the internal modules
- ctx.ModuleForTests("test", "android_common")
- ctx.ModuleForTests("test_first", "android_common")
- ctx.ModuleForTests("test_both", "android_common")
- ctx.ModuleForTests("test_32", "android_common")
- ctx.ModuleForTests("test_64", "android_common")
-
testCases := []struct {
name string
abis []string
@@ -652,6 +612,90 @@
}
}
+func TestJNIPackaging(t *testing.T) {
+ ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
+ cc_library {
+ name: "libjni",
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ android_app {
+ name: "app",
+ jni_libs: ["libjni"],
+ }
+
+ android_app {
+ name: "app_noembed",
+ jni_libs: ["libjni"],
+ use_embedded_native_libs: false,
+ }
+
+ android_app {
+ name: "app_embed",
+ jni_libs: ["libjni"],
+ use_embedded_native_libs: true,
+ }
+
+ android_test {
+ name: "test",
+ no_framework_libs: true,
+ jni_libs: ["libjni"],
+ }
+
+ android_test {
+ name: "test_noembed",
+ no_framework_libs: true,
+ jni_libs: ["libjni"],
+ use_embedded_native_libs: false,
+ }
+
+ android_test_helper_app {
+ name: "test_helper",
+ no_framework_libs: true,
+ jni_libs: ["libjni"],
+ }
+
+ android_test_helper_app {
+ name: "test_helper_noembed",
+ no_framework_libs: true,
+ jni_libs: ["libjni"],
+ use_embedded_native_libs: false,
+ }
+ `)
+
+ testCases := []struct {
+ name string
+ packaged bool
+ compressed bool
+ }{
+ {"app", false, false},
+ {"app_noembed", false, false},
+ {"app_embed", true, false},
+ {"test", true, false},
+ {"test_noembed", true, true},
+ {"test_helper", true, false},
+ {"test_helper_noembed", true, true},
+ }
+
+ for _, test := range testCases {
+ t.Run(test.name, func(t *testing.T) {
+ app := ctx.ModuleForTests(test.name, "android_common")
+ jniLibZip := app.MaybeOutput("jnilibs.zip")
+ if g, w := (jniLibZip.Rule != nil), test.packaged; g != w {
+ t.Errorf("expected jni packaged %v, got %v", w, g)
+ }
+
+ if jniLibZip.Rule != nil {
+ if g, w := !strings.Contains(jniLibZip.Args["jarArgs"], "-L 0"), test.compressed; g != w {
+ t.Errorf("expected jni compressed %v, got %v", w, g)
+ }
+ }
+ })
+ }
+
+}
+
func TestCertificates(t *testing.T) {
testCases := []struct {
name string
@@ -833,6 +877,7 @@
android_app {
name: "foo",
srcs: ["a.java"],
+ certificate: "expiredkey",
overrides: ["baz"],
}
@@ -846,6 +891,12 @@
name: "new_certificate",
certificate: "cert/new_cert",
}
+
+ override_android_app {
+ name: "baz",
+ base: "foo",
+ package_name: "org.dandroid.bp",
+ }
`)
expectedVariants := []struct {
@@ -854,18 +905,28 @@
apkPath string
signFlag string
overrides []string
+ aaptFlag string
}{
{
variantName: "android_common",
apkPath: "/target/product/test_device/system/app/foo/foo.apk",
- signFlag: "build/target/product/security/testkey.x509.pem build/target/product/security/testkey.pk8",
+ signFlag: "build/target/product/security/expiredkey.x509.pem build/target/product/security/expiredkey.pk8",
overrides: []string{"baz"},
+ aaptFlag: "",
},
{
variantName: "bar_android_common",
apkPath: "/target/product/test_device/system/app/bar/bar.apk",
signFlag: "cert/new_cert.x509.pem cert/new_cert.pk8",
overrides: []string{"baz", "foo"},
+ aaptFlag: "",
+ },
+ {
+ variantName: "baz_android_common",
+ apkPath: "/target/product/test_device/system/app/baz/baz.apk",
+ signFlag: "build/target/product/security/expiredkey.x509.pem build/target/product/security/expiredkey.pk8",
+ overrides: []string{"baz", "foo"},
+ aaptFlag: "--rename-manifest-package org.dandroid.bp",
},
}
for _, expected := range expectedVariants {
@@ -892,10 +953,18 @@
t.Errorf("Incorrect signing flags, expected: %q, got: %q", expected.signFlag, signFlag)
}
+ // Check if the overrides field values are correctly aggregated.
mod := variant.Module().(*AndroidApp)
if !reflect.DeepEqual(expected.overrides, mod.appProperties.Overrides) {
t.Errorf("Incorrect overrides property value, expected: %q, got: %q",
expected.overrides, mod.appProperties.Overrides)
}
+
+ // Check the package renaming flag, if exists.
+ res := variant.Output("package-res.apk")
+ aapt2Flags := res.Args["flags"]
+ if !strings.Contains(aapt2Flags, expected.aaptFlag) {
+ t.Errorf("package renaming flag, %q is missing in aapt2 link flags, %q", expected.aaptFlag, aapt2Flags)
+ }
}
}
diff --git a/java/java_test.go b/java/java_test.go
index ec6d27a..6cb4818 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -103,6 +103,7 @@
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory))
ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory))
+ ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory))
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index 79b0f4e..a7aff59 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -73,6 +73,7 @@
})
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
+ ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(cc.LibraryHeaderFactory))
ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(cc.LibraryFactory))
ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory))
ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory))
@@ -271,6 +272,25 @@
soc_specific: true,
static_libs: ["sysprop-platform", "sysprop-vendor"],
}
+
+ cc_library_headers {
+ name: "libbase_headers",
+ vendor_available: true,
+ recovery_available: true,
+ }
+
+ cc_library {
+ name: "liblog",
+ no_libgcc: true,
+ nocrt: true,
+ system_shared_libs: [],
+ recovery_available: true,
+ }
+
+ llndk_library {
+ name: "liblog",
+ symbol_file: "",
+ }
`)
for _, variant := range []string{