rust: Add header library support to rust_bindgen.
Allow rust_bindgen modules to define dependencies that only provide headers and may not necessarily need to be linked in. Bug: 161141999 Test: Soong tests pass. Test: Example module has appropriate include flags when compiling. Change-Id: Ic9ce8b1204008ad8dcb18766c914e48bb292d485
This commit is contained in:
parent
3d0f191c35
commit
9b44383788
|
@ -687,6 +687,9 @@ type RustBindgenClangProperties struct {
|
||||||
// list of shared libraries that provide headers for this binding.
|
// list of shared libraries that provide headers for this binding.
|
||||||
Shared_libs []string `android:"arch_variant"`
|
Shared_libs []string `android:"arch_variant"`
|
||||||
|
|
||||||
|
// List of libraries which export include paths required for this module
|
||||||
|
Header_libs []string `android:"arch_variant,variant_prepend"`
|
||||||
|
|
||||||
// list of clang flags required to correctly interpret the headers.
|
// list of clang flags required to correctly interpret the headers.
|
||||||
Cflags []string `android:"arch_variant"`
|
Cflags []string `android:"arch_variant"`
|
||||||
|
|
||||||
|
|
|
@ -258,5 +258,6 @@ func (b *bindgenDecorator) SourceProviderDeps(ctx DepsContext, deps Deps) Deps {
|
||||||
|
|
||||||
deps.SharedLibs = append(deps.SharedLibs, b.ClangProperties.Shared_libs...)
|
deps.SharedLibs = append(deps.SharedLibs, b.ClangProperties.Shared_libs...)
|
||||||
deps.StaticLibs = append(deps.StaticLibs, b.ClangProperties.Static_libs...)
|
deps.StaticLibs = append(deps.StaticLibs, b.ClangProperties.Static_libs...)
|
||||||
|
deps.HeaderLibs = append(deps.StaticLibs, b.ClangProperties.Header_libs...)
|
||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ func TestRustBindgen(t *testing.T) {
|
||||||
cflags: ["--clang-flag()"],
|
cflags: ["--clang-flag()"],
|
||||||
shared_libs: ["libfoo_shared"],
|
shared_libs: ["libfoo_shared"],
|
||||||
static_libs: ["libfoo_static"],
|
static_libs: ["libfoo_static"],
|
||||||
|
header_libs: ["libfoo_header"],
|
||||||
}
|
}
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
name: "libfoo_shared",
|
name: "libfoo_shared",
|
||||||
|
@ -41,6 +42,10 @@ func TestRustBindgen(t *testing.T) {
|
||||||
name: "libfoo_static",
|
name: "libfoo_static",
|
||||||
export_include_dirs: ["static_include"],
|
export_include_dirs: ["static_include"],
|
||||||
}
|
}
|
||||||
|
cc_library_headers {
|
||||||
|
name: "libfoo_header",
|
||||||
|
export_include_dirs: ["header_include"],
|
||||||
|
}
|
||||||
cc_defaults {
|
cc_defaults {
|
||||||
name: "cc_defaults_flags",
|
name: "cc_defaults_flags",
|
||||||
cflags: ["--default-flag"],
|
cflags: ["--default-flag"],
|
||||||
|
@ -60,6 +65,9 @@ func TestRustBindgen(t *testing.T) {
|
||||||
if !strings.Contains(libbindgen.Args["cflags"], "-Istatic_include") {
|
if !strings.Contains(libbindgen.Args["cflags"], "-Istatic_include") {
|
||||||
t.Errorf("missing static_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
|
t.Errorf("missing static_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.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(libbindgen.Args["cflags"], "--default-flag") {
|
if !strings.Contains(libbindgen.Args["cflags"], "--default-flag") {
|
||||||
t.Errorf("rust_bindgen missing cflags defined in cc_defaults: cflags %#v", libbindgen.Args["cflags"])
|
t.Errorf("rust_bindgen missing cflags defined in cc_defaults: cflags %#v", libbindgen.Args["cflags"])
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ type ProtobufProperties struct {
|
||||||
Proto_flags []string `android:"arch_variant"`
|
Proto_flags []string `android:"arch_variant"`
|
||||||
|
|
||||||
// List of libraries which export include paths required for this module
|
// List of libraries which export include paths required for this module
|
||||||
Header_libs []string `android:"arch_variant"`
|
Header_libs []string `android:"arch_variant,variant_prepend"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type protobufDecorator struct {
|
type protobufDecorator struct {
|
||||||
|
|
Loading…
Reference in New Issue