Merge "Allow excluding specific overlay sub-directories"
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/apex.go b/apex/apex.go
index 46c9dcf..aeeff78 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -329,10 +329,10 @@
type apexFile struct {
builtFile android.Path
moduleName string
- archType android.ArchType
installDir string
class apexFileClass
module android.Module
+ symlinks []string
}
type apexBundle struct {
@@ -396,7 +396,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,9 +484,17 @@
}
}
-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) {
@@ -563,7 +572,7 @@
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})
+ 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 +585,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 +596,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 +605,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)
@@ -631,7 +640,7 @@
}
depName := ctx.OtherModuleName(child)
fileToCopy, dirInApex := getCopyManifestForNativeLibrary(cc)
- filesInfo = append(filesInfo, apexFile{fileToCopy, depName, cc.Arch().ArchType, dirInApex, nativeSharedLib, cc})
+ filesInfo = append(filesInfo, apexFile{fileToCopy, depName, dirInApex, nativeSharedLib, cc, nil})
return true
}
}
@@ -724,6 +733,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 +752,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 +887,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 +913,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 +1013,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 {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index dbc85d9..7ae49f6 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) {
@@ -668,17 +722,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 +772,95 @@
"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")
+}
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..d4edc1a 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"
}
@@ -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,15 @@
}
}
+ return ret
+}
+
+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..645b3c2 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,
@@ -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,
diff --git a/cc/cc.go b/cc/cc.go
index baee70a..58ea5e1 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 {
@@ -404,6 +405,15 @@
return c.outputFile
}
+func (c *Module) UnstrippedOutputFile() android.Path {
+ if library, ok := c.linker.(*libraryDecorator); ok {
+ return library.unstrippedOutputFile
+ } else if binary, ok := c.linker.(*binaryDecorator); ok {
+ return binary.unstrippedOutputFile
+ }
+ return nil
+}
+
func (c *Module) Init() android.Module {
c.AddProperties(&c.Properties, &c.VendorProperties)
if c.compiler != nil {
@@ -562,6 +572,10 @@
return false
}
+func (c *Module) bootstrap() bool {
+ return Bool(c.Properties.Bootstrap)
+}
+
type baseModuleContext struct {
android.BaseContext
moduleContextImpl
@@ -720,9 +734,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 +746,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 +790,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 +1169,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 +1183,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 +1562,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 +1848,16 @@
return false
}
+func (c *Module) imageVariation() string {
+ variation := "core"
+ if c.useVndk() {
+ variation = "vendor"
+ } else if c.inRecovery() {
+ variation = "recovery"
+ }
+ return variation
+}
+
//
// Defaults
//
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..e3d36bd 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -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/library.go b/cc/library.go
index ad07db4..7213a73 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 {
@@ -760,7 +773,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 +883,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/sanitize.go b/cc/sanitize.go
index 90656da..4576aa1 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -787,7 +787,7 @@
}
if mctx.Device() && runtimeLibrary != "" {
- if inList(runtimeLibrary, llndkLibraries) && !c.static() {
+ if inList(runtimeLibrary, llndkLibraries) && !c.static() && c.useVndk() {
runtimeLibrary = runtimeLibrary + llndkLibrarySuffix
}
@@ -802,12 +802,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 +822,7 @@
type Sanitizeable interface {
android.Module
- IsSanitizerEnabled() bool
+ IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool
}
// Create sanitized variants for modules that need them
@@ -924,7 +926,7 @@
}
}
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.String()) {
// APEX modules fall here
mctx.CreateVariations(t.String())
}
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/java/androidmk.go b/java/androidmk.go
index ccb5109..62d754a 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" {
+ 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" {
+ 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/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/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/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/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/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())
}