-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meson/rust: wrap
bindgen
s wrap-static-fns
functionality
This way the `rust.bindgen` can generate a second output being a C file, which contains wrapper functions for static inline ones. This output file can then be compiled via C targets.
- Loading branch information
1 parent
ca60f71
commit 491c2bf
Showing
2 changed files
with
24 additions
and
4 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
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 |
---|---|---|
|
@@ -191,6 +191,12 @@ def test(self, state: ModuleState, args: T.Tuple[str, BuildTarget], kwargs: Func | |
), | ||
INCLUDE_DIRECTORIES.evolve(since_values={ContainerTypeInfo(list, str): '1.0.0'}), | ||
OUTPUT_KW, | ||
KwargInfo( | ||
'output_inline_wrapper', | ||
str, | ||
default='', | ||
since='1.3.0', | ||
), | ||
DEPENDENCIES_KW.evolve(since='1.0.0'), | ||
) | ||
def bindgen(self, state: ModuleState, args: T.List, kwargs: FuncBindgen) -> ModuleReturnValue: | ||
|
@@ -243,12 +249,22 @@ def bindgen(self, state: ModuleState, args: T.List, kwargs: FuncBindgen) -> Modu | |
else: | ||
name = header.get_outputs()[0] | ||
|
||
inline_wrapper_args = [] | ||
outputs = [kwargs['output']] | ||
if kwargs['output_inline_wrapper']: | ||
outputs.append(kwargs['output_inline_wrapper']) | ||
inline_wrapper_args = [ | ||
'--experimental', '--wrap-static-fns', | ||
'--wrap-static-fns-path', os.path.join(state.environment.build_dir, state.subdir, kwargs['output_inline_wrapper']) | ||
] | ||
|
||
cmd = self._bindgen_bin.get_command() + \ | ||
[ | ||
'@INPUT@', '--output', | ||
os.path.join(state.environment.build_dir, '@OUTPUT@') | ||
os.path.join(state.environment.build_dir, '@OUTPUT0@') | ||
] + \ | ||
kwargs['args'] + ['--'] + kwargs['c_args'] + clang_args + \ | ||
kwargs['args'] + inline_wrapper_args + ['--'] + \ | ||
kwargs['c_args'] + clang_args + \ | ||
['-MD', '-MQ', '@INPUT@', '-MF', '@DEPFILE@'] | ||
|
||
target = CustomTarget( | ||
|
@@ -258,15 +274,15 @@ def bindgen(self, state: ModuleState, args: T.List, kwargs: FuncBindgen) -> Modu | |
state.environment, | ||
cmd, | ||
[header], | ||
[kwargs['output']], | ||
outputs, | ||
depfile='@[email protected]', | ||
extra_depends=depends, | ||
depend_files=depend_files, | ||
backend=state.backend, | ||
description='Generating bindings for Rust {}', | ||
) | ||
|
||
return ModuleReturnValue([target], [target]) | ||
return ModuleReturnValue(target, [target]) | ||
|
||
|
||
def initialize(interp: Interpreter) -> RustModule: | ||
|