Cosmetic Changes plus log errors
Test: N/A
Bug: N/A
Change-Id: I39e622a93270c922bdbea27ca79632a606431a2c
diff --git a/bp2build/bp2build.go b/bp2build/bp2build.go
index 5bff956..0e3d2a5 100644
--- a/bp2build/bp2build.go
+++ b/bp2build/bp2build.go
@@ -29,7 +29,9 @@
func Codegen(ctx *CodegenContext) CodegenMetrics {
// This directory stores BUILD files that could be eventually checked-in.
bp2buildDir := android.PathForOutput(ctx, "bp2build")
- android.RemoveAllOutputDir(bp2buildDir)
+ if err := android.RemoveAllOutputDir(bp2buildDir); err != nil {
+ fmt.Printf("ERROR: Encountered error while cleaning %s: %s", bp2buildDir, err.Error())
+ }
res, errs := GenerateBazelTargets(ctx, true)
if len(errs) > 0 {
@@ -52,7 +54,9 @@
// Get the output directory and create it if it doesn't exist.
func getOrCreateOutputDir(outputDir android.OutputPath, ctx android.PathContext, dir string) android.OutputPath {
dirPath := outputDir.Join(ctx, dir)
- android.CreateOutputDirIfNonexistent(dirPath, os.ModePerm)
+ if err := android.CreateOutputDirIfNonexistent(dirPath, os.ModePerm); err != nil {
+ fmt.Printf("ERROR: path %s: %s", dirPath, err.Error())
+ }
return dirPath
}
@@ -60,13 +64,13 @@
func writeFiles(ctx android.PathContext, outputDir android.OutputPath, files []BazelFile) {
for _, f := range files {
p := getOrCreateOutputDir(outputDir, ctx, f.Dir).Join(ctx, f.Basename)
- if err := writeFile(ctx, p, f.Contents); err != nil {
+ if err := writeFile(p, f.Contents); err != nil {
panic(fmt.Errorf("Failed to write %q (dir %q) due to %q", f.Basename, f.Dir, err))
}
}
}
-func writeFile(ctx android.PathContext, pathToFile android.OutputPath, content string) error {
+func writeFile(pathToFile android.OutputPath, content string) error {
// These files are made editable to allow users to modify and iterate on them
// in the source tree.
return android.WriteFileToOutputDir(pathToFile, []byte(content), 0644)
diff --git a/bp2build/build_conversion.go b/bp2build/build_conversion.go
index a96a3fc..415becb 100644
--- a/bp2build/build_conversion.go
+++ b/bp2build/build_conversion.go
@@ -161,22 +161,22 @@
unconvertedDepMode unconvertedDepsMode
}
-func (c *CodegenContext) Mode() CodegenMode {
- return c.mode
+func (ctx *CodegenContext) Mode() CodegenMode {
+ return ctx.mode
}
// CodegenMode is an enum to differentiate code-generation modes.
type CodegenMode int
const (
- // Bp2Build: generate BUILD files with targets buildable by Bazel directly.
+ // Bp2Build - generate BUILD files with targets buildable by Bazel directly.
//
// This mode is used for the Soong->Bazel build definition conversion.
Bp2Build CodegenMode = iota
- // QueryView: generate BUILD files with targets representing fully mutated
+ // QueryView - generate BUILD files with targets representing fully mutated
// Soong modules, representing the fully configured Soong module graph with
- // variants and dependency endges.
+ // variants and dependency edges.
//
// This mode is used for discovering and introspecting the existing Soong
// module graph.
@@ -470,13 +470,13 @@
})
}
- for p, _ := range ignoredPropNames {
+ for p := range ignoredPropNames {
delete(props.Attrs, p)
}
attributes := propsToAttributes(props.Attrs)
depLabelList := "[\n"
- for depLabel, _ := range depLabels {
+ for depLabel := range depLabels {
depLabelList += fmt.Sprintf(" %q,\n", depLabel)
}
depLabelList += " ]"
diff --git a/bp2build/symlink_forest.go b/bp2build/symlink_forest.go
index c5075e5..78e7b0e 100644
--- a/bp2build/symlink_forest.go
+++ b/bp2build/symlink_forest.go
@@ -22,7 +22,7 @@
children map[string]*node
}
-// Ensures that the a node for the given path exists in the tree and returns it.
+// Ensures that the node for the given path exists in the tree and returns it.
func ensureNodeExists(root *node, path string) *node {
if path == "" {
return root
@@ -126,11 +126,11 @@
buildFilesMap := readdirToMap(shared.JoinPath(topdir, buildFilesDir))
allEntries := make(map[string]bool)
- for n, _ := range srcDirMap {
+ for n := range srcDirMap {
allEntries[n] = true
}
- for n, _ := range buildFilesMap {
+ for n := range buildFilesMap {
allEntries[n] = true
}
@@ -140,7 +140,7 @@
os.Exit(1)
}
- for f, _ := range allEntries {
+ for f := range allEntries {
if f[0] == '.' {
continue // Ignore dotfiles
}