Merge "Add bp2build converter for cc library stubs and use the stub library target of a library while linking it in APEXs."
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 6686c87..7a0dac3 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -26,6 +26,7 @@
"strings"
"android/soong/bazel/cquery"
+
"github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/proptools"
@@ -468,6 +469,7 @@
return "SOONG_ERROR", nil
}
+ // Apply shell escape to each cases to prevent source file paths containing $ from being evaluated in shell
switch name {
case "location":
if len(g.properties.Tools) == 0 && len(g.properties.Tool_files) == 0 {
@@ -481,15 +483,15 @@
return reportError("default label %q has multiple files, use $(locations %s) to reference it",
firstLabel, firstLabel)
}
- return paths[0], nil
+ return proptools.ShellEscape(paths[0]), nil
case "in":
- return strings.Join(cmd.PathsForInputs(srcFiles), " "), nil
+ return strings.Join(proptools.ShellEscapeList(cmd.PathsForInputs(srcFiles)), " "), nil
case "out":
var sandboxOuts []string
for _, out := range task.out {
sandboxOuts = append(sandboxOuts, cmd.PathForOutput(out))
}
- return strings.Join(sandboxOuts, " "), nil
+ return strings.Join(proptools.ShellEscapeList(sandboxOuts), " "), nil
case "depfile":
referencedDepfile = true
if !Bool(g.properties.Depfile) {
@@ -497,7 +499,7 @@
}
return "__SBOX_DEPFILE__", nil
case "genDir":
- return cmd.PathForOutput(task.genDir), nil
+ return proptools.ShellEscape(cmd.PathForOutput(task.genDir)), nil
default:
if strings.HasPrefix(name, "location ") {
label := strings.TrimSpace(strings.TrimPrefix(name, "location "))
@@ -509,7 +511,7 @@
return reportError("label %q has multiple files, use $(locations %s) to reference it",
label, label)
}
- return paths[0], nil
+ return proptools.ShellEscape(paths[0]), nil
} else {
return reportError("unknown location label %q is not in srcs, out, tools or tool_files.", label)
}
@@ -520,7 +522,7 @@
if len(paths) == 0 {
return reportError("label %q has no files", label)
}
- return strings.Join(paths, " "), nil
+ return proptools.ShellEscape(strings.Join(paths, " ")), nil
} else {
return reportError("unknown locations label %q is not in srcs, out, tools or tool_files.", label)
}
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index b9be1f7..cd941cc 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -422,7 +422,7 @@
allowMissingDependencies: true,
- expect: "cat ***missing srcs :missing*** > __SBOX_SANDBOX_DIR__/out/out",
+ expect: "cat '***missing srcs :missing***' > __SBOX_SANDBOX_DIR__/out/out",
},
{
name: "tool allow missing dependencies",
@@ -434,7 +434,7 @@
allowMissingDependencies: true,
- expect: "***missing tool :missing*** > __SBOX_SANDBOX_DIR__/out/out",
+ expect: "'***missing tool :missing***' > __SBOX_SANDBOX_DIR__/out/out",
},
}
@@ -878,6 +878,92 @@
android.AssertDeepEquals(t, "output deps", expectedOutputFiles, gen.outputDeps.Strings())
}
+func TestGenruleWithGlobPaths(t *testing.T) {
+ testcases := []struct {
+ name string
+ bp string
+ additionalFiles android.MockFS
+ expectedCmd string
+ }{
+ {
+ name: "single file in directory with $ sign",
+ bp: `
+ genrule {
+ name: "gen",
+ srcs: ["inn*.txt"],
+ out: ["out.txt"],
+ cmd: "cp $(in) $(out)",
+ }
+ `,
+ additionalFiles: android.MockFS{"inn$1.txt": nil},
+ expectedCmd: "cp 'inn$1.txt' __SBOX_SANDBOX_DIR__/out/out.txt",
+ },
+ {
+ name: "multiple file in directory with $ sign",
+ bp: `
+ genrule {
+ name: "gen",
+ srcs: ["inn*.txt"],
+ out: ["."],
+ cmd: "cp $(in) $(out)",
+ }
+ `,
+ additionalFiles: android.MockFS{"inn$1.txt": nil, "inn$2.txt": nil},
+ expectedCmd: "cp 'inn$1.txt' 'inn$2.txt' __SBOX_SANDBOX_DIR__/out",
+ },
+ {
+ name: "file in directory with other shell unsafe character",
+ bp: `
+ genrule {
+ name: "gen",
+ srcs: ["inn*.txt"],
+ out: ["out.txt"],
+ cmd: "cp $(in) $(out)",
+ }
+ `,
+ additionalFiles: android.MockFS{"inn@1.txt": nil},
+ expectedCmd: "cp 'inn@1.txt' __SBOX_SANDBOX_DIR__/out/out.txt",
+ },
+ {
+ name: "glob location param with filepath containing $",
+ bp: `
+ genrule {
+ name: "gen",
+ srcs: ["**/inn*"],
+ out: ["."],
+ cmd: "cp $(in) $(location **/inn*)",
+ }
+ `,
+ additionalFiles: android.MockFS{"a/inn$1.txt": nil},
+ expectedCmd: "cp 'a/inn$1.txt' 'a/inn$1.txt'",
+ },
+ {
+ name: "glob locations param with filepath containing $",
+ bp: `
+ genrule {
+ name: "gen",
+ tool_files: ["**/inn*"],
+ out: ["out.txt"],
+ cmd: "cp $(locations **/inn*) $(out)",
+ }
+ `,
+ additionalFiles: android.MockFS{"a/inn$1.txt": nil},
+ expectedCmd: "cp '__SBOX_SANDBOX_DIR__/tools/src/a/inn$1.txt' __SBOX_SANDBOX_DIR__/out/out.txt",
+ },
+ }
+
+ for _, test := range testcases {
+ t.Run(test.name, func(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForGenRuleTest,
+ android.FixtureMergeMockFs(test.additionalFiles),
+ ).RunTestWithBp(t, test.bp)
+ gen := result.Module("gen", "").(*Module)
+ android.AssertStringEquals(t, "command", test.expectedCmd, gen.rawCommands[0])
+ })
+ }
+}
+
type testTool struct {
android.ModuleBase
outputFile android.Path
diff --git a/java/base.go b/java/base.go
index fe92b47..2da7cbd 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1195,12 +1195,21 @@
}
}
if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 {
+ hasErrorproneableFiles := false
+ for _, ext := range j.sourceExtensions {
+ if ext != ".proto" && ext != ".aidl" {
+ // Skip running errorprone on pure proto or pure aidl modules. Some modules take a long time to
+ // compile, and it's not useful to have warnings on these generated sources.
+ hasErrorproneableFiles = true
+ break
+ }
+ }
var extraJarDeps android.Paths
if Bool(j.properties.Errorprone.Enabled) {
// If error-prone is enabled, enable errorprone flags on the regular
// build.
flags = enableErrorproneFlags(flags)
- } else if ctx.Config().RunErrorProne() && j.properties.Errorprone.Enabled == nil {
+ } else if hasErrorproneableFiles && ctx.Config().RunErrorProne() && j.properties.Errorprone.Enabled == nil {
// Otherwise, if the RUN_ERROR_PRONE environment variable is set, create
// a new jar file just for compiling with the errorprone compiler to.
// This is because we don't want to cause the java files to get completely
diff --git a/rust/config/global.go b/rust/config/global.go
index 9acbfb3..e676837 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -24,7 +24,7 @@
var pctx = android.NewPackageContext("android/soong/rust/config")
var (
- RustDefaultVersion = "1.62.0.p1"
+ RustDefaultVersion = "1.63.0"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2021"
Stdlibs = []string{