From 2a929ad250972cc702b6e81843546b37428f5fa8 Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Thu, 8 Jun 2023 19:02:07 +0000 Subject: [PATCH] Revert^2 "Default from-text stub generation in build" This change defaults Java stubs to be generated from API text files during build. Using the `--build-from-source-stubs` flag, users can toggle between the feature. This change relands aosp/2617457. Test: m nothing && verify ninja path exists between android_stubs_current and android_stubs_current.from-text, and does not exist between android_stubs_current.from-source, m nothing --build-from-source-stub && verify the opposite Bug: 301522358 Change-Id: Ic129dafc3231e71470af982374739930947b69cb --- android/config.go | 14 +++++++------- cmd/soong_build/main.go | 2 +- ui/build/config.go | 8 ++++---- ui/build/soong.go | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/android/config.go b/android/config.go index 4c31bb052..c37691025 100644 --- a/android/config.go +++ b/android/config.go @@ -99,7 +99,7 @@ type CmdArgs struct { UseBazelProxy bool - BuildFromTextStub bool + BuildFromSourceStub bool EnsureAllowlistIntegrity bool } @@ -344,9 +344,9 @@ type config struct { // unix sockets, instead of spawning Bazel as a subprocess. UseBazelProxy bool - // If buildFromTextStub is true then the Java API stubs are - // built from the signature text files, not the source Java files. - buildFromTextStub bool + // If buildFromSourceStub is true then the Java API stubs are + // built from the source Java files, not the signature text files. + buildFromSourceStub bool // If ensureAllowlistIntegrity is true, then the presence of any allowlisted // modules that aren't mixed-built for at least one variant will cause a build @@ -563,7 +563,7 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) MultitreeBuild: cmdArgs.MultitreeBuild, UseBazelProxy: cmdArgs.UseBazelProxy, - buildFromTextStub: cmdArgs.BuildFromTextStub, + buildFromSourceStub: cmdArgs.BuildFromSourceStub, } config.deviceConfig = &deviceConfig{ @@ -2079,11 +2079,11 @@ func (c *config) BuildFromTextStub() bool { // TODO: b/302320354 - Remove the coverage build specific logic once the // robust solution for handling native properties in from-text stub build // is implemented. - return c.buildFromTextStub && !c.JavaCoverageEnabled() + return !c.buildFromSourceStub && !c.JavaCoverageEnabled() } func (c *config) SetBuildFromTextStub(b bool) { - c.buildFromTextStub = b + c.buildFromSourceStub = !b c.productVariables.Build_from_text_stub = boolPtr(b) } diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 568a6f822..5abbdb7d5 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -84,7 +84,7 @@ func init() { flag.BoolVar(&cmdlineArgs.BazelMode, "bazel-mode", false, "use bazel for analysis of certain modules") flag.BoolVar(&cmdlineArgs.BazelModeStaging, "bazel-mode-staging", false, "use bazel for analysis of certain near-ready modules") flag.BoolVar(&cmdlineArgs.UseBazelProxy, "use-bazel-proxy", false, "communicate with bazel using unix socket proxy instead of spawning subprocesses") - flag.BoolVar(&cmdlineArgs.BuildFromTextStub, "build-from-text-stub", false, "build Java stubs from API text files instead of source files") + flag.BoolVar(&cmdlineArgs.BuildFromSourceStub, "build-from-source-stub", false, "build Java stubs from source files instead of API text files") flag.BoolVar(&cmdlineArgs.EnsureAllowlistIntegrity, "ensure-allowlist-integrity", false, "verify that allowlisted modules are mixed-built") // Flags that probably shouldn't be flags of soong_build, but we haven't found // the time to remove them yet diff --git a/ui/build/config.go b/ui/build/config.go index 20d920485..d345415b5 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -86,7 +86,7 @@ type configImpl struct { 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 + buildFromSourceStub bool ensureAllowlistIntegrity bool // For CI builds - make sure modules are mixed-built bazelExitCode int32 // For b runs - necessary for updating NonZeroExit besId string // For b runs, to identify the BuildEventService logs @@ -820,8 +820,8 @@ func (c *configImpl) parseArgs(ctx Context, args []string) { } else { ctx.Fatalf("unknown option for ninja_weight_source: %s", source) } - } else if arg == "--build-from-text-stub" { - c.buildFromTextStub = true + } else if arg == "--build-from-source-stub" { + c.buildFromSourceStub = true } else if strings.HasPrefix(arg, "--build-command=") { buildCmd := strings.TrimPrefix(arg, "--build-command=") // remove quotations @@ -1156,7 +1156,7 @@ func (c *configImpl) SkipConfig() bool { } func (c *configImpl) BuildFromTextStub() bool { - return c.buildFromTextStub + return !c.buildFromSourceStub } func (c *configImpl) TargetProduct() string { diff --git a/ui/build/soong.go b/ui/build/soong.go index 90f1798f3..667f0c90b 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -193,8 +193,8 @@ func (pb PrimaryBuilderFactory) primaryBuilderInvocation() bootstrap.PrimaryBuil if pb.config.multitreeBuild { commonArgs = append(commonArgs, "--multitree-build") } - if pb.config.buildFromTextStub { - commonArgs = append(commonArgs, "--build-from-text-stub") + if pb.config.buildFromSourceStub { + commonArgs = append(commonArgs, "--build-from-source-stub") } commonArgs = append(commonArgs, "-l", filepath.Join(pb.config.FileListDir(), "Android.bp.list")) @@ -310,8 +310,8 @@ func bootstrapBlueprint(ctx Context, config Config) { if config.MultitreeBuild() { mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--multitree-build") } - if config.buildFromTextStub { - mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--build-from-text-stub") + if config.buildFromSourceStub { + mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--build-from-source-stub") } if config.ensureAllowlistIntegrity { mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--ensure-allowlist-integrity")