Loading android/allowlists/allowlists.go +5 −0 Original line number Diff line number Diff line Loading @@ -620,4 +620,9 @@ var ( "prebuilt_platform-robolectric-4.5.1-prebuilt", "prebuilt_currysrc_org.eclipse", } ProdMixedBuildsEnabledList = []string{ // This list left intentionally empty for now. Add specific module names // to have them built by Bazel in Prod Mixed Builds mode. } ) android/bazel.go +5 −5 Original line number Diff line number Diff line Loading @@ -219,16 +219,16 @@ type bp2BuildConversionAllowlist struct { // in the synthetic Bazel workspace. keepExistingBuildFile map[string]bool // Per-module allowlist to always opt modules in of both bp2build and mixed builds. // These modules are usually in directories with many other modules that are not ready for // conversion. // Per-module allowlist to always opt modules into both bp2build and Bazel Dev Mode mixed // builds. These modules are usually in directories with many other modules that are not ready // for conversion. // // A module can either be in this list or its directory allowlisted entirely // in bp2buildDefaultConfig, but not both at the same time. moduleAlwaysConvert map[string]bool // Per-module-type allowlist to always opt modules in to both bp2build and mixed builds // when they have the same type as one listed. // Per-module-type allowlist to always opt modules in to both bp2build and // Bazel Dev Mode mixed builds when they have the same type as one listed. moduleTypeAlwaysConvert map[string]bool // Per-module denylist to always opt modules out of bp2build conversion. Loading android/bazel_handler.go +26 −15 Original line number Diff line number Diff line Loading @@ -343,18 +343,20 @@ func (m noopBazelContext) AqueryDepsets() []bazel.AqueryDepset { } func NewBazelContext(c *config) (BazelContext, error) { if !c.IsMixedBuildsEnabled() { return noopBazelContext{}, nil } var modulesDefaultToBazel bool disabledModules := map[string]bool{} enabledModules := map[string]bool{} p, err := bazelPathsFromConfig(c) if err != nil { return nil, err switch c.BuildMode { case BazelProdMode: modulesDefaultToBazel = false for _, enabledProdModule := range allowlists.ProdMixedBuildsEnabledList { enabledModules[enabledProdModule] = true } case BazelDevMode: modulesDefaultToBazel = true // TODO(cparsons): Use a different allowlist depending on prod vs. dev // bazel mode. disabledModules := map[string]bool{} // Don't use partially-converted cc_library targets in mixed builds, // since mixed builds would generally rely on both static and shared // variants of a cc_library. Loading @@ -364,12 +366,21 @@ func NewBazelContext(c *config) (BazelContext, error) { for _, disabledDevModule := range allowlists.MixedBuildsDisabledList { disabledModules[disabledDevModule] = true } default: return noopBazelContext{}, nil } p, err := bazelPathsFromConfig(c) if err != nil { return nil, err } return &bazelContext{ bazelRunner: &builtinBazelRunner{}, paths: p, requests: make(map[cqueryKey]bool), modulesDefaultToBazel: true, modulesDefaultToBazel: modulesDefaultToBazel, bazelEnabledModules: enabledModules, bazelDisabledModules: disabledModules, }, nil } Loading android/config.go +1 −12 Original line number Diff line number Diff line Loading @@ -96,7 +96,6 @@ const ( // Use bazel during analysis of build modules from an allowlist carefully // curated by the build team to be proven stable. // TODO(cparsons): Implement this mode. BazelProdMode ) Loading Loading @@ -481,14 +480,6 @@ func NewConfig(moduleListFile string, buildMode SoongBuildMode, runGoTests bool, config.AndroidFirstDeviceTarget = FirstTarget(config.Targets[Android], "lib64", "lib32")[0] } // Checking USE_BAZEL_ANALYSIS must be done here instead of in the caller, so // that we can invoke IsEnvTrue (which also registers the env var as a // dependency of the build). // TODO(cparsons): Remove this hack once USE_BAZEL_ANALYSIS is removed. if buildMode == AnalysisNoBazel && config.IsEnvTrue("USE_BAZEL_ANALYSIS") { buildMode = BazelDevMode } config.BuildMode = buildMode config.BazelContext, err = NewBazelContext(config) config.bp2buildPackageConfig = GetBp2BuildAllowList() Loading Loading @@ -678,9 +669,7 @@ func (c *config) DeviceName() string { // DeviceProduct returns the current product target. There could be multiple of // these per device type. // // NOTE: Do not base conditional logic on this value. It may break product // // inheritance. // NOTE: Do not base conditional logic on this value. It may break product inheritance. func (c *config) DeviceProduct() string { return *c.productVariables.DeviceProduct } Loading cmd/soong_build/main.go +6 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,8 @@ func init() { flag.StringVar(&bp2buildMarker, "bp2build_marker", "", "If set, run bp2build, touch the specified marker file then exit") flag.StringVar(&cmdlineArgs.OutFile, "o", "build.ninja", "the Ninja file to output") flag.BoolVar(&cmdlineArgs.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file") flag.BoolVar(&cmdlineArgs.BazelMode, "bazel-mode", false, "use bazel for analysis of certain modules") flag.BoolVar(&cmdlineArgs.BazelModeDev, "bazel-mode-dev", false, "use bazel for analysis of a large number of modules (less stable)") // Flags that probably shouldn't be flags of soong_build but we haven't found // the time to remove them yet Loading Loading @@ -131,6 +133,10 @@ func newConfig(availableEnv map[string]string) android.Config { buildMode = android.GenerateModuleGraph } else if docFile != "" { buildMode = android.GenerateDocFile } else if cmdlineArgs.BazelModeDev { buildMode = android.BazelDevMode } else if cmdlineArgs.BazelMode { buildMode = android.BazelProdMode } else { buildMode = android.AnalysisNoBazel } Loading Loading
android/allowlists/allowlists.go +5 −0 Original line number Diff line number Diff line Loading @@ -620,4 +620,9 @@ var ( "prebuilt_platform-robolectric-4.5.1-prebuilt", "prebuilt_currysrc_org.eclipse", } ProdMixedBuildsEnabledList = []string{ // This list left intentionally empty for now. Add specific module names // to have them built by Bazel in Prod Mixed Builds mode. } )
android/bazel.go +5 −5 Original line number Diff line number Diff line Loading @@ -219,16 +219,16 @@ type bp2BuildConversionAllowlist struct { // in the synthetic Bazel workspace. keepExistingBuildFile map[string]bool // Per-module allowlist to always opt modules in of both bp2build and mixed builds. // These modules are usually in directories with many other modules that are not ready for // conversion. // Per-module allowlist to always opt modules into both bp2build and Bazel Dev Mode mixed // builds. These modules are usually in directories with many other modules that are not ready // for conversion. // // A module can either be in this list or its directory allowlisted entirely // in bp2buildDefaultConfig, but not both at the same time. moduleAlwaysConvert map[string]bool // Per-module-type allowlist to always opt modules in to both bp2build and mixed builds // when they have the same type as one listed. // Per-module-type allowlist to always opt modules in to both bp2build and // Bazel Dev Mode mixed builds when they have the same type as one listed. moduleTypeAlwaysConvert map[string]bool // Per-module denylist to always opt modules out of bp2build conversion. Loading
android/bazel_handler.go +26 −15 Original line number Diff line number Diff line Loading @@ -343,18 +343,20 @@ func (m noopBazelContext) AqueryDepsets() []bazel.AqueryDepset { } func NewBazelContext(c *config) (BazelContext, error) { if !c.IsMixedBuildsEnabled() { return noopBazelContext{}, nil } var modulesDefaultToBazel bool disabledModules := map[string]bool{} enabledModules := map[string]bool{} p, err := bazelPathsFromConfig(c) if err != nil { return nil, err switch c.BuildMode { case BazelProdMode: modulesDefaultToBazel = false for _, enabledProdModule := range allowlists.ProdMixedBuildsEnabledList { enabledModules[enabledProdModule] = true } case BazelDevMode: modulesDefaultToBazel = true // TODO(cparsons): Use a different allowlist depending on prod vs. dev // bazel mode. disabledModules := map[string]bool{} // Don't use partially-converted cc_library targets in mixed builds, // since mixed builds would generally rely on both static and shared // variants of a cc_library. Loading @@ -364,12 +366,21 @@ func NewBazelContext(c *config) (BazelContext, error) { for _, disabledDevModule := range allowlists.MixedBuildsDisabledList { disabledModules[disabledDevModule] = true } default: return noopBazelContext{}, nil } p, err := bazelPathsFromConfig(c) if err != nil { return nil, err } return &bazelContext{ bazelRunner: &builtinBazelRunner{}, paths: p, requests: make(map[cqueryKey]bool), modulesDefaultToBazel: true, modulesDefaultToBazel: modulesDefaultToBazel, bazelEnabledModules: enabledModules, bazelDisabledModules: disabledModules, }, nil } Loading
android/config.go +1 −12 Original line number Diff line number Diff line Loading @@ -96,7 +96,6 @@ const ( // Use bazel during analysis of build modules from an allowlist carefully // curated by the build team to be proven stable. // TODO(cparsons): Implement this mode. BazelProdMode ) Loading Loading @@ -481,14 +480,6 @@ func NewConfig(moduleListFile string, buildMode SoongBuildMode, runGoTests bool, config.AndroidFirstDeviceTarget = FirstTarget(config.Targets[Android], "lib64", "lib32")[0] } // Checking USE_BAZEL_ANALYSIS must be done here instead of in the caller, so // that we can invoke IsEnvTrue (which also registers the env var as a // dependency of the build). // TODO(cparsons): Remove this hack once USE_BAZEL_ANALYSIS is removed. if buildMode == AnalysisNoBazel && config.IsEnvTrue("USE_BAZEL_ANALYSIS") { buildMode = BazelDevMode } config.BuildMode = buildMode config.BazelContext, err = NewBazelContext(config) config.bp2buildPackageConfig = GetBp2BuildAllowList() Loading Loading @@ -678,9 +669,7 @@ func (c *config) DeviceName() string { // DeviceProduct returns the current product target. There could be multiple of // these per device type. // // NOTE: Do not base conditional logic on this value. It may break product // // inheritance. // NOTE: Do not base conditional logic on this value. It may break product inheritance. func (c *config) DeviceProduct() string { return *c.productVariables.DeviceProduct } Loading
cmd/soong_build/main.go +6 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,8 @@ func init() { flag.StringVar(&bp2buildMarker, "bp2build_marker", "", "If set, run bp2build, touch the specified marker file then exit") flag.StringVar(&cmdlineArgs.OutFile, "o", "build.ninja", "the Ninja file to output") flag.BoolVar(&cmdlineArgs.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file") flag.BoolVar(&cmdlineArgs.BazelMode, "bazel-mode", false, "use bazel for analysis of certain modules") flag.BoolVar(&cmdlineArgs.BazelModeDev, "bazel-mode-dev", false, "use bazel for analysis of a large number of modules (less stable)") // Flags that probably shouldn't be flags of soong_build but we haven't found // the time to remove them yet Loading Loading @@ -131,6 +133,10 @@ func newConfig(availableEnv map[string]string) android.Config { buildMode = android.GenerateModuleGraph } else if docFile != "" { buildMode = android.GenerateDocFile } else if cmdlineArgs.BazelModeDev { buildMode = android.BazelDevMode } else if cmdlineArgs.BazelMode { buildMode = android.BazelProdMode } else { buildMode = android.AnalysisNoBazel } Loading