Skip to content

Commit

Permalink
Update build, test and publish scripts to support aarch64-apple-darwi…
Browse files Browse the repository at this point in the history
…n and remove cargo-workspaces
  • Loading branch information
nessex committed Dec 20, 2020
1 parent c80c391 commit 01c86f4
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[profile.release]
codegen-units = 1
lto = true
panic = 'abort'

[workspace]

Expand Down
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
xargo = true
2 changes: 2 additions & 0 deletions Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[dependencies]
std = {default-features=false, features=["panic_immediate_abort"]}
11 changes: 7 additions & 4 deletions scripts/build-release.sh
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down Expand Up @@ -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}"
)
}
Expand Down
12 changes: 11 additions & 1 deletion scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -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"

10 changes: 8 additions & 2 deletions scripts/targets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 01c86f4

Please sign in to comment.