Merge "rust: Emit -x c++ for bindgen modules with cpp_std" into main
This commit is contained in:
@@ -124,18 +124,20 @@ func (b *bindgenDecorator) getStdVersion(ctx ModuleContext, src android.Path) (s
|
|||||||
ctx.PropertyErrorf("c_std", "c_std and cpp_std cannot both be defined at the same time.")
|
ctx.PropertyErrorf("c_std", "c_std and cpp_std cannot both be defined at the same time.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if String(b.ClangProperties.Cpp_std) != "" {
|
if b.ClangProperties.Cpp_std != nil {
|
||||||
|
isCpp = true
|
||||||
if String(b.ClangProperties.Cpp_std) == "experimental" {
|
if String(b.ClangProperties.Cpp_std) == "experimental" {
|
||||||
stdVersion = cc_config.ExperimentalCppStdVersion
|
stdVersion = cc_config.ExperimentalCppStdVersion
|
||||||
} else if String(b.ClangProperties.Cpp_std) == "default" {
|
} else if String(b.ClangProperties.Cpp_std) == "default" || String(b.ClangProperties.Cpp_std) == "" {
|
||||||
stdVersion = cc_config.CppStdVersion
|
stdVersion = cc_config.CppStdVersion
|
||||||
} else {
|
} else {
|
||||||
stdVersion = String(b.ClangProperties.Cpp_std)
|
stdVersion = String(b.ClangProperties.Cpp_std)
|
||||||
}
|
}
|
||||||
} else if b.ClangProperties.C_std != nil {
|
} else if b.ClangProperties.C_std != nil {
|
||||||
|
isCpp = false
|
||||||
if String(b.ClangProperties.C_std) == "experimental" {
|
if String(b.ClangProperties.C_std) == "experimental" {
|
||||||
stdVersion = cc_config.ExperimentalCStdVersion
|
stdVersion = cc_config.ExperimentalCStdVersion
|
||||||
} else if String(b.ClangProperties.C_std) == "default" {
|
} else if String(b.ClangProperties.C_std) == "default" || String(b.ClangProperties.C_std) == "" {
|
||||||
stdVersion = cc_config.CStdVersion
|
stdVersion = cc_config.CStdVersion
|
||||||
} else {
|
} else {
|
||||||
stdVersion = String(b.ClangProperties.C_std)
|
stdVersion = String(b.ClangProperties.C_std)
|
||||||
|
@@ -115,7 +115,7 @@ func TestRustBindgenStdVersions(t *testing.T) {
|
|||||||
ctx := testRust(t, `
|
ctx := testRust(t, `
|
||||||
rust_bindgen {
|
rust_bindgen {
|
||||||
name: "libbindgen_cstd",
|
name: "libbindgen_cstd",
|
||||||
wrapper_src: "src/any.h",
|
wrapper_src: "src/any.hpp",
|
||||||
crate_name: "bindgen",
|
crate_name: "bindgen",
|
||||||
stem: "libbindgen",
|
stem: "libbindgen",
|
||||||
source_stem: "bindings",
|
source_stem: "bindings",
|
||||||
@@ -141,6 +141,16 @@ func TestRustBindgenStdVersions(t *testing.T) {
|
|||||||
if !strings.Contains(libbindgen_cppstd.Args["cflags"], "-std=foo") {
|
if !strings.Contains(libbindgen_cppstd.Args["cflags"], "-std=foo") {
|
||||||
t.Errorf("cpp_std value not passed in to rust_bindgen as a clang flag")
|
t.Errorf("cpp_std value not passed in to rust_bindgen as a clang flag")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure specifying cpp_std emits the '-x c++' flag
|
||||||
|
if !strings.Contains(libbindgen_cppstd.Args["cflags"], "-x c++") {
|
||||||
|
t.Errorf("Setting cpp_std should cause the '-x c++' flag to be emitted")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure specifying c_std omits the '-x c++' flag
|
||||||
|
if strings.Contains(libbindgen_cstd.Args["cflags"], "-x c++") {
|
||||||
|
t.Errorf("Setting c_std should not cause the '-x c++' flag to be emitted")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBindgenDisallowedFlags(t *testing.T) {
|
func TestBindgenDisallowedFlags(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user