Merge "Revert "Exclude prebuilts/clang/host/linux-x86/clang-dev/BUILD from the symlink forest.""
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index f4b368b..d5ccfca 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -92,10 +92,11 @@
type ApexConfigKey struct {
WithinApex bool
ApexSdkVersion string
+ ApiDomain string
}
func (c ApexConfigKey) String() string {
- return fmt.Sprintf("%s_%s", withinApexToString(c.WithinApex), c.ApexSdkVersion)
+ return fmt.Sprintf("%s_%s_%s", withinApexToString(c.WithinApex), c.ApexSdkVersion, c.ApiDomain)
}
func withinApexToString(withinApex bool) string {
@@ -175,8 +176,6 @@
// (for example, that it is MixedBuildBuildable).
IsModuleNameAllowed(moduleName string, withinApex bool) bool
- IsModuleDclaAllowed(moduleName string) bool
-
// Returns the bazel output base (the root directory for all bazel intermediate outputs).
OutputBase() string
@@ -315,10 +314,6 @@
return true
}
-func (m MockBazelContext) IsModuleDclaAllowed(_ string) bool {
- return true
-}
-
func (m MockBazelContext) OutputBase() string { return m.OutputBaseDir }
func (m MockBazelContext) BuildStatementsToRegister() []*bazel.BuildStatement {
@@ -460,10 +455,6 @@
return false
}
-func (n noopBazelContext) IsModuleDclaAllowed(_ string) bool {
- return false
-}
-
func (m noopBazelContext) BuildStatementsToRegister() []*bazel.BuildStatement {
return []*bazel.BuildStatement{}
}
@@ -597,17 +588,13 @@
if context.bazelEnabledModules[moduleName] {
return true
}
- if withinApex && context.IsModuleDclaAllowed(moduleName) {
+ if withinApex && context.bazelDclaEnabledModules[moduleName] {
return true
}
return false
}
-func (context *mixedBuildBazelContext) IsModuleDclaAllowed(moduleName string) bool {
- return context.bazelDclaEnabledModules[moduleName]
-}
-
func pwdPrefix() string {
// Darwin doesn't have /proc
if runtime.GOOS != "darwin" {
@@ -737,6 +724,7 @@
"@//build/bazel/rules/apex:within_apex": attr.within_apex,
"@//build/bazel/rules/apex:min_sdk_version": attr.apex_sdk_version,
"@//build/bazel/rules/apex:apex_name": apex_name,
+ "@//build/bazel/rules/apex:api_domain": attr.api_domain,
}
return outputs
@@ -749,6 +737,7 @@
"@//build/bazel/rules/apex:within_apex",
"@//build/bazel/rules/apex:min_sdk_version",
"@//build/bazel/rules/apex:apex_name",
+ "@//build/bazel/rules/apex:api_domain",
],
)
@@ -762,6 +751,7 @@
"os" : attr.string(mandatory = True),
"within_apex" : attr.bool(default = False),
"apex_sdk_version" : attr.string(mandatory = True),
+ "api_domain" : attr.string(mandatory = True),
"deps" : attr.label_list(cfg = _config_node_transition, allow_files = True),
"_allowlist_function_transition": attr.label(default = "@bazel_tools//tools/allowlists/function_transition_allowlist"),
},
@@ -823,6 +813,7 @@
os = "%s",
within_apex = %s,
apex_sdk_version = "%s",
+ api_domain = "%s",
deps = [%s],
testonly = True, # Unblocks testonly deps.
)
@@ -856,6 +847,11 @@
osString := configTokens[1]
withinApex := "False"
apexSdkVerString := ""
+ apiDomainString := ""
+ if osString == "android" {
+ // api domains are meaningful only for device variants
+ apiDomainString = "system"
+ }
targetString := fmt.Sprintf("%s_%s", osString, archString)
if len(configTokens) > 2 {
targetString += "_" + configTokens[2]
@@ -867,9 +863,13 @@
targetString += "_" + configTokens[3]
apexSdkVerString = configTokens[3]
}
+ if len(configTokens) > 4 {
+ apiDomainString = configTokens[4]
+ targetString += "_" + apiDomainString
+ }
allLabels = append(allLabels, fmt.Sprintf("\":%s\"", targetString))
labelsString := strings.Join(labels, ",\n ")
- configNodesSection += fmt.Sprintf(configNodeFormatString, targetString, archString, osString, withinApex, apexSdkVerString,
+ configNodesSection += fmt.Sprintf(configNodeFormatString, targetString, archString, osString, withinApex, apexSdkVerString, apiDomainString,
labelsString)
}
@@ -974,11 +974,14 @@
within_apex = buildoptions.get("//build/bazel/rules/apex:within_apex")
apex_sdk_version = buildoptions.get("//build/bazel/rules/apex:min_sdk_version")
+ api_domain = buildoptions.get("//build/bazel/rules/apex:api_domain")
if within_apex:
config_key += "|within_apex"
if apex_sdk_version != None and len(apex_sdk_version) > 0:
config_key += "|" + apex_sdk_version
+ if api_domain != None and len(api_domain) > 0:
+ config_key += "|" + api_domain
return config_key
@@ -1385,6 +1388,10 @@
keyString += "|" + key.configKey.apexKey.ApexSdkVersion
}
+ if len(key.configKey.apexKey.ApiDomain) > 0 {
+ keyString += "|" + key.configKey.apexKey.ApiDomain
+ }
+
return keyString
}
@@ -1403,6 +1410,7 @@
configKey.apexKey = ApexConfigKey{
WithinApex: apexKey.WithinApex,
ApexSdkVersion: apexKey.ApexSdkVersion,
+ ApiDomain: apexKey.ApiDomain,
}
}
diff --git a/android/bazel_handler_test.go b/android/bazel_handler_test.go
index a81a878..65cd5a8 100644
--- a/android/bazel_handler_test.go
+++ b/android/bazel_handler_test.go
@@ -58,11 +58,12 @@
apexKey := ApexConfigKey{
WithinApex: true,
ApexSdkVersion: "29",
+ ApiDomain: "myapex",
}
cfg_foo := configKey{"arm64_armv8-a", Android, apexKey}
cfg_bar := configKey{arch: "arm64_armv8-a", osType: Android}
cmd_results := []string{
- `@//foo:foo|arm64_armv8-a|android|within_apex|29>>out/foo/foo.txt`,
+ `@//foo:foo|arm64_armv8-a|android|within_apex|29|myapex>>out/foo/foo.txt`,
`@//foo:bar|arm64_armv8-a|android>>out/foo/bar.txt`,
}
bazelContext, _ := testBazelContext(t, map[bazelCommand]string{cqueryCmd: strings.Join(cmd_results, "\n")})
diff --git a/cc/cc.go b/cc/cc.go
index 69d65e5..6087970 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1997,12 +1997,10 @@
func GetApexConfigKey(ctx android.BaseModuleContext) *android.ApexConfigKey {
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
if !apexInfo.IsForPlatform() {
- if !ctx.Config().BazelContext.IsModuleDclaAllowed(ctx.Module().Name()) {
- return nil
- }
apexKey := android.ApexConfigKey{
WithinApex: true,
ApexSdkVersion: findApexSdkVersion(ctx, apexInfo).String(),
+ ApiDomain: findApiDomain(apexInfo),
}
return &apexKey
}
@@ -2010,6 +2008,30 @@
return nil
}
+// Returns the api domain of a module for an apexInfo group
+// Input:
+// ai.InApexModules: [com.android.foo, test_com.android.foo, com.google.android.foo]
+// Return:
+// com.android.foo
+
+// If a module is included in multiple api domains (collated by min_sdk_version), it will return
+// the first match. The other matches have the same build actions since they share a min_sdk_version, so returning
+// the first match is fine.
+func findApiDomain(ai android.ApexInfo) string {
+ // Remove any test apexes
+ matches, _ := android.FilterList(ai.InApexModules, ai.TestApexes)
+ // Remove any google apexes. Rely on naming convention.
+ pred := func(s string) bool { return !strings.HasPrefix(s, "com.google") }
+ matches = android.FilterListPred(matches, pred)
+ if len(matches) > 0 {
+ // Return the first match
+ return android.SortedUniqueStrings(matches)[0]
+ } else {
+ // No apex in the tree has a dependency on this module
+ return ""
+ }
+}
+
func (c *Module) ProcessBazelQueryResponse(ctx android.ModuleContext) {
bazelModuleLabel := c.getBazelModuleLabel(ctx)
c.bazelHandler.ProcessBazelQueryResponse(ctx, bazelModuleLabel)
diff --git a/genrule/allowlists.go b/genrule/allowlists.go
index 495bc19..c767685 100644
--- a/genrule/allowlists.go
+++ b/genrule/allowlists.go
@@ -48,7 +48,6 @@
SandboxingDenyModuleList = []string{
"RsBalls-rscript",
- "CtsRsBlasTestCases-rscript",
"pvmfw_fdt_template_rs",
"RSTest_v14-rscript",
"com.android.apex.test.bar_stripped",
@@ -95,7 +94,6 @@
"com.android.apex.test.baz_stripped",
"com.android.apex.test.foo_stripped",
"com.android.apex.test.sharedlibs_generated",
- "CtsRenderscriptTestCases-rscript",
"BlueberryFacadeAndCertGeneratedStub_py",
"BlueberryFacadeGeneratedStub_cc",
"BlueberryFacadeGeneratedStub_h",
diff --git a/rust/builder.go b/rust/builder.go
index bf009a5..c31bc88 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -217,6 +217,22 @@
envVars = append(envVars, "OUT_DIR=out")
}
+ envVars = append(envVars, "ANDROID_RUST_VERSION="+config.GetRustVersion(ctx))
+
+ if ctx.RustModule().compiler.CargoEnvCompat() {
+ if bin, ok := ctx.RustModule().compiler.(*binaryDecorator); ok {
+ envVars = append(envVars, "CARGO_BIN_NAME="+bin.getStem(ctx))
+ }
+ envVars = append(envVars, "CARGO_CRATE_NAME="+ctx.RustModule().CrateName())
+ envVars = append(envVars, "CARGO_PKG_NAME="+ctx.RustModule().CrateName())
+ pkgVersion := ctx.RustModule().compiler.CargoPkgVersion()
+ if pkgVersion != "" {
+ envVars = append(envVars, "CARGO_PKG_VERSION="+pkgVersion)
+ }
+ }
+
+ envVars = append(envVars, "AR=${cc_config.ClangBin}/llvm-ar")
+
return envVars
}
@@ -317,22 +333,6 @@
implicits = append(implicits, outputs.Paths()...)
}
- envVars = append(envVars, "ANDROID_RUST_VERSION="+config.GetRustVersion(ctx))
-
- if ctx.RustModule().compiler.CargoEnvCompat() {
- if _, ok := ctx.RustModule().compiler.(*binaryDecorator); ok {
- envVars = append(envVars, "CARGO_BIN_NAME="+strings.TrimSuffix(outputFile.Base(), outputFile.Ext()))
- }
- envVars = append(envVars, "CARGO_CRATE_NAME="+ctx.RustModule().CrateName())
- envVars = append(envVars, "CARGO_PKG_NAME="+ctx.RustModule().CrateName())
- pkgVersion := ctx.RustModule().compiler.CargoPkgVersion()
- if pkgVersion != "" {
- envVars = append(envVars, "CARGO_PKG_VERSION="+pkgVersion)
- }
- }
-
- envVars = append(envVars, "AR=${cc_config.ClangBin}/llvm-ar")
-
if flags.Clippy {
clippyFile := android.PathForModuleOut(ctx, outputFile.Base()+".clippy")
ctx.Build(pctx, android.BuildParams{