diff --git a/build-aux/cargo.sh b/build-aux/cargo.sh deleted file mode 100644 index 3c37396..0000000 --- a/build-aux/cargo.sh +++ /dev/null @@ -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 - diff --git a/meson.build b/meson.build index d106943..1b785b2 100644 --- a/meson.build +++ b/meson.build @@ -11,6 +11,8 @@ gnome = import('gnome') dependency('gtk4', version: '>=4.0.0') dependency('libadwaita-1') +cargo = find_program('cargo', required: true) + iv_prefix = get_option('prefix') iv_bindir = join_paths(iv_prefix, get_option('bindir')) iv_localedir = join_paths(iv_prefix, get_option('localedir')) diff --git a/src/meson.build b/src/meson.build index 11b7671..85b6a97 100644 --- a/src/meson.build +++ b/src/meson.build @@ -12,38 +12,34 @@ run_command( check: true ) -rust_sources = files( - 'widgets/image.rs', - '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', -) +cargo_options = [ '--manifest-path', meson.source_root() / 'Cargo.toml' ] +cargo_options += [ '--target-dir', meson.build_root() / 'src' ] -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-build', build_by_default: true, - input: sources, + build_always_stale: true, output: meson.project_name(), console: true, install: true, install_dir: get_option('bindir'), command: [ - cargo_script, - meson.build_root(), - meson.source_root(), - '@OUTPUT@', - get_option('buildtype'), - meson.project_name(), + 'env', + cargo_env, + cargo, 'build', + cargo_options, + '&&', + 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@', ] )