From 01c86f4b7a698198b09f6ec0627aca56072483f7 Mon Sep 17 00:00:00 2001 From: Nathan Essex Date: Sun, 20 Dec 2020 18:01:06 +0900 Subject: [PATCH] Update build, test and publish scripts to support aarch64-apple-darwin and remove cargo-workspaces --- Cargo.lock | 6 +++--- Cargo.toml | 1 + Cross.toml | 2 ++ Xargo.toml | 2 ++ scripts/build-release.sh | 11 +++++++---- scripts/publish.sh | 12 +++++++++++- scripts/targets.sh | 10 ++++++++-- scripts/test-all.sh | 4 ++-- 8 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 Cross.toml create mode 100644 Xargo.toml diff --git a/Cargo.lock b/Cargo.lock index 6cdfeaf..85e2071 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,14 +230,14 @@ dependencies = [ [[package]] name = "yaml-split" -version = "0.2.7" +version = "0.2.8" dependencies = [ "thiserror", ] [[package]] name = "yaml2json-rs" -version = "0.2.7" +version = "0.2.8" dependencies = [ "serde", "serde_json", @@ -247,7 +247,7 @@ dependencies = [ [[package]] name = "yaml2json-rs-bin" -version = "0.2.7" +version = "0.2.8" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 1bb6d60..4137f57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [profile.release] codegen-units = 1 lto = true +panic = 'abort' [workspace] diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..0e64fd8 --- /dev/null +++ b/Cross.toml @@ -0,0 +1,2 @@ +[build] +xargo = true diff --git a/Xargo.toml b/Xargo.toml new file mode 100644 index 0000000..01cf5eb --- /dev/null +++ b/Xargo.toml @@ -0,0 +1,2 @@ +[dependencies] +std = {default-features=false, features=["panic_immediate_abort"]} diff --git a/scripts/build-release.sh b/scripts/build-release.sh index ebe22ff..dfa0014 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -1,12 +1,11 @@ #!/bin/bash repo_root=$(git rev-parse --show-toplevel) -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -source "${DIR}/targets.sh" +source "${repo_root}/scripts/targets.sh" targets=$(get_targets) -version=$(cargo workspaces list --json | jq -r '.[] | select(.name=="yaml2json-rs-bin") | .version') +version=$(grep --max-count=1 'version\ ' < 'crates/yaml2json-rs-bin/Cargo.toml' | cut -d' ' -f 3 | tr -d '"') version_dir="${repo_root}/target/versions/${version}" mkdir -p "${version_dir}" @@ -35,9 +34,13 @@ build_target() { ;; esac + if command -v strip 1>/dev/null; then + strip "${filename}" + fi + out="yaml2json-rs-v${version}-${target}.${extension}" - atool -a "${out}" "${filename}" + atool -qa "${out}" "${filename}" mv "${out}" "${version_dir}/${out}" ) } diff --git a/scripts/publish.sh b/scripts/publish.sh index f0d28b7..fa6e4c6 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -1,3 +1,13 @@ #!/bin/bash -cargo workspaces publish --exact +repo_root=$(git rev-parse --show-toplevel) +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# The order here matters, as yaml2json-rs-bin depends upon yaml-split and yaml2json-rs +cargo publish --manifest-path "${repo_root}/crates/yaml-split/Cargo.toml" +cargo publish --manifest-path "${repo_root}/crates/yaml2json-rs/Cargo.toml" + +# Hack: wait for the other crates' latest versions to become visible +sleep 5 +cargo publish --manifest-path "${repo_root}/crates/yaml2json-rs-bin/Cargo.toml" + diff --git a/scripts/targets.sh b/scripts/targets.sh index 88ed744..55e91e0 100755 --- a/scripts/targets.sh +++ b/scripts/targets.sh @@ -7,12 +7,18 @@ riscv64gc-unknown-linux-gnu x86_64-pc-windows-gnu x86_64-unknown-linux-gnu EOF +) + + macos_targets=$(cat <<-'EOF' +aarch64-apple-darwin +x86_64-apple-darwin +EOF ) if [[ -n "${ONLY_MACOS}" ]]; then - echo "x86_64-apple-darwin" + echo "${macos_targets}" elif [[ -z "${EXCLUDE_MACOS}" ]]; then - printf "%s\n%s" "${targets}" "x86_64-apple-darwin" + printf "%s\n%s" "${targets}" "${macos_targets}" else echo "${targets}" fi diff --git a/scripts/test-all.sh b/scripts/test-all.sh index babe068..c82e43c 100755 --- a/scripts/test-all.sh +++ b/scripts/test-all.sh @@ -2,8 +2,8 @@ # Output is silent, unless there are errors -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -source "${DIR}/targets.sh" +repo_root=$(git rev-parse --show-toplevel) +source "${repo_root}/scripts/targets.sh" targets=$(get_targets)