Merge "Switch to clang-r353983b"
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/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..781fdff 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
@@ -846,6 +890,12 @@
name: "new_certificate",
certificate: "cert/new_cert",
}
+
+ override_android_app {
+ name: "baz",
+ base: "foo",
+ package_name: "org.dandroid.bp",
+ }
`)
expectedVariants := []struct {
@@ -854,18 +904,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",
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/testkey.x509.pem build/target/product/security/testkey.pk8",
+ overrides: []string{"baz", "foo"},
+ aaptFlag: "--rename-manifest-package org.dandroid.bp",
},
}
for _, expected := range expectedVariants {
@@ -892,10 +952,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()