rust: Allow rust_bindgen to use cc_defaults.
rust_bindgen modules can't inherit properties in cc_defaults that would be useful for generating bindings (such as cflags). This CL moves these common properties out into a new struct in cc and adds that struct to cc_default. Additionally, Cppflags is added to rust_bindgen to make sure that these get picked up as well from cc_defaults. Bug: 163598610 Test: rust_bindgen module uses cflags in cc_defaults. Test: New Soong test passes Change-Id: I702442a355244dc01954083f98a2eebbcea12e47
This commit is contained in:
@@ -23,6 +23,7 @@ func TestRustBindgen(t *testing.T) {
|
||||
ctx := testRust(t, `
|
||||
rust_bindgen {
|
||||
name: "libbindgen",
|
||||
defaults: ["cc_defaults_flags"],
|
||||
wrapper_src: "src/any.h",
|
||||
crate_name: "bindgen",
|
||||
stem: "libbindgen",
|
||||
@@ -40,6 +41,10 @@ func TestRustBindgen(t *testing.T) {
|
||||
name: "libfoo_static",
|
||||
export_include_dirs: ["static_include"],
|
||||
}
|
||||
cc_defaults {
|
||||
name: "cc_defaults_flags",
|
||||
cflags: ["--default-flag"],
|
||||
}
|
||||
`)
|
||||
libbindgen := ctx.ModuleForTests("libbindgen", "android_arm64_armv8-a_source").Output("bindings.rs")
|
||||
// Ensure that the flags are present and escaped
|
||||
@@ -55,6 +60,9 @@ func TestRustBindgen(t *testing.T) {
|
||||
if !strings.Contains(libbindgen.Args["cflags"], "-Istatic_include") {
|
||||
t.Errorf("missing static_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
|
||||
}
|
||||
if !strings.Contains(libbindgen.Args["cflags"], "--default-flag") {
|
||||
t.Errorf("rust_bindgen missing cflags defined in cc_defaults: cflags %#v", libbindgen.Args["cflags"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestRustBindgenCustomBindgen(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user