Remove infrastructure to run bp2build
Bug: 315353489
Test: m blueprint_tests
Change-Id: Idcf6377d389b94c39e4e6ff4b8efa8a9f9e78b17
diff --git a/bp2build/conversion.go b/bp2build/conversion.go
index be3c7ff..9f1aa09 100644
--- a/bp2build/conversion.go
+++ b/bp2build/conversion.go
@@ -1,15 +1,10 @@
package bp2build
import (
- "encoding/json"
- "fmt"
"reflect"
- "strconv"
"strings"
"android/soong/android"
- "android/soong/starlark_fmt"
-
"github.com/google/blueprint/proptools"
)
@@ -19,79 +14,6 @@
Contents string
}
-// createSoongInjectionDirFiles returns most of the files to write to the soong_injection directory.
-// Some other files also come from CreateProductConfigFiles
-func createSoongInjectionDirFiles(ctx *CodegenContext, metrics CodegenMetrics) ([]BazelFile, error) {
- cfg := ctx.Config()
- var files []BazelFile
-
- files = append(files, newFile("android", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package.
- files = append(files, newFile("android", "constants.bzl", android.BazelCcToolchainVars(cfg)))
-
- if buf, err := json.MarshalIndent(metrics.convertedModuleWithType, "", " "); err != nil {
- return []BazelFile{}, err
- } else {
- files = append(files, newFile("metrics", "converted_modules.json", string(buf)))
- }
-
- convertedModulePathMap, err := json.MarshalIndent(metrics.convertedModulePathMap, "", "\t")
- if err != nil {
- panic(err)
- }
- files = append(files, newFile("metrics", GeneratedBuildFileName, "")) // Creates a //metrics package.
- files = append(files, newFile("metrics", "converted_modules_path_map.json", string(convertedModulePathMap)))
- files = append(files, newFile("metrics", "converted_modules_path_map.bzl", "modules = "+strings.ReplaceAll(string(convertedModulePathMap), "\\", "\\\\")))
-
- files = append(files, newFile("product_config", "soong_config_variables.bzl", cfg.Bp2buildSoongConfigDefinitions.String()))
-
- files = append(files, newFile("product_config", "arch_configuration.bzl", android.StarlarkArchConfigurations()))
-
- apiLevelsMap, err := android.GetApiLevelsMap(cfg)
- if err != nil {
- return nil, err
- }
- apiLevelsContent, err := json.Marshal(apiLevelsMap)
- if err != nil {
- return nil, err
- }
- files = append(files, newFile("api_levels", GeneratedBuildFileName, `exports_files(["api_levels.json"])`))
- // TODO(b/269691302) value of apiLevelsContent is product variable dependent and should be avoided for soong injection
- files = append(files, newFile("api_levels", "api_levels.json", string(apiLevelsContent)))
- files = append(files, newFile("api_levels", "platform_versions.bzl", platformVersionContents(cfg)))
-
- files = append(files, newFile("allowlists", GeneratedBuildFileName, ""))
- // 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_staging_allowlist.txt", strings.Join(android.GetBazelEnabledModules(android.BazelStagingMode), "\n")+"\n"))
-
- return files, nil
-}
-
-func platformVersionContents(cfg android.Config) string {
- // Despite these coming from cfg.productVariables, they are actually hardcoded in global
- // makefiles, not set in individual product config makesfiles, so they're safe to just export
- // and load() directly.
-
- platformVersionActiveCodenames := make([]string, 0, len(cfg.PlatformVersionActiveCodenames()))
- for _, codename := range cfg.PlatformVersionActiveCodenames() {
- platformVersionActiveCodenames = append(platformVersionActiveCodenames, fmt.Sprintf("%q", codename))
- }
-
- platformSdkVersion := "None"
- if cfg.RawPlatformSdkVersion() != nil {
- platformSdkVersion = strconv.Itoa(*cfg.RawPlatformSdkVersion())
- }
-
- return fmt.Sprintf(`
-platform_versions = struct(
- platform_sdk_final = %s,
- platform_sdk_version = %s,
- platform_sdk_codename = %q,
- platform_version_active_codenames = [%s],
-)
-`, starlark_fmt.PrintBool(cfg.PlatformSdkFinal()), platformSdkVersion, cfg.PlatformSdkCodename(), strings.Join(platformVersionActiveCodenames, ", "))
-}
-
func CreateBazelFiles(ruleShims map[string]RuleShim, buildToTargets map[string]BazelTargets, mode CodegenMode) []BazelFile {
var files []BazelFile
@@ -125,20 +47,7 @@
targets.sort()
var content string
- if mode == Bp2Build {
- content = `# READ THIS FIRST:
-# This file was automatically generated by bp2build for the Bazel migration project.
-# Feel free to edit or test it, but do *not* check it into your version control system.
-`
- content += targets.LoadStatements()
- content += "\n\n"
- // Get package rule from the handcrafted BUILD file, otherwise emit the default one.
- prText := "package(default_visibility = [\"//visibility:public\"])\n"
- if pr := targets.packageRule(); pr != nil {
- prText = pr.content
- }
- content += prText
- } else if mode == QueryView {
+ if mode == QueryView {
content = soongModuleLoad
}
if content != "" {
@@ -161,14 +70,6 @@
const (
bazelRulesSubDir = "build/bazel/queryview_rules"
-
- // additional files:
- // * workspace file
- // * base BUILD file
- // * rules BUILD file
- // * rules providers.bzl file
- // * rules soong_module.bzl file
- numAdditionalFiles = 5
)
var (