Merge branch 'release' into 'master'
Use Cargo release flag See merge request Librem5/squeekboard!256
This commit is contained in:
@ -114,7 +114,7 @@ Use the `cargo.sh` script for maintaining the Cargo part of the build. The scrip
|
|||||||
|
|
||||||
```
|
```
|
||||||
cd build_dir
|
cd build_dir
|
||||||
sh /source_path/cargo.sh '' test
|
sh /source_path/cargo.sh test
|
||||||
```
|
```
|
||||||
|
|
||||||
### Cargo dependencies
|
### Cargo dependencies
|
||||||
@ -125,6 +125,6 @@ Dependencies must be specified in `Cargo.toml` with 2 numbers: "major.minor". Si
|
|||||||
|
|
||||||
```
|
```
|
||||||
cd build_dir
|
cd build_dir
|
||||||
sh /source_path/cargo.sh '' update
|
sh /source_path/cargo.sh update
|
||||||
ninja test
|
ninja test
|
||||||
```
|
```
|
||||||
|
|||||||
14
cargo.sh
14
cargo.sh
@ -11,21 +11,7 @@ SOURCE_DIR="$(dirname "$SCRIPT_PATH")"
|
|||||||
|
|
||||||
CARGO_TARGET_DIR="$(pwd)"
|
CARGO_TARGET_DIR="$(pwd)"
|
||||||
export CARGO_TARGET_DIR
|
export CARGO_TARGET_DIR
|
||||||
if [ "${1}" = "--rename" ]; then
|
|
||||||
shift
|
|
||||||
FILENAME="${1}"
|
|
||||||
shift
|
|
||||||
OUT_PATH="$(realpath "${1}")"
|
|
||||||
elif [ "${1}" = "--output" ]; then
|
|
||||||
shift
|
|
||||||
OUT_PATH="$(realpath "${1}")"
|
|
||||||
FILENAME="$(basename "${OUT_PATH}")"
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
|
|
||||||
cd "$SOURCE_DIR"
|
cd "$SOURCE_DIR"
|
||||||
cargo "$@"
|
cargo "$@"
|
||||||
|
|
||||||
if [ -n "${OUT_PATH}" ]; then
|
|
||||||
cp -a "${CARGO_TARGET_DIR}"/debug/"${FILENAME}" "${OUT_PATH}"
|
|
||||||
fi
|
|
||||||
|
|||||||
34
cargo_build.sh
Executable file
34
cargo_build.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script manages Cargo builds
|
||||||
|
# while keeping the artifact directory within the build tree
|
||||||
|
# instead of the source tree
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_PATH="$(realpath "$0")"
|
||||||
|
SOURCE_DIR="$(dirname "$SCRIPT_PATH")"
|
||||||
|
|
||||||
|
RELEASE=""
|
||||||
|
BINARY_DIR="debug"
|
||||||
|
if [ "${1}" = "--release" ]; then
|
||||||
|
shift
|
||||||
|
BINARY_DIR="release"
|
||||||
|
RELEASE="--release"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${1}" = "--rename" ]; then
|
||||||
|
shift
|
||||||
|
FILENAME="${1}"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
OUT_PATH="$(realpath "${1}")"
|
||||||
|
shift
|
||||||
|
OUT_BASENAME="$(basename "${OUT_PATH}")"
|
||||||
|
FILENAME="${FILENAME:-"${OUT_BASENAME}"}"
|
||||||
|
|
||||||
|
sh "$SOURCE_DIR"/cargo.sh build $RELEASE "$@"
|
||||||
|
|
||||||
|
if [ -n "${OUT_PATH}" ]; then
|
||||||
|
cp -a ./"${BINARY_DIR}"/"${FILENAME}" "${OUT_PATH}"
|
||||||
|
fi
|
||||||
@ -33,6 +33,11 @@ endif
|
|||||||
if get_option('buildtype') != 'plain'
|
if get_option('buildtype') != 'plain'
|
||||||
add_project_arguments('-fstack-protector-strong', language: 'c')
|
add_project_arguments('-fstack-protector-strong', language: 'c')
|
||||||
endif
|
endif
|
||||||
|
if get_option('buildtype') == 'release'
|
||||||
|
cargo_build_flags = ['--release'] # for artifacts
|
||||||
|
else
|
||||||
|
cargo_build_flags = []
|
||||||
|
endif
|
||||||
|
|
||||||
prefix = get_option('prefix')
|
prefix = get_option('prefix')
|
||||||
datadir = join_paths(prefix, get_option('datadir'))
|
datadir = join_paths(prefix, get_option('datadir'))
|
||||||
@ -54,8 +59,9 @@ summary = [
|
|||||||
]
|
]
|
||||||
message('\n'.join(summary))
|
message('\n'.join(summary))
|
||||||
|
|
||||||
cargo = find_program('cargo')
|
dep_cargo = find_program('cargo')
|
||||||
cargo_script = find_program('cargo.sh')
|
cargo_script = find_program('cargo.sh')
|
||||||
|
cargo_build = find_program('cargo_build.sh')
|
||||||
|
|
||||||
subdir('data')
|
subdir('data')
|
||||||
subdir('protocols')
|
subdir('protocols')
|
||||||
|
|||||||
@ -58,7 +58,7 @@ rslibs = custom_target(
|
|||||||
output: ['librs.a'],
|
output: ['librs.a'],
|
||||||
install: false,
|
install: false,
|
||||||
console: true,
|
console: true,
|
||||||
command: [cargo_script, '--output', '@OUTPUT@', 'build', '--lib']
|
command: [cargo_build] + cargo_build_flags + ['@OUTPUT@', '--lib']
|
||||||
)
|
)
|
||||||
|
|
||||||
build_rstests = custom_target(
|
build_rstests = custom_target(
|
||||||
@ -72,14 +72,14 @@ build_rstests = custom_target(
|
|||||||
output: ['src'],
|
output: ['src'],
|
||||||
install: false,
|
install: false,
|
||||||
console: true,
|
console: true,
|
||||||
command: [cargo_script, '', 'test', '--no-run'],
|
command: [cargo_script, 'test', '--no-run'],
|
||||||
depends: rslibs, # no point building tests if the code itself fails
|
depends: rslibs, # no point building tests if the code itself fails
|
||||||
)
|
)
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'rstest',
|
'rstest',
|
||||||
cargo_script,
|
cargo_script,
|
||||||
args: ['', 'test'],
|
args: ['test'],
|
||||||
# this is a whole Carg-based test suite, let it run for a while
|
# this is a whole Carg-based test suite, let it run for a while
|
||||||
timeout: 900,
|
timeout: 900,
|
||||||
depends: build_rstests,
|
depends: build_rstests,
|
||||||
@ -131,7 +131,8 @@ test_layout = custom_target('squeekboard-test-layout',
|
|||||||
build_always_stale: true,
|
build_always_stale: true,
|
||||||
output: ['squeekboard-test-layout'],
|
output: ['squeekboard-test-layout'],
|
||||||
console: true,
|
console: true,
|
||||||
command: [cargo_script, '--rename', 'test_layout', '@OUTPUT@', 'build', '--bin', 'test_layout'],
|
command: [cargo_build] + cargo_build_flags
|
||||||
|
+ ['--rename', 'test_layout', '@OUTPUT@', '--bin', 'test_layout'],
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: bindir,
|
install_dir: bindir,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -62,7 +62,7 @@ foreach layout : [
|
|||||||
test(
|
test(
|
||||||
'test_layout_' + layout,
|
'test_layout_' + layout,
|
||||||
cargo_script,
|
cargo_script,
|
||||||
args: ['', 'run', '--example', 'test_layout', layout]
|
args: ['run', '--example', 'test_layout', layout]
|
||||||
)
|
)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user