Merge "Add missing directories to bp2build."
diff --git a/androidmk/androidmk/android.go b/androidmk/androidmk/android.go
index 963e905..f3ad152 100644
--- a/androidmk/androidmk/android.go
+++ b/androidmk/androidmk/android.go
@@ -639,6 +639,12 @@
if len(val.Variables) == 1 && varLiteralName(val.Variables[0]) != "" && len(val.Strings) == 2 && val.Strings[0] == "" {
fixed = val.Strings[1]
varname = val.Variables[0].Name.Strings[0]
+ // TARGET_OUT_OPTIONAL_EXECUTABLES puts the artifact in xbin, which is
+ // deprecated. TARGET_OUT_DATA_APPS install location will be handled
+ // automatically by Soong
+ if varname == "TARGET_OUT_OPTIONAL_EXECUTABLES" || varname == "TARGET_OUT_DATA_APPS" {
+ return nil
+ }
} else if len(val.Variables) == 2 && varLiteralName(val.Variables[0]) == "PRODUCT_OUT" && varLiteralName(val.Variables[1]) == "TARGET_COPY_OUT_VENDOR" &&
len(val.Strings) == 3 && val.Strings[0] == "" && val.Strings[1] == "/" {
fixed = val.Strings[2]
diff --git a/androidmk/androidmk/androidmk_test.go b/androidmk/androidmk/androidmk_test.go
index 9fd4ff9..775a9a8 100644
--- a/androidmk/androidmk/androidmk_test.go
+++ b/androidmk/androidmk/androidmk_test.go
@@ -1516,7 +1516,23 @@
],
}
`,
- },
+ }, {
+ desc: "Obsolete LOCAL_MODULE_PATH",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := foo
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_CTS_TEST_PACKAGE := bar
+LOCAL_USE_AAPT2 := blah
+include $(BUILD_PACKAGE)
+`,
+ expected: `
+android_app {
+ name: "foo",
+
+}
+`},
}
func TestEndToEnd(t *testing.T) {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 4a5373f..78a6bb8 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -3183,7 +3183,6 @@
"myapex",
"otherapex",
],
- use_apex_name_macro: true,
recovery_available: true,
min_sdk_version: "29",
}
@@ -3198,13 +3197,11 @@
mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_apex10000").Rule("cc").Args["cFlags"]
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__=10000")
- ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
// APEX variant has __ANDROID_APEX__ and __ANDROID_APEX_SDK__ defined
mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_apex29").Rule("cc").Args["cFlags"]
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__=29")
- ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
// When a cc_library sets use_apex_name_macro: true each apex gets a unique variant and
// each variant defines additional macros to distinguish which apex variant it is built for
@@ -3213,42 +3210,15 @@
mylibCFlags = ctx.ModuleForTests("mylib3", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
- // APEX variant has __ANDROID_APEX__ defined
- mylibCFlags = ctx.ModuleForTests("mylib3", "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__ defined
- mylibCFlags = ctx.ModuleForTests("mylib3", "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__")
-
// recovery variant does not set __ANDROID_APEX_MIN_SDK_VERSION__
mylibCFlags = ctx.ModuleForTests("mylib3", "android_recovery_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__")
- // When a dependency of a cc_library sets use_apex_name_macro: true each apex gets a unique
- // variant.
-
// non-APEX variant does not have __ANDROID_APEX__ defined
mylibCFlags = ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
- // APEX variant has __ANDROID_APEX__ defined
- mylibCFlags = ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"]
- ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
- ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
- ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
-
- // APEX variant has __ANDROID_APEX__ defined
- mylibCFlags = ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_otherapex").Rule("cc").Args["cFlags"]
- ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
- ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
- ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
-
// recovery variant does not set __ANDROID_APEX_MIN_SDK_VERSION__
mylibCFlags = ctx.ModuleForTests("mylib2", "android_recovery_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
diff --git a/cc/cc.go b/cc/cc.go
index 87de1c8..1c65549 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3249,16 +3249,6 @@
return c.Properties.Test_for
}
-func (c *Module) UniqueApexVariations() bool {
- if u, ok := c.compiler.(interface {
- uniqueApexVariations() bool
- }); ok {
- return u.uniqueApexVariations()
- } else {
- return false
- }
-}
-
func (c *Module) EverInstallable() bool {
return c.installer != nil &&
// Check to see whether the module is actually ever installable.
diff --git a/cc/compiler.go b/cc/compiler.go
index 4f96712..2ac7bf3 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -209,15 +209,6 @@
// Build and link with OpenMP
Openmp *bool `android:"arch_variant"`
-
- // Deprecated.
- // Adds __ANDROID_APEX_<APEX_MODULE_NAME>__ macro defined for apex variants in addition to __ANDROID_APEX__
- Use_apex_name_macro *bool
-
- // Adds two macros for apex variants in addition to __ANDROID_APEX__
- // * __ANDROID_APEX_COM_ANDROID_FOO__
- // * __ANDROID_APEX_NAME__="com.android.foo"
- UseApexNameMacro bool `blueprint:"mutated"`
}
func NewBaseCompiler() *baseCompiler {
@@ -291,10 +282,6 @@
return deps
}
-func (compiler *baseCompiler) useApexNameMacro() bool {
- return Bool(compiler.Properties.Use_apex_name_macro) || compiler.Properties.UseApexNameMacro
-}
-
// Return true if the module is in the WarningAllowedProjects.
func warningsAreAllowed(subdir string) bool {
subdir += "/"
@@ -405,10 +392,6 @@
if ctx.apexVariationName() != "" {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX__")
- if compiler.useApexNameMacro() {
- flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX_"+makeDefineString(ctx.apexVariationName())+"__")
- flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX_NAME__='\""+ctx.apexVariationName()+"\"'")
- }
if ctx.Device() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags,
fmt.Sprintf("-D__ANDROID_APEX_MIN_SDK_VERSION__=%d",
@@ -634,10 +617,6 @@
return false
}
-func (compiler *baseCompiler) uniqueApexVariations() bool {
- return compiler.useApexNameMacro()
-}
-
var invalidDefineCharRegex = regexp.MustCompile("[^a-zA-Z0-9_]")
// makeDefineString transforms a name of an APEX module into a value to be used as value for C define
diff --git a/cc/lto.go b/cc/lto.go
index d9a0118..6d55579 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -49,8 +49,9 @@
// Dep properties indicate that this module needs to be built with LTO
// since it is an object dependency of an LTO module.
- FullDep bool `blueprint:"mutated"`
- ThinDep bool `blueprint:"mutated"`
+ FullDep bool `blueprint:"mutated"`
+ ThinDep bool `blueprint:"mutated"`
+ NoLtoDep bool `blueprint:"mutated"`
// Use clang lld instead of gnu ld.
Use_clang_lld *bool
@@ -70,15 +71,6 @@
func (lto *lto) begin(ctx BaseModuleContext) {
if ctx.Config().IsEnvTrue("DISABLE_LTO") {
lto.Properties.Lto.Never = proptools.BoolPtr(true)
- } else if ctx.Config().IsEnvTrue("GLOBAL_THINLTO") {
- staticLib := ctx.static() && !ctx.staticBinary()
- hostBin := ctx.Host()
- vndk := ctx.isVndk() // b/169217596
- if !staticLib && !hostBin && !vndk {
- if !lto.Never() && !lto.FullLTO() {
- lto.Properties.Lto.Thin = proptools.BoolPtr(true)
- }
- }
}
}
@@ -96,22 +88,27 @@
return flags
}
- if lto.LTO() {
- var ltoFlag string
+ if lto.LTO(ctx) {
+ var ltoCFlag string
+ var ltoLdFlag string
if lto.ThinLTO() {
- ltoFlag = "-flto=thin -fsplit-lto-unit"
+ ltoCFlag = "-flto=thin -fsplit-lto-unit"
+ } else if lto.FullLTO() {
+ ltoCFlag = "-flto"
} else {
- ltoFlag = "-flto"
+ ltoCFlag = "-flto=thin -fsplit-lto-unit"
+ ltoLdFlag = "-Wl,--lto-O0"
}
- flags.Local.CFlags = append(flags.Local.CFlags, ltoFlag)
- flags.Local.LdFlags = append(flags.Local.LdFlags, ltoFlag)
+ flags.Local.CFlags = append(flags.Local.CFlags, ltoCFlag)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, ltoCFlag)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, ltoLdFlag)
if Bool(lto.Properties.Whole_program_vtables) {
flags.Local.CFlags = append(flags.Local.CFlags, "-fwhole-program-vtables")
}
- if lto.ThinLTO() && ctx.Config().IsEnvTrue("USE_THINLTO_CACHE") && lto.useClangLld(ctx) {
+ if (lto.DefaultThinLTO(ctx) || lto.ThinLTO()) && ctx.Config().IsEnvTrue("USE_THINLTO_CACHE") && lto.useClangLld(ctx) {
// Set appropriate ThinLTO cache policy
cacheDirFormat := "-Wl,--thinlto-cache-dir="
cacheDir := android.PathForOutput(ctx, "thinlto-cache").String()
@@ -134,33 +131,40 @@
return flags
}
-// Can be called with a null receiver
-func (lto *lto) LTO() bool {
- if lto == nil || lto.Never() {
- return false
- }
+func (lto *lto) LTO(ctx BaseModuleContext) bool {
+ return lto.ThinLTO() || lto.FullLTO() || lto.DefaultThinLTO(ctx)
+}
- return lto.FullLTO() || lto.ThinLTO()
+func (lto *lto) DefaultThinLTO(ctx BaseModuleContext) bool {
+ host := ctx.Host()
+ vndk := ctx.isVndk() // b/169217596
+ return GlobalThinLTO(ctx) && !lto.Never() && !host && !vndk
}
func (lto *lto) FullLTO() bool {
- return Bool(lto.Properties.Lto.Full)
+ return lto != nil && Bool(lto.Properties.Lto.Full)
}
func (lto *lto) ThinLTO() bool {
- return Bool(lto.Properties.Lto.Thin)
+ return lto != nil && Bool(lto.Properties.Lto.Thin)
}
-// Is lto.never explicitly set to true?
func (lto *lto) Never() bool {
- return Bool(lto.Properties.Lto.Never)
+ return lto != nil && Bool(lto.Properties.Lto.Never)
+}
+
+func GlobalThinLTO(ctx android.BaseModuleContext) bool {
+ return ctx.Config().IsEnvTrue("GLOBAL_THINLTO")
}
// Propagate lto requirements down from binaries
func ltoDepsMutator(mctx android.TopDownMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok && m.lto.LTO() {
+ globalThinLTO := GlobalThinLTO(mctx)
+
+ if m, ok := mctx.Module().(*Module); ok {
full := m.lto.FullLTO()
thin := m.lto.ThinLTO()
+ never := m.lto.Never()
if full && thin {
mctx.PropertyErrorf("LTO", "FullLTO and ThinLTO are mutually exclusive")
}
@@ -180,14 +184,16 @@
}
}
- if dep, ok := dep.(*Module); ok && dep.lto != nil &&
- !dep.lto.Never() {
+ if dep, ok := dep.(*Module); ok {
if full && !dep.lto.FullLTO() {
dep.lto.Properties.FullDep = true
}
- if thin && !dep.lto.ThinLTO() {
+ if !globalThinLTO && thin && !dep.lto.ThinLTO() {
dep.lto.Properties.ThinDep = true
}
+ if globalThinLTO && never && !dep.lto.Never() {
+ dep.lto.Properties.NoLtoDep = true
+ }
}
// Recursively walk static dependencies
@@ -198,6 +204,8 @@
// Create lto variants for modules that need them
func ltoMutator(mctx android.BottomUpMutatorContext) {
+ globalThinLTO := GlobalThinLTO(mctx)
+
if m, ok := mctx.Module().(*Module); ok && m.lto != nil {
// Create variations for LTO types required as static
// dependencies
@@ -205,18 +213,25 @@
if m.lto.Properties.FullDep && !m.lto.FullLTO() {
variationNames = append(variationNames, "lto-full")
}
- if m.lto.Properties.ThinDep && !m.lto.ThinLTO() {
+ if !globalThinLTO && m.lto.Properties.ThinDep && !m.lto.ThinLTO() {
variationNames = append(variationNames, "lto-thin")
}
+ if globalThinLTO && m.lto.Properties.NoLtoDep && !m.lto.Never() {
+ variationNames = append(variationNames, "lto-none")
+ }
// Use correct dependencies if LTO property is explicitly set
// (mutually exclusive)
if m.lto.FullLTO() {
mctx.SetDependencyVariation("lto-full")
}
- if m.lto.ThinLTO() {
+ if !globalThinLTO && m.lto.ThinLTO() {
mctx.SetDependencyVariation("lto-thin")
}
+ // Never must be the last, it overrides Thin or Full.
+ if globalThinLTO && m.lto.Never() {
+ mctx.SetDependencyVariation("lto-none")
+ }
if len(variationNames) > 1 {
modules := mctx.CreateVariations(variationNames...)
@@ -232,16 +247,18 @@
// LTO properties for dependencies
if name == "lto-full" {
variation.lto.Properties.Lto.Full = proptools.BoolPtr(true)
- variation.lto.Properties.Lto.Thin = proptools.BoolPtr(false)
}
if name == "lto-thin" {
- variation.lto.Properties.Lto.Full = proptools.BoolPtr(false)
variation.lto.Properties.Lto.Thin = proptools.BoolPtr(true)
}
+ if name == "lto-none" {
+ variation.lto.Properties.Lto.Never = proptools.BoolPtr(true)
+ }
variation.Properties.PreventInstall = true
variation.Properties.HideFromMake = true
variation.lto.Properties.FullDep = false
variation.lto.Properties.ThinDep = false
+ variation.lto.Properties.NoLtoDep = false
}
}
}