Merge "Remove infrastructure to run bp2build" into main am: fa6995f75e
am: 1fbc110ba7
am: d9c2df9601
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2864664 Change-Id: I08fa8b09285278381da817ee8283ede481376315 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -84,21 +84,13 @@ type CmdArgs struct {
|
||||
SoongOutDir string
|
||||
SoongVariables string
|
||||
|
||||
SymlinkForestMarker string
|
||||
Bp2buildMarker string
|
||||
BazelQueryViewDir string
|
||||
ModuleGraphFile string
|
||||
ModuleActionsFile string
|
||||
DocFile string
|
||||
BazelQueryViewDir string
|
||||
ModuleGraphFile string
|
||||
ModuleActionsFile string
|
||||
DocFile string
|
||||
|
||||
MultitreeBuild bool
|
||||
|
||||
BazelMode bool
|
||||
BazelModeStaging bool
|
||||
BazelForceEnabledModules string
|
||||
|
||||
UseBazelProxy bool
|
||||
|
||||
BuildFromSourceStub bool
|
||||
|
||||
EnsureAllowlistIntegrity bool
|
||||
@@ -109,12 +101,6 @@ const (
|
||||
// Don't use bazel at all during module analysis.
|
||||
AnalysisNoBazel SoongBuildMode = iota
|
||||
|
||||
// Symlink fores mode: merge two directory trees into a symlink forest
|
||||
SymlinkForest
|
||||
|
||||
// Bp2build mode: Generate BUILD files from blueprint files and exit.
|
||||
Bp2build
|
||||
|
||||
// Generate BUILD files which faithfully represent the dependency graph of
|
||||
// blueprint modules. Individual BUILD targets will not, however, faitfhully
|
||||
// express build semantics.
|
||||
@@ -125,15 +111,6 @@ const (
|
||||
|
||||
// Generate a documentation file for module type definitions and exit.
|
||||
GenerateDocFile
|
||||
|
||||
// Use bazel during analysis of a few allowlisted build modules. The allowlist
|
||||
// is considered "staging, as these are modules being prepared to be released
|
||||
// into prod mode shortly after.
|
||||
BazelStagingMode
|
||||
|
||||
// Use bazel during analysis of build modules from an allowlist carefully
|
||||
// curated by the build team to be proven stable.
|
||||
BazelProdMode
|
||||
)
|
||||
|
||||
// SoongOutDir returns the build output directory for the configuration.
|
||||
@@ -250,10 +227,6 @@ type config struct {
|
||||
// Only available on configs created by TestConfig
|
||||
TestProductVariables *ProductVariables
|
||||
|
||||
// A specialized context object for Bazel/Soong mixed builds and migration
|
||||
// purposes.
|
||||
BazelContext BazelContext
|
||||
|
||||
ProductVariablesFileName string
|
||||
|
||||
// BuildOS stores the OsType for the OS that the build is running on.
|
||||
@@ -295,9 +268,7 @@ type config struct {
|
||||
fs pathtools.FileSystem
|
||||
mockBpList string
|
||||
|
||||
BuildMode SoongBuildMode
|
||||
Bp2buildPackageConfig Bp2BuildConversionAllowlist
|
||||
Bp2buildSoongConfigDefinitions soongconfig.Bp2BuildSoongConfigDefinitions
|
||||
BuildMode SoongBuildMode
|
||||
|
||||
// If MultitreeBuild is true then this is one inner tree of a multitree
|
||||
// build directed by the multitree orchestrator.
|
||||
@@ -313,29 +284,6 @@ type config struct {
|
||||
|
||||
OncePer
|
||||
|
||||
// These fields are only used for metrics collection. A module should be added
|
||||
// to these maps only if its implementation supports Bazel handling in mixed
|
||||
// builds. A module being in the "enabled" list indicates that there is a
|
||||
// variant of that module for which bazel-handling actually took place.
|
||||
// A module being in the "disabled" list indicates that there is a variant of
|
||||
// that module for which bazel-handling was denied.
|
||||
mixedBuildsLock sync.Mutex
|
||||
mixedBuildEnabledModules map[string]struct{}
|
||||
mixedBuildDisabledModules map[string]struct{}
|
||||
|
||||
// These are modules to be built with Bazel beyond the allowlisted/build-mode
|
||||
// specified modules. They are passed via the command-line flag
|
||||
// "--bazel-force-enabled-modules"
|
||||
bazelForceEnabledModules map[string]struct{}
|
||||
|
||||
// Names of Bazel targets as defined by BUILD files in the source tree,
|
||||
// keyed by the directory in which they are defined.
|
||||
bazelTargetsByDir map[string][]string
|
||||
|
||||
// If true, for any requests to Bazel, communicate with a Bazel proxy using
|
||||
// unix sockets, instead of spawning Bazel as a subprocess.
|
||||
UseBazelProxy bool
|
||||
|
||||
// If buildFromSourceStub is true then the Java API stubs are
|
||||
// built from the source Java files, not the signature text files.
|
||||
buildFromSourceStub bool
|
||||
@@ -546,14 +494,10 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error)
|
||||
runGoTests: cmdArgs.RunGoTests,
|
||||
multilibConflicts: make(map[ArchType]bool),
|
||||
|
||||
moduleListFile: cmdArgs.ModuleListFile,
|
||||
fs: pathtools.NewOsFs(absSrcDir),
|
||||
mixedBuildDisabledModules: make(map[string]struct{}),
|
||||
mixedBuildEnabledModules: make(map[string]struct{}),
|
||||
bazelForceEnabledModules: make(map[string]struct{}),
|
||||
moduleListFile: cmdArgs.ModuleListFile,
|
||||
fs: pathtools.NewOsFs(absSrcDir),
|
||||
|
||||
MultitreeBuild: cmdArgs.MultitreeBuild,
|
||||
UseBazelProxy: cmdArgs.UseBazelProxy,
|
||||
|
||||
buildFromSourceStub: cmdArgs.BuildFromSourceStub,
|
||||
}
|
||||
@@ -646,28 +590,9 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error)
|
||||
config.BuildMode = mode
|
||||
}
|
||||
}
|
||||
setBazelMode := func(arg bool, argName string, mode SoongBuildMode) {
|
||||
if arg {
|
||||
if config.BuildMode != AnalysisNoBazel {
|
||||
fmt.Fprintf(os.Stderr, "buildMode is already set, illegal argument: %s", argName)
|
||||
os.Exit(1)
|
||||
}
|
||||
config.BuildMode = mode
|
||||
}
|
||||
}
|
||||
setBuildMode(cmdArgs.SymlinkForestMarker, SymlinkForest)
|
||||
setBuildMode(cmdArgs.Bp2buildMarker, Bp2build)
|
||||
setBuildMode(cmdArgs.BazelQueryViewDir, GenerateQueryView)
|
||||
setBuildMode(cmdArgs.ModuleGraphFile, GenerateModuleGraph)
|
||||
setBuildMode(cmdArgs.DocFile, GenerateDocFile)
|
||||
setBazelMode(cmdArgs.BazelMode, "--bazel-mode", BazelProdMode)
|
||||
setBazelMode(cmdArgs.BazelModeStaging, "--bazel-mode-staging", BazelStagingMode)
|
||||
|
||||
for _, module := range getForceEnabledModulesFromFlag(cmdArgs.BazelForceEnabledModules) {
|
||||
config.bazelForceEnabledModules[module] = struct{}{}
|
||||
}
|
||||
config.BazelContext, err = NewBazelContext(config)
|
||||
config.Bp2buildPackageConfig = GetBp2BuildAllowList()
|
||||
|
||||
// TODO(b/276958307): Replace the hardcoded list to a sdk_library local prop.
|
||||
config.apiLibraries = map[string]struct{}{
|
||||
@@ -707,13 +632,6 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error)
|
||||
return Config{config}, err
|
||||
}
|
||||
|
||||
func getForceEnabledModulesFromFlag(forceEnabledFlag string) []string {
|
||||
if forceEnabledFlag == "" {
|
||||
return []string{}
|
||||
}
|
||||
return strings.Split(forceEnabledFlag, ",")
|
||||
}
|
||||
|
||||
// mockFileSystem replaces all reads with accesses to the provided map of
|
||||
// filenames to contents stored as a byte slice.
|
||||
func (c *config) mockFileSystem(bp string, fs map[string][]byte) {
|
||||
@@ -744,41 +662,6 @@ func (c *config) mockFileSystem(bp string, fs map[string][]byte) {
|
||||
c.mockBpList = blueprint.MockModuleListFile
|
||||
}
|
||||
|
||||
// TODO(b/265062549): Add a field to our collected (and uploaded) metrics which
|
||||
// describes a reason that we fell back to non-mixed builds.
|
||||
// Returns true if "Bazel builds" is enabled. In this mode, part of build
|
||||
// analysis is handled by Bazel.
|
||||
func (c *config) IsMixedBuildsEnabled() bool {
|
||||
globalMixedBuildsSupport := c.Once(OnceKey{"globalMixedBuildsSupport"}, func() interface{} {
|
||||
if c.productVariables.DeviceArch != nil && *c.productVariables.DeviceArch == "riscv64" {
|
||||
return false
|
||||
}
|
||||
// Disable Bazel when Kythe is running
|
||||
if c.EmitXrefRules() {
|
||||
return false
|
||||
}
|
||||
if c.IsEnvTrue("GLOBAL_THINLTO") {
|
||||
return false
|
||||
}
|
||||
if len(c.productVariables.SanitizeHost) > 0 {
|
||||
return false
|
||||
}
|
||||
if len(c.productVariables.SanitizeDevice) > 0 {
|
||||
return false
|
||||
}
|
||||
if len(c.productVariables.SanitizeDeviceDiag) > 0 {
|
||||
return false
|
||||
}
|
||||
if len(c.productVariables.SanitizeDeviceArch) > 0 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}).(bool)
|
||||
|
||||
bazelModeEnabled := c.BuildMode == BazelProdMode || c.BuildMode == BazelStagingMode
|
||||
return globalMixedBuildsSupport && bazelModeEnabled
|
||||
}
|
||||
|
||||
func (c *config) SetAllowMissingDependencies() {
|
||||
c.productVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
||||
}
|
||||
@@ -1054,8 +937,6 @@ func (c *config) AllSupportedApiLevels() []ApiLevel {
|
||||
// DefaultAppTargetSdk returns the API level that platform apps are targeting.
|
||||
// This converts a codename to the exact ApiLevel it represents.
|
||||
func (c *config) DefaultAppTargetSdk(ctx EarlyModuleContext) ApiLevel {
|
||||
// This logic is replicated in starlark, if changing logic here update starlark code too
|
||||
// https://cs.android.com/android/platform/superproject/+/master:build/bazel/rules/common/api.bzl;l=72;drc=231c7e8c8038fd478a79eb68aa5b9f5c64e0e061
|
||||
if Bool(c.productVariables.Platform_sdk_final) {
|
||||
return c.PlatformSdkVersion()
|
||||
}
|
||||
@@ -1413,10 +1294,6 @@ func (c *config) PrebuiltHiddenApiDir(_ PathContext) string {
|
||||
return String(c.productVariables.PrebuiltHiddenApiDir)
|
||||
}
|
||||
|
||||
func (c *config) BazelModulesForceEnabledByFlag() map[string]struct{} {
|
||||
return c.bazelForceEnabledModules
|
||||
}
|
||||
|
||||
func (c *config) IsVndkDeprecated() bool {
|
||||
return !Bool(c.productVariables.KeepVndk)
|
||||
}
|
||||
@@ -2029,38 +1906,6 @@ func (c *config) UseHostMusl() bool {
|
||||
return Bool(c.productVariables.HostMusl)
|
||||
}
|
||||
|
||||
func (c *config) GetMixedBuildsEnabledModules() map[string]struct{} {
|
||||
return c.mixedBuildEnabledModules
|
||||
}
|
||||
|
||||
func (c *config) GetMixedBuildsDisabledModules() map[string]struct{} {
|
||||
return c.mixedBuildDisabledModules
|
||||
}
|
||||
|
||||
func (c *config) LogMixedBuild(ctx BaseModuleContext, useBazel bool) {
|
||||
moduleName := ctx.Module().Name()
|
||||
c.mixedBuildsLock.Lock()
|
||||
defer c.mixedBuildsLock.Unlock()
|
||||
if useBazel {
|
||||
c.mixedBuildEnabledModules[moduleName] = struct{}{}
|
||||
} else {
|
||||
c.mixedBuildDisabledModules[moduleName] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *config) HasBazelBuildTargetInSource(dir string, target string) bool {
|
||||
for _, existingTarget := range c.bazelTargetsByDir[dir] {
|
||||
if target == existingTarget {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *config) SetBazelBuildFileTargets(bazelTargetsByDir map[string][]string) {
|
||||
c.bazelTargetsByDir = bazelTargetsByDir
|
||||
}
|
||||
|
||||
// ApiSurfaces directory returns the source path inside the api_surfaces repo
|
||||
// (relative to workspace root).
|
||||
func (c *config) ApiSurfacesDir(s ApiSurface, version string) string {
|
||||
@@ -2094,12 +1939,6 @@ func (c *config) SetBuildFromTextStub(b bool) {
|
||||
c.productVariables.Build_from_text_stub = boolPtr(b)
|
||||
}
|
||||
|
||||
func (c *config) AddForceEnabledModules(forceEnabled []string) {
|
||||
for _, forceEnabledModule := range forceEnabled {
|
||||
c.bazelForceEnabledModules[forceEnabledModule] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *config) SetApiLibraries(libs []string) {
|
||||
c.apiLibraries = make(map[string]struct{})
|
||||
for _, lib := range libs {
|
||||
@@ -2111,11 +1950,6 @@ func (c *config) GetApiLibraries() map[string]struct{} {
|
||||
return c.apiLibraries
|
||||
}
|
||||
|
||||
// Bp2buildMode indicates whether the config is for bp2build mode of Soong
|
||||
func (c *config) Bp2buildMode() bool {
|
||||
return c.BuildMode == Bp2build
|
||||
}
|
||||
|
||||
func (c *deviceConfig) CheckVendorSeappViolations() bool {
|
||||
return Bool(c.config.productVariables.CheckVendorSeappViolations)
|
||||
}
|
||||
|
Reference in New Issue
Block a user