Support rust modules when packaging aconfig files in apex.
Also remove the code to package aconfig files for transitive dependencies since those files should have already been included in the direct dependencies. Bug: 311173471 Test: Unit tests Change-Id: I25637af9381f71a78b70a8de9894618188c9735d
This commit is contained in:
@@ -211,6 +211,7 @@ func CollectDependencyAconfigFiles(ctx android.ModuleContext, mergedAconfigFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mergeAconfigFiles(ctx android.ModuleContext, inputs android.Paths) android.Paths {
|
func mergeAconfigFiles(ctx android.ModuleContext, inputs android.Paths) android.Paths {
|
||||||
|
inputs = android.LastUniquePaths(inputs)
|
||||||
if len(inputs) == 1 {
|
if len(inputs) == 1 {
|
||||||
return android.Paths{inputs[0]}
|
return android.Paths{inputs[0]}
|
||||||
}
|
}
|
||||||
|
@@ -1970,6 +1970,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
fi := apexFileForRustLibrary(ctx, ch)
|
fi := apexFileForRustLibrary(ctx, ch)
|
||||||
fi.isJniLib = isJniLib
|
fi.isJniLib = isJniLib
|
||||||
vctx.filesInfo = append(vctx.filesInfo, fi)
|
vctx.filesInfo = append(vctx.filesInfo, fi)
|
||||||
|
addAconfigFiles(vctx, ctx, child)
|
||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
default:
|
default:
|
||||||
ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
|
ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
|
||||||
@@ -1982,6 +1983,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
case *rust.Module:
|
case *rust.Module:
|
||||||
vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, ch))
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, ch))
|
||||||
|
addAconfigFiles(vctx, ctx, child)
|
||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
default:
|
default:
|
||||||
ctx.PropertyErrorf("binaries",
|
ctx.PropertyErrorf("binaries",
|
||||||
@@ -2189,7 +2191,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vctx.filesInfo = append(vctx.filesInfo, af)
|
vctx.filesInfo = append(vctx.filesInfo, af)
|
||||||
addAconfigFiles(vctx, ctx, child)
|
|
||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
} else if rm, ok := child.(*rust.Module); ok {
|
} else if rm, ok := child.(*rust.Module); ok {
|
||||||
af := apexFileForRustLibrary(ctx, rm)
|
af := apexFileForRustLibrary(ctx, rm)
|
||||||
|
@@ -10897,9 +10897,7 @@ func TestAconfigFilesJavaDeps(t *testing.T) {
|
|||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
static_libs: ["my_java_aconfig_library_foo"],
|
static_libs: ["my_java_aconfig_library_foo"],
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -10910,9 +10908,7 @@ func TestAconfigFilesJavaDeps(t *testing.T) {
|
|||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
static_libs: ["my_java_aconfig_library_bar"],
|
static_libs: ["my_java_aconfig_library_bar"],
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -10927,9 +10923,7 @@ func TestAconfigFilesJavaDeps(t *testing.T) {
|
|||||||
java_aconfig_library {
|
java_aconfig_library {
|
||||||
name: "my_java_aconfig_library_foo",
|
name: "my_java_aconfig_library_foo",
|
||||||
aconfig_declarations: "my_aconfig_declarations_foo",
|
aconfig_declarations: "my_aconfig_declarations_foo",
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -10944,9 +10938,7 @@ func TestAconfigFilesJavaDeps(t *testing.T) {
|
|||||||
java_aconfig_library {
|
java_aconfig_library {
|
||||||
name: "my_java_aconfig_library_bar",
|
name: "my_java_aconfig_library_bar",
|
||||||
aconfig_declarations: "my_aconfig_declarations_bar",
|
aconfig_declarations: "my_aconfig_declarations_bar",
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11001,9 +10993,7 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
|
|||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
static_libs: ["my_java_aconfig_library_foo"],
|
static_libs: ["my_java_aconfig_library_foo"],
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11011,10 +11001,11 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
|
|||||||
cc_library {
|
cc_library {
|
||||||
name: "my_cc_library_bar",
|
name: "my_cc_library_bar",
|
||||||
srcs: ["foo/bar/MyClass.cc"],
|
srcs: ["foo/bar/MyClass.cc"],
|
||||||
static_libs: ["my_cc_aconfig_library_bar"],
|
static_libs: [
|
||||||
// TODO: remove //apex_available:platform
|
"my_cc_aconfig_library_bar",
|
||||||
|
"my_cc_aconfig_library_baz",
|
||||||
|
],
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11023,9 +11014,7 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
|
|||||||
name: "my_cc_binary_baz",
|
name: "my_cc_binary_baz",
|
||||||
srcs: ["foo/bar/MyClass.cc"],
|
srcs: ["foo/bar/MyClass.cc"],
|
||||||
static_libs: ["my_cc_aconfig_library_baz"],
|
static_libs: ["my_cc_aconfig_library_baz"],
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11040,9 +11029,7 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
|
|||||||
java_aconfig_library {
|
java_aconfig_library {
|
||||||
name: "my_java_aconfig_library_foo",
|
name: "my_java_aconfig_library_foo",
|
||||||
aconfig_declarations: "my_aconfig_declarations_foo",
|
aconfig_declarations: "my_aconfig_declarations_foo",
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11057,9 +11044,7 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
|
|||||||
cc_aconfig_library {
|
cc_aconfig_library {
|
||||||
name: "my_cc_aconfig_library_bar",
|
name: "my_cc_aconfig_library_bar",
|
||||||
aconfig_declarations: "my_aconfig_declarations_bar",
|
aconfig_declarations: "my_aconfig_declarations_bar",
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11074,9 +11059,7 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
|
|||||||
cc_aconfig_library {
|
cc_aconfig_library {
|
||||||
name: "my_cc_aconfig_library_baz",
|
name: "my_cc_aconfig_library_baz",
|
||||||
aconfig_declarations: "my_aconfig_declarations_baz",
|
aconfig_declarations: "my_aconfig_declarations_baz",
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11116,6 +11099,151 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
|
|||||||
ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
|
ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAconfigFilesRustDeps(t *testing.T) {
|
||||||
|
ctx := testApex(t, apex_default_bp+`
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
manifest: ":myapex.manifest",
|
||||||
|
androidManifest: ":myapex.androidmanifest",
|
||||||
|
key: "myapex.key",
|
||||||
|
native_shared_libs: [
|
||||||
|
"libmy_rust_library",
|
||||||
|
],
|
||||||
|
binaries: [
|
||||||
|
"my_rust_binary",
|
||||||
|
],
|
||||||
|
rust_dyn_libs: [
|
||||||
|
"libmy_rust_dylib",
|
||||||
|
],
|
||||||
|
updatable: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_library {
|
||||||
|
name: "libflags_rust", // test mock
|
||||||
|
crate_name: "flags_rust",
|
||||||
|
srcs: ["lib.rs"],
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_library {
|
||||||
|
name: "liblazy_static", // test mock
|
||||||
|
crate_name: "lazy_static",
|
||||||
|
srcs: ["src/lib.rs"],
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_ffi_shared {
|
||||||
|
name: "libmy_rust_library",
|
||||||
|
srcs: ["src/lib.rs"],
|
||||||
|
rustlibs: ["libmy_rust_aconfig_library_foo"],
|
||||||
|
crate_name: "my_rust_library",
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_library_dylib {
|
||||||
|
name: "libmy_rust_dylib",
|
||||||
|
srcs: ["foo/bar/MyClass.rs"],
|
||||||
|
rustlibs: ["libmy_rust_aconfig_library_bar"],
|
||||||
|
crate_name: "my_rust_dylib",
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_binary {
|
||||||
|
name: "my_rust_binary",
|
||||||
|
srcs: ["foo/bar/MyClass.rs"],
|
||||||
|
rustlibs: [
|
||||||
|
"libmy_rust_aconfig_library_baz",
|
||||||
|
"libmy_rust_dylib",
|
||||||
|
],
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
aconfig_declarations {
|
||||||
|
name: "my_aconfig_declarations_foo",
|
||||||
|
package: "com.example.package",
|
||||||
|
container: "myapex",
|
||||||
|
srcs: ["foo.aconfig"],
|
||||||
|
}
|
||||||
|
|
||||||
|
aconfig_declarations {
|
||||||
|
name: "my_aconfig_declarations_bar",
|
||||||
|
package: "com.example.package",
|
||||||
|
container: "myapex",
|
||||||
|
srcs: ["bar.aconfig"],
|
||||||
|
}
|
||||||
|
|
||||||
|
aconfig_declarations {
|
||||||
|
name: "my_aconfig_declarations_baz",
|
||||||
|
package: "com.example.package",
|
||||||
|
container: "myapex",
|
||||||
|
srcs: ["baz.aconfig"],
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_aconfig_library {
|
||||||
|
name: "libmy_rust_aconfig_library_foo",
|
||||||
|
aconfig_declarations: "my_aconfig_declarations_foo",
|
||||||
|
crate_name: "my_rust_aconfig_library_foo",
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_aconfig_library {
|
||||||
|
name: "libmy_rust_aconfig_library_bar",
|
||||||
|
aconfig_declarations: "my_aconfig_declarations_bar",
|
||||||
|
crate_name: "my_rust_aconfig_library_bar",
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_aconfig_library {
|
||||||
|
name: "libmy_rust_aconfig_library_baz",
|
||||||
|
aconfig_declarations: "my_aconfig_declarations_baz",
|
||||||
|
crate_name: "my_rust_aconfig_library_baz",
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
mod := ctx.ModuleForTests("myapex", "android_common_myapex")
|
||||||
|
s := mod.Rule("apexRule").Args["copy_commands"]
|
||||||
|
copyCmds := regexp.MustCompile(" *&& *").Split(s, -1)
|
||||||
|
if len(copyCmds) != 23 {
|
||||||
|
t.Fatalf("Expected 23 commands, got %d in:\n%s", len(copyCmds), s)
|
||||||
|
}
|
||||||
|
|
||||||
|
ensureMatches(t, copyCmds[22], "^cp -f .*/aconfig_flags.pb .*/image.apex$")
|
||||||
|
|
||||||
|
combineAconfigRule := mod.Rule("All_aconfig_declarations_dump")
|
||||||
|
s = " " + combineAconfigRule.Args["cache_files"]
|
||||||
|
aconfigArgs := regexp.MustCompile(" --cache ").Split(s, -1)[1:]
|
||||||
|
if len(aconfigArgs) != 2 {
|
||||||
|
t.Fatalf("Expected 2 commands, got %d in:\n%s", len(aconfigArgs), s)
|
||||||
|
}
|
||||||
|
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_foo/intermediate.pb")
|
||||||
|
android.EnsureListContainsSuffix(t, aconfigArgs, "my_rust_binary/android_arm64_armv8-a_apex10000/aconfig_merged.pb")
|
||||||
|
|
||||||
|
buildParams := combineAconfigRule.BuildParams
|
||||||
|
if len(buildParams.Inputs) != 2 {
|
||||||
|
t.Fatalf("Expected 3 input, got %d", len(buildParams.Inputs))
|
||||||
|
}
|
||||||
|
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_foo/intermediate.pb")
|
||||||
|
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_rust_binary/android_arm64_armv8-a_apex10000/aconfig_merged.pb")
|
||||||
|
ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
|
||||||
|
}
|
||||||
|
|
||||||
func TestAconfigFilesOnlyMatchCurrentApex(t *testing.T) {
|
func TestAconfigFilesOnlyMatchCurrentApex(t *testing.T) {
|
||||||
ctx := testApex(t, apex_default_bp+`
|
ctx := testApex(t, apex_default_bp+`
|
||||||
apex {
|
apex {
|
||||||
@@ -11136,9 +11264,7 @@ func TestAconfigFilesOnlyMatchCurrentApex(t *testing.T) {
|
|||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
static_libs: ["my_java_aconfig_library_foo"],
|
static_libs: ["my_java_aconfig_library_foo"],
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11149,9 +11275,7 @@ func TestAconfigFilesOnlyMatchCurrentApex(t *testing.T) {
|
|||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
static_libs: ["other_java_aconfig_library_bar"],
|
static_libs: ["other_java_aconfig_library_bar"],
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11166,9 +11290,7 @@ func TestAconfigFilesOnlyMatchCurrentApex(t *testing.T) {
|
|||||||
java_aconfig_library {
|
java_aconfig_library {
|
||||||
name: "my_java_aconfig_library_foo",
|
name: "my_java_aconfig_library_foo",
|
||||||
aconfig_declarations: "my_aconfig_declarations_foo",
|
aconfig_declarations: "my_aconfig_declarations_foo",
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11183,9 +11305,7 @@ func TestAconfigFilesOnlyMatchCurrentApex(t *testing.T) {
|
|||||||
java_aconfig_library {
|
java_aconfig_library {
|
||||||
name: "other_java_aconfig_library_bar",
|
name: "other_java_aconfig_library_bar",
|
||||||
aconfig_declarations: "other_aconfig_declarations_bar",
|
aconfig_declarations: "other_aconfig_declarations_bar",
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11228,9 +11348,7 @@ func TestAconfigFilesRemoveDuplicates(t *testing.T) {
|
|||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
static_libs: ["my_java_aconfig_library_foo"],
|
static_libs: ["my_java_aconfig_library_foo"],
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11241,9 +11359,7 @@ func TestAconfigFilesRemoveDuplicates(t *testing.T) {
|
|||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
static_libs: ["my_java_aconfig_library_bar"],
|
static_libs: ["my_java_aconfig_library_bar"],
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11258,9 +11374,7 @@ func TestAconfigFilesRemoveDuplicates(t *testing.T) {
|
|||||||
java_aconfig_library {
|
java_aconfig_library {
|
||||||
name: "my_java_aconfig_library_foo",
|
name: "my_java_aconfig_library_foo",
|
||||||
aconfig_declarations: "my_aconfig_declarations_foo",
|
aconfig_declarations: "my_aconfig_declarations_foo",
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -11268,9 +11382,7 @@ func TestAconfigFilesRemoveDuplicates(t *testing.T) {
|
|||||||
java_aconfig_library {
|
java_aconfig_library {
|
||||||
name: "my_java_aconfig_library_bar",
|
name: "my_java_aconfig_library_bar",
|
||||||
aconfig_declarations: "my_aconfig_declarations_foo",
|
aconfig_declarations: "my_aconfig_declarations_foo",
|
||||||
// TODO: remove //apex_available:platform
|
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
|
||||||
"myapex",
|
"myapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user