Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8f50fde authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Move bazel environment variable list to bzl files"

parents abcfc777 8a161be1
Loading
Loading
Loading
Loading
+6 −40
Original line number Original line Diff line number Diff line
@@ -28,7 +28,7 @@ import (
	"android/soong/android/allowlists"
	"android/soong/android/allowlists"
	"android/soong/bazel/cquery"
	"android/soong/bazel/cquery"
	"android/soong/shared"
	"android/soong/shared"
	"android/soong/starlark_fmt"
	"android/soong/starlark_import"


	"github.com/google/blueprint"
	"github.com/google/blueprint"
	"github.com/google/blueprint/metrics"
	"github.com/google/blueprint/metrics"
@@ -44,34 +44,6 @@ var (
		Description: "",
		Description: "",
		CommandDeps: []string{"${bazelBuildRunfilesTool}"},
		CommandDeps: []string{"${bazelBuildRunfilesTool}"},
	}, "outDir")
	}, "outDir")
	allowedBazelEnvironmentVars = []string{
		// clang-tidy
		"ALLOW_LOCAL_TIDY_TRUE",
		"DEFAULT_TIDY_HEADER_DIRS",
		"TIDY_TIMEOUT",
		"WITH_TIDY",
		"WITH_TIDY_FLAGS",
		"TIDY_EXTERNAL_VENDOR",

		"SKIP_ABI_CHECKS",
		"UNSAFE_DISABLE_APEX_ALLOWED_DEPS_CHECK",
		"AUTO_ZERO_INITIALIZE",
		"AUTO_PATTERN_INITIALIZE",
		"AUTO_UNINITIALIZE",
		"USE_CCACHE",
		"LLVM_NEXT",
		"LLVM_PREBUILTS_VERSION",
		"LLVM_RELEASE_VERSION",
		"ALLOW_UNKNOWN_WARNING_OPTION",

		"UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT",

		// Overrides the version in the apex_manifest.json. The version is unique for
		// each branch (internal, aosp, mainline releases, dessert releases).  This
		// enables modules built on an older branch to be installed against a newer
		// device for development purposes.
		"OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION",
	}
)
)


func registerMixedBuildsMutator(ctx RegisterMutatorsContext) {
func registerMixedBuildsMutator(ctx RegisterMutatorsContext) {
@@ -722,7 +694,11 @@ func (context *mixedBuildBazelContext) createBazelCommand(config Config, runName
		// explicitly in BUILD files.
		// explicitly in BUILD files.
		"BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1",
		"BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1",
	}
	}
	for _, envvar := range allowedBazelEnvironmentVars {
	capturedEnvVars, err := starlark_import.GetStarlarkValue[[]string]("captured_env_vars")
	if err != nil {
		panic(err)
	}
	for _, envvar := range capturedEnvVars {
		val := config.Getenv(envvar)
		val := config.Getenv(envvar)
		if val == "" {
		if val == "" {
			continue
			continue
@@ -1441,13 +1417,3 @@ func GetConfigKeyApexVariant(ctx BaseModuleContext, apexKey *ApexConfigKey) conf
func bazelDepsetName(contentHash string) string {
func bazelDepsetName(contentHash string) string {
	return fmt.Sprintf("bazel_depset_%s", contentHash)
	return fmt.Sprintf("bazel_depset_%s", contentHash)
}
}

func EnvironmentVarsFile(config Config) string {
	return fmt.Sprintf(bazel.GeneratedBazelFileWarning+`
_env = %s

env = _env
`,
		starlark_fmt.PrintStringList(allowedBazelEnvironmentVars, 0),
	)
}
+0 −1
Original line number Original line Diff line number Diff line
@@ -73,7 +73,6 @@ func soongInjectionFiles(cfg android.Config, metrics CodegenMetrics) ([]BazelFil
	files = append(files, newFile("api_levels", "platform_versions.bzl", platformVersionContents(cfg)))
	files = append(files, newFile("api_levels", "platform_versions.bzl", platformVersionContents(cfg)))


	files = append(files, newFile("allowlists", GeneratedBuildFileName, ""))
	files = append(files, newFile("allowlists", GeneratedBuildFileName, ""))
	files = append(files, newFile("allowlists", "env.bzl", android.EnvironmentVarsFile(cfg)))
	// TODO(b/262781701): Create an alternate soong_build entrypoint for writing out these files only when requested
	// TODO(b/262781701): Create an alternate soong_build entrypoint for writing out these files only when requested
	files = append(files, newFile("allowlists", "mixed_build_prod_allowlist.txt", strings.Join(android.GetBazelEnabledModules(android.BazelProdMode), "\n")+"\n"))
	files = append(files, newFile("allowlists", "mixed_build_prod_allowlist.txt", strings.Join(android.GetBazelEnabledModules(android.BazelProdMode), "\n")+"\n"))
	files = append(files, newFile("allowlists", "mixed_build_staging_allowlist.txt", strings.Join(android.GetBazelEnabledModules(android.BazelStagingMode), "\n")+"\n"))
	files = append(files, newFile("allowlists", "mixed_build_staging_allowlist.txt", strings.Join(android.GetBazelEnabledModules(android.BazelStagingMode), "\n")+"\n"))
+0 −4
Original line number Original line Diff line number Diff line
@@ -165,10 +165,6 @@ func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) {
			dir:      "allowlists",
			dir:      "allowlists",
			basename: GeneratedBuildFileName,
			basename: GeneratedBuildFileName,
		},
		},
		{
			dir:      "allowlists",
			basename: "env.bzl",
		},
		{
		{
			dir:      "allowlists",
			dir:      "allowlists",
			basename: "mixed_build_prod_allowlist.txt",
			basename: "mixed_build_prod_allowlist.txt",