summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jingwen Chen <jingwen@google.com> 2020-11-06 07:56:26 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2020-11-06 07:56:26 +0000
commit1a3922bf09cf68f7c317b69ad059416d7352ccbf (patch)
tree5e72d880bd298da439544673726dea688815841a
parent567f46fe63ee2b2d0143ea8ba93a14374bf9e501 (diff)
parent50f93d207865bb29f03c226d5428d8fad11275c7 (diff)
Merge "Rename bazel overlay to queryview."
-rw-r--r--android/Android.bp2
-rw-r--r--android/queryview.go (renamed from android/bazel_overlay.go)36
-rw-r--r--cmd/soong_build/Android.bp4
-rw-r--r--cmd/soong_build/main.go14
-rw-r--r--cmd/soong_build/queryview.go (renamed from cmd/soong_build/bazel_overlay.go)25
-rw-r--r--cmd/soong_build/queryview_test.go (renamed from cmd/soong_build/bazel_overlay_test.go)8
6 files changed, 45 insertions, 44 deletions
diff --git a/android/Android.bp b/android/Android.bp
index 2de0ca9ff..7bd145080 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -16,7 +16,6 @@ bootstrap_go_package {
"api_levels.go",
"arch.go",
"bazel_handler.go",
- "bazel_overlay.go",
"config.go",
"csuite_config.go",
"defaults.go",
@@ -44,6 +43,7 @@ bootstrap_go_package {
"prebuilt.go",
"prebuilt_build_tool.go",
"proto.go",
+ "queryview.go",
"register.go",
"rule_builder.go",
"sandbox.go",
diff --git a/android/bazel_overlay.go b/android/queryview.go
index a0342826d..dff00f686 100644
--- a/android/bazel_overlay.go
+++ b/android/queryview.go
@@ -22,55 +22,55 @@ import (
"github.com/google/blueprint"
)
-// The Bazel Overlay singleton is responsible for generating the Ninja actions
+// The Bazel QueryView singleton is responsible for generating the Ninja actions
// for calling the soong_build primary builder in the main build.ninja file.
func init() {
- RegisterSingletonType("bazel_overlay", BazelOverlaySingleton)
+ RegisterSingletonType("bazel_queryView", BazelQueryViewSingleton)
}
-func BazelOverlaySingleton() Singleton {
- return &bazelOverlaySingleton{}
+func BazelQueryViewSingleton() Singleton {
+ return &bazelQueryViewSingleton{}
}
-type bazelOverlaySingleton struct{}
+type bazelQueryViewSingleton struct{}
-func (c *bazelOverlaySingleton) GenerateBuildActions(ctx SingletonContext) {
- // Create a build and rule statement, using the Bazel overlay's WORKSPACE
+func (c *bazelQueryViewSingleton) GenerateBuildActions(ctx SingletonContext) {
+ // Create a build and rule statement, using the Bazel QueryView's WORKSPACE
// file as the output file marker.
var deps Paths
moduleListFilePath := pathForBuildToolDep(ctx, ctx.Config().moduleListFile)
deps = append(deps, moduleListFilePath)
deps = append(deps, pathForBuildToolDep(ctx, ctx.Config().ProductVariablesFileName))
- bazelOverlayDirectory := PathForOutput(ctx, "bazel_overlay")
- bazelOverlayWorkspaceFile := bazelOverlayDirectory.Join(ctx, "WORKSPACE")
+ bazelQueryViewDirectory := PathForOutput(ctx, "queryview")
+ bazelQueryViewWorkspaceFile := bazelQueryViewDirectory.Join(ctx, "WORKSPACE")
primaryBuilder := primaryBuilderPath(ctx)
- bazelOverlay := ctx.Rule(pctx, "bazelOverlay",
+ bazelQueryView := ctx.Rule(pctx, "bazelQueryView",
blueprint.RuleParams{
Command: fmt.Sprintf(
- "rm -rf ${outDir}/* && %s --bazel_overlay_dir ${outDir} %s && echo WORKSPACE: `cat %s` > ${outDir}/.overlay-depfile.d",
+ "rm -rf ${outDir}/* && %s --bazel_queryview_dir ${outDir} %s && echo WORKSPACE: `cat %s` > ${outDir}/.queryview-depfile.d",
primaryBuilder.String(),
strings.Join(os.Args[1:], " "),
moduleListFilePath.String(), // Use the contents of Android.bp.list as the depfile.
),
CommandDeps: []string{primaryBuilder.String()},
Description: fmt.Sprintf(
- "Creating the Bazel overlay workspace with %s at $outDir",
+ "Creating the Bazel QueryView workspace with %s at $outDir",
primaryBuilder.Base()),
Deps: blueprint.DepsGCC,
- Depfile: "${outDir}/.overlay-depfile.d",
+ Depfile: "${outDir}/.queryview-depfile.d",
},
"outDir")
ctx.Build(pctx, BuildParams{
- Rule: bazelOverlay,
- Output: bazelOverlayWorkspaceFile,
+ Rule: bazelQueryView,
+ Output: bazelQueryViewWorkspaceFile,
Inputs: deps,
Args: map[string]string{
- "outDir": bazelOverlayDirectory.String(),
+ "outDir": bazelQueryViewDirectory.String(),
},
})
- // Add a phony target for building the bazel overlay
- ctx.Phony("bazel_overlay", bazelOverlayWorkspaceFile)
+ // Add a phony target for building the Bazel QueryView
+ ctx.Phony("queryview", bazelQueryViewWorkspaceFile)
}
diff --git a/cmd/soong_build/Android.bp b/cmd/soong_build/Android.bp
index 4ebbe6895..680c00a9b 100644
--- a/cmd/soong_build/Android.bp
+++ b/cmd/soong_build/Android.bp
@@ -26,10 +26,10 @@ bootstrap_go_binary {
srcs: [
"main.go",
"writedocs.go",
- "bazel_overlay.go",
+ "queryview.go",
],
testSrcs: [
- "bazel_overlay_test.go",
+ "queryview_test.go",
],
primaryBuilder: true,
}
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 7ae1c3738..9d7dddd84 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -26,13 +26,13 @@ import (
)
var (
- docFile string
- bazelOverlayDir string
+ docFile string
+ bazelQueryViewDir string
)
func init() {
flag.StringVar(&docFile, "soong_docs", "", "build documentation file to output")
- flag.StringVar(&bazelOverlayDir, "bazel_overlay_dir", "", "path to the bazel overlay directory")
+ flag.StringVar(&bazelQueryViewDir, "bazel_queryview_dir", "", "path to the bazel queryview directory")
}
func newNameResolver(config android.Config) *android.NameResolver {
@@ -113,8 +113,8 @@ func main() {
ctx = newContext(srcDir, configuration)
bootstrap.Main(ctx.Context, configuration, extraNinjaDeps...)
}
- if bazelOverlayDir != "" {
- if err := createBazelOverlay(ctx, bazelOverlayDir); err != nil {
+ if bazelQueryViewDir != "" {
+ if err := createBazelQueryView(ctx, bazelQueryViewDir); err != nil {
fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1)
}
@@ -140,7 +140,7 @@ func main() {
}
func shouldPrepareBuildActions() bool {
- // If we're writing soong_docs or bazel_overlay, don't write build.ninja or
+ // If we're writing soong_docs or queryview, don't write build.ninja or
// collect metrics.
- return docFile == "" && bazelOverlayDir == ""
+ return docFile == "" && bazelQueryViewDir == ""
}
diff --git a/cmd/soong_build/bazel_overlay.go b/cmd/soong_build/queryview.go
index fc1b4929c..27856b53a 100644
--- a/cmd/soong_build/bazel_overlay.go
+++ b/cmd/soong_build/queryview.go
@@ -31,7 +31,7 @@ import (
const (
// The default `load` preamble for every generated BUILD file.
soongModuleLoad = `package(default_visibility = ["//visibility:public"])
-load("//build/bazel/overlay_rules:soong_module.bzl", "soong_module")
+load("//build/bazel/queryview_rules:soong_module.bzl", "soong_module")
`
@@ -62,7 +62,7 @@ load("//build/bazel/overlay_rules:soong_module.bzl", "soong_module")
soongModuleBzl = `
%s
-load("//build/bazel/overlay_rules:providers.bzl", "SoongModuleInfo")
+load("//build/bazel/queryview_rules:providers.bzl", "SoongModuleInfo")
def _generic_soong_module_impl(ctx):
return [
@@ -396,7 +396,7 @@ func createRuleShims(packages []*bpdoc.Package) (map[string]RuleShim, error) {
ruleShims := map[string]RuleShim{}
for _, pkg := range packages {
- content := "load(\"//build/bazel/overlay_rules:providers.bzl\", \"SoongModuleInfo\")\n"
+ content := "load(\"//build/bazel/queryview_rules:providers.bzl\", \"SoongModuleInfo\")\n"
bzlFileName := strings.ReplaceAll(pkg.Path, "android/soong/", "")
bzlFileName = strings.ReplaceAll(bzlFileName, ".", "_")
@@ -441,10 +441,10 @@ func createRuleShims(packages []*bpdoc.Package) (map[string]RuleShim, error) {
return ruleShims, nil
}
-func createBazelOverlay(ctx *android.Context, bazelOverlayDir string) error {
+func createBazelQueryView(ctx *android.Context, bazelQueryViewDir string) error {
blueprintCtx := ctx.Context
blueprintCtx.VisitAllModules(func(module blueprint.Module) {
- buildFile, err := buildFileForModule(blueprintCtx, module)
+ buildFile, err := buildFileForModule(blueprintCtx, module, bazelQueryViewDir)
if err != nil {
panic(err)
}
@@ -455,12 +455,12 @@ func createBazelOverlay(ctx *android.Context, bazelOverlayDir string) error {
var err error
// Write top level files: WORKSPACE and BUILD. These files are empty.
- if err = writeReadOnlyFile(bazelOverlayDir, "WORKSPACE", ""); err != nil {
+ if err = writeReadOnlyFile(bazelQueryViewDir, "WORKSPACE", ""); err != nil {
return err
}
// Used to denote that the top level directory is a package.
- if err = writeReadOnlyFile(bazelOverlayDir, "BUILD", ""); err != nil {
+ if err = writeReadOnlyFile(bazelQueryViewDir, "BUILD", ""); err != nil {
return err
}
@@ -474,7 +474,7 @@ func createBazelOverlay(ctx *android.Context, bazelOverlayDir string) error {
}
// Write .bzl Starlark files into the bazel_rules top level directory (provider and rule definitions)
- bazelRulesDir := bazelOverlayDir + "/build/bazel/overlay_rules"
+ bazelRulesDir := bazelQueryViewDir + "/build/bazel/queryview_rules"
if err = writeReadOnlyFile(bazelRulesDir, "BUILD", ""); err != nil {
return err
}
@@ -497,7 +497,7 @@ func generateSoongModuleBzl(bzlLoads map[string]RuleShim) string {
var loadStmts string
var moduleRuleMap string
for bzlFileName, ruleShim := range bzlLoads {
- loadStmt := "load(\"//build/bazel/overlay_rules:"
+ loadStmt := "load(\"//build/bazel/queryview_rules:"
loadStmt += bzlFileName
loadStmt += ".bzl\""
for _, rule := range ruleShim.rules {
@@ -563,9 +563,10 @@ func generateSoongModuleTarget(
attributes)
}
-func buildFileForModule(ctx *blueprint.Context, module blueprint.Module) (*os.File, error) {
+func buildFileForModule(
+ ctx *blueprint.Context, module blueprint.Module, bazelQueryViewDir string) (*os.File, error) {
// Create nested directories for the BUILD file
- dirPath := filepath.Join(bazelOverlayDir, packagePath(ctx, module))
+ dirPath := filepath.Join(bazelQueryViewDir, packagePath(ctx, module))
createDirectoryIfNonexistent(dirPath)
// Open the file for appending, and create it if it doesn't exist
f, err := os.OpenFile(
@@ -594,7 +595,7 @@ func createDirectoryIfNonexistent(dir string) {
}
}
-// The overlay directory should be read-only, sufficient for bazel query. The files
+// The QueryView directory should be read-only, sufficient for bazel query. The files
// are not intended to be edited by end users.
func writeReadOnlyFile(dir string, baseName string, content string) error {
createDirectoryIfNonexistent(dir)
diff --git a/cmd/soong_build/bazel_overlay_test.go b/cmd/soong_build/queryview_test.go
index 548888e9e..675b53280 100644
--- a/cmd/soong_build/bazel_overlay_test.go
+++ b/cmd/soong_build/queryview_test.go
@@ -28,7 +28,7 @@ var buildDir string
func setUp() {
var err error
- buildDir, err = ioutil.TempDir("", "bazel_overlay_test")
+ buildDir, err = ioutil.TempDir("", "bazel_queryview_test")
if err != nil {
panic(err)
}
@@ -63,7 +63,7 @@ func customModuleFactory() android.Module {
return module
}
-func TestGenerateBazelOverlayFromBlueprint(t *testing.T) {
+func TestGenerateBazelQueryViewFromBlueprint(t *testing.T) {
testCases := []struct {
bp string
expectedBazelTarget string
@@ -362,7 +362,7 @@ func TestGenerateModuleRuleShims(t *testing.T) {
}
}
- expectedBzl := `load("//build/bazel/overlay_rules:providers.bzl", "SoongModuleInfo")
+ expectedBzl := `load("//build/bazel/queryview_rules:providers.bzl", "SoongModuleInfo")
def _foo_binary_impl(ctx):
return [SoongModuleInfo()]
@@ -440,7 +440,7 @@ func TestGenerateSoongModuleBzl(t *testing.T) {
}
actualSoongModuleBzl := generateSoongModuleBzl(ruleShims)
- expectedLoad := "load(\"//build/bazel/overlay_rules:foo.bzl\", \"foo_binary\", \"foo_library\", \"foo_test_\")"
+ expectedLoad := "load(\"//build/bazel/queryview_rules:foo.bzl\", \"foo_binary\", \"foo_library\", \"foo_test_\")"
expectedRuleMap := `soong_module_rule_map = {
"foo_binary": foo_binary,
"foo_library": foo_library,