mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-14 14:21:02 +00:00
meson: support rust cross-compiling with cargo wrapper
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1189>
This commit is contained in:
parent
d7ec86defe
commit
7a0f6272ce
2 changed files with 28 additions and 3 deletions
|
@ -82,6 +82,16 @@ if __name__ == "__main__":
|
|||
pkg_config_path.append(str(opts.root_dir / 'meson-uninstalled'))
|
||||
env['PKG_CONFIG_PATH'] = os.pathsep.join(pkg_config_path)
|
||||
|
||||
rustc_target = None
|
||||
if 'RUSTFLAGS' in env:
|
||||
# grab target from RUSTFLAGS
|
||||
rust_flags = env['RUSTFLAGS'].split()
|
||||
if '--target' in rust_flags:
|
||||
rustc_target_idx = rust_flags.index('--target')
|
||||
_ = rust_flags.pop(rustc_target_idx) # drop '--target'
|
||||
rustc_target = rust_flags.pop(rustc_target_idx)
|
||||
env['RUSTFLAGS'] = ' '.join(rust_flags)
|
||||
|
||||
features = opts.features
|
||||
if opts.command == 'build':
|
||||
cargo_cmd = ['cargo']
|
||||
|
@ -100,6 +110,8 @@ if __name__ == "__main__":
|
|||
print("Unknown command:", opts.command, file=logfile)
|
||||
sys.exit(1)
|
||||
|
||||
if rustc_target:
|
||||
cargo_cmd += ['--target', rustc_target]
|
||||
if features:
|
||||
cargo_cmd += ['--features', ','.join(features)]
|
||||
cargo_cmd += ['--target-dir', cargo_target_dir]
|
||||
|
|
19
meson.build
19
meson.build
|
@ -21,13 +21,14 @@ endif
|
|||
cargo = find_program('cargo', version:'>=1.40')
|
||||
cargo_wrapper = find_program('cargo_wrapper.py')
|
||||
cargo_c = find_program('cargo-cbuild', version:'>=0.9.3', required: false)
|
||||
rustc = find_program('rustc', version:'>=1.52')
|
||||
|
||||
rustc = meson.get_compiler('rust')
|
||||
|
||||
if not cargo_c.found()
|
||||
error('cargo-c missing, install it with: \'cargo install cargo-c\'')
|
||||
endif
|
||||
|
||||
system = build_machine.system()
|
||||
system = host_machine.system()
|
||||
exe_suffix = ''
|
||||
if system == 'windows'
|
||||
exe_suffix = '.exe'
|
||||
|
@ -365,7 +366,7 @@ pkgconfig_install_dir = get_option('libdir') / 'pkgconfig'
|
|||
|
||||
extra_args = []
|
||||
if get_option('doc').disabled()
|
||||
extra_args = ['--disable-doc']
|
||||
extra_args += ['--disable-doc']
|
||||
endif
|
||||
|
||||
# 'pkgconfig' is the entry in the machine file, if specified
|
||||
|
@ -383,6 +384,18 @@ if pkg_config_path.length() > 0
|
|||
extra_env += {'PKG_CONFIG_PATH': pathsep.join(pkg_config_path)}
|
||||
endif
|
||||
|
||||
# get compiler and flags for rust (if any)
|
||||
rustc_cmd = ''
|
||||
rust_flags = []
|
||||
foreach rustc_arg : rustc.cmd_array()
|
||||
if rustc_cmd == ''
|
||||
rustc_cmd = rustc_arg
|
||||
else
|
||||
rust_flags += [rustc_arg]
|
||||
endif
|
||||
endforeach
|
||||
extra_env += {'RUSTC': rustc_cmd, 'RUSTFLAGS': ' '.join(rust_flags)}
|
||||
|
||||
rs_plugins = custom_target('gst-plugins-rs',
|
||||
build_by_default: true,
|
||||
output: output,
|
||||
|
|
Loading…
Reference in a new issue