Merge changes from topic "add-vndk-apex"
* changes:
Add __ANDROID_APEX_<NAME>__ for apex variants
Supports VNDK APEX with different versions
diff --git a/apex/apex.go b/apex/apex.go
index d84ddb7..9382c19 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -555,7 +555,14 @@
case nativeTest:
return "NATIVE_TESTS"
case app:
- return "APPS"
+ // b/142537672 Why isn't this APP? We want to have full control over
+ // the paths and file names of the apk file under the flattend APEX.
+ // If this is set to APP, then the paths and file names are modified
+ // by the Make build system. For example, it is installed to
+ // /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
+ // /system/apex/<apexname>/app/<Appname> because the build system automatically
+ // appends module name (which is <apexname>.<Appname> to the path.
+ return "ETC"
default:
panic(fmt.Errorf("unknown class %d", class))
}
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index 40644a3..511b840 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -581,7 +581,8 @@
}
for _, f := range global.PatternsOnSystemOther {
- if makefileMatch(filepath.Join(SystemPartition, f), dexLocation) {
+ // See comment of SYSTEM_OTHER_ODEX_FILTER for details on the matching.
+ if makefileMatch("/"+f, dexLocation) || makefileMatch(filepath.Join(SystemPartition, f), dexLocation) {
return true
}
}
diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go
index aca5e63..bf692fe 100644
--- a/dexpreopt/dexpreopt_test.go
+++ b/dexpreopt/dexpreopt_test.go
@@ -122,13 +122,12 @@
{module: productModule, expectedPartition: "product"},
},
},
- // product/app/% only applies to product apps inside the system partition
{
patterns: []string{"app/%", "product/app/%"},
moduleTests: []moduleTest{
{module: systemModule, expectedPartition: "system_other/system"},
{module: systemProductModule, expectedPartition: "system_other/system/product"},
- {module: productModule, expectedPartition: "product"},
+ {module: productModule, expectedPartition: "system_other/product"},
},
},
}
@@ -148,7 +147,7 @@
}
if rule.Installs().String() != wantInstalls.String() {
- t.Errorf("\nwant installs:\n %v\ngot:\n %v", wantInstalls, rule.Installs())
+ t.Errorf("\npatterns: %v\nwant installs:\n %v\ngot:\n %v", test.patterns, wantInstalls, rule.Installs())
}
}
}
diff --git a/go.mod b/go.mod
index cc328e0..1483a31 100644
--- a/go.mod
+++ b/go.mod
@@ -7,3 +7,5 @@
replace github.com/golang/protobuf v0.0.0 => ../../external/golang-protobuf
replace github.com/google/blueprint v0.0.0 => ../blueprint
+
+go 1.13
diff --git a/java/aar.go b/java/aar.go
index 6a883d3..6426ac3 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -520,6 +520,10 @@
return proptools.StringDefault(a.properties.Sdk_version, defaultSdkVersion(a))
}
+func (a *AARImport) systemModules() string {
+ return ""
+}
+
func (a *AARImport) minSdkVersion() string {
if a.properties.Min_sdk_version != nil {
return *a.properties.Min_sdk_version
diff --git a/java/androidmk.go b/java/androidmk.go
index bc61297..5067e2f 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -598,6 +598,18 @@
fmt.Fprintln(w, "droidcore: checkapi")
}
}
+ if dstubs.apiLintTimestamp != nil {
+ fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
+ fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
+ dstubs.apiLintTimestamp.String())
+
+ fmt.Fprintln(w, ".PHONY: checkapi")
+ fmt.Fprintln(w, "checkapi:",
+ dstubs.apiLintTimestamp.String())
+
+ fmt.Fprintln(w, ".PHONY: droidcore")
+ fmt.Fprintln(w, "droidcore: checkapi")
+ }
if dstubs.checkNullabilityWarningsTimestamp != nil {
fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
diff --git a/java/droiddoc.go b/java/droiddoc.go
index aab61c5..8a283cd 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -67,9 +67,15 @@
// If set to false, don't allow this module(-docs.zip) to be exported. Defaults to true.
Installable *bool
- // if not blank, set to the version of the sdk to compile against
+ // if not blank, set to the version of the sdk to compile against.
+ // Defaults to compiling against the current platform.
Sdk_version *string `android:"arch_variant"`
+ // When targeting 1.9 and above, override the modules to use with --system,
+ // otherwise provides defaults libraries to add to the bootclasspath.
+ // Defaults to "none"
+ System_modules *string
+
Aidl struct {
// Top level directories to pass to aidl tool
Include_dirs []string
@@ -238,6 +244,16 @@
// do not perform API check against Last_released, in the case that both two specified API
// files by Last_released are modules which don't exist.
Ignore_missing_latest_api *bool `blueprint:"mutated"`
+
+ Api_lint struct {
+ Enabled *bool
+
+ // If set, performs api_lint on any new APIs not found in the given signature file
+ New_since *string `android:"path"`
+
+ // If not blank, path to the baseline txt file for approved API lint violations.
+ Baseline_file *string `android:"path"`
+ }
}
// user can specify the version of previous released API file in order to do compatibility check.
@@ -391,6 +407,10 @@
return proptools.StringDefault(j.properties.Sdk_version, defaultSdkVersion(j))
}
+func (j *Javadoc) systemModules() string {
+ return proptools.String(j.properties.System_modules)
+}
+
func (j *Javadoc) minSdkVersion() string {
return j.sdkVersion()
}
@@ -417,6 +437,10 @@
}
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...)
}
+ } else if sdkDep.systemModules != "" {
+ // Add the system modules to both the system modules and bootclasspath.
+ ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
+ ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.systemModules)
}
}
@@ -504,6 +528,10 @@
case bootClasspathTag:
if dep, ok := module.(Dependency); ok {
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars()...)
+ } else if sm, ok := module.(*SystemModules); ok {
+ // A system modules dependency has been added to the bootclasspath
+ // so add its libs to the bootclasspath.
+ deps.bootClasspath = append(deps.bootClasspath, sm.headerJars...)
} else {
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
}
@@ -1154,6 +1182,7 @@
checkCurrentApiTimestamp android.WritablePath
updateCurrentApiTimestamp android.WritablePath
checkLastReleasedApiTimestamp android.WritablePath
+ apiLintTimestamp android.WritablePath
checkNullabilityWarningsTimestamp android.WritablePath
@@ -1490,6 +1519,55 @@
// Create rule for apicheck
+ if BoolDefault(d.properties.Check_api.Api_lint.Enabled, false) && !ctx.Config().IsPdkBuild() {
+ rule := android.NewRuleBuilder()
+ rule.Command().Text("( true")
+
+ srcJarDir := android.PathForModuleOut(ctx, "api_lint", "srcjars")
+ srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
+
+ cmd := metalavaCmd(ctx, rule, javaVersion, d.Javadoc.srcFiles, srcJarList,
+ deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths)
+
+ newSince := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.New_since)
+ if newSince.Valid() {
+ cmd.FlagWithInput("--api-lint ", newSince.Path())
+ } else {
+ cmd.Flag("--api-lint")
+ }
+
+ d.inclusionAnnotationsFlags(ctx, cmd)
+ d.mergeAnnoDirFlags(ctx, cmd)
+
+ baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.Baseline_file)
+ updatedBaselineOutput := android.PathForModuleOut(ctx, "api_lint_baseline.txt")
+ d.apiLintTimestamp = android.PathForModuleOut(ctx, "api_lint.timestamp")
+
+ if baselineFile.Valid() {
+ cmd.FlagWithInput("--baseline ", baselineFile.Path())
+ cmd.FlagWithOutput("--update-baseline ", updatedBaselineOutput)
+ }
+
+ zipSyncCleanupCmd(rule, srcJarDir)
+
+ msg := fmt.Sprintf(`\n******************************\n`+
+ `Your API changes are triggering API Lint warnings or errors.\n\n`+
+ `To make these errors go away, you have two choices:\n`+
+ ` 1. You can suppress the errors with @SuppressLint(\"<id>\").\n\n`+
+ ` 2. You can update the baseline by executing the following command:\n`+
+ ` cp \"$PWD/%s\" \"$PWD/%s\"\n\n`+
+ `******************************\n`, updatedBaselineOutput, baselineFile.Path())
+ rule.Command().
+ Text("touch").Output(d.apiLintTimestamp).
+ Text(") || (").
+ Text("echo").Flag("-e").Flag(`"` + msg + `"`).
+ Text("; exit 38").
+ Text(")")
+
+ rule.Build(pctx, ctx, "metalavaApiLint", "metalava API lint")
+
+ }
+
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") &&
!ctx.Config().IsPdkBuild() {
diff --git a/java/java.go b/java/java.go
index 4264ba9..52f3c11 100644
--- a/java/java.go
+++ b/java/java.go
@@ -270,7 +270,8 @@
Proguard_flags_files []string `android:"path"`
}
- // When targeting 1.9, override the modules to use with --system
+ // When targeting 1.9 and above, override the modules to use with --system,
+ // otherwise provides defaults libraries to add to the bootclasspath.
System_modules *string
UncompressDex bool `blueprint:"mutated"`
@@ -347,8 +348,8 @@
// list of SDK lib names that this java moudule is exporting
exportedSdkLibs []string
- // list of source files, collected from compiledJavaSrcs and compiledSrcJars
- // filter out Exclude_srcs, will be used by android.IDEInfo struct
+ // list of source files, collected from srcFiles with uniqie java and all kt files,
+ // will be used by android.IDEInfo struct
expandIDEInfoCompiledSrcs []string
// expanded Jarjar_rules
@@ -457,7 +458,10 @@
type sdkDep struct {
useModule, useFiles, useDefaultLibs, invalidVersion bool
- modules []string
+ modules []string
+
+ // The default system modules to use. Will be an empty string if no system
+ // modules are to be used.
systemModules string
frameworkResModule string
@@ -496,6 +500,10 @@
return proptools.StringDefault(j.deviceProperties.Sdk_version, defaultSdkVersion(j))
}
+func (j *Module) systemModules() string {
+ return proptools.String(j.deviceProperties.System_modules)
+}
+
func (j *Module) minSdkVersion() string {
if j.deviceProperties.Min_sdk_version != nil {
return *j.deviceProperties.Min_sdk_version
@@ -528,13 +536,10 @@
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...)
}
}
- } else if j.deviceProperties.System_modules == nil {
- ctx.PropertyErrorf("sdk_version",
- `system_modules is required to be set when sdk_version is "none", did you mean "core_platform"`)
- } else if *j.deviceProperties.System_modules != "none" {
+ } else if sdkDep.systemModules != "" {
// Add the system modules to both the system modules and bootclasspath.
- ctx.AddVariationDependencies(nil, systemModulesTag, *j.deviceProperties.System_modules)
- ctx.AddVariationDependencies(nil, bootClasspathTag, *j.deviceProperties.System_modules)
+ ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
+ ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.systemModules)
}
if ctx.ModuleName() == "android_stubs_current" ||
ctx.ModuleName() == "android_system_stubs_current" ||
@@ -1032,9 +1037,6 @@
srcJars = append(srcJars, aaptSrcJar)
}
- // Collect source files and filter out Exclude_srcs that IDEInfo struct will use
- j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.Strings()...)
-
if j.properties.Jarjar_rules != nil {
j.expandJarjarRules = android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
}
@@ -1051,6 +1053,9 @@
}
}
+ // Collect .java files for AIDEGen
+ j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, uniqueSrcFiles.Strings()...)
+
var kotlinJars android.Paths
if srcFiles.HasExt(".kt") {
@@ -1075,6 +1080,9 @@
kotlinSrcFiles = append(kotlinSrcFiles, uniqueSrcFiles...)
kotlinSrcFiles = append(kotlinSrcFiles, srcFiles.FilterByExt(".kt")...)
+ // Collect .kt files for AIDEGen
+ j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.FilterByExt(".kt").Strings()...)
+
flags.classpath = append(flags.classpath, deps.kotlinStdlib...)
flags.classpath = append(flags.classpath, deps.kotlinAnnotations...)
diff --git a/java/sdk.go b/java/sdk.go
index 3451774..c6a9a73 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -39,6 +39,8 @@
type sdkContext interface {
// sdkVersion returns the sdk_version property of the current module, or an empty string if it is not set.
sdkVersion() string
+ // systemModules returns the system_modules property of the current module, or an empty string if it is not set.
+ systemModules() string
// minSdkVersion returns the min_sdk_version property of the current module, or sdkVersion() if it is not set.
minSdkVersion() string
// targetSdkVersion returns the target_sdk_version property of the current module, or sdkVersion() if it is not set.
@@ -185,8 +187,18 @@
frameworkResModule: "framework-res",
}
case "none":
+ systemModules := sdkContext.systemModules()
+ if systemModules == "" {
+ ctx.PropertyErrorf("sdk_version",
+ `system_modules is required to be set to a non-empty value when sdk_version is "none", did you mean sdk_version: "core_platform"?`)
+ } else if systemModules == "none" {
+ // Normalize no system modules to an empty string.
+ systemModules = ""
+ }
+
return sdkDep{
noStandardLibs: true,
+ systemModules: systemModules,
}
case "core_platform":
return sdkDep{
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index 8581387..4270bb1 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -222,6 +222,7 @@
"DEFAULT_WARNING_BUILD_MODULE_TYPES",
"DEFAULT_ERROR_BUILD_MODULE_TYPES",
"BUILD_BROKEN_PREBUILT_ELF_FILES",
+ "BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW",
"BUILD_BROKEN_USES_BUILD_AUX_EXECUTABLE",
"BUILD_BROKEN_USES_BUILD_AUX_STATIC_LIBRARY",
"BUILD_BROKEN_USES_BUILD_COPY_HEADERS",