diff options
author | 2024-03-29 14:48:11 +0000 | |
---|---|---|
committer | 2024-03-29 16:30:30 +0000 | |
commit | 1dbfa144f9d63000bb0c55c9d86de55c800463dd (patch) | |
tree | 3dc9e24869ef109a0c1a8c5421b0a48c2fc44ad7 /rust/bindgen_test.go | |
parent | f875565c7f169e41a9007e4513289235322dee2b (diff) |
rust: Fix handling of bindgen header libs
Static libraries were being appended to the list of header library
dependencies. They should not be. This also makes sure we track them
appropriately in Make.
Test: m blueprint_tests
Change-Id: Ifa664f09fe2102aea57d22cbaaeba71f0c26074d
Diffstat (limited to 'rust/bindgen_test.go')
-rw-r--r-- | rust/bindgen_test.go | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/rust/bindgen_test.go b/rust/bindgen_test.go index 0ba0ff840..0c0a6dad0 100644 --- a/rust/bindgen_test.go +++ b/rust/bindgen_test.go @@ -17,6 +17,8 @@ package rust import ( "strings" "testing" + + "android/soong/android" ) func TestRustBindgen(t *testing.T) { @@ -31,7 +33,21 @@ func TestRustBindgen(t *testing.T) { bindgen_flags: ["--bindgen-flag.*"], cflags: ["--clang-flag()"], shared_libs: ["libfoo_shared"], + } + rust_bindgen { + name: "libbindgen_staticlib", + wrapper_src: "src/any.h", + crate_name: "bindgen_staticlib", + stem: "libbindgen_staticlib", + source_stem: "bindings", static_libs: ["libfoo_static"], + } + rust_bindgen { + name: "libbindgen_headerlib", + wrapper_src: "src/any.h", + crate_name: "bindgen_headerlib", + stem: "libbindgen_headerlib", + source_stem: "bindings", header_libs: ["libfoo_header"], } cc_library_shared { @@ -52,6 +68,9 @@ func TestRustBindgen(t *testing.T) { } `) libbindgen := ctx.ModuleForTests("libbindgen", "android_arm64_armv8-a_source").Output("bindings.rs") + libbindgenStatic := ctx.ModuleForTests("libbindgen_staticlib", "android_arm64_armv8-a_source").Output("bindings.rs") + libbindgenHeader := ctx.ModuleForTests("libbindgen_headerlib", "android_arm64_armv8-a_source").Output("bindings.rs") + libbindgenHeaderModule := ctx.ModuleForTests("libbindgen_headerlib", "android_arm64_armv8-a_source").Module().(*Module) // Ensure that the flags are present and escaped if !strings.Contains(libbindgen.Args["flags"], "'--bindgen-flag.*'") { t.Errorf("missing bindgen flags in rust_bindgen rule: flags %#v", libbindgen.Args["flags"]) @@ -62,12 +81,17 @@ func TestRustBindgen(t *testing.T) { if !strings.Contains(libbindgen.Args["cflags"], "-Ishared_include") { t.Errorf("missing shared_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"]) } - 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(libbindgenStatic.Args["cflags"], "-Istatic_include") { + t.Errorf("missing static_libs exported includes in rust_bindgen rule: cflags %#v", libbindgenStatic.Args["cflags"]) } - if !strings.Contains(libbindgen.Args["cflags"], "-Iheader_include") { - t.Errorf("missing static_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"]) + if !strings.Contains(libbindgenHeader.Args["cflags"], "-Iheader_include") { + t.Errorf("missing header_libs exported includes in rust_bindgen rule: cflags %#v", libbindgenHeader.Args["cflags"]) } + + if android.InList("libfoo_static", libbindgenHeaderModule.Properties.AndroidMkHeaderLibs) { + t.Errorf("Static library dependency should not be in HeaderLibs list") + } + if !strings.Contains(libbindgen.Args["cflags"], "--default-flag") { t.Errorf("rust_bindgen missing cflags defined in cc_defaults: cflags %#v", libbindgen.Args["cflags"]) } |