Merge "Stop exporting the windows toolchain to Make"
diff --git a/OWNERS b/OWNERS
index 7983c19..85c70df 100644
--- a/OWNERS
+++ b/OWNERS
@@ -3,4 +3,3 @@
per-file clang.go,global.go = srhines@google.com, chh@google.com, pirama@google.com, yikong@google.com
per-file tidy.go = srhines@google.com, chh@google.com
per-file lto.go,pgo.go = srhines@google.com, pirama@google.com, yikong@google.com
-per-file apex.go = jiyong@google.com
diff --git a/android/arch.go b/android/arch.go
index 6aeccb0..953e6cf 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -1169,7 +1169,7 @@
targets := make(map[OsType][]Target)
var targetErr error
- addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi *[]string) {
+ addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi []string) {
if targetErr != nil {
return
}
@@ -1358,7 +1358,7 @@
for _, config := range archConfigs {
arch, err := decodeArch(os, config.arch, &config.archVariant,
- &config.cpuVariant, &config.abi)
+ &config.cpuVariant, config.abi)
if err != nil {
return nil, err
}
@@ -1373,7 +1373,7 @@
}
// Convert a set of strings from product variables into a single Arch struct
-func decodeArch(os OsType, arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) {
+func decodeArch(os OsType, arch string, archVariant, cpuVariant *string, abi []string) (Arch, error) {
stringPtr := func(p *string) string {
if p != nil {
return *p
@@ -1381,13 +1381,6 @@
return ""
}
- slicePtr := func(p *[]string) []string {
- if p != nil {
- return *p
- }
- return nil
- }
-
archType, ok := archTypeMap[arch]
if !ok {
return Arch{}, fmt.Errorf("unknown arch %q", arch)
@@ -1397,7 +1390,7 @@
ArchType: archType,
ArchVariant: stringPtr(archVariant),
CpuVariant: stringPtr(cpuVariant),
- Abi: slicePtr(abi),
+ Abi: abi,
Native: true,
}
diff --git a/android/config.go b/android/config.go
index 122b99b..92010fc 100644
--- a/android/config.go
+++ b/android/config.go
@@ -202,10 +202,10 @@
productVariables: productVariables{
DeviceName: stringPtr("test_device"),
Platform_sdk_version: intPtr(26),
- AAPTConfig: &[]string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
+ AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
AAPTPreferredConfig: stringPtr("xhdpi"),
AAPTCharacteristics: stringPtr("nosdcard"),
- AAPTPrebuiltDPI: &[]string{"xhdpi", "xxhdpi"},
+ AAPTPrebuiltDPI: []string{"xhdpi", "xxhdpi"},
},
buildDir: buildDir,
@@ -476,10 +476,7 @@
}
func (c *config) ResourceOverlays() []string {
- if c.productVariables.ResourceOverlays == nil {
- return nil
- }
- return *c.productVariables.ResourceOverlays
+ return c.productVariables.ResourceOverlays
}
func (c *config) PlatformVersionName() string {
@@ -544,7 +541,7 @@
}
func (c *config) ProductAAPTConfig() []string {
- return stringSlice(c.productVariables.AAPTConfig)
+ return c.productVariables.AAPTConfig
}
func (c *config) ProductAAPTPreferredConfig() string {
@@ -556,7 +553,7 @@
}
func (c *config) ProductAAPTPrebuiltDPI() []string {
- return stringSlice(c.productVariables.AAPTPrebuiltDPI)
+ return c.productVariables.AAPTPrebuiltDPI
}
func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath {
@@ -668,6 +665,10 @@
}
}
+func (c *config) DisableScudo() bool {
+ return Bool(c.productVariables.DisableScudo)
+}
+
func (c *config) EnableXOM() bool {
if c.productVariables.EnableXOM == nil {
return true
@@ -734,10 +735,10 @@
func (c *config) EnforceRROForModule(name string) bool {
enforceList := c.productVariables.EnforceRROTargets
if enforceList != nil {
- if len(*enforceList) == 1 && (*enforceList)[0] == "*" {
+ if len(enforceList) == 1 && (enforceList)[0] == "*" {
return true
}
- return InList(name, *enforceList)
+ return InList(name, enforceList)
}
return false
}
@@ -745,7 +746,7 @@
func (c *config) EnforceRROExcludedOverlay(path string) bool {
excluded := c.productVariables.EnforceRROExcludedOverlays
if excluded != nil {
- for _, exclude := range *excluded {
+ for _, exclude := range excluded {
if strings.HasPrefix(path, exclude) {
return true
}
@@ -830,10 +831,7 @@
}
func (c *deviceConfig) SystemSdkVersions() []string {
- if c.config.productVariables.DeviceSystemSdkVersions == nil {
- return nil
- }
- return *c.config.productVariables.DeviceSystemSdkVersions
+ return c.config.productVariables.DeviceSystemSdkVersions
}
func (c *deviceConfig) PlatformSystemSdkVersions() []string {
@@ -876,12 +874,12 @@
func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
coverage := false
if c.config.productVariables.CoveragePaths != nil {
- if PrefixInList(path, *c.config.productVariables.CoveragePaths) {
+ if PrefixInList(path, c.config.productVariables.CoveragePaths) {
coverage = true
}
}
if coverage && c.config.productVariables.CoverageExcludePaths != nil {
- if PrefixInList(path, *c.config.productVariables.CoverageExcludePaths) {
+ if PrefixInList(path, c.config.productVariables.CoverageExcludePaths) {
coverage = false
}
}
@@ -962,28 +960,28 @@
if c.productVariables.IntegerOverflowExcludePaths == nil {
return false
}
- return PrefixInList(path, *c.productVariables.IntegerOverflowExcludePaths)
+ return PrefixInList(path, c.productVariables.IntegerOverflowExcludePaths)
}
func (c *config) CFIDisabledForPath(path string) bool {
if c.productVariables.CFIExcludePaths == nil {
return false
}
- return PrefixInList(path, *c.productVariables.CFIExcludePaths)
+ return PrefixInList(path, c.productVariables.CFIExcludePaths)
}
func (c *config) CFIEnabledForPath(path string) bool {
if c.productVariables.CFIIncludePaths == nil {
return false
}
- return PrefixInList(path, *c.productVariables.CFIIncludePaths)
+ return PrefixInList(path, c.productVariables.CFIIncludePaths)
}
func (c *config) XOMDisabledForPath(path string) bool {
if c.productVariables.XOMExcludePaths == nil {
return false
}
- return PrefixInList(path, *c.productVariables.XOMExcludePaths)
+ return PrefixInList(path, c.productVariables.XOMExcludePaths)
}
func (c *config) VendorConfig(name string) VendorConfig {
@@ -1035,11 +1033,3 @@
func (c *config) HiddenAPIExtraAppUsageJars() []string {
return c.productVariables.HiddenAPIExtraAppUsageJars
}
-
-func stringSlice(s *[]string) []string {
- if s != nil {
- return *s
- } else {
- return nil
- }
-}
diff --git a/android/module.go b/android/module.go
index 551824d..f2f1af1 100644
--- a/android/module.go
+++ b/android/module.go
@@ -481,6 +481,8 @@
prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
}
+func (a *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
+
func (a *ModuleBase) AddProperties(props ...interface{}) {
a.registerProps = append(a.registerProps, props...)
}
diff --git a/android/namespace.go b/android/namespace.go
index b027ceb..dca2b8c 100644
--- a/android/namespace.go
+++ b/android/namespace.go
@@ -366,9 +366,6 @@
}
}
-func (n *NamespaceModule) DepsMutator(context BottomUpMutatorContext) {
-}
-
func (n *NamespaceModule) GenerateAndroidBuildActions(ctx ModuleContext) {
}
diff --git a/android/neverallow_test.go b/android/neverallow_test.go
index 9e4886c..8d53087 100644
--- a/android/neverallow_test.go
+++ b/android/neverallow_test.go
@@ -222,9 +222,6 @@
return m
}
-func (p *mockCcLibraryModule) DepsMutator(ctx BottomUpMutatorContext) {
-}
-
func (p *mockCcLibraryModule) GenerateAndroidBuildActions(ModuleContext) {
}
@@ -244,8 +241,5 @@
return m
}
-func (p *mockJavaLibraryModule) DepsMutator(ctx BottomUpMutatorContext) {
-}
-
func (p *mockJavaLibraryModule) GenerateAndroidBuildActions(ModuleContext) {
}
diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go
index 42c7c2c..e180342 100644
--- a/android/prebuilt_etc.go
+++ b/android/prebuilt_etc.go
@@ -145,6 +145,9 @@
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
fmt.Fprintln(w, "LOCAL_MODULE :=", name+nameSuffix)
fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC")
+ if p.commonProperties.Owner != nil {
+ fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", *p.commonProperties.Owner)
+ }
fmt.Fprintln(w, "LOCAL_MODULE_TAGS := optional")
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", p.outputFilePath.String())
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go
index 8ab978b..d1a80af 100644
--- a/android/prebuilt_etc_test.go
+++ b/android/prebuilt_etc_test.go
@@ -15,8 +15,11 @@
package android
import (
+ "bufio"
+ "bytes"
"io/ioutil"
"os"
+ "strings"
"testing"
)
@@ -130,3 +133,47 @@
t.Errorf("expected bar.conf, got %q", p.outputFilePath.Base())
}
}
+
+func TestPrebuiltEtcAndroidMk(t *testing.T) {
+ ctx := testPrebuiltEtc(t, `
+ prebuilt_etc {
+ name: "foo",
+ src: "foo.conf",
+ owner: "abc",
+ filename_from_src: true,
+ }
+ `)
+
+ data := AndroidMkData{}
+ data.Required = append(data.Required, "modA", "moduleB")
+
+ expected := map[string]string{
+ "LOCAL_MODULE": "foo",
+ "LOCAL_MODULE_CLASS": "ETC",
+ "LOCAL_MODULE_OWNER": "abc",
+ "LOCAL_INSTALLED_MODULE_STEM": "foo.conf",
+ "LOCAL_REQUIRED_MODULES": "modA moduleB",
+ }
+
+ mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
+ buf := &bytes.Buffer{}
+ mod.AndroidMk().Custom(buf, "foo", "", "", data)
+ for k, expected := range expected {
+ found := false
+ scanner := bufio.NewScanner(bytes.NewReader(buf.Bytes()))
+ for scanner.Scan() {
+ line := scanner.Text()
+ tok := strings.Split(line, " := ")
+ if tok[0] == k {
+ found = true
+ if tok[1] != expected {
+ t.Errorf("Incorrect %s '%s', expected '%s'", k, tok[1], expected)
+ }
+ }
+ }
+
+ if !found {
+ t.Errorf("No %s defined, saw %s", k, buf.String())
+ }
+ }
+}
diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go
index cd1ffae..b30ca1a 100644
--- a/android/prebuilt_test.go
+++ b/android/prebuilt_test.go
@@ -212,9 +212,6 @@
return p.prebuilt.Name(p.ModuleBase.Name())
}
-func (p *prebuiltModule) DepsMutator(ctx BottomUpMutatorContext) {
-}
-
func (p *prebuiltModule) GenerateAndroidBuildActions(ModuleContext) {
}
diff --git a/android/variable.go b/android/variable.go
index 2cccd50..f38cf25 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -144,18 +144,18 @@
Platform_vndk_version *string `json:",omitempty"`
Platform_systemsdk_versions []string `json:",omitempty"`
- DeviceName *string `json:",omitempty"`
- DeviceArch *string `json:",omitempty"`
- DeviceArchVariant *string `json:",omitempty"`
- DeviceCpuVariant *string `json:",omitempty"`
- DeviceAbi *[]string `json:",omitempty"`
- DeviceVndkVersion *string `json:",omitempty"`
- DeviceSystemSdkVersions *[]string `json:",omitempty"`
+ DeviceName *string `json:",omitempty"`
+ DeviceArch *string `json:",omitempty"`
+ DeviceArchVariant *string `json:",omitempty"`
+ DeviceCpuVariant *string `json:",omitempty"`
+ DeviceAbi []string `json:",omitempty"`
+ DeviceVndkVersion *string `json:",omitempty"`
+ DeviceSystemSdkVersions []string `json:",omitempty"`
- DeviceSecondaryArch *string `json:",omitempty"`
- DeviceSecondaryArchVariant *string `json:",omitempty"`
- DeviceSecondaryCpuVariant *string `json:",omitempty"`
- DeviceSecondaryAbi *[]string `json:",omitempty"`
+ DeviceSecondaryArch *string `json:",omitempty"`
+ DeviceSecondaryArchVariant *string `json:",omitempty"`
+ DeviceSecondaryCpuVariant *string `json:",omitempty"`
+ DeviceSecondaryAbi []string `json:",omitempty"`
HostArch *string `json:",omitempty"`
HostSecondaryArch *string `json:",omitempty"`
@@ -164,14 +164,14 @@
CrossHostArch *string `json:",omitempty"`
CrossHostSecondaryArch *string `json:",omitempty"`
- ResourceOverlays *[]string `json:",omitempty"`
- EnforceRROTargets *[]string `json:",omitempty"`
- EnforceRROExcludedOverlays *[]string `json:",omitempty"`
+ ResourceOverlays []string `json:",omitempty"`
+ EnforceRROTargets []string `json:",omitempty"`
+ EnforceRROExcludedOverlays []string `json:",omitempty"`
- AAPTCharacteristics *string `json:",omitempty"`
- AAPTConfig *[]string `json:",omitempty"`
- AAPTPreferredConfig *string `json:",omitempty"`
- AAPTPrebuiltDPI *[]string `json:",omitempty"`
+ AAPTCharacteristics *string `json:",omitempty"`
+ AAPTConfig []string `json:",omitempty"`
+ AAPTPreferredConfig *string `json:",omitempty"`
+ AAPTPrebuiltDPI []string `json:",omitempty"`
DefaultAppCertificate *string `json:",omitempty"`
@@ -207,14 +207,16 @@
DisableDexPreoptModules []string `json:",omitempty"`
DexPreoptProfileDir *string `json:",omitempty"`
- IntegerOverflowExcludePaths *[]string `json:",omitempty"`
+ IntegerOverflowExcludePaths []string `json:",omitempty"`
- EnableCFI *bool `json:",omitempty"`
- CFIExcludePaths *[]string `json:",omitempty"`
- CFIIncludePaths *[]string `json:",omitempty"`
+ EnableCFI *bool `json:",omitempty"`
+ CFIExcludePaths []string `json:",omitempty"`
+ CFIIncludePaths []string `json:",omitempty"`
- EnableXOM *bool `json:",omitempty"`
- XOMExcludePaths *[]string `json:",omitempty"`
+ DisableScudo *bool `json:",omitempty"`
+
+ EnableXOM *bool `json:",omitempty"`
+ XOMExcludePaths []string `json:",omitempty"`
VendorPath *string `json:",omitempty"`
OdmPath *string `json:",omitempty"`
@@ -224,9 +226,9 @@
ClangTidy *bool `json:",omitempty"`
TidyChecks *string `json:",omitempty"`
- NativeCoverage *bool `json:",omitempty"`
- CoveragePaths *[]string `json:",omitempty"`
- CoverageExcludePaths *[]string `json:",omitempty"`
+ NativeCoverage *bool `json:",omitempty"`
+ CoveragePaths []string `json:",omitempty"`
+ CoverageExcludePaths []string `json:",omitempty"`
DevicePrefer32BitApps *bool `json:",omitempty"`
DevicePrefer32BitExecutables *bool `json:",omitempty"`
@@ -306,16 +308,16 @@
DeviceArch: stringPtr("arm64"),
DeviceArchVariant: stringPtr("armv8-a"),
DeviceCpuVariant: stringPtr("generic"),
- DeviceAbi: &[]string{"arm64-v8a"},
+ DeviceAbi: []string{"arm64-v8a"},
DeviceSecondaryArch: stringPtr("arm"),
DeviceSecondaryArchVariant: stringPtr("armv8-a"),
DeviceSecondaryCpuVariant: stringPtr("generic"),
- DeviceSecondaryAbi: &[]string{"armeabi-v7a", "armeabi"},
+ DeviceSecondaryAbi: []string{"armeabi-v7a", "armeabi"},
- AAPTConfig: &[]string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
+ AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
AAPTPreferredConfig: stringPtr("xhdpi"),
AAPTCharacteristics: stringPtr("nosdcard"),
- AAPTPrebuiltDPI: &[]string{"xhdpi", "xxhdpi"},
+ AAPTPrebuiltDPI: []string{"xhdpi", "xxhdpi"},
Malloc_not_svelte: boolPtr(true),
Safestack: boolPtr(false),
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go
index e7f2531..aef8944 100644
--- a/androidmk/cmd/androidmk/android.go
+++ b/androidmk/cmd/androidmk/android.go
@@ -56,6 +56,7 @@
"LOCAL_CFLAGS": cflags,
"LOCAL_UNINSTALLABLE_MODULE": invert("installable"),
"LOCAL_PROGUARD_ENABLED": proguardEnabled,
+ "LOCAL_MODULE_PATH": prebuiltModulePath,
// composite functions
"LOCAL_MODULE_TAGS": includeVariableIf(bpVariable{"tags", bpparser.ListType}, not(valueDumpEquals("optional"))),
@@ -519,6 +520,55 @@
return nil
}
+func makeBlueprintStringAssignment(file *bpFile, prefix string, suffix string, value string) error {
+ val, err := makeVariableToBlueprint(file, mkparser.SimpleMakeString(value, mkparser.NoPos), bpparser.StringType)
+ if err == nil {
+ err = setVariable(file, false, prefix, suffix, val, true)
+ }
+ return err
+}
+
+// If variable is a literal variable name, return the name, otherwise return ""
+func varLiteralName(variable mkparser.Variable) string {
+ if len(variable.Name.Variables) == 0 {
+ return variable.Name.Strings[0]
+ }
+ return ""
+}
+
+func prebuiltModulePath(ctx variableAssignmentContext) error {
+ // Cannot handle appending
+ if ctx.append {
+ return fmt.Errorf("Cannot handle appending to LOCAL_MODULE_PATH")
+ }
+ // Analyze value in order to set the correct values for the 'device_specific',
+ // 'product_specific', 'product_services_specific' 'vendor'/'soc_specific',
+ // 'product_services_specific' attribute. Two cases are allowed:
+ // $(VAR)/<literal-value>
+ // $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/<literal-value>
+ // The last case is equivalent to $(TARGET_OUT_VENDOR)/<literal-value>
+ // Map the variable name if present to `local_module_path_var`
+ // Map literal-path to local_module_path_fixed
+ varname := ""
+ fixed := ""
+ val := ctx.mkvalue
+ 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]
+ } 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]
+ varname = "TARGET_OUT_VENDOR"
+ } else {
+ return fmt.Errorf("LOCAL_MODULE_PATH value should start with $(<some-varaible>)/ or $(PRODUCT_OUT)/$(TARGET_COPY_VENDOR)/")
+ }
+ err := makeBlueprintStringAssignment(ctx.file, "local_module_path", "var", varname)
+ if err == nil && fixed != "" {
+ err = makeBlueprintStringAssignment(ctx.file, "local_module_path", "fixed", fixed)
+ }
+ return err
+}
+
func ldflags(ctx variableAssignmentContext) error {
val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
if err != nil {
@@ -816,6 +866,7 @@
"STATIC_LIBRARIES": "cc_prebuilt_library_static",
"EXECUTABLES": "cc_prebuilt_binary",
"JAVA_LIBRARIES": "java_import",
+ "ETC": "prebuilt_etc",
}
var soongModuleTypes = map[string]bool{}
@@ -834,7 +885,6 @@
globalScope.SetFunc("first-makefiles-under", includeIgnored)
globalScope.SetFunc("all-named-subdir-makefiles", includeIgnored)
globalScope.SetFunc("all-subdir-makefiles", includeIgnored)
-
for k, v := range moduleTypes {
globalScope.Set(k, v)
soongModuleTypes[v] = true
diff --git a/androidmk/cmd/androidmk/androidmk_test.go b/androidmk/cmd/androidmk/androidmk_test.go
index 5fbe62a0..52b8476 100644
--- a/androidmk/cmd/androidmk/androidmk_test.go
+++ b/androidmk/cmd/androidmk/androidmk_test.go
@@ -824,6 +824,210 @@
}
`,
},
+ {
+ desc: "prebuilt_etc_TARGET_OUT_ETC",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_SRC_FILES := mymod
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ src: "mymod",
+ sub_dir: "foo/bar",
+
+}
+`,
+ },
+
+ {
+ desc: "prebuilt_etc_PRODUCT_OUT/system/etc",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/system/etc/foo/bar
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+
+ src: "etc.test1",
+ sub_dir: "foo/bar",
+
+}
+`,
+ },
+ {
+ desc: "prebuilt_etc_TARGET_OUT_ODM/etc",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_ODM)/etc/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ sub_dir: "foo/bar",
+ device_specific: true,
+
+}
+`,
+ },
+ {
+ desc: "prebuilt_etc_TARGET_OUT_PRODUCT/etc",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT)/etc/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ sub_dir: "foo/bar",
+ product_specific: true,
+
+
+}
+`,
+ },
+ {
+ desc: "prebuilt_etc_TARGET_OUT_PRODUCT_ETC",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT_ETC)/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ sub_dir: "foo/bar",
+ product_specific: true,
+
+}
+`,
+ },
+ {
+ desc: "prebuilt_etc_TARGET_OUT_PRODUCT_SERVICES/etc",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT_SERVICES)/etc/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ sub_dir: "foo/bar",
+ product_services_specific: true,
+
+}
+`,
+ },
+ {
+ desc: "prebuilt_etc_TARGET_OUT_PRODUCT_SERVICES_ETC",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT_SERVICES_ETC)/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ sub_dir: "foo/bar",
+ product_services_specific: true,
+
+
+}
+`,
+ },
+ {
+ desc: "prebuilt_etc_TARGET_OUT_VENDOR/etc",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ sub_dir: "foo/bar",
+ proprietary: true,
+
+}
+`,
+ },
+ {
+ desc: "prebuilt_etc_PRODUCT_OUT/TARGET_COPY_OUT_VENDOR/etc",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/etc/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ sub_dir: "foo/bar",
+ proprietary: true,
+
+}
+`,
+ },
+ {
+ desc: "prebuilt_etc_TARGET_OUT_VENDOR_ETC",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ sub_dir: "foo/bar",
+ proprietary: true,
+
+}
+`,
+ },
+ {
+ desc: "prebuilt_etc_TARGET_RECOVERY_ROOT_OUT/system/etc",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE := etc.test1
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/system/etc/foo/bar
+include $(BUILD_PREBUILT)
+`,
+ expected: `
+prebuilt_etc {
+ name: "etc.test1",
+ sub_dir: "foo/bar",
+ recovery: true,
+
+}
+`,
+ },
}
func TestEndToEnd(t *testing.T) {
diff --git a/apex/OWNERS b/apex/OWNERS
new file mode 100644
index 0000000..a382ae8
--- /dev/null
+++ b/apex/OWNERS
@@ -0,0 +1 @@
+per-file * = jiyong@google.com
\ No newline at end of file
diff --git a/apex/apex.go b/apex/apex.go
index 46c9dcf..eb791d9 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -177,6 +177,29 @@
}
}
+type apexNativeDependencies struct {
+ // List of native libraries
+ Native_shared_libs []string
+ // List of native executables
+ Binaries []string
+}
+type apexMultilibProperties struct {
+ // Native dependencies whose compile_multilib is "first"
+ First apexNativeDependencies
+
+ // Native dependencies whose compile_multilib is "both"
+ Both apexNativeDependencies
+
+ // Native dependencies whose compile_multilib is "prefer32"
+ Prefer32 apexNativeDependencies
+
+ // Native dependencies whose compile_multilib is "32"
+ Lib32 apexNativeDependencies
+
+ // Native dependencies whose compile_multilib is "64"
+ Lib64 apexNativeDependencies
+}
+
type apexBundleProperties struct {
// Json manifest file describing meta info of this APEX bundle. Default:
// "apex_manifest.json"
@@ -218,36 +241,29 @@
// Default is false.
Use_vendor *bool
- Multilib struct {
- First struct {
- // List of native libraries whose compile_multilib is "first"
- Native_shared_libs []string
- // List of native executables whose compile_multilib is "first"
- Binaries []string
+ // For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
+ Ignore_system_library_special_case *bool
+
+ Multilib apexMultilibProperties
+}
+
+type apexTargetBundleProperties struct {
+ Target struct {
+ // Multilib properties only for android.
+ Android struct {
+ Multilib apexMultilibProperties
}
- Both struct {
- // List of native libraries whose compile_multilib is "both"
- Native_shared_libs []string
- // List of native executables whose compile_multilib is "both"
- Binaries []string
+ // Multilib properties only for host.
+ Host struct {
+ Multilib apexMultilibProperties
}
- Prefer32 struct {
- // List of native libraries whose compile_multilib is "prefer32"
- Native_shared_libs []string
- // List of native executables whose compile_multilib is "prefer32"
- Binaries []string
+ // Multilib properties only for host linux_bionic.
+ Linux_bionic struct {
+ Multilib apexMultilibProperties
}
- Lib32 struct {
- // List of native libraries whose compile_multilib is "32"
- Native_shared_libs []string
- // List of native executables whose compile_multilib is "32"
- Binaries []string
- }
- Lib64 struct {
- // List of native libraries whose compile_multilib is "64"
- Native_shared_libs []string
- // List of native executables whose compile_multilib is "64"
- Binaries []string
+ // Multilib properties only for host linux_glibc.
+ Linux_glibc struct {
+ Multilib apexMultilibProperties
}
}
}
@@ -329,17 +345,18 @@
type apexFile struct {
builtFile android.Path
moduleName string
- archType android.ArchType
installDir string
class apexFileClass
module android.Module
+ symlinks []string
}
type apexBundle struct {
android.ModuleBase
android.DefaultableModuleBase
- properties apexBundleProperties
+ properties apexBundleProperties
+ targetProperties apexTargetBundleProperties
apexTypes apexPackaging
@@ -372,9 +389,26 @@
}, executableTag, binaries...)
}
+func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
+ if ctx.Os().Class == android.Device {
+ proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
+ } else {
+ proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
+ if ctx.Os().Bionic() {
+ proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
+ } else {
+ proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
+ }
+ }
+}
+
func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
+
targets := ctx.MultiTargets()
config := ctx.DeviceConfig()
+
+ a.combineProperties(ctx)
+
has32BitTarget := false
for _, target := range targets {
if target.Arch.ArchType.Multilib == "lib32" {
@@ -396,7 +430,8 @@
a.properties.Multilib.Both.Binaries, target.String(),
a.getImageVariation(config))
- if i == 0 {
+ isPrimaryAbi := i == 0
+ if isPrimaryAbi {
// When multilib.* is omitted for binaries, it implies
// multilib.first.
ctx.AddFarVariationDependencies([]blueprint.Variation{
@@ -483,12 +518,20 @@
}
}
-func (a *apexBundle) IsSanitizerEnabled() bool {
- // APEX can be mutated for sanitizers
- return true
+func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
+ globalSanitizerNames := []string{}
+ if a.Host() {
+ globalSanitizerNames = ctx.Config().SanitizeHost()
+ } else {
+ arches := ctx.Config().SanitizeDeviceArch()
+ if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
+ globalSanitizerNames = ctx.Config().SanitizeDevice()
+ }
+ }
+ return android.InList(sanitizerName, globalSanitizerNames)
}
-func getCopyManifestForNativeLibrary(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
+func getCopyManifestForNativeLibrary(cc *cc.Module, handleSpecialLibs bool) (fileToCopy android.Path, dirInApex string) {
// Decide the APEX-local directory by the multilib of the library
// In the future, we may query this to the module.
switch cc.Arch().ArchType.Multilib {
@@ -497,21 +540,24 @@
case "lib64":
dirInApex = "lib64"
}
+ dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
if !cc.Arch().Native {
dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
}
- switch cc.Name() {
- case "libc", "libm", "libdl":
- // Special case for bionic libs. This is to prevent the bionic libs
- // from being included in the search path /apex/com.android.apex/lib.
- // This exclusion is required because bionic libs in the runtime APEX
- // are available via the legacy paths /system/lib/libc.so, etc. By the
- // init process, the bionic libs in the APEX are bind-mounted to the
- // legacy paths and thus will be loaded into the default linker namespace.
- // If the bionic libs are directly in /apex/com.android.apex/lib then
- // the same libs will be again loaded to the runtime linker namespace,
- // which will result double loading of bionic libs that isn't supported.
- dirInApex = filepath.Join(dirInApex, "bionic")
+ if handleSpecialLibs {
+ switch cc.Name() {
+ case "libc", "libm", "libdl":
+ // Special case for bionic libs. This is to prevent the bionic libs
+ // from being included in the search path /apex/com.android.apex/lib.
+ // This exclusion is required because bionic libs in the runtime APEX
+ // are available via the legacy paths /system/lib/libc.so, etc. By the
+ // init process, the bionic libs in the APEX are bind-mounted to the
+ // legacy paths and thus will be loaded into the default linker namespace.
+ // If the bionic libs are directly in /apex/com.android.apex/lib then
+ // the same libs will be again loaded to the runtime linker namespace,
+ // which will result double loading of bionic libs that isn't supported.
+ dirInApex = filepath.Join(dirInApex, "bionic")
+ }
}
fileToCopy = cc.OutputFile().Path()
@@ -519,6 +565,8 @@
}
func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
+ // TODO(b/123721777) respect relative_install_path also for binaries
+ // dirInApex = filepath.Join("bin", cc.RelativeInstallPath())
dirInApex = "bin"
fileToCopy = cc.OutputFile().Path()
return
@@ -554,6 +602,8 @@
return
}
+ handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
+
ctx.WalkDeps(func(child, parent android.Module) bool {
if _, ok := parent.(*apexBundle); ok {
// direct dependencies
@@ -562,8 +612,8 @@
switch depTag {
case sharedLibTag:
if cc, ok := child.(*cc.Module); ok {
- fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc)
- filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeSharedLib, cc})
+ fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, handleSpecialLibs)
+ filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeSharedLib, cc, nil})
return true
} else {
ctx.PropertyErrorf("native_shared_libs", "%q is not a cc_library or cc_library_shared module", depName)
@@ -576,7 +626,7 @@
return true
}
fileToCopy, dirInApex := getCopyManifestForExecutable(cc)
- filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeExecutable, cc})
+ filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeExecutable, cc, cc.Symlinks()})
return true
} else {
ctx.PropertyErrorf("binaries", "%q is not a cc_binary module", depName)
@@ -587,7 +637,7 @@
if fileToCopy == nil {
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
} else {
- filesInfo = append(filesInfo, apexFile{fileToCopy, depName, java.Arch().ArchType, dirInApex, javaSharedLib, java})
+ filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, javaSharedLib, java, nil})
}
return true
} else {
@@ -596,7 +646,7 @@
case prebuiltTag:
if prebuilt, ok := child.(*android.PrebuiltEtc); ok {
fileToCopy, dirInApex := getCopyManifestForPrebuiltEtc(prebuilt)
- filesInfo = append(filesInfo, apexFile{fileToCopy, depName, prebuilt.Arch().ArchType, dirInApex, etc, prebuilt})
+ filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, etc, prebuilt, nil})
return true
} else {
ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
@@ -630,8 +680,8 @@
return false
}
depName := ctx.OtherModuleName(child)
- fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc)
- filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeSharedLib, cc})
+ fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc, handleSpecialLibs)
+ filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeSharedLib, cc, nil})
return true
}
}
@@ -724,6 +774,10 @@
dest_path := filepath.Join(android.PathForModuleOut(ctx, "image"+suffix).String(), dest)
copyCommands = append(copyCommands, "mkdir -p "+filepath.Dir(dest_path))
copyCommands = append(copyCommands, "cp "+src.String()+" "+dest_path)
+ for _, sym := range a.filesInfo[i].symlinks {
+ symlinkDest := filepath.Join(filepath.Dir(dest_path), sym)
+ copyCommands = append(copyCommands, "ln -s "+filepath.Base(dest)+" "+symlinkDest)
+ }
}
implicitInputs := append(android.Paths(nil), filesToCopy...)
implicitInputs = append(implicitInputs, manifest)
@@ -739,6 +793,9 @@
pathInApex := filepath.Join(f.installDir, f.builtFile.Base())
if f.installDir == "bin" {
executablePaths = append(executablePaths, pathInApex)
+ for _, s := range f.symlinks {
+ executablePaths = append(executablePaths, filepath.Join("bin", s))
+ }
} else {
readOnlyPaths = append(readOnlyPaths, pathInApex)
}
@@ -871,7 +928,7 @@
Input: manifest,
Output: copiedManifest,
})
- a.filesInfo = append(a.filesInfo, apexFile{copiedManifest, ctx.ModuleName() + ".apex_manifest.json", android.Common, ".", etc, nil})
+ a.filesInfo = append(a.filesInfo, apexFile{copiedManifest, ctx.ModuleName() + ".apex_manifest.json", ".", etc, nil, nil})
for _, fi := range a.filesInfo {
dir := filepath.Join("apex", ctx.ModuleName(), fi.installDir)
@@ -897,57 +954,92 @@
}
func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkData {
- // Only image APEXes can be flattened.
- if a.flattened && apexType.image() {
- return android.AndroidMkData{
- Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
- moduleNames := []string{}
- for _, fi := range a.filesInfo {
- if !android.InList(fi.moduleName, moduleNames) {
- moduleNames = append(moduleNames, fi.moduleName)
+ return android.AndroidMkData{
+ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ moduleNames := []string{}
+ for _, fi := range a.filesInfo {
+ if !android.InList(fi.moduleName, moduleNames) {
+ moduleNames = append(moduleNames, fi.moduleName)
+ }
+ }
+
+ for _, fi := range a.filesInfo {
+ if cc, ok := fi.module.(*cc.Module); ok && cc.Properties.HideFromMake {
+ continue
+ }
+ fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
+ fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
+ fmt.Fprintln(w, "LOCAL_MODULE :=", fi.moduleName)
+ if a.flattened {
+ // /system/apex/<name>/{lib|framework|...}
+ fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)",
+ a.installDir.RelPathString(), name, fi.installDir))
+ } else {
+ // /apex/<name>/{lib|framework|...}
+ fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(PRODUCT_OUT)",
+ "apex", name, fi.installDir))
+ }
+ fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
+ fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake())
+ fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
+ if fi.module != nil {
+ archStr := fi.module.Target().Arch.ArchType.String()
+ host := false
+ switch fi.module.Target().Os.Class {
+ case android.Host:
+ if archStr != "common" {
+ fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
+ }
+ host = true
+ case android.HostCross:
+ if archStr != "common" {
+ fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
+ }
+ host = true
+ case android.Device:
+ if archStr != "common" {
+ fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
+ }
+ }
+ if host {
+ makeOs := fi.module.Target().Os.String()
+ if fi.module.Target().Os == android.Linux || fi.module.Target().Os == android.LinuxBionic {
+ makeOs = "linux"
+ }
+ fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
+ fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
}
}
+ if fi.class == javaSharedLib {
+ javaModule := fi.module.(*java.Library)
+ // soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
+ // we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
+ // we will have foo.jar.jar
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.builtFile.Base(), ".jar"))
+ fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
+ fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
+ fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String())
+ fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
+ fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
+ } else if fi.class == nativeSharedLib || fi.class == nativeExecutable {
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base())
+ if cc, ok := fi.module.(*cc.Module); ok && cc.UnstrippedOutputFile() != nil {
+ fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", cc.UnstrippedOutputFile().String())
+ }
+ fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk")
+ } else {
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base())
+ fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
+ }
+ }
+ if a.flattened && apexType.image() {
+ // Only image APEXes can be flattened.
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
fmt.Fprintln(w, "LOCAL_MODULE :=", name)
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
-
- for _, fi := range a.filesInfo {
- if cc, ok := fi.module.(*cc.Module); ok && cc.Properties.HideFromMake {
- continue
- }
- fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
- fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
- fmt.Fprintln(w, "LOCAL_MODULE :=", fi.moduleName)
- fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString(), name, fi.installDir))
- fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
- fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake())
- fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
- archStr := fi.archType.String()
- if archStr != "common" {
- fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
- }
- if fi.class == javaSharedLib {
- javaModule := fi.module.(*java.Library)
- // soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
- // we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
- // we will have foo.jar.jar
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.builtFile.Base(), ".jar"))
- fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
- fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
- fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String())
- fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
- fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
- } else {
- fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base())
- fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
- }
- }
- }}
- } else {
- return android.AndroidMkData{
- Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ } else {
// zip-apex is the less common type so have the name refer to the image-apex
// only and use {name}.zip if you want the zip-apex
if apexType == zipApex && a.apexTypes == both {
@@ -962,13 +1054,14 @@
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix())
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(a.properties.Key))
+ fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
if apexType == imageApex {
fmt.Fprintln(w, "ALL_MODULES.$(LOCAL_MODULE).BUNDLE :=", a.bundleModuleFile.String())
}
- }}
- }
+ }
+ }}
}
func ApexBundleFactory() android.Module {
@@ -976,6 +1069,7 @@
outputFiles: map[apexPackaging]android.WritablePath{},
}
module.AddProperties(&module.properties)
+ module.AddProperties(&module.targetProperties)
module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
})
diff --git a/apex/apex_test.go b/apex/apex_test.go
index dbc85d9..1315c25 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -41,6 +41,7 @@
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory))
+ ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(cc.LibraryHeaderFactory))
ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(cc.BinaryFactory))
ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory))
ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory))
@@ -106,6 +107,16 @@
recovery_available: true,
}
+ cc_object {
+ name: "crtbegin_static",
+ stl: "none",
+ }
+
+ cc_object {
+ name: "crtend_android",
+ stl: "none",
+ }
+
llndk_library {
name: "libc",
symbol_file: "",
@@ -123,16 +134,18 @@
`
ctx.MockFileSystem(map[string][]byte{
- "Android.bp": []byte(bp),
- "build/target/product/security": nil,
- "apex_manifest.json": nil,
- "system/sepolicy/apex/myapex-file_contexts": nil,
- "mylib.cpp": nil,
- "myprebuilt": nil,
- "vendor/foo/devkeys/test.x509.pem": nil,
- "vendor/foo/devkeys/test.pk8": nil,
- "vendor/foo/devkeys/testkey.avbpubkey": nil,
- "vendor/foo/devkeys/testkey.pem": nil,
+ "Android.bp": []byte(bp),
+ "build/target/product/security": nil,
+ "apex_manifest.json": nil,
+ "system/sepolicy/apex/myapex-file_contexts": nil,
+ "system/sepolicy/apex/otherapex-file_contexts": nil,
+ "mylib.cpp": nil,
+ "myprebuilt": nil,
+ "my_include": nil,
+ "vendor/foo/devkeys/test.x509.pem": nil,
+ "vendor/foo/devkeys/test.pk8": nil,
+ "vendor/foo/devkeys/testkey.avbpubkey": nil,
+ "vendor/foo/devkeys/testkey.pem": nil,
})
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
@@ -191,6 +204,11 @@
name: "myapex",
key: "myapex.key",
native_shared_libs: ["mylib"],
+ multilib: {
+ both: {
+ binaries: ["foo",],
+ }
+ }
}
apex_key {
@@ -207,6 +225,25 @@
stl: "none",
}
+ cc_binary {
+ name: "foo",
+ srcs: ["mylib.cpp"],
+ compile_multilib: "both",
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
+ symlinks: ["foo_link_"],
+ symlink_preferred_arch: true,
+ system_shared_libs: [],
+ static_executable: true,
+ stl: "none",
+ }
+
cc_library {
name: "mylib2",
srcs: ["mylib.cpp"],
@@ -234,6 +271,23 @@
// Ensure that the platform variant ends with _core_shared
ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared")
ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared")
+
+ // Ensure that all symlinks are present.
+ found_foo_link_64 := false
+ found_foo := false
+ for _, cmd := range strings.Split(copyCmds, " && ") {
+ if strings.HasPrefix(cmd, "ln -s foo64") {
+ if strings.HasSuffix(cmd, "bin/foo") {
+ found_foo = true
+ } else if strings.HasSuffix(cmd, "bin/foo_link_64") {
+ found_foo_link_64 = true
+ }
+ }
+ }
+ good := found_foo && found_foo_link_64
+ if !good {
+ t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_foo, found_foo_link_64, copyCmds)
+ }
}
func TestBasicZipApex(t *testing.T) {
@@ -561,7 +615,10 @@
apex {
name: "myapex",
key: "myapex.key",
+ native_shared_libs: ["mylib"],
+ binaries: ["mybin"],
prebuilts: ["myetc"],
+ compile_multilib: "both",
}
apex_key {
@@ -575,15 +632,43 @@
src: "myprebuilt",
sub_dir: "foo/bar",
}
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ relative_install_path: "foo/bar",
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_binary {
+ name: "mybin",
+ srcs: ["mylib.cpp"],
+ relative_install_path: "foo/bar",
+ system_shared_libs: [],
+ static_executable: true,
+ stl: "none",
+ }
`)
generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig")
dirs := strings.Split(generateFsRule.Args["exec_paths"], " ")
- // Ensure that etc, etc/foo, and etc/foo/bar are all listed
+ // Ensure that the subdirectories are all listed
ensureListContains(t, dirs, "etc")
ensureListContains(t, dirs, "etc/foo")
ensureListContains(t, dirs, "etc/foo/bar")
+ ensureListContains(t, dirs, "lib64")
+ ensureListContains(t, dirs, "lib64/foo")
+ ensureListContains(t, dirs, "lib64/foo/bar")
+ ensureListContains(t, dirs, "lib")
+ ensureListContains(t, dirs, "lib/foo")
+ ensureListContains(t, dirs, "lib/foo/bar")
+
+ // TODO(b/123721777) respect relative path for binaries
+ // ensureListContains(t, dirs, "bin")
+ // ensureListContains(t, dirs, "bin/foo")
+ // ensureListContains(t, dirs, "bin/foo/bar")
}
func TestUseVendor(t *testing.T) {
@@ -668,17 +753,6 @@
system_shared_libs: [],
stl: "none",
}
-
- cc_object {
- name: "crtbegin_static",
- stl: "none",
- }
-
- cc_object {
- name: "crtend_android",
- stl: "none",
- }
-
`)
ldFlags := ctx.ModuleForTests("not_in_apex", "android_arm64_armv8-a_core").Rule("ld").Args["libFlags"]
@@ -729,3 +803,175 @@
"vendor/foo/devkeys/test.x509.pem vendor/foo/devkeys/test.pk8")
}
}
+
+func TestMacro(t *testing.T) {
+ ctx := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ native_shared_libs: ["mylib"],
+ }
+
+ apex {
+ name: "otherapex",
+ key: "myapex.key",
+ native_shared_libs: ["mylib"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ // non-APEX variant does not have __ANDROID__APEX__ defined
+ mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"]
+ ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex")
+ ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex")
+
+ // APEX variant has __ANDROID_APEX__=<apexname> defined
+ mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"]
+ ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex")
+ ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex")
+
+ // APEX variant has __ANDROID_APEX__=<apexname> defined
+ mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_otherapex").Rule("cc").Args["cFlags"]
+ ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex")
+ ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex")
+}
+
+func TestHeaderLibsDependency(t *testing.T) {
+ ctx := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ native_shared_libs: ["mylib"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library_headers {
+ name: "mylib_headers",
+ export_include_dirs: ["my_include"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ header_libs: ["mylib_headers"],
+ export_header_lib_headers: ["mylib_headers"],
+ stubs: {
+ versions: ["1", "2", "3"],
+ },
+ }
+
+ cc_library {
+ name: "otherlib",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ shared_libs: ["mylib"],
+ }
+ `)
+
+ cFlags := ctx.ModuleForTests("otherlib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"]
+
+ // Ensure that the include path of the header lib is exported to 'otherlib'
+ ensureContains(t, cFlags, "-Imy_include")
+}
+
+func TestApexWithTarget(t *testing.T) {
+ ctx := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ multilib: {
+ first: {
+ native_shared_libs: ["mylib_common"],
+ }
+ },
+ target: {
+ android: {
+ multilib: {
+ first: {
+ native_shared_libs: ["mylib"],
+ }
+ }
+ },
+ host: {
+ multilib: {
+ first: {
+ native_shared_libs: ["mylib2"],
+ }
+ }
+ }
+ }
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library {
+ name: "mylib_common",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ compile_multilib: "first",
+ }
+
+ cc_library {
+ name: "mylib2",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ compile_multilib: "first",
+ }
+ `)
+
+ apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
+ copyCmds := apexRule.Args["copy_commands"]
+
+ // Ensure that main rule creates an output
+ 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")
+
+ // 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")
+}
diff --git a/apex/key.go b/apex/key.go
index 7e98d2b..6d1032d 100644
--- a/apex/key.go
+++ b/apex/key.go
@@ -19,6 +19,7 @@
"io"
"android/soong/android"
+
"github.com/google/blueprint/proptools"
)
@@ -61,9 +62,6 @@
return m.properties.Installable == nil || proptools.Bool(m.properties.Installable)
}
-func (m *apexKey) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func (m *apexKey) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild() {
// Flattened APEXes are not signed
diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go
index 6a75517..11f1877 100644
--- a/bpfix/bpfix/bpfix.go
+++ b/bpfix/bpfix/bpfix.go
@@ -83,6 +83,10 @@
fix: rewriteJavaStaticLibs,
},
{
+ name: "rewritePrebuiltEtc",
+ fix: rewriteAndroidmkPrebuiltEtc,
+ },
+ {
name: "mergeMatchingModuleProperties",
fix: runPatchListMod(mergeMatchingModuleProperties),
},
@@ -407,6 +411,156 @@
return nil
}
+// Helper function to get the value of a string-valued property in a given compound property.
+func getStringProperty(prop *parser.Property, fieldName string) string {
+ if propsAsMap, ok := prop.Value.(*parser.Map); ok {
+ for _, propField := range propsAsMap.Properties {
+ if fieldName == propField.Name {
+ if propFieldAsString, ok := propField.Value.(*parser.String); ok {
+ return propFieldAsString.Value
+ } else {
+ return ""
+ }
+ }
+ }
+ }
+ return ""
+}
+
+// Create sub_dir: attribute for the given path
+func makePrebuiltEtcDestination(mod *parser.Module, path string) {
+ mod.Properties = append(mod.Properties, &parser.Property{
+ Name: "sub_dir",
+ Value: &parser.String{Value: path},
+ })
+}
+
+// Set the value of the given attribute to the error message
+func indicateAttributeError(mod *parser.Module, attributeName string, format string, a ...interface{}) error {
+ msg := fmt.Sprintf(format, a...)
+ mod.Properties = append(mod.Properties, &parser.Property{
+ Name: attributeName,
+ Value: &parser.String{Value: "ERROR: " + msg},
+ })
+ return errors.New(msg)
+}
+
+// If a variable is LOCAL_MODULE, get its value from the 'name' attribute.
+// This handles the statement
+// LOCAL_SRC_FILES := $(LOCAL_MODULE)
+// which occurs often.
+func resolveLocalModule(mod *parser.Module, val parser.Expression) parser.Expression {
+ if varLocalName, ok := val.(*parser.Variable); ok {
+ if varLocalName.Name == "LOCAL_MODULE" {
+ if v, ok := getLiteralStringProperty(mod, "name"); ok {
+ return v
+ }
+ }
+ }
+ return val
+}
+
+// A prefix to strip before setting 'filename' attribute and an array of boolean attributes to set.
+type filenamePrefixToFlags struct {
+ prefix string
+ flags []string
+}
+
+var localModulePathRewrite = map[string][]filenamePrefixToFlags{
+ "HOST_OUT": {{prefix: "/etc"}},
+ "PRODUCT_OUT": {{prefix: "/system/etc"}, {prefix: "/vendor/etc", flags: []string{"proprietary"}}},
+ "TARGET_OUT": {{prefix: "/etc"}},
+ "TARGET_OUT_ETC": {{prefix: ""}},
+ "TARGET_OUT_PRODUCT": {{prefix: "/etc", flags: []string{"product_specific"}}},
+ "TARGET_OUT_PRODUCT_ETC": {{prefix: "", flags: []string{"product_specific"}}},
+ "TARGET_OUT_ODM": {{prefix: "/etc", flags: []string{"device_specific"}}},
+ "TARGET_OUT_PRODUCT_SERVICES": {{prefix: "/etc", flags: []string{"product_services_specific"}}},
+ "TARGET_OUT_PRODUCT_SERVICES_ETC": {{prefix: "", flags: []string{"product_services_specific"}}},
+ "TARGET_OUT_VENDOR": {{prefix: "/etc", flags: []string{"proprietary"}}},
+ "TARGET_OUT_VENDOR_ETC": {{prefix: "", flags: []string{"proprietary"}}},
+ "TARGET_RECOVERY_ROOT_OUT": {{prefix: "/system/etc", flags: []string{"recovery"}}},
+}
+
+// rewriteAndroidPrebuiltEtc fixes prebuilt_etc rule
+func rewriteAndroidmkPrebuiltEtc(f *Fixer) error {
+ for _, def := range f.tree.Defs {
+ mod, ok := def.(*parser.Module)
+ if !ok {
+ continue
+ }
+
+ if mod.Type != "prebuilt_etc" && mod.Type != "prebuilt_etc_host" {
+ continue
+ }
+
+ // The rewriter converts LOCAL_SRC_FILES to `srcs` attribute. Convert
+ // it to 'src' attribute (which is where the file is installed). If the
+ // value 'srcs' is a list, we can convert it only if it contains a single
+ // element.
+ if srcs, ok := mod.GetProperty("srcs"); ok {
+ if srcList, ok := srcs.Value.(*parser.List); ok {
+ removeProperty(mod, "srcs")
+ if len(srcList.Values) == 1 {
+ mod.Properties = append(mod.Properties,
+ &parser.Property{Name: "src", NamePos: srcs.NamePos, ColonPos: srcs.ColonPos, Value: resolveLocalModule(mod, srcList.Values[0])})
+ } else if len(srcList.Values) > 1 {
+ indicateAttributeError(mod, "src", "LOCAL_SRC_FILES should contain at most one item")
+ }
+ } else if _, ok = srcs.Value.(*parser.Variable); ok {
+ removeProperty(mod, "srcs")
+ mod.Properties = append(mod.Properties,
+ &parser.Property{Name: "src", NamePos: srcs.NamePos, ColonPos: srcs.ColonPos, Value: resolveLocalModule(mod, srcs.Value)})
+ } else {
+ renameProperty(mod, "srcs", "src")
+ }
+ }
+
+ // The rewriter converts LOCAL_MODULE_PATH attribute into a struct attribute
+ // 'local_module_path'. Analyze its contents and create the correct sub_dir:,
+ // filename: and boolean attributes combination
+ const local_module_path = "local_module_path"
+ if prop_local_module_path, ok := mod.GetProperty(local_module_path); ok {
+ removeProperty(mod, local_module_path)
+ prefixVariableName := getStringProperty(prop_local_module_path, "var")
+ path := getStringProperty(prop_local_module_path, "fixed")
+ if prefixRewrites, ok := localModulePathRewrite[prefixVariableName]; ok {
+ rewritten := false
+ for _, prefixRewrite := range prefixRewrites {
+ if path == prefixRewrite.prefix {
+ rewritten = true
+ } else if trimmedPath := strings.TrimPrefix(path, prefixRewrite.prefix+"/"); trimmedPath != path {
+ makePrebuiltEtcDestination(mod, trimmedPath)
+ rewritten = true
+ }
+ if rewritten {
+ for _, flag := range prefixRewrite.flags {
+ mod.Properties = append(mod.Properties, &parser.Property{Name: flag, Value: &parser.Bool{Value: true, Token: "true"}})
+ }
+ break
+ }
+ }
+ if !rewritten {
+ expectedPrefices := ""
+ sep := ""
+ for _, prefixRewrite := range prefixRewrites {
+ expectedPrefices += sep
+ sep = ", "
+ expectedPrefices += prefixRewrite.prefix
+ }
+ return indicateAttributeError(mod, "filename",
+ "LOCAL_MODULE_PATH value under $(%s) should start with %s", prefixVariableName, expectedPrefices)
+ }
+ if prefixVariableName == "HOST_OUT" {
+ mod.Type = "prebuilt_etc_host"
+ }
+ } else {
+ return indicateAttributeError(mod, "filename", "Cannot handle $(%s) for the prebuilt_etc", prefixVariableName)
+ }
+ }
+ }
+ return nil
+}
+
func runPatchListMod(modFunc func(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error) func(*Fixer) error {
return func(f *Fixer) error {
// Make sure all the offsets are accurate
diff --git a/bpfix/bpfix/bpfix_test.go b/bpfix/bpfix/bpfix_test.go
index 5224ee3..1394223 100644
--- a/bpfix/bpfix/bpfix_test.go
+++ b/bpfix/bpfix/bpfix_test.go
@@ -692,3 +692,62 @@
})
}
}
+
+func TestRewritePrebuiltEtc(t *testing.T) {
+ tests := []struct {
+ name string
+ in string
+ out string
+ }{
+ {
+ name: "prebuilt_etc src",
+ in: `
+ prebuilt_etc {
+ name: "foo",
+ srcs: ["bar"],
+ }
+ `,
+ out: `prebuilt_etc {
+ name: "foo",
+ src: "bar",
+ }
+ `,
+ },
+ {
+ name: "prebuilt_etc src",
+ in: `
+ prebuilt_etc {
+ name: "foo",
+ srcs: FOO,
+ }
+ `,
+ out: `prebuilt_etc {
+ name: "foo",
+ src: FOO,
+ }
+ `,
+ },
+ {
+ name: "prebuilt_etc src",
+ in: `
+ prebuilt_etc {
+ name: "foo",
+ srcs: ["bar", "baz"],
+ }
+ `,
+ out: `prebuilt_etc {
+ name: "foo",
+ src: "ERROR: LOCAL_SRC_FILES should contain at most one item",
+
+ }
+ `,
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ runPass(t, test.in, test.out, func(fixer *Fixer) error {
+ return rewriteAndroidmkPrebuiltEtc(fixer)
+ })
+ })
+ }
+}
diff --git a/cc/binary.go b/cc/binary.go
index 65e8eb5..4794815 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -249,7 +249,11 @@
} else {
switch ctx.Os() {
case android.Android:
- flags.DynamicLinker = "/system/bin/linker"
+ if ctx.bootstrap() {
+ flags.DynamicLinker = "/system/bin/bootstrap/linker"
+ } else {
+ flags.DynamicLinker = "/system/bin/linker"
+ }
if flags.Toolchain.Is64Bit() {
flags.DynamicLinker += "64"
}
@@ -313,9 +317,9 @@
builderFlags := flagsToBuilderFlags(flags)
if binary.stripper.needsStrip(ctx) {
- // b/80093681, GNU strip/objcopy bug.
- // Use llvm-{strip,objcopy} when clang lld is used.
- builderFlags.stripUseLlvmStrip = binary.baseLinker.useClangLld(ctx)
+ if ctx.Darwin() {
+ builderFlags.stripUseGnuStrip = true
+ }
strippedOutputFile := outputFile
outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
binary.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
@@ -382,11 +386,8 @@
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
binary.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, binary.getStem(ctx))
- return ret
-}
-
-func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) {
- binary.baseInstaller.install(ctx, file)
+ // Need to determine symlinks early since some targets (ie APEX) need this
+ // information but will not call 'install'
for _, symlink := range binary.Properties.Symlinks {
binary.symlinks = append(binary.symlinks,
symlink+String(binary.Properties.Suffix)+ctx.toolchain().ExecutableSuffix())
@@ -401,6 +402,19 @@
}
}
+ return ret
+}
+
+func (binary *binaryDecorator) unstrippedOutputFilePath() android.Path {
+ return binary.unstrippedOutputFile
+}
+
+func (binary *binaryDecorator) symlinkList() []string {
+ return binary.symlinks
+}
+
+func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) {
+ binary.baseInstaller.install(ctx, file)
for _, symlink := range binary.symlinks {
ctx.InstallSymlink(binary.baseInstaller.installDir(ctx), symlink, binary.baseInstaller.path)
}
diff --git a/cc/builder.go b/cc/builder.go
index 5dbd23e..6e24d56 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -199,7 +199,7 @@
// TODO(b/78139997): Add -check-all-apis back
commandStr := "($sAbiDiffer $allowFlags -lib $libName -arch $arch -o ${out} -new $in -old $referenceDump)"
commandStr += "|| (echo ' ---- Please update abi references by running $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l ${libName} ----'"
- commandStr += " && (mkdir -p $$DIST_DIR/abidiffs && cp ${out} $$DIST_DIR/abidiff/)"
+ commandStr += " && (mkdir -p $$DIST_DIR/abidiffs && cp ${out} $$DIST_DIR/abidiffs/)"
commandStr += " && exit 1)"
return blueprint.RuleParams{
Command: commandStr,
@@ -255,7 +255,7 @@
stripKeepSymbols bool
stripKeepMiniDebugInfo bool
stripAddGnuDebuglink bool
- stripUseLlvmStrip bool
+ stripUseGnuStrip bool
protoDeps android.Paths
protoFlags string
@@ -663,18 +663,33 @@
// Generate a rule to combine .dump sAbi dump files from multiple source files
// into a single .ldump sAbi dump file
func TransformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Paths, soFile android.Path,
- baseName, exportedHeaderFlags string) android.OptionalPath {
+ baseName, exportedHeaderFlags string, symbolFile android.OptionalPath,
+ excludedSymbolVersions, excludedSymbolTags []string) android.OptionalPath {
+
outputFile := android.PathForModuleOut(ctx, baseName+".lsdump")
sabiLock.Lock()
lsdumpPaths = append(lsdumpPaths, outputFile.String())
sabiLock.Unlock()
+
+ implicits := android.Paths{soFile}
symbolFilterStr := "-so " + soFile.String()
+
+ if symbolFile.Valid() {
+ implicits = append(implicits, symbolFile.Path())
+ symbolFilterStr += " -v " + symbolFile.String()
+ }
+ for _, ver := range excludedSymbolVersions {
+ symbolFilterStr += " --exclude-symbol-version " + ver
+ }
+ for _, tag := range excludedSymbolTags {
+ symbolFilterStr += " --exclude-symbol-tag " + tag
+ }
ctx.Build(pctx, android.BuildParams{
Rule: sAbiLink,
Description: "header-abi-linker " + outputFile.Base(),
Output: outputFile,
Inputs: sAbiDumps,
- Implicit: soFile,
+ Implicits: implicits,
Args: map[string]string{
"symbolFilter": symbolFilterStr,
"arch": ctx.Arch().ArchType.Name,
@@ -806,8 +821,8 @@
if flags.stripKeepSymbols {
args += " --keep-symbols"
}
- if flags.stripUseLlvmStrip {
- args += " --use-llvm-strip"
+ if flags.stripUseGnuStrip {
+ args += " --use-gnu-strip"
}
ctx.Build(pctx, android.BuildParams{
diff --git a/cc/cc.go b/cc/cc.go
index baee70a..02f36d5 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -258,9 +258,10 @@
getVndkExtendsModuleName() string
isPgoCompile() bool
useClangLld(actx ModuleContext) bool
- isApex() bool
+ apexName() string
hasStubsVariants() bool
isStubs() bool
+ bootstrap() bool
}
type ModuleContext interface {
@@ -305,6 +306,7 @@
link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
appendLdflags([]string)
+ unstrippedOutputFilePath() android.Path
}
type installer interface {
@@ -313,6 +315,7 @@
inData() bool
inSanitizerDir() bool
hostToolPath() android.OptionalPath
+ relativeInstallPath() string
}
type dependencyTag struct {
@@ -404,6 +407,20 @@
return c.outputFile
}
+func (c *Module) UnstrippedOutputFile() android.Path {
+ if c.linker != nil {
+ return c.linker.unstrippedOutputFilePath()
+ }
+ return nil
+}
+
+func (c *Module) RelativeInstallPath() string {
+ if c.installer != nil {
+ return c.installer.relativeInstallPath()
+ }
+ return ""
+}
+
func (c *Module) Init() android.Module {
c.AddProperties(&c.Properties, &c.VendorProperties)
if c.compiler != nil {
@@ -562,6 +579,10 @@
return false
}
+func (c *Module) bootstrap() bool {
+ return Bool(c.Properties.Bootstrap)
+}
+
type baseModuleContext struct {
android.BaseContext
moduleContextImpl
@@ -720,9 +741,8 @@
return ctx.mod.getVndkExtendsModuleName()
}
-// Tests if this module is built for APEX
-func (ctx *moduleContextImpl) isApex() bool {
- return ctx.mod.ApexName() != ""
+func (ctx *moduleContextImpl) apexName() string {
+ return ctx.mod.ApexName()
}
func (ctx *moduleContextImpl) hasStubsVariants() bool {
@@ -733,6 +753,10 @@
return ctx.mod.IsStubs()
}
+func (ctx *moduleContextImpl) bootstrap() bool {
+ return ctx.mod.bootstrap()
+}
+
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
return &Module{
hod: hod,
@@ -773,6 +797,15 @@
return name
}
+func (c *Module) Symlinks() []string {
+ if p, ok := c.installer.(interface {
+ symlinkList() []string
+ }); ok {
+ return p.symlinkList()
+ }
+ return nil
+}
+
// orderDeps reorders dependencies into a list such that if module A depends on B, then
// A will precede B in the resultant list.
// This is convenient for passing into a linker.
@@ -1143,11 +1176,11 @@
deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders)
}
+ buildStubs := false
if c.linker != nil {
if library, ok := c.linker.(*libraryDecorator); ok {
if library.buildStubs() {
- // Stubs lib does not have dependency to other libraries. Don't proceed.
- return
+ buildStubs = true
}
}
}
@@ -1157,7 +1190,20 @@
if inList(lib, deps.ReexportHeaderLibHeaders) {
depTag = headerExportDepTag
}
- actx.AddVariationDependencies(nil, depTag, lib)
+ if buildStubs {
+ actx.AddFarVariationDependencies([]blueprint.Variation{
+ {Mutator: "arch", Variation: ctx.Target().String()},
+ {Mutator: "image", Variation: c.imageVariation()},
+ }, depTag, lib)
+ } else {
+ actx.AddVariationDependencies(nil, depTag, lib)
+ }
+ }
+
+ if buildStubs {
+ // Stubs lib does not have dependency to other static/shared libraries.
+ // Don't proceed.
+ return
}
actx.AddVariationDependencies([]blueprint.Variation{
@@ -1523,7 +1569,7 @@
// If not building for APEX, use stubs only when it is from
// an APEX (and not from platform)
useThisDep = (depInPlatform != depIsStubs)
- if c.inRecovery() || Bool(c.Properties.Bootstrap) {
+ if c.inRecovery() || c.bootstrap() {
// However, for recovery or bootstrap modules,
// always link to non-stub variant
useThisDep = !depIsStubs
@@ -1809,6 +1855,16 @@
return false
}
+func (c *Module) imageVariation() string {
+ variation := "core"
+ if c.useVndk() {
+ variation = "vendor"
+ } else if c.inRecovery() {
+ variation = "recovery"
+ }
+ return variation
+}
+
//
// Defaults
//
@@ -1821,9 +1877,6 @@
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
-func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func defaultsFactory() android.Module {
return DefaultsFactory()
}
diff --git a/cc/compdb.go b/cc/compdb.go
index 4dfc55b..1102651 100644
--- a/cc/compdb.go
+++ b/cc/compdb.go
@@ -170,14 +170,14 @@
return
}
- pathToCC, err := ctx.Eval(pctx, "${config.ClangBin}/")
+ rootDir := getCompdbAndroidSrcRootDirectory(ctx)
+ pathToCC, err := ctx.Eval(pctx, rootDir+"/${config.ClangBin}/")
ccPath := "/bin/false"
cxxPath := "/bin/false"
if err == nil {
ccPath = pathToCC + "clang"
cxxPath = pathToCC + "clang++"
}
- rootDir := getCompdbAndroidSrcRootDirectory(ctx)
for _, src := range srcs {
if _, ok := builds[src.String()]; !ok {
builds[src.String()] = compDbEntry{
diff --git a/cc/compiler.go b/cc/compiler.go
index 63d2ade..fbe10b5 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -341,6 +341,10 @@
flags.GlobalFlags = append(flags.GlobalFlags, "-D__ANDROID_RECOVERY__")
}
+ if ctx.apexName() != "" {
+ flags.GlobalFlags = append(flags.GlobalFlags, "-D__ANDROID_APEX__="+ctx.apexName())
+ }
+
instructionSet := String(compiler.Properties.Instruction_set)
if flags.RequiredInstructionSet != "" {
instructionSet = flags.RequiredInstructionSet
diff --git a/cc/config/global.go b/cc/config/global.go
index ff11a8a..689b315 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-r346389c"
- ClangDefaultShortVersion = "8.0.7"
+ ClangDefaultVersion = "clang-r349610"
+ ClangDefaultShortVersion = "8.0.8"
// Directories with warnings from Android.bp files.
WarningAllowedProjects = []string{
@@ -176,7 +176,6 @@
"hardware/libhardware/include",
"hardware/libhardware_legacy/include",
"hardware/ril/include",
- "libnativehelper/include",
"frameworks/native/include",
"frameworks/native/opengl/include",
"frameworks/av/include",
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index 8da21b3..f072f34 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -111,14 +111,22 @@
)
const (
- linuxGccVersion = "4.8"
+ linuxGccVersion = "4.8.3"
+ linuxGlibcVersion = "2.17"
)
func init() {
pctx.StaticVariable("LinuxGccVersion", linuxGccVersion)
+ pctx.StaticVariable("LinuxGlibcVersion", linuxGlibcVersion)
+ // Most places use the full GCC version. A few only use up to the first two numbers.
+ if p := strings.Split(linuxGccVersion, "."); len(p) > 2 {
+ pctx.StaticVariable("ShortLinuxGccVersion", strings.Join(p[:2], "."))
+ } else {
+ pctx.StaticVariable("ShortLinuxGccVersion", linuxGccVersion)
+ }
pctx.SourcePathVariable("LinuxGccRoot",
- "prebuilts/gcc/${HostPrebuiltTag}/host/x86_64-linux-glibc2.15-${LinuxGccVersion}")
+ "prebuilts/gcc/${HostPrebuiltTag}/host/x86_64-linux-glibc${LinuxGlibcVersion}-${ShortLinuxGccVersion}")
pctx.StaticVariable("LinuxGccTriple", "x86_64-linux")
diff --git a/cc/installer.go b/cc/installer.go
index 33f29f2..bd8f9e7 100644
--- a/cc/installer.go
+++ b/cc/installer.go
@@ -73,7 +73,7 @@
dir = filepath.Join(dir, "vendor")
}
return android.PathForModuleInstall(ctx, dir, installer.subDir,
- String(installer.Properties.Relative_install_path), installer.relative)
+ installer.relativeInstallPath(), installer.relative)
}
func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {
@@ -91,3 +91,7 @@
func (installer *baseInstaller) hostToolPath() android.OptionalPath {
return android.OptionalPath{}
}
+
+func (installer *baseInstaller) relativeInstallPath() string {
+ return String(installer.Properties.Relative_install_path)
+}
diff --git a/cc/library.go b/cc/library.go
index ad07db4..d716ffa 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -87,6 +87,19 @@
// binaries would be installed by default (in PRODUCT_PACKAGES) the other library will be removed
// from PRODUCT_PACKAGES.
Overrides []string
+
+ // Properties for ABI compatibility checker
+ Header_abi_checker struct {
+ // Path to a symbol file that specifies the symbols to be included in the generated
+ // ABI dump file
+ Symbol_file *string
+
+ // Symbol versions that should be ignored from the symbol file
+ Exclude_symbol_versions []string
+
+ // Symbol tags that should be ignored from the symbol file
+ Exclude_symbol_tags []string
+ }
}
type LibraryMutatedProperties struct {
@@ -567,11 +580,15 @@
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs)
deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Vendor.Exclude_shared_libs)
deps.StaticLibs = removeListFromList(deps.StaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs)
+ deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, library.baseLinker.Properties.Target.Vendor.Exclude_shared_libs)
+ deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs)
}
if ctx.inRecovery() {
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs)
deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Recovery.Exclude_shared_libs)
deps.StaticLibs = removeListFromList(deps.StaticLibs, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs)
+ deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, library.baseLinker.Properties.Target.Recovery.Exclude_shared_libs)
+ deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs)
}
android.ExtractSourceDeps(ctx, library.Properties.Unexported_symbols_list)
@@ -669,9 +686,9 @@
TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
if library.stripper.needsStrip(ctx) {
- // b/80093681, GNU strip/objcopy bug.
- // Use llvm-{strip,objcopy} when clang lld is used.
- builderFlags.stripUseLlvmStrip = library.baseLinker.useClangLld(ctx)
+ if ctx.Darwin() {
+ builderFlags.stripUseGnuStrip = true
+ }
strippedOutputFile := outputFile
outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
library.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
@@ -723,6 +740,10 @@
return ret
}
+func (library *libraryDecorator) unstrippedOutputFilePath() android.Path {
+ return library.unstrippedOutputFile
+}
+
func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
isLlndk := inList(ctx.baseModuleName(), llndkLibraries) || inList(ctx.baseModuleName(), ndkMigratedLibs)
@@ -760,7 +781,10 @@
SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
}
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
- library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags)
+ library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags,
+ android.OptionalPathForModuleSrc(ctx, library.Properties.Header_abi_checker.Symbol_file),
+ library.Properties.Header_abi_checker.Exclude_symbol_versions,
+ library.Properties.Header_abi_checker.Exclude_symbol_tags)
refAbiDumpFile := getRefAbiDumpFile(ctx, vndkVersion, fileName)
if refAbiDumpFile != nil {
@@ -867,6 +891,18 @@
library.baseInstaller.subDir += "-" + vndkVersion
}
}
+ } else if len(library.Properties.Stubs.Versions) > 0 && android.DirectlyInAnyApex(ctx, ctx.ModuleName()) {
+ // If a library in an APEX has stable versioned APIs, we basically don't need
+ // to have the platform variant of the library in /system partition because
+ // platform components can just use the lib from the APEX without fearing about
+ // compatibility. However, if the library is required for some early processes
+ // before the APEX is activated, the platform variant may also be required.
+ // In that case, it is installed to the subdirectory 'bootstrap' in order to
+ // be distinguished/isolated from other non-bootstrap libraries in /system/lib
+ // so that the bootstrap libraries are used only when the APEX isn't ready.
+ if !library.buildStubs() && ctx.Arch().Native {
+ library.baseInstaller.subDir = "bootstrap"
+ }
}
library.baseInstaller.install(ctx, file)
}
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 504a6a0..c0ce9c3 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -93,9 +93,6 @@
licensePath android.ModuleSrcPath
}
-func (m *headerModule) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string,
to string) android.OutputPath {
// Output path is the sysroot base + "usr/include" + to directory + directory component
@@ -210,9 +207,6 @@
licensePath android.ModuleSrcPath
}
-func (m *versionedHeaderModule) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func (m *versionedHeaderModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if String(m.properties.License) == "" {
ctx.PropertyErrorf("license", "field is required")
@@ -335,9 +329,6 @@
licensePath android.ModuleSrcPath
}
-func (m *preprocessedHeadersModule) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func (m *preprocessedHeadersModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if String(m.properties.License) == "" {
ctx.PropertyErrorf("license", "field is required")
diff --git a/cc/object.go b/cc/object.go
index 552f639..b9c5742 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -107,3 +107,7 @@
ctx.CheckbuildFile(outputFile)
return outputFile
}
+
+func (object *objectLinker) unstrippedOutputFilePath() android.Path {
+ return nil
+}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 90656da..bcc4de3 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -35,7 +35,7 @@
asanLdflags = []string{"-Wl,-u,__asan_preinit"}
asanLibs = []string{"libasan"}
- hwasanCflags = []string{"-mllvm", "-hwasan-with-ifunc=0", "-fno-omit-frame-pointer", "-Wno-frame-larger-than=", "-mllvm", "-hwasan-create-frame-descriptions=0"}
+ hwasanCflags = []string{"-fno-omit-frame-pointer", "-Wno-frame-larger-than=", "-mllvm", "-hwasan-create-frame-descriptions=0"}
cfiCflags = []string{"-flto", "-fsanitize-cfi-cross-dso",
"-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blacklist.txt"}
@@ -79,7 +79,8 @@
scs
)
-func (t sanitizerType) String() string {
+// Name of the sanitizer variation for this sanitizer type
+func (t sanitizerType) variationName() string {
switch t {
case asan:
return "asan"
@@ -98,6 +99,26 @@
}
}
+// This is the sanitizer names in SANITIZE_[TARGET|HOST]
+func (t sanitizerType) name() string {
+ switch t {
+ case asan:
+ return "address"
+ case hwasan:
+ return "hwaddress"
+ case tsan:
+ return "thread"
+ case intOverflow:
+ return "integer_overflow"
+ case cfi:
+ return "cfi"
+ case scs:
+ return "shadow-call-stack"
+ default:
+ panic(fmt.Errorf("unknown sanitizerType %d", t))
+ }
+}
+
type SanitizeProperties struct {
// enable AddressSanitizer, ThreadSanitizer, or UndefinedBehaviorSanitizer
Sanitize struct {
@@ -349,8 +370,8 @@
sanitize.Properties.SanitizerEnabled = true
}
- // Disable Scudo if ASan or TSan is enabled.
- if Bool(s.Address) || Bool(s.Thread) || Bool(s.Hwaddress) {
+ // Disable Scudo if ASan or TSan is enabled, or if it's disabled globally.
+ if Bool(s.Address) || Bool(s.Thread) || Bool(s.Hwaddress) || ctx.Config().DisableScudo() {
s.Scudo = nil
}
@@ -423,7 +444,11 @@
flags.LdFlags = append(flags.LdFlags, "-Wl,--no-as-needed")
} else {
flags.CFlags = append(flags.CFlags, "-mllvm", "-asan-globals=0")
- flags.DynamicLinker = "/system/bin/linker_asan"
+ if ctx.bootstrap() {
+ flags.DynamicLinker = "/system/bin/bootstrap/linker_asan"
+ } else {
+ flags.DynamicLinker = "/system/bin/linker_asan"
+ }
if flags.Toolchain.Is64Bit() {
flags.DynamicLinker += "64"
}
@@ -787,7 +812,7 @@
}
if mctx.Device() && runtimeLibrary != "" {
- if inList(runtimeLibrary, llndkLibraries) && !c.static() {
+ if inList(runtimeLibrary, llndkLibraries) && !c.static() && c.useVndk() {
runtimeLibrary = runtimeLibrary + llndkLibrarySuffix
}
@@ -802,12 +827,14 @@
// static executable gets static runtime libs
mctx.AddFarVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
+ {Mutator: "image", Variation: c.imageVariation()},
{Mutator: "arch", Variation: mctx.Target().String()},
}, staticDepTag, runtimeLibrary)
} else if !c.static() {
- // dynamic executable andshared libs get shared runtime libs
+ // dynamic executable and shared libs get shared runtime libs
mctx.AddFarVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "shared"},
+ {Mutator: "image", Variation: c.imageVariation()},
{Mutator: "arch", Variation: mctx.Target().String()},
}, earlySharedDepTag, runtimeLibrary)
}
@@ -820,7 +847,7 @@
type Sanitizeable interface {
android.Module
- IsSanitizerEnabled() bool
+ IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool
}
// Create sanitized variants for modules that need them
@@ -828,14 +855,14 @@
return func(mctx android.BottomUpMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
if c.isDependencyRoot() && c.sanitize.isSanitizerEnabled(t) {
- modules := mctx.CreateVariations(t.String())
+ modules := mctx.CreateVariations(t.variationName())
modules[0].(*Module).sanitize.SetSanitizer(t, true)
} else if c.sanitize.isSanitizerEnabled(t) || c.sanitize.Properties.SanitizeDep {
// Save original sanitizer status before we assign values to variant
// 0 as that overwrites the original.
isSanitizerEnabled := c.sanitize.isSanitizerEnabled(t)
- modules := mctx.CreateVariations("", t.String())
+ modules := mctx.CreateVariations("", t.variationName())
modules[0].(*Module).sanitize.SetSanitizer(t, false)
modules[1].(*Module).sanitize.SetSanitizer(t, true)
@@ -924,9 +951,9 @@
}
}
c.sanitize.Properties.SanitizeDep = false
- } else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok && sanitizeable.IsSanitizerEnabled() {
+ } else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok && sanitizeable.IsSanitizerEnabled(mctx, t.name()) {
// APEX modules fall here
- mctx.CreateVariations(t.String())
+ mctx.CreateVariations(t.variationName())
}
}
}
diff --git a/cc/xom.go b/cc/xom.go
index 182069f..9337990 100644
--- a/cc/xom.go
+++ b/cc/xom.go
@@ -50,7 +50,7 @@
// If any static dependencies have XOM disabled, we should disable XOM in this module,
// the assumption being if it's been explicitly disabled then there's probably incompatible
// code in the library which may get pulled in.
- if !ctx.static() && !disableXom {
+ if !disableXom {
ctx.VisitDirectDeps(func(m android.Module) {
cc, ok := m.(*Module)
if !ok || cc.xom == nil || !cc.static() {
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 503af7e..3725146 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -87,14 +87,14 @@
}
type ModuleConfig struct {
- Name string
- DexLocation string // dex location on device
- BuildPath string
- DexPath string
- PreferCodeIntegrity bool
- UncompressedDex bool
- HasApkLibraries bool
- PreoptFlags []string
+ Name string
+ DexLocation string // dex location on device
+ BuildPath string
+ DexPath string
+ UseEmbeddedDex bool
+ UncompressedDex bool
+ HasApkLibraries bool
+ PreoptFlags []string
ProfileClassListing string
ProfileIsTextListing bool
diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go
index f218d01..073d463 100644
--- a/dexpreopt/dexpreopt_test.go
+++ b/dexpreopt/dexpreopt_test.go
@@ -66,7 +66,7 @@
DexLocation: "",
BuildPath: "",
DexPath: "",
- PreferCodeIntegrity: false,
+ UseEmbeddedDex: false,
UncompressedDex: false,
HasApkLibraries: false,
PreoptFlags: nil,
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 77bc196..7695ffb 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -528,9 +528,6 @@
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
-func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func defaultsFactory() android.Module {
return DefaultsFactory()
}
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index 70b9090..19b22f7 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -519,8 +519,6 @@
return module
}
-func (t *testTool) DepsMutator(ctx android.BottomUpMutatorContext) {}
-
func (t *testTool) GenerateAndroidBuildActions(ctx android.ModuleContext) {
t.outputFile = android.PathForTesting("out", ctx.ModuleName())
}
diff --git a/java/android_resources.go b/java/android_resources.go
index 47535d2..efd3e3d 100644
--- a/java/android_resources.go
+++ b/java/android_resources.go
@@ -44,10 +44,6 @@
type overlayGlobResult struct {
dir string
paths android.DirectorySortedPaths
-
- // Set to true of the product has selected that values in this overlay should not be moved to
- // Runtime Resource Overlay (RRO) packages.
- excludeFromRRO bool
}
const overlayDataKey = "overlayDataKey"
@@ -69,10 +65,11 @@
files := data.paths.PathsInDirectory(filepath.Join(data.dir, dir.String()))
if len(files) > 0 {
overlayModuleDir := android.PathForSource(ctx, data.dir, dir.String())
+
// If enforce RRO is enabled for this module and this overlay is not in the
// exclusion list, ignore the overlay. The list of ignored overlays will be
// passed to Make to be turned into an RRO package.
- if rroEnabled && !data.excludeFromRRO {
+ if rroEnabled && !ctx.Config().EnforceRROExcludedOverlay(overlayModuleDir.String()) {
rroDirs = append(rroDirs, overlayModuleDir)
} else {
res = append(res, globbedResourceDir{
@@ -102,10 +99,6 @@
var result overlayGlobResult
result.dir = overlay
- // Mark overlays that will not have Runtime Resource Overlays enforced on them
- // based on the product config
- result.excludeFromRRO = ctx.Config().EnforceRROExcludedOverlay(overlay)
-
files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), androidResourceIgnoreFilenames)
if err != nil {
ctx.Errorf("failed to glob resource dir %q: %s", overlay, err.Error())
diff --git a/java/androidmk.go b/java/androidmk.go
index ccb5109..089ed4f 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -381,6 +381,15 @@
fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
ddoc.checkLastReleasedApiTimestamp.String())
+
+ if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
+ fmt.Fprintln(w, ".PHONY: checkapi")
+ fmt.Fprintln(w, "checkapi:",
+ ddoc.checkLastReleasedApiTimestamp.String())
+
+ fmt.Fprintln(w, ".PHONY: droidcore")
+ fmt.Fprintln(w, "droidcore: checkapi")
+ }
}
apiFilePrefix := "INTERNAL_PLATFORM_"
if String(ddoc.properties.Api_tag_name) != "" {
@@ -459,6 +468,15 @@
fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
dstubs.checkLastReleasedApiTimestamp.String())
+
+ if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
+ fmt.Fprintln(w, ".PHONY: checkapi")
+ fmt.Fprintln(w, "checkapi:",
+ dstubs.checkLastReleasedApiTimestamp.String())
+
+ fmt.Fprintln(w, ".PHONY: droidcore")
+ fmt.Fprintln(w, "droidcore: checkapi")
+ }
}
if dstubs.checkNullabilityWarningsTimestamp != nil {
fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
diff --git a/java/app.go b/java/app.go
index cc863e6..e9c12e0 100644
--- a/java/app.go
+++ b/java/app.go
@@ -503,9 +503,6 @@
return module
}
-func (c *AndroidAppCertificate) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func (c *AndroidAppCertificate) GenerateAndroidBuildActions(ctx android.ModuleContext) {
cert := String(c.properties.Certificate)
c.Certificate = Certificate{
diff --git a/java/app_test.go b/java/app_test.go
index 7e06dba..2455145 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -149,9 +149,13 @@
},
},
{
- name: "enforce RRO on all",
- enforceRROTargets: []string{"*"},
- enforceRROExcludedOverlays: []string{"device/vendor/blah/static_overlay"},
+ name: "enforce RRO on all",
+ enforceRROTargets: []string{"*"},
+ enforceRROExcludedOverlays: []string{
+ // Excluding specific apps/res directories also allowed.
+ "device/vendor/blah/static_overlay/foo",
+ "device/vendor/blah/static_overlay/bar/res",
+ },
overlayFiles: map[string][]string{
"foo": []string{"device/vendor/blah/static_overlay/foo/res/values/strings.xml"},
"bar": []string{"device/vendor/blah/static_overlay/bar/res/values/strings.xml"},
@@ -195,12 +199,12 @@
for _, testCase := range testEnforceRROTests {
t.Run(testCase.name, func(t *testing.T) {
config := testConfig(nil)
- config.TestProductVariables.ResourceOverlays = &resourceOverlays
+ config.TestProductVariables.ResourceOverlays = resourceOverlays
if testCase.enforceRROTargets != nil {
- config.TestProductVariables.EnforceRROTargets = &testCase.enforceRROTargets
+ config.TestProductVariables.EnforceRROTargets = testCase.enforceRROTargets
}
if testCase.enforceRROExcludedOverlays != nil {
- config.TestProductVariables.EnforceRROExcludedOverlays = &testCase.enforceRROExcludedOverlays
+ config.TestProductVariables.EnforceRROExcludedOverlays = testCase.enforceRROExcludedOverlays
}
ctx := testAppContext(config, bp, fs)
@@ -208,11 +212,12 @@
getOverlays := func(moduleName string) ([]string, []string) {
module := ctx.ModuleForTests(moduleName, "android_common")
- overlayCompiledPaths := module.Output("aapt2/overlay.list").Inputs.Strings()
-
+ overlayFile := module.MaybeOutput("aapt2/overlay.list")
var overlayFiles []string
- for _, o := range overlayCompiledPaths {
- overlayFiles = append(overlayFiles, module.Output(o).Inputs.Strings()...)
+ if overlayFile.Rule != nil {
+ for _, o := range overlayFile.Inputs.Strings() {
+ overlayFiles = append(overlayFiles, module.Output(o).Inputs.Strings()...)
+ }
}
rroDirs := module.Module().(*AndroidApp).rroDirs.Strings()
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 2c8de55..6e46bc9 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -149,14 +149,14 @@
}
dexpreoptConfig := dexpreopt.ModuleConfig{
- Name: ctx.ModuleName(),
- DexLocation: dexLocation,
- BuildPath: android.PathForModuleOut(ctx, "dexpreopt", ctx.ModuleName()+".jar").String(),
- DexPath: dexJarFile.String(),
- PreferCodeIntegrity: false,
- UncompressedDex: d.uncompressedDex,
- HasApkLibraries: false,
- PreoptFlags: nil,
+ Name: ctx.ModuleName(),
+ DexLocation: dexLocation,
+ BuildPath: android.PathForModuleOut(ctx, "dexpreopt", ctx.ModuleName()+".jar").String(),
+ DexPath: dexJarFile.String(),
+ UseEmbeddedDex: false,
+ UncompressedDex: d.uncompressedDex,
+ HasApkLibraries: false,
+ PreoptFlags: nil,
ProfileClassListing: profileClassListing.String(),
ProfileIsTextListing: profileIsTextListing,
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 01e2989..d893c09 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -1816,9 +1816,6 @@
func (*DocDefaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
-func (d *DocDefaults) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func DocDefaultsFactory() android.Module {
module := &DocDefaults{}
diff --git a/java/java.go b/java/java.go
index 230e8f2..70c6c43 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1840,9 +1840,6 @@
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
-func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func defaultsFactory() android.Module {
return DefaultsFactory()
}
diff --git a/java/java_test.go b/java/java_test.go
index a0b8952..57b2a59 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -61,7 +61,7 @@
env["ANDROID_JAVA8_HOME"] = "jdk8"
}
config := android.TestArchConfig(buildDir, env)
- config.TestProductVariables.DeviceSystemSdkVersions = &[]string{"14", "15"}
+ config.TestProductVariables.DeviceSystemSdkVersions = []string{"14", "15"}
return config
}
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go
index c11e010..0410daf 100644
--- a/java/prebuilt_apis.go
+++ b/java/prebuilt_apis.go
@@ -47,10 +47,6 @@
properties prebuiltApisProperties
}
-func (module *prebuiltApis) DepsMutator(ctx android.BottomUpMutatorContext) {
- // no need to implement
-}
-
func (module *prebuiltApis) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// no need to implement
}
diff --git a/phony/phony.go b/phony/phony.go
index 0c62e8a..e8a6550 100644
--- a/phony/phony.go
+++ b/phony/phony.go
@@ -38,9 +38,6 @@
return module
}
-func (p *phony) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func (p *phony) GenerateAndroidBuildActions(ctx android.ModuleContext) {
p.requiredModuleNames = ctx.RequiredModuleNames()
if len(p.requiredModuleNames) == 0 {
diff --git a/python/androidmk.go b/python/androidmk.go
index c1eaa5e..1e51e7b 100644
--- a/python/androidmk.go
+++ b/python/androidmk.go
@@ -96,5 +96,6 @@
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
+ fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(installer.androidMkSharedLibs, " "))
})
}
diff --git a/python/defaults.go b/python/defaults.go
index 641aca4..dba23a7 100644
--- a/python/defaults.go
+++ b/python/defaults.go
@@ -30,9 +30,6 @@
func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
-func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
-}
-
func defaultsFactory() android.Module {
return DefaultsFactory()
}
diff --git a/python/installer.go b/python/installer.go
index ab3d9b4..62f36f4 100644
--- a/python/installer.go
+++ b/python/installer.go
@@ -34,6 +34,8 @@
relative string
path android.OutputPath
+
+ androidMkSharedLibs []string
}
func NewPythonInstaller(dir, dir64 string) *pythonInstaller {
@@ -59,3 +61,7 @@
func (installer *pythonInstaller) install(ctx android.ModuleContext, file android.Path) {
installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
}
+
+func (installer *pythonInstaller) setAndroidMkSharedLibs(sharedLibs []string) {
+ installer.androidMkSharedLibs = sharedLibs
+}
diff --git a/python/python.go b/python/python.go
index e8b4713..ddc3f1f 100644
--- a/python/python.go
+++ b/python/python.go
@@ -160,6 +160,7 @@
type installer interface {
install(ctx android.ModuleContext, path android.Path)
+ setAndroidMkSharedLibs(sharedLibs []string)
}
type PythonDependency interface {
@@ -203,18 +204,19 @@
}
var (
- pythonLibTag = dependencyTag{name: "pythonLib"}
- launcherTag = dependencyTag{name: "launcher"}
- pyIdentifierRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
- pyExt = ".py"
- protoExt = ".proto"
- pyVersion2 = "PY2"
- pyVersion3 = "PY3"
- initFileName = "__init__.py"
- mainFileName = "__main__.py"
- entryPointFile = "entry_point.txt"
- parFileExt = ".zip"
- internal = "internal"
+ pythonLibTag = dependencyTag{name: "pythonLib"}
+ launcherTag = dependencyTag{name: "launcher"}
+ launcherSharedLibTag = dependencyTag{name: "launcherSharedLib"}
+ pyIdentifierRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
+ pyExt = ".py"
+ protoExt = ".proto"
+ pyVersion2 = "PY2"
+ pyVersion3 = "PY3"
+ initFileName = "__init__.py"
+ mainFileName = "__main__.py"
+ entryPointFile = "entry_point.txt"
+ parFileExt = ".zip"
+ internal = "internal"
)
// create version variants for modules.
@@ -308,6 +310,20 @@
ctx.AddFarVariationDependencies([]blueprint.Variation{
{Mutator: "arch", Variation: ctx.Target().String()},
}, launcherTag, "py2-launcher")
+
+ // Add py2-launcher shared lib dependencies. Ideally, these should be
+ // derived from the `shared_libs` property of "py2-launcher". However, we
+ // cannot read the property at this stage and it will be too late to add
+ // dependencies later.
+ ctx.AddFarVariationDependencies([]blueprint.Variation{
+ {Mutator: "arch", Variation: ctx.Target().String()},
+ }, launcherSharedLibTag, "libsqlite")
+
+ if ctx.Target().Os.Bionic() {
+ ctx.AddFarVariationDependencies([]blueprint.Variation{
+ {Mutator: "arch", Variation: ctx.Target().String()},
+ }, launcherSharedLibTag, "libc", "libdl", "libm")
+ }
}
case pyVersion3:
@@ -374,8 +390,18 @@
embeddedLauncher, p.srcsPathMappings, p.srcsZip, p.depsSrcsZips)
}
- if p.installer != nil && p.installSource.Valid() {
- p.installer.install(ctx, p.installSource.Path())
+ if p.installer != nil {
+ var sharedLibs []string
+ ctx.VisitDirectDeps(func(dep android.Module) {
+ if ctx.OtherModuleDependencyTag(dep) == launcherSharedLibTag {
+ sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
+ }
+ })
+ p.installer.setAndroidMkSharedLibs(sharedLibs)
+
+ if p.installSource.Valid() {
+ p.installer.install(ctx, p.installSource.Path())
+ }
}
}
diff --git a/scripts/OWNERS b/scripts/OWNERS
new file mode 100644
index 0000000..076b3f5
--- /dev/null
+++ b/scripts/OWNERS
@@ -0,0 +1 @@
+per-file system-clang-format,system-clang-format-2 = enh@google.com,smoreland@google.com
diff --git a/scripts/manifest_fixer.py b/scripts/manifest_fixer.py
index ebfc4d8..917f55b 100755
--- a/scripts/manifest_fixer.py
+++ b/scripts/manifest_fixer.py
@@ -61,9 +61,10 @@
help='specify additional <uses-library> tag to add. android:requred is set to false')
parser.add_argument('--uses-non-sdk-api', dest='uses_non_sdk_api', action='store_true',
help='manifest is for a package built against the platform')
- parser.add_argument('--prefer-code-integrity', dest='prefer_code_integrity', action='store_true',
- help=('specify if the app prefers strict code integrity. Should not be conflict '
- 'if already declared in the manifest.'))
+ parser.add_argument('--use-embedded-dex', dest='use_embedded_dex', action='store_true',
+ help=('specify if the app wants to use embedded dex and avoid extracted,'
+ 'locally compiled code. Should not be conflict if already declared '
+ 'in the manifest.'))
parser.add_argument('input', help='input AndroidManifest.xml file')
parser.add_argument('output', help='output AndroidManifest.xml file')
return parser.parse_args()
@@ -272,7 +273,7 @@
application.setAttributeNode(attr)
-def add_prefer_code_integrity(doc):
+def add_use_embedded_dex(doc):
manifest = parse_manifest(doc)
elems = get_children_with_tag(manifest, 'application')
application = elems[0] if len(elems) == 1 else None
@@ -285,13 +286,13 @@
manifest.insertBefore(doc.createTextNode(indent), first)
manifest.insertBefore(application, first)
- attr = application.getAttributeNodeNS(android_ns, 'preferCodeIntegrity')
+ attr = application.getAttributeNodeNS(android_ns, 'useEmbeddedDex')
if attr is None:
- attr = doc.createAttributeNS(android_ns, 'android:preferCodeIntegrity')
+ attr = doc.createAttributeNS(android_ns, 'android:useEmbeddedDex')
attr.value = 'true'
application.setAttributeNode(attr)
elif attr.value != 'true':
- raise RuntimeError('existing attribute mismatches the option of --prefer-code-integrity')
+ raise RuntimeError('existing attribute mismatches the option of --use-embedded-dex')
def write_xml(f, doc):
@@ -321,8 +322,8 @@
if args.uses_non_sdk_api:
add_uses_non_sdk_api(doc)
- if args.prefer_code_integrity:
- add_prefer_code_integrity(doc)
+ if args.use_embedded_dex:
+ add_use_embedded_dex(doc)
with open(args.output, 'wb') as f:
write_xml(f, doc)
diff --git a/scripts/manifest_fixer_test.py b/scripts/manifest_fixer_test.py
index edc98cd..1d8de55 100755
--- a/scripts/manifest_fixer_test.py
+++ b/scripts/manifest_fixer_test.py
@@ -346,12 +346,12 @@
self.assertEqual(output, expected)
-class PreferCodeIntegrityTest(unittest.TestCase):
- """Unit tests for add_prefer_code_integrity function."""
+class UseEmbeddedDexTest(unittest.TestCase):
+ """Unit tests for add_use_embedded_dex function."""
def run_test(self, input_manifest):
doc = minidom.parseString(input_manifest)
- manifest_fixer.add_prefer_code_integrity(doc)
+ manifest_fixer.add_use_embedded_dex(doc)
output = StringIO.StringIO()
manifest_fixer.write_xml(output, doc)
return output.getvalue()
@@ -362,23 +362,23 @@
' <application%s/>\n'
'</manifest>\n')
- def prefer_code_integrity(self, value):
- return ' android:preferCodeIntegrity="%s"' % value
+ def use_embedded_dex(self, value):
+ return ' android:useEmbeddedDex="%s"' % value
def test_manifest_with_undeclared_preference(self):
manifest_input = self.manifest_tmpl % ''
- expected = self.manifest_tmpl % self.prefer_code_integrity('true')
+ expected = self.manifest_tmpl % self.use_embedded_dex('true')
output = self.run_test(manifest_input)
self.assertEqual(output, expected)
- def test_manifest_with_prefer_code_integrity(self):
- manifest_input = self.manifest_tmpl % self.prefer_code_integrity('true')
+ def test_manifest_with_use_embedded_dex(self):
+ manifest_input = self.manifest_tmpl % self.use_embedded_dex('true')
expected = manifest_input
output = self.run_test(manifest_input)
self.assertEqual(output, expected)
- def test_manifest_with_not_prefer_code_integrity(self):
- manifest_input = self.manifest_tmpl % self.prefer_code_integrity('false')
+ def test_manifest_with_not_use_embedded_dex(self):
+ manifest_input = self.manifest_tmpl % self.use_embedded_dex('false')
self.assertRaises(RuntimeError, self.run_test, manifest_input)
if __name__ == '__main__':
diff --git a/scripts/strip.sh b/scripts/strip.sh
index 4634c18..bedc527 100755
--- a/scripts/strip.sh
+++ b/scripts/strip.sh
@@ -27,7 +27,7 @@
# --add-gnu-debuglink
# --keep-mini-debug-info
# --keep-symbols
-# --use-llvm-strip
+# --use-gnu-strip
set -o pipefail
@@ -40,12 +40,12 @@
--add-gnu-debuglink Add a gnu-debuglink section to out-file
--keep-mini-debug-info Keep compressed debug info in out-file
--keep-symbols Keep symbols in out-file
- --use-llvm-strip Use llvm-{strip,objcopy} instead of strip/objcopy
+ --use-gnu-strip Use strip/objcopy instead of llvm-{strip,objcopy}
EOF
exit 1
}
-# With --use-llvm-strip, GNU strip is replaced with llvm-strip to work around
+# Without --use-gnu-strip, GNU strip is replaced with llvm-strip to work around
# old GNU strip bug on lld output files, b/80093681.
# Similary, calls to objcopy are replaced with llvm-objcopy,
# with some exceptions.
@@ -53,18 +53,16 @@
do_strip() {
# ${CROSS_COMPILE}strip --strip-all does not strip .ARM.attributes,
# so we tell llvm-strip to keep it too.
- if [ ! -z "${use_llvm_strip}" ]; then
- "${CLANG_BIN}/llvm-strip" --strip-all -keep=.ARM.attributes "${infile}" -o "${outfile}.tmp"
+ if [ -z "${use_gnu_strip}" ]; then
+ "${CLANG_BIN}/llvm-strip" --strip-all -keep-section=.ARM.attributes "${infile}" -o "${outfile}.tmp"
else
"${CROSS_COMPILE}strip" --strip-all "${infile}" -o "${outfile}.tmp"
fi
}
do_strip_keep_symbols() {
- # Maybe we should replace this objcopy with llvm-objcopy, but
- # we have not found a use case that is broken by objcopy yet.
REMOVE_SECTIONS=`"${CROSS_COMPILE}readelf" -S "${infile}" | awk '/.debug_/ {print "--remove-section " $2}' | xargs`
- if [ ! -z "${use_llvm_strip}" ]; then
+ if [ -z "${use_gnu_strip}" ]; then
"${CLANG_BIN}/llvm-objcopy" "${infile}" "${outfile}.tmp" ${REMOVE_SECTIONS}
else
"${CROSS_COMPILE}objcopy" "${infile}" "${outfile}.tmp" ${REMOVE_SECTIONS}
@@ -74,8 +72,8 @@
do_strip_keep_mini_debug_info() {
rm -f "${outfile}.dynsyms" "${outfile}.funcsyms" "${outfile}.keep_symbols" "${outfile}.debug" "${outfile}.mini_debuginfo" "${outfile}.mini_debuginfo.xz"
local fail=
- if [ ! -z "${use_llvm_strip}" ]; then
- "${CLANG_BIN}/llvm-strip" --strip-all -keep=.ARM.attributes -remove-section=.comment "${infile}" -o "${outfile}.tmp" || fail=true
+ if [ -z "${use_gnu_strip}" ]; then
+ "${CLANG_BIN}/llvm-strip" --strip-all -keep-section=.ARM.attributes -remove-section=.comment "${infile}" -o "${outfile}.tmp" || fail=true
else
"${CROSS_COMPILE}strip" --strip-all -R .comment "${infile}" -o "${outfile}.tmp" || fail=true
fi
@@ -93,7 +91,7 @@
"${CROSS_COMPILE}objcopy" -S --remove-section .gdb_index --remove-section .comment --keep-symbols="${outfile}.keep_symbols" "${outfile}.mini_debuginfo"
"${CROSS_COMPILE}objcopy" --rename-section saved_debug_frame=.debug_frame "${outfile}.mini_debuginfo"
"${XZ}" "${outfile}.mini_debuginfo"
- if [ ! -z "${use_llvm_strip}" ]; then
+ if [ -z "${use_gnu_strip}" ]; then
"${CLANG_BIN}/llvm-objcopy" --add-section .gnu_debugdata="${outfile}.mini_debuginfo.xz" "${outfile}.tmp"
else
"${CROSS_COMPILE}objcopy" --add-section .gnu_debugdata="${outfile}.mini_debuginfo.xz" "${outfile}.tmp"
@@ -105,7 +103,7 @@
}
do_add_gnu_debuglink() {
- if [ ! -z "${use_llvm_strip}" ]; then
+ if [ -z "${use_gnu_strip}" ]; then
"${CLANG_BIN}/llvm-objcopy" --add-gnu-debuglink="${infile}" "${outfile}.tmp"
else
"${CROSS_COMPILE}objcopy" --add-gnu-debuglink="${infile}" "${outfile}.tmp"
@@ -122,7 +120,7 @@
add-gnu-debuglink) add_gnu_debuglink=true ;;
keep-mini-debug-info) keep_mini_debug_info=true ;;
keep-symbols) keep_symbols=true ;;
- use-llvm-strip) use_llvm_strip=true ;;
+ use-gnu-strip) use_gnu_strip=true ;;
*) echo "Unknown option --${OPTARG}"; usage ;;
esac;;
?) usage ;;
@@ -172,7 +170,7 @@
rm -f "${outfile}"
mv "${outfile}.tmp" "${outfile}"
-if [ ! -z "${use_llvm_strip}" ]; then
+if [ -z "${use_gnu_strip}" ]; then
USED_STRIP_OBJCOPY="${CLANG_BIN}/llvm-strip ${CLANG_BIN}/llvm-objcopy"
else
USED_STRIP_OBJCOPY="${CROSS_COMPILE}strip"
diff --git a/scripts/system-clang-format b/scripts/system-clang-format
new file mode 100644
index 0000000..55773a2
--- /dev/null
+++ b/scripts/system-clang-format
@@ -0,0 +1,11 @@
+BasedOnStyle: Google
+AccessModifierOffset: -2
+AllowShortFunctionsOnASingleLine: Inline
+ColumnLimit: 100
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+IndentWidth: 4
+ContinuationIndentWidth: 8
+PointerAlignment: Left
+TabWidth: 4
+UseTab: Never
diff --git a/scripts/system-clang-format-2 b/scripts/system-clang-format-2
new file mode 100644
index 0000000..ede5d7e
--- /dev/null
+++ b/scripts/system-clang-format-2
@@ -0,0 +1,9 @@
+BasedOnStyle: Google
+AllowShortFunctionsOnASingleLine: Inline
+ColumnLimit: 100
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+IndentWidth: 2
+PointerAlignment: Left
+TabWidth: 2
+UseTab: Never
diff --git a/ui/build/kati.go b/ui/build/kati.go
index f924b9c..959d0bd 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -202,8 +202,11 @@
defer ctx.EndTrace()
runKati(ctx, config, katiCleanspecSuffix, []string{
+ "--werror_writable",
"--werror_implicit_rules",
"--werror_overriding_commands",
+ "--werror_real_to_phony",
+ "--werror_phony_looks_real",
"-f", "build/make/core/cleanbuild.mk",
"SOONG_MAKEVARS_MK=" + config.SoongMakeVarsMk(),
"TARGET_DEVICE_DIR=" + config.TargetDeviceDir(),
diff --git a/ui/logger/logger.go b/ui/logger/logger.go
index c763e50..58890e9 100644
--- a/ui/logger/logger.go
+++ b/ui/logger/logger.go
@@ -73,7 +73,9 @@
}
// fatalLog is the type used when Fatal[f|ln]
-type fatalLog error
+type fatalLog struct {
+ error
+}
func fileRotation(from, baseName, ext string, cur, max int) error {
newName := baseName + "." + strconv.Itoa(cur) + ext
@@ -273,7 +275,7 @@
func (s *stdLogger) Fatal(v ...interface{}) {
output := fmt.Sprint(v...)
s.Output(2, output)
- panic(fatalLog(errors.New(output)))
+ panic(fatalLog{errors.New(output)})
}
// Fatalf is equivalent to Printf() followed by a call to panic() that
@@ -281,7 +283,7 @@
func (s *stdLogger) Fatalf(format string, v ...interface{}) {
output := fmt.Sprintf(format, v...)
s.Output(2, output)
- panic(fatalLog(errors.New(output)))
+ panic(fatalLog{errors.New(output)})
}
// Fatalln is equivalent to Println() followed by a call to panic() that
@@ -289,7 +291,7 @@
func (s *stdLogger) Fatalln(v ...interface{}) {
output := fmt.Sprintln(v...)
s.Output(2, output)
- panic(fatalLog(errors.New(output)))
+ panic(fatalLog{errors.New(output)})
}
// Panic is equivalent to Print() followed by a call to panic().
diff --git a/ui/logger/logger_test.go b/ui/logger/logger_test.go
index bdf0231..044e6f0 100644
--- a/ui/logger/logger_test.go
+++ b/ui/logger/logger_test.go
@@ -196,3 +196,17 @@
log.Panic("Test")
t.Errorf("Should not get here")
}
+
+func TestRuntimePanic(t *testing.T) {
+ defer func() {
+ if p := recover(); p == nil {
+ t.Errorf("Panic not thrown")
+ }
+ }()
+ defer Recover(func(err error) {
+ t.Errorf("Recover function should not be called")
+ })
+ var i *int
+ *i = 0
+ t.Errorf("Should not get here")
+}
diff --git a/ui/status/kati.go b/ui/status/kati.go
index 7c26d42..1485c8d 100644
--- a/ui/status/kati.go
+++ b/ui/status/kati.go
@@ -121,6 +121,7 @@
}
scanner := bufio.NewScanner(pipe)
+ scanner.Buffer(nil, 2*1024*1024)
for scanner.Scan() {
parser.parseLine(scanner.Text())
}