forked from mesonbuild/meson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules/rust: Allow explicitly setting the language to bind
This may be of particular use when a header is .h but should be treated as a C++ header instead of a C header.
- Loading branch information
Showing
4 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ short-description: Rust language integration module | |
authors: | ||
- name: Dylan Baker | ||
email: [email protected] | ||
years: [2020, 2021, 2022] | ||
years: [2020, 2021, 2022, 2024] | ||
... | ||
|
||
# Rust module | ||
|
@@ -62,6 +62,7 @@ It takes the following keyword arguments | |
- `c_args`: a list of string arguments to pass to clang untouched | ||
- `args`: a list of string arguments to pass to `bindgen` untouched. | ||
- `dependencies`: a list of `Dependency` objects to pass to the underlying clang call (*since 1.0.0*) | ||
- `language`: A literal string value of `c` or `cpp`. When set this will force bindgen to treat a source as the given language. Defaults to checking based on the input file extension. *(since 1.4.0)* | ||
|
||
```meson | ||
rust = import('unstable-rust') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Overriding bindgen language setting | ||
|
||
Even though Meson will now tell bindgen to do the right thing in most cases, | ||
there may still be cases where Meson does not have the intended behavior, | ||
specifically with headers with a `.h` suffix, but are C++ headers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SPDX-license-identifer: Apache-2.0 | ||
# Copyright © 2021-2023 Intel Corporation | ||
|
||
fs = import('fs') | ||
|
||
cpp_header = fs.copyfile('../src/header.hpp', 'cpp_header.h') | ||
|
||
cpp_bind_override = rust.bindgen( | ||
input : cpp_header, | ||
output : 'generated-cpp.rs', | ||
language : 'cpp', | ||
) | ||
|
||
cpp_exe2 = executable( | ||
'cpp_exe2', | ||
structured_sources(['../src/cpp.rs', cpp_bind_override]), | ||
link_with : cpp_lib, | ||
) | ||
test('cpp-forced', cpp_exe2) |