Commit 7d8f3e46 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

build-aux: replace the bash script with a python one

parent 5c087952
#!/usr/bin/env python3
from os import environ, path
from subprocess import run
from argparse import ArgumentParser
from shutil import copy
parser = ArgumentParser()
parser.add_argument("build_root")
parser.add_argument("source_root")
parser.add_argument("output")
parser.add_argument("profile")
parser.add_argument("project_name")
parser.add_argument("features")
args = parser.parse_args()
environ["CARGO_TARGET_DIR"] = path.join(args.build_root, "target")
environ["CARGO_HOME"] = path.join(args.build_root, "cargo-home")
cargo_toml_path = path.join(args.source_root, "Cargo.toml")
if args.profile == "Devel":
print("DEBUG MODE")
run(
[
"cargo",
"build",
"--manifest-path",
cargo_toml_path,
"--features",
args.features,
],
check=True,
)
build_dir = path.join(environ["CARGO_TARGET_DIR"], "debug", args.project_name)
copy(build_dir, args.output)
else:
print("RELEASE MODE")
run(
[
"cargo",
"build",
"--manifest-path",
cargo_toml_path,
"--release",
"--features",
args.features,
],
check=True,
)
build_dir = path.join(environ["CARGO_TARGET_DIR"], "release", args.project_name)
copy(build_dir, args.output)
#!/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
FEATURES="$6"
if [ $4 = "Devel" ]
then
echo "DEBUG MODE"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml $FEATURES && \
cp "$CARGO_TARGET_DIR"/debug/$5 $3
else
echo "RELEASE MODE"
cargo build --manifest-path \
"$MESON_SOURCE_ROOT"/Cargo.toml $FEATURES --release && \
cp "$CARGO_TARGET_DIR"/release/$5 $3
fi
...@@ -24,7 +24,7 @@ glib_compile_resources = find_program('glib-compile-resources', required: true) ...@@ -24,7 +24,7 @@ glib_compile_resources = find_program('glib-compile-resources', required: true)
desktop_file_validate = find_program('desktop-file-validate', required: false) desktop_file_validate = find_program('desktop-file-validate', required: false)
appstream_util = find_program('appstream-util', required: false) appstream_util = find_program('appstream-util', required: false)
cargo = find_program('cargo', required: false) cargo = find_program('cargo', required: false)
cargo_script = find_program('build-aux/cargo.sh') cargo_script = find_program('build-aux/cargo.py')
version = meson.project_version() version = meson.project_version()
......
...@@ -53,6 +53,7 @@ features = '' ...@@ -53,6 +53,7 @@ features = ''
if get_option('video_path') != '' if get_option('video_path') != ''
features = '--features video' features = '--features video'
endif endif
custom_target( custom_target(
'cargo-build', 'cargo-build',
build_by_default: true, build_by_default: true,
...@@ -69,7 +70,6 @@ custom_target( ...@@ -69,7 +70,6 @@ custom_target(
'@OUTPUT@', '@OUTPUT@',
profile, profile,
meson.project_name(), meson.project_name(),
features features,
] ]
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment