mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-11-22 00:50:59 +00:00
meson: rename cargo.sh to cargo.py
To be cross platform, use cargo.py to manage cargo
This commit is contained in:
parent
d0e284d0a2
commit
378d867520
4 changed files with 45 additions and 29 deletions
32
build-aux/cargo.py
Executable file
32
build-aux/cargo.py
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
import shutil
|
||||
|
||||
env = os.environ
|
||||
|
||||
MESON_BUILD_ROOT=sys.argv[1]
|
||||
MESON_SOURCE_ROOT=sys.argv[2]
|
||||
CARGO_TARGET_DIR = os.path.join (MESON_BUILD_ROOT, "target")
|
||||
env["CARGO_TARGET_DIR"] = CARGO_TARGET_DIR
|
||||
CARGO_HOME = os.path.join (CARGO_TARGET_DIR, "cargo-home")
|
||||
env["CARGO_HOME"] = CARGO_HOME
|
||||
OUTPUT=sys.argv[3]
|
||||
BUILDTYPE=sys.argv[4]
|
||||
APP_BIN=sys.argv[5]
|
||||
|
||||
|
||||
if BUILDTYPE == "release":
|
||||
print("RELEASE MODE")
|
||||
CMD = ['cargo', 'build', '--manifest-path', os.path.join(MESON_SOURCE_ROOT, 'Cargo.toml'), '--release']
|
||||
subprocess.run(CMD, env=env)
|
||||
shutil.copyfile(os.path.join(CARGO_TARGET_DIR, "release", APP_BIN), OUTPUT)
|
||||
else:
|
||||
print("DEBUG MODE")
|
||||
CMD = ['cargo', 'build', '--manifest-path', os.path.join(MESON_SOURCE_ROOT, 'Cargo.toml')]
|
||||
subprocess.run(CMD, env=env)
|
||||
shutil.copyfile(os.path.join(CARGO_TARGET_DIR, "debug", APP_BIN), OUTPUT)
|
||||
|
||||
|
|
@ -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="$CARGO_TARGET_DIR"/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
|
||||
|
|
@ -9,6 +9,7 @@ python_mod = import('python')
|
|||
python3 = python_mod.find_installation()
|
||||
current_date = run_command(python3, '-c', 'import datetime; print(datetime.datetime.now().strftime("%Y-%m-%d"), end ="")').stdout()
|
||||
i18n = import('i18n')
|
||||
host_system = host_machine.system()
|
||||
|
||||
dependency('glib-2.0', version: '>= 2.66')
|
||||
dependency('gio-2.0', version: '>= 2.66')
|
||||
|
@ -69,5 +70,6 @@ meson.add_dist_script(
|
|||
meson.source_root(),
|
||||
join_paths(meson.build_root(), 'meson-dist', meson.project_name() + '-' + version)
|
||||
)
|
||||
|
||||
meson.add_install_script('build-aux/meson/postinstall.py')
|
||||
if host_system == 'linux'
|
||||
meson.add_install_script('build-aux/meson/postinstall.py')
|
||||
endif
|
||||
|
|
|
@ -39,12 +39,18 @@ rust_sources = files(
|
|||
|
||||
sources = [cargo_sources, rust_sources]
|
||||
|
||||
cargo_script = find_program(join_paths(meson.source_root(), 'build-aux/cargo.sh'))
|
||||
cargo_script = find_program(join_paths(meson.source_root(), 'build-aux/cargo.py'))
|
||||
|
||||
app_name = meson.project_name()
|
||||
if host_system == 'windows'
|
||||
app_name += '.exe'
|
||||
endif
|
||||
|
||||
cargo_release = custom_target(
|
||||
'cargo-build',
|
||||
build_by_default: true,
|
||||
input: sources,
|
||||
output: meson.project_name(),
|
||||
output: app_name,
|
||||
console: true,
|
||||
install: true,
|
||||
install_dir: get_option('bindir'),
|
||||
|
@ -54,6 +60,6 @@ cargo_release = custom_target(
|
|||
meson.source_root(),
|
||||
'@OUTPUT@',
|
||||
get_option('buildtype'),
|
||||
meson.project_name(),
|
||||
app_name,
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue