build: Drop custom cargo script

This commit is contained in:
Christopher Davis 2022-08-05 00:13:59 -04:00
parent 38c00cc2ec
commit 8fd63ab9b7
3 changed files with 21 additions and 47 deletions

View file

@ -1,24 +0,0 @@
#!/bin/sh
export MESON_BUILD_ROOT="$1"
export MESON_SOURCE_ROOT="$2"
export CARGO_TARGET_DIR="$MESON_BUILD_ROOT"/target
export CARGO_HOME="$MESON_BUILD_ROOT"/cargo-home
export OUTPUT="$3"
export BUILDTYPE="$4"
export APP_BIN="$5"
if [ $BUILDTYPE = "release" ]
then
echo "RELEASE MODE"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml --release && \
cp "$CARGO_TARGET_DIR"/release/"$APP_BIN" "$OUTPUT"
else
echo "DEBUG MODE"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml && \
cp "$CARGO_TARGET_DIR"/debug/"$APP_BIN" "$OUTPUT"
fi

View file

@ -11,6 +11,8 @@ gnome = import('gnome')
dependency('gtk4', version: '>=4.0.0') dependency('gtk4', version: '>=4.0.0')
dependency('libadwaita-1') dependency('libadwaita-1')
cargo = find_program('cargo', required: true)
iv_prefix = get_option('prefix') iv_prefix = get_option('prefix')
iv_bindir = join_paths(iv_prefix, get_option('bindir')) iv_bindir = join_paths(iv_prefix, get_option('bindir'))
iv_localedir = join_paths(iv_prefix, get_option('localedir')) iv_localedir = join_paths(iv_prefix, get_option('localedir'))

View file

@ -12,38 +12,34 @@ run_command(
check: true check: true
) )
rust_sources = files( cargo_options = [ '--manifest-path', meson.source_root() / 'Cargo.toml' ]
'widgets/image.rs', cargo_options += [ '--target-dir', meson.build_root() / 'src' ]
'widgets/image_page.rs',
'widgets/image_view.rs',
'widgets/mod.rs',
'widgets/properties_view.rs',
'application.rs',
'config.rs',
'file_model.rs',
'main.rs',
'util.rs',
'thumbnail.rs',
'window.rs',
)
sources = [cargo_sources, rust_sources] if get_option('profile') == 'default'
cargo_options += [ '--release' ]
rust_target = 'release'
message('Building in release mode')
else
rust_target = 'debug'
message('Building in debug mode')
endif
cargo_env = [ 'CARGO_HOME=' + meson.build_root() / 'cargo-home' ]
cargo_script = find_program(join_paths(meson.source_root(), 'build-aux/cargo.sh'))
cargo_release = custom_target( cargo_release = custom_target(
'cargo-build', 'cargo-build',
build_by_default: true, build_by_default: true,
input: sources, build_always_stale: true,
output: meson.project_name(), output: meson.project_name(),
console: true, console: true,
install: true, install: true,
install_dir: get_option('bindir'), install_dir: get_option('bindir'),
command: [ command: [
cargo_script, 'env',
meson.build_root(), cargo_env,
meson.source_root(), cargo, 'build',
'@OUTPUT@', cargo_options,
get_option('buildtype'), '&&',
meson.project_name(), 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@',
] ]
) )