diff options
author | 2024-10-21 15:02:44 -0700 | |
---|---|---|
committer | 2024-10-21 15:04:55 -0700 | |
commit | 35f300dff0179053099972d48d89d7d47bb4de1b (patch) | |
tree | 9aed8a88f84a7764e4849d848dfb75ee66aca575 /cmd | |
parent | d117bec818132461f48625ea5c423e012e3b5164 (diff) |
Remove bp2build and appurtenances.
Bug: 374816306
Test: treehugger
Change-Id: Ic26f6d6e0772fb07e43d22873519c5afb2ee9a45
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/soong_build/Android.bp | 2 | ||||
-rw-r--r-- | cmd/soong_build/main.go | 18 | ||||
-rw-r--r-- | cmd/soong_build/queryview.go | 112 | ||||
-rw-r--r-- | cmd/soong_ui/main.go | 3 |
4 files changed, 2 insertions, 133 deletions
diff --git a/cmd/soong_build/Android.bp b/cmd/soong_build/Android.bp index 72af3e00c..d8f563bf0 100644 --- a/cmd/soong_build/Android.bp +++ b/cmd/soong_build/Android.bp @@ -26,13 +26,11 @@ blueprint_go_binary { "soong", "soong-android", "soong-provenance", - "soong-bp2build", "soong-ui-metrics_proto", ], srcs: [ "main.go", "writedocs.go", - "queryview.go", ], primaryBuilder: true, } diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 5b1ae5406..6642023a5 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -26,7 +26,6 @@ import ( "android/soong/android" "android/soong/android/allowlists" - "android/soong/bp2build" "android/soong/shared" "github.com/google/blueprint" @@ -78,7 +77,6 @@ func init() { flag.StringVar(&cmdlineArgs.ModuleGraphFile, "module_graph_file", "", "JSON module graph file to output") flag.StringVar(&cmdlineArgs.ModuleActionsFile, "module_actions_file", "", "JSON file to output inputs/outputs of actions of modules") flag.StringVar(&cmdlineArgs.DocFile, "soong_docs", "", "build documentation file to output") - flag.StringVar(&cmdlineArgs.BazelQueryViewDir, "bazel_queryview_dir", "", "path to the bazel queryview directory relative to --top") flag.StringVar(&cmdlineArgs.OutFile, "o", "build.ninja", "the Ninja file to output") flag.StringVar(&cmdlineArgs.SoongVariables, "soong_variables", "soong.variables", "the file contains all build variables") flag.BoolVar(&cmdlineArgs.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file") @@ -121,16 +119,6 @@ func needToWriteNinjaHint(ctx *android.Context) bool { return false } -// Run the code-generation phase to convert BazelTargetModules to BUILD files. -func runQueryView(queryviewDir, queryviewMarker string, ctx *android.Context) { - ctx.EventHandler.Begin("queryview") - defer ctx.EventHandler.End("queryview") - codegenContext := bp2build.NewCodegenContext(ctx.Config(), ctx, bp2build.QueryView, topDir) - err := createBazelWorkspace(codegenContext, shared.JoinPath(topDir, queryviewDir), false) - maybeQuit(err, "") - touch(shared.JoinPath(topDir, queryviewMarker)) -} - func writeNinjaHint(ctx *android.Context) error { ctx.BeginEvent("ninja_hint") defer ctx.EndEvent("ninja_hint") @@ -283,7 +271,7 @@ func runSoongOnlyBuild(ctx *android.Context) (string, []string) { switch ctx.Config().BuildMode { case android.GenerateModuleGraph: stopBefore = bootstrap.StopBeforeWriteNinja - case android.GenerateQueryView, android.GenerateDocFile: + case android.GenerateDocFile: stopBefore = bootstrap.StopBeforePrepareBuildActions default: stopBefore = bootstrap.DoEverything @@ -294,10 +282,6 @@ func runSoongOnlyBuild(ctx *android.Context) (string, []string) { // Convert the Soong module graph into Bazel BUILD files. switch ctx.Config().BuildMode { - case android.GenerateQueryView: - queryviewMarkerFile := cmdlineArgs.BazelQueryViewDir + ".marker" - runQueryView(cmdlineArgs.BazelQueryViewDir, queryviewMarkerFile, ctx) - return queryviewMarkerFile, ninjaDeps case android.GenerateModuleGraph: writeJsonModuleGraphAndActions(ctx, cmdlineArgs) return cmdlineArgs.ModuleGraphFile, ninjaDeps diff --git a/cmd/soong_build/queryview.go b/cmd/soong_build/queryview.go deleted file mode 100644 index eafd67a2d..000000000 --- a/cmd/soong_build/queryview.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2020 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "io/fs" - "io/ioutil" - "os" - "path/filepath" - - "android/soong/android" - "android/soong/bp2build" -) - -// A helper function to generate a Read-only Bazel workspace in outDir -func createBazelWorkspace(ctx *bp2build.CodegenContext, outDir string, generateFilegroups bool) error { - os.RemoveAll(outDir) - ruleShims := bp2build.CreateRuleShims(android.ModuleTypeFactories()) - - res, err := bp2build.GenerateBazelTargets(ctx, generateFilegroups) - if err != nil { - panic(err) - } - - filesToWrite := bp2build.CreateBazelFiles(ruleShims, res.BuildDirToTargets(), ctx.Mode()) - bazelRcFiles, err2 := CopyBazelRcFiles() - if err2 != nil { - return err2 - } - filesToWrite = append(filesToWrite, bazelRcFiles...) - for _, f := range filesToWrite { - if err := writeReadOnlyFile(outDir, f); err != nil { - return err - } - } - - return nil -} - -// CopyBazelRcFiles creates BazelFiles for all the bazelrc files under -// build/bazel. They're needed because the rc files are still read when running -// queryview, so they have to be in the queryview workspace. -func CopyBazelRcFiles() ([]bp2build.BazelFile, error) { - result := make([]bp2build.BazelFile, 0) - err := filepath.WalkDir(filepath.Join(topDir, "build/bazel"), func(path string, info fs.DirEntry, err error) error { - if filepath.Ext(path) == ".bazelrc" { - contents, err := os.ReadFile(path) - if err != nil { - return err - } - path, err = filepath.Rel(topDir, path) - if err != nil { - return err - } - result = append(result, bp2build.BazelFile{ - Dir: filepath.Dir(path), - Basename: filepath.Base(path), - Contents: string(contents), - }) - } - return nil - }) - return result, err -} - -// The auto-conversion directory should be read-only, sufficient for bazel query. The files -// are not intended to be edited by end users. -func writeReadOnlyFile(dir string, f bp2build.BazelFile) error { - dir = filepath.Join(dir, f.Dir) - if err := createDirectoryIfNonexistent(dir); err != nil { - return err - } - pathToFile := filepath.Join(dir, f.Basename) - - // 0444 is read-only - err := ioutil.WriteFile(pathToFile, []byte(f.Contents), 0444) - - return err -} - -func writeReadWriteFile(dir string, f bp2build.BazelFile) error { - dir = filepath.Join(dir, f.Dir) - if err := createDirectoryIfNonexistent(dir); err != nil { - return err - } - pathToFile := filepath.Join(dir, f.Basename) - - // 0644 is read-write - err := ioutil.WriteFile(pathToFile, []byte(f.Contents), 0644) - - return err -} - -func createDirectoryIfNonexistent(dir string) error { - if _, err := os.Stat(dir); os.IsNotExist(err) { - return os.MkdirAll(dir, os.ModePerm) - } else { - return err - } -} diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go index 2d3156a46..c7134d70d 100644 --- a/cmd/soong_ui/main.go +++ b/cmd/soong_ui/main.go @@ -251,11 +251,10 @@ func preProductConfigSetup(buildCtx build.Context, config build.Config) { buildErrorFile := filepath.Join(logsDir, logsPrefix+"build_error") rbeMetricsFile := filepath.Join(logsDir, logsPrefix+"rbe_metrics.pb") soongMetricsFile := filepath.Join(logsDir, logsPrefix+"soong_metrics") - bp2buildMetricsFile := filepath.Join(logsDir, logsPrefix+"bp2build_metrics.pb") soongBuildMetricsFile := filepath.Join(logsDir, logsPrefix+"soong_build_metrics.pb") //Delete the stale metrics files - staleFileSlice := []string{buildErrorFile, rbeMetricsFile, soongMetricsFile, bp2buildMetricsFile, soongBuildMetricsFile} + staleFileSlice := []string{buildErrorFile, rbeMetricsFile, soongMetricsFile, soongBuildMetricsFile} if err := deleteStaleMetrics(staleFileSlice); err != nil { log.Fatalln(err) } |