Skip to content

Commit

Permalink
Build C versions of dav1d tools and tests against librav1d
Browse files Browse the repository at this point in the history
Closes #803.

Can be toggled on off via the test_rust meson configuration option.
  • Loading branch information
thedataking committed Mar 16, 2024
1 parent e6f7a1c commit ab66bba
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
20 changes: 20 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,27 @@ endif
# Generate config.h
config_h_target = configure_file(output: 'config.h', configuration: cdata)

# Use --out-dir instead of --target-dir to fully control where librav1d.a goes.
# Using --target-dir would put it in a subdirectory. The --out-dir option is
# currently unstable so we need to tell cargo to enable those.
# FIXME: this will only work if the host matches the build target.
cargo_command = [
'cargo', 'build', '--lib',
'-Z', 'unstable-options',
'--out-dir', meson.current_build_dir()
]
if get_option('buildtype') == 'release'
cargo_command += ['--release']
endif

librav1d = custom_target(
'librav1d',
output: 'librav1d.a',
input: ['lib.rs'],
command: cargo_command,
install: true,
install_dir: get_option('libdir')
)

#
# Include subdir meson.build files
Expand Down
21 changes: 4 additions & 17 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ if get_option('enable_tools')
dav1d_input_objs.extract_objects('input/input.c', 'input/ivf.c'),
],
include_directories: [dav1d_inc_dirs, include_directories('../tools')],
link_with: libdav1d,
link_with: get_option('test_rust') ? librav1d : libdav1d,
dependencies: [
thread_dependency,
rt_dependency,
Expand All @@ -149,22 +149,9 @@ if get_option('test_rust')
test_rust_path = get_option('test_rust_path')
seek_stress_test_rust_path = get_option('seek_stress_test_rust_path')

# HACK: If we're trying to test the Rust build, override the `dav1d` and
# `seek_stress` executables to point to the versions produced by Cargo.
# This will test the Rust executables instead of the C versions.
if test_rust_path == ''
if get_option('debug')
profile = 'debug'
else
profile = 'release'
endif
test_rust_path = '../target/' + profile + '/dav1d'
test_rust_path = join_paths(meson.current_source_dir(), test_rust_path)
dav1d = find_program(test_rust_path, required: true)
seek_stress_test_rust_path = '../target/' + profile + '/seek_stress'
seek_stress_test_rust_path = join_paths(meson.current_source_dir(), seek_stress_test_rust_path)
seek_stress = find_program(seek_stress_test_rust_path, required: true)
else
# We're trying to test the Rust build, override the `dav1d` and
# `seek_stress` executables to point to the versions given during setup.
if test_rust_path != ''
# Adjust relative paths so one can use binary paths relative to project
# top dir rather than relative to the location of the test subdirectory.
dav1d = files(join_paths('../', get_option('test_rust_path')))
Expand Down
6 changes: 5 additions & 1 deletion tools/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ dav1d = executable('dav1d',
dav1d_rc_obj,
rev_target, cli_config_h_target,

link_with : [libdav1d, dav1d_input_objs, dav1d_output_objs],
link_with : [
get_option('test_rust') ? librav1d : libdav1d,
dav1d_input_objs,
dav1d_output_objs
],
include_directories : [dav1d_inc_dirs],
dependencies : [
getopt_dependency,
Expand Down

0 comments on commit ab66bba

Please sign in to comment.