Merge "Use list comprehensions in Starlark"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index cc854a3..3e7b040 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -1082,7 +1082,6 @@
}
ProdMixedBuildsEnabledList = []string{
- // This list left intentionally empty for now. Add specific module names
- // to have them built by Bazel in Prod Mixed Builds mode.
+ "com.android.adbd",
}
)
diff --git a/android/proto.go b/android/proto.go
index 8ad16a6..25cecf4 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -15,9 +15,10 @@
package android
import (
- "android/soong/bazel"
"strings"
+ "android/soong/bazel"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -161,6 +162,13 @@
type protoAttrs struct {
Srcs bazel.LabelListAttribute
Strip_import_prefix *string
+ Deps bazel.LabelListAttribute
+}
+
+// For each package in the include_dirs property a proto_library target should
+// be added to the BUILD file in that package and a mapping should be added here
+var includeDirsToProtoDeps = map[string]string{
+ "external/protobuf/src": "//external/protobuf:libprotobuf-proto",
}
// Bp2buildProtoProperties converts proto properties, creating a proto_library and returning the
@@ -191,6 +199,14 @@
path := ""
attrs.Strip_import_prefix = &path
}
+
+ for _, dir := range props.Proto.Include_dirs {
+ if dep, ok := includeDirsToProtoDeps[dir]; ok {
+ attrs.Deps.Add(bazel.MakeLabelAttribute(dep))
+ } else {
+ ctx.PropertyErrorf("Could not find the proto_library target for include dir", dir)
+ }
+ }
} else if props.Proto.Type != info.Type && props.Proto.Type != nil {
ctx.ModuleErrorf("Cannot handle arch-variant types for protos at this time.")
}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 5117c62..a21a566 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -2217,6 +2217,50 @@
})
}
+func TestCcLibraryProtoIncludeDirs(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: soongCcProtoPreamble + `cc_library {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: {
+ include_dirs: ["external/protobuf/src"],
+ },
+ include_build_directory: false,
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{
+ "srcs": `["foo.proto"]`,
+ "deps": `["//external/protobuf:libprotobuf-proto"]`,
+ }), MakeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{
+ "deps": `[":foo_proto"]`,
+ }), MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "implementation_whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ }), MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryProtoIncludeDirsUnknown(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: soongCcProtoPreamble + `cc_library {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: {
+ include_dirs: ["external/protobuf/abc"],
+ },
+ include_build_directory: false,
+}`,
+ ExpectedErr: fmt.Errorf("module \"foo\": Could not find the proto_library target for include dir: external/protobuf/abc"),
+ })
+}
+
func TestCcLibraryProtoFilegroups(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
ModuleTypeUnderTest: "cc_library",
diff --git a/java/config/config.go b/java/config/config.go
index 422f860..b026d73 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -124,6 +124,10 @@
// This is set up and guaranteed by soong_ui
return ctx.Config().Getenv("ANDROID_JAVA_HOME")
})
+ pctx.VariableFunc("Java11Home", func(ctx android.PackageVarContext) string {
+ // This is set up and guaranteed by soong_ui
+ return ctx.Config().Getenv("ANDROID_JAVA11_HOME")
+ })
pctx.VariableFunc("JlinkVersion", func(ctx android.PackageVarContext) string {
if override := ctx.Config().Getenv("OVERRIDE_JLINK_VERSION_NUMBER"); override != "" {
return override
@@ -137,11 +141,12 @@
})
pctx.SourcePathVariable("JavaToolchain", "${JavaHome}/bin")
+ pctx.SourcePathVariable("Java11Toolchain", "${Java11Home}/bin")
pctx.SourcePathVariableWithEnvOverride("JavacCmd",
"${JavaToolchain}/javac", "ALTERNATE_JAVAC")
pctx.SourcePathVariable("JavaCmd", "${JavaToolchain}/java")
pctx.SourcePathVariable("JarCmd", "${JavaToolchain}/jar")
- pctx.SourcePathVariable("JavadocCmd", "${JavaToolchain}/javadoc")
+ pctx.SourcePathVariable("JavadocCmd", "${Java11Toolchain}/javadoc")
pctx.SourcePathVariable("JlinkCmd", "${JavaToolchain}/jlink")
pctx.SourcePathVariable("JmodCmd", "${JavaToolchain}/jmod")
pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar")
@@ -267,7 +272,7 @@
// JavadocCmd returns a SourcePath object with the path to the java command.
func JavadocCmd(ctx android.PathContext) android.SourcePath {
- return javaTool(ctx, "javadoc")
+ return java11Tool(ctx, "javadoc")
}
func javaTool(ctx android.PathContext, tool string) android.SourcePath {
@@ -281,6 +286,17 @@
}
+func java11Tool(ctx android.PathContext, tool string) android.SourcePath {
+ type javaToolKey string
+
+ key := android.NewCustomOnceKey(javaToolKey(tool))
+
+ return ctx.Config().OnceSourcePath(key, func() android.SourcePath {
+ return java11Toolchain(ctx).Join(ctx, tool)
+ })
+
+}
+
var javaToolchainKey = android.NewOnceKey("javaToolchain")
func javaToolchain(ctx android.PathContext) android.SourcePath {
@@ -289,6 +305,14 @@
})
}
+var java11ToolchainKey = android.NewOnceKey("java11Toolchain")
+
+func java11Toolchain(ctx android.PathContext) android.SourcePath {
+ return ctx.Config().OnceSourcePath(java11ToolchainKey, func() android.SourcePath {
+ return java11Home(ctx).Join(ctx, "bin")
+ })
+}
+
var javaHomeKey = android.NewOnceKey("javaHome")
func javaHome(ctx android.PathContext) android.SourcePath {
@@ -297,3 +321,12 @@
return android.PathForSource(ctx, ctx.Config().Getenv("ANDROID_JAVA_HOME"))
})
}
+
+var java11HomeKey = android.NewOnceKey("java11Home")
+
+func java11Home(ctx android.PathContext) android.SourcePath {
+ return ctx.Config().OnceSourcePath(java11HomeKey, func() android.SourcePath {
+ // This is set up and guaranteed by soong_ui
+ return android.PathForSource(ctx, ctx.Config().Getenv("ANDROID_JAVA11_HOME"))
+ })
+}
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 9b1f43b..fc95184 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -755,6 +755,7 @@
return rule.Command().
BuiltTool("dokka").
Flag(config.JavacVmFlags).
+ Flag("-J--add-opens=java.base/java.lang=ALL-UNNAMED").
Flag(srcJarDir.String()).
FlagWithInputList("-classpath ", dokkaClasspath, ":").
FlagWithArg("-format ", "dac").