Merge "rust: Fix handling of bindgen header libs" into main am: 2aee601e95
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3016907 Change-Id: I8179d150d9a3e166709d391e98ce32cc1f6d8011 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -62,6 +62,7 @@ func (mod *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
entries.AddStrings("LOCAL_PROC_MACRO_LIBRARIES", mod.Properties.AndroidMkProcMacroLibs...)
|
entries.AddStrings("LOCAL_PROC_MACRO_LIBRARIES", mod.Properties.AndroidMkProcMacroLibs...)
|
||||||
entries.AddStrings("LOCAL_SHARED_LIBRARIES", mod.transitiveAndroidMkSharedLibs.ToList()...)
|
entries.AddStrings("LOCAL_SHARED_LIBRARIES", mod.transitiveAndroidMkSharedLibs.ToList()...)
|
||||||
entries.AddStrings("LOCAL_STATIC_LIBRARIES", mod.Properties.AndroidMkStaticLibs...)
|
entries.AddStrings("LOCAL_STATIC_LIBRARIES", mod.Properties.AndroidMkStaticLibs...)
|
||||||
|
entries.AddStrings("LOCAL_HEADER_LIBRARIES", mod.Properties.AndroidMkHeaderLibs...)
|
||||||
entries.AddStrings("LOCAL_SOONG_LINK_TYPE", mod.makeLinkType)
|
entries.AddStrings("LOCAL_SOONG_LINK_TYPE", mod.makeLinkType)
|
||||||
if mod.InVendor() {
|
if mod.InVendor() {
|
||||||
entries.SetBool("LOCAL_IN_VENDOR", true)
|
entries.SetBool("LOCAL_IN_VENDOR", true)
|
||||||
|
@@ -346,6 +346,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...)
|
deps.HeaderLibs = append(deps.HeaderLibs, b.ClangProperties.Header_libs...)
|
||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,8 @@ package rust
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRustBindgen(t *testing.T) {
|
func TestRustBindgen(t *testing.T) {
|
||||||
@@ -31,7 +33,21 @@ func TestRustBindgen(t *testing.T) {
|
|||||||
bindgen_flags: ["--bindgen-flag.*"],
|
bindgen_flags: ["--bindgen-flag.*"],
|
||||||
cflags: ["--clang-flag()"],
|
cflags: ["--clang-flag()"],
|
||||||
shared_libs: ["libfoo_shared"],
|
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"],
|
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"],
|
header_libs: ["libfoo_header"],
|
||||||
}
|
}
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
@@ -52,6 +68,9 @@ func TestRustBindgen(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
libbindgen := ctx.ModuleForTests("libbindgen", "android_arm64_armv8-a_source").Output("bindings.rs")
|
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
|
// Ensure that the flags are present and escaped
|
||||||
if !strings.Contains(libbindgen.Args["flags"], "'--bindgen-flag.*'") {
|
if !strings.Contains(libbindgen.Args["flags"], "'--bindgen-flag.*'") {
|
||||||
t.Errorf("missing bindgen flags in rust_bindgen rule: flags %#v", libbindgen.Args["flags"])
|
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") {
|
if !strings.Contains(libbindgen.Args["cflags"], "-Ishared_include") {
|
||||||
t.Errorf("missing shared_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
|
t.Errorf("missing shared_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
|
||||||
}
|
}
|
||||||
if !strings.Contains(libbindgen.Args["cflags"], "-Istatic_include") {
|
if !strings.Contains(libbindgenStatic.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", libbindgenStatic.Args["cflags"])
|
||||||
}
|
}
|
||||||
if !strings.Contains(libbindgen.Args["cflags"], "-Iheader_include") {
|
if !strings.Contains(libbindgenHeader.Args["cflags"], "-Iheader_include") {
|
||||||
t.Errorf("missing static_libs exported includes in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
|
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") {
|
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"])
|
||||||
}
|
}
|
||||||
|
@@ -68,6 +68,7 @@ type BaseProperties struct {
|
|||||||
AndroidMkDylibs []string `blueprint:"mutated"`
|
AndroidMkDylibs []string `blueprint:"mutated"`
|
||||||
AndroidMkProcMacroLibs []string `blueprint:"mutated"`
|
AndroidMkProcMacroLibs []string `blueprint:"mutated"`
|
||||||
AndroidMkStaticLibs []string `blueprint:"mutated"`
|
AndroidMkStaticLibs []string `blueprint:"mutated"`
|
||||||
|
AndroidMkHeaderLibs []string `blueprint:"mutated"`
|
||||||
|
|
||||||
ImageVariation string `blueprint:"mutated"`
|
ImageVariation string `blueprint:"mutated"`
|
||||||
VndkVersion string `blueprint:"mutated"`
|
VndkVersion string `blueprint:"mutated"`
|
||||||
@@ -1399,6 +1400,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
|
depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
|
||||||
depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
|
depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
|
||||||
depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...)
|
depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...)
|
||||||
|
mod.Properties.AndroidMkHeaderLibs = append(mod.Properties.AndroidMkHeaderLibs, makeLibName)
|
||||||
case depTag == cc.CrtBeginDepTag:
|
case depTag == cc.CrtBeginDepTag:
|
||||||
depPaths.CrtBegin = append(depPaths.CrtBegin, linkObject.Path())
|
depPaths.CrtBegin = append(depPaths.CrtBegin, linkObject.Path())
|
||||||
case depTag == cc.CrtEndDepTag:
|
case depTag == cc.CrtEndDepTag:
|
||||||
|
Reference in New Issue
Block a user