Modify Soong to utilize from-text android.jar in build
Context
- from-text android.jar files are built using Metalava, and these can be
utilized in `decodeSdkDep` so that any modules that depends on APIs
can be compiled using from-text android.jars
- This change removes dependency on source java files when compiling
stub android.jar files
Implementation
- Modify java_api_library module to create system modules using the
generated android.jar
- Replace modules in decodeSdkDep to link against java_api_library
modules
- Add --build-from-text-stub flag to hide the feature behind a flag
Test: m --build-from-text-stub
Bug: 271154441
Change-Id: I104df595edc65c0006820d5ae5b15f1fb167e190
diff --git a/ui/build/config.go b/ui/build/config.go
index 20cc9fb..7c226dd 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -88,6 +88,7 @@
searchApiDir bool // Scan the Android.bp files generated in out/api_surfaces
skipMetricsUpload bool
buildStartedTime int64 // For metrics-upload-only - manually specify a build-started time
+ buildFromTextStub bool
// From the product config
katiArgs []string
@@ -509,6 +510,11 @@
}
}
+ if ret.BuildFromTextStub() {
+ // TODO(b/271443071): support hidden api check for from-text stub build
+ ret.environ.Set("UNSAFE_DISABLE_HIDDENAPI_FLAGS", "true")
+ }
+
bpd := ret.BazelMetricsDir()
if err := os.RemoveAll(bpd); err != nil {
ctx.Fatalf("Unable to remove bazel profile directory %q: %v", bpd, err)
@@ -833,6 +839,8 @@
} else {
ctx.Fatalf("unknown option for ninja_weight_source: %s", source)
}
+ } else if arg == "--build-from-text-stub" {
+ c.buildFromTextStub = true
} else if strings.HasPrefix(arg, "--build-command=") {
buildCmd := strings.TrimPrefix(arg, "--build-command=")
// remove quotations
@@ -1155,6 +1163,10 @@
return c.skipConfig
}
+func (c *configImpl) BuildFromTextStub() bool {
+ return c.buildFromTextStub
+}
+
func (c *configImpl) TargetProduct() string {
if v, ok := c.environ.Get("TARGET_PRODUCT"); ok {
return v