Move raw FFI bindings generation to separate crates. This makes it possible to reuse bindgen declarations for a header file in its dependencies (this was not the case before this change), while keeping multiple -sys crates to avoid rebuilding all the code whenever something changes. Because the -sys crates are generated in dependency order, this also enforces that the crates are organized in something that resembles the dependencies between C headers. The meson.build for rust-safe crates becomes simpler, and it should be possible in the future to let Meson's cargo support handle most of it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> [General cleanup and Python script. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
38 lines
1015 B
Meson
38 lines
1015 B
Meson
# Generate bindgen arguments from Cargo.toml metadata
|
|
# Sort these in dependency order, same as the subdir()
|
|
# invocations below.
|
|
bindgen_dirs = [
|
|
'util-sys',
|
|
'migration-sys',
|
|
'qom-sys',
|
|
'chardev-sys',
|
|
'hwcore-sys',
|
|
'system-sys',
|
|
]
|
|
bindgen_args_file = configure_file(
|
|
command: [files('generate_bindgen_args.py'),
|
|
'-I', meson.project_source_root() / 'include',
|
|
'--source-dir', meson.current_source_dir(),
|
|
'-o', '@OUTPUT@', '--dep-file', '@DEPFILE@'] + bindgen_dirs,
|
|
output: 'bindgen_args.mak',
|
|
depfile: 'bindgen_args.d'
|
|
)
|
|
|
|
# now generate all bindgen files
|
|
bindgen_args_data = keyval.load(bindgen_args_file)
|
|
bindgen_kwargs = {
|
|
'input': 'wrapper.h',
|
|
'dependencies': common_ss.all_dependencies(),
|
|
'output': 'bindings.inc.rs',
|
|
'include_directories': bindings_incdir,
|
|
'bindgen_version': ['>=0.60.0'],
|
|
'c_args': bindgen_c_args,
|
|
}
|
|
|
|
subdir('util-sys')
|
|
subdir('migration-sys')
|
|
subdir('qom-sys')
|
|
subdir('chardev-sys')
|
|
subdir('hwcore-sys')
|
|
subdir('system-sys')
|