add APEX transitive dependency validation
Bug: 218419109
Test: b build //packages/modules/adb/apex:com.android.adbd
Change-Id: I93b0c99d6521e419e52c63271646448f6d708c22
diff --git a/android/proto.go b/android/proto.go
index 8204f77..09e50c8 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -234,10 +234,13 @@
}
}
+ tags := ApexAvailableTags(ctx.Module())
+
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
- CommonAttributes{Name: info.Name},
- &attrs)
+ CommonAttributes{Name: info.Name, Tags: tags},
+ &attrs,
+ )
protoLibraries.Add(&bazel.Label{
Label: ":" + info.Name,
diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go
index 118a3a9..9feb82b 100644
--- a/bazel/cquery/request_type.go
+++ b/bazel/cquery/request_type.go
@@ -227,7 +227,7 @@
// - The function body should not be indented outside of its own scope.
func (g getApexInfoType) StarlarkFunctionBody() string {
return `
-info = providers(target).get("//build/bazel/rules/apex:apex.bzl%ApexInfo")
+info = providers(target).get("//build/bazel/rules/apex:apex_info.bzl%ApexInfo")
if not info:
fail("%s did not provide ApexInfo" % id_string)
bundle_key_info = info.bundle_key_info
diff --git a/cc/library_headers.go b/cc/library_headers.go
index 1c4f354..4d38068 100644
--- a/cc/library_headers.go
+++ b/cc/library_headers.go
@@ -145,7 +145,12 @@
Bzl_load_location: "//build/bazel/rules/cc:cc_library_headers.bzl",
}
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
+ tags := android.ApexAvailableTags(module)
+
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{
+ Name: module.Name(),
+ Tags: tags,
+ }, attrs)
}
// Append .contribution suffix to input labels
diff --git a/cc/object.go b/cc/object.go
index 1a96b72..ce9bb08 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -208,7 +208,12 @@
Bzl_load_location: "//build/bazel/rules/cc:cc_object.bzl",
}
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
+ tags := android.ApexAvailableTags(m)
+
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{
+ Name: m.Name(),
+ Tags: tags,
+ }, attrs)
}
func (object *objectLinker) appendLdflags(flags []string) {
diff --git a/cc/proto.go b/cc/proto.go
index 27f37cb..97470e5 100644
--- a/cc/proto.go
+++ b/cc/proto.go
@@ -165,7 +165,8 @@
}
type protoAttributes struct {
- Deps bazel.LabelListAttribute
+ Deps bazel.LabelListAttribute
+ Min_sdk_version *string
}
type bp2buildProtoDeps struct {
@@ -203,6 +204,7 @@
var protoAttrs protoAttributes
protoAttrs.Deps.SetValue(protoInfo.Proto_libs)
+ protoAttrs.Min_sdk_version = m.Properties.Min_sdk_version
name := m.Name() + suffix
tags := android.ApexAvailableTags(m)
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 14895c9..f5da50e 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -940,6 +940,8 @@
}
}
+ tags := android.ApexAvailableTags(m)
+
if ctx.ModuleType() == "gensrcs" {
// The Output_extension prop is not in an immediately accessible field
// in the Module struct, so use GetProperties and cast it
@@ -961,7 +963,10 @@
Cmd: cmd,
Tools: tools,
}
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{
+ Name: m.Name(),
+ Tags: tags,
+ }, attrs)
} else {
// The Out prop is not in an immediately accessible field
// in the Module struct, so use GetProperties and cast it
@@ -982,7 +987,10 @@
props := bazel.BazelTargetModuleProperties{
Rule_class: "genrule",
}
- ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{
+ Name: m.Name(),
+ Tags: tags,
+ }, attrs)
}
}
diff --git a/tests/lib.sh b/tests/lib.sh
index f68199a..ae8875a 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -119,6 +119,7 @@
copy_directory build/bazel
copy_directory build/bazel_common_rules
+ symlink_directory packages/modules/common/build
symlink_directory prebuilts/bazel
symlink_directory prebuilts/clang
symlink_directory prebuilts/jdk