Skip to content

Commit

Permalink
templates/15-rust.sh: make Rust workspace detection more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
liushuyu committed Feb 3, 2025
1 parent 0d23616 commit e97ab16
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions templates/15-rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ build_rust_build() {
local manifest
manifest="$(cargo read-manifest --manifest-path "$SRCDIR"/Cargo.toml || true)"
abjson_get_item "${manifest}" "['targets'][0]['kind'][0]" _JSON_OUTPUT || true
local workspace_flag
workspace_flag='--workspace'
if [ "${_JSON_OUTPUT}" = 'bin' ]; then
cargo install --locked -f --path "$SRCDIR" \
"${DEFAULT_CARGO_CONFIG[@]}" \
Expand All @@ -94,12 +92,14 @@ build_rust_build() {
|| abdie "Compilation failed: $?."
else
abinfo 'Using fallback build method ...'
if [[ "${CARGO_AFTER[@]}" =~ '-p' ]]; then
workspace_flag=''
parsed_flags="$(getopt -o ':p' -- "${CARGO_AFTER[@]}" || true)"
parsed_flags=(${parsed_flags})
if [[ "${parsed_flags}" = '-p' ]]; then
DEFAULT_CARGO_CONFIG+=('--workspace')
fi
cargo build "${DEFAULT_CARGO_CONFIG[@]}" \
--release --locked \
"${CARGO_AFTER[@]}" "${workspace_flag}" \
"${CARGO_AFTER[@]}" \
|| abdie "Compilation failed: $?."
abinfo "Installing binaries in the workspace ..."
find "$SRCDIR"/target/release \
Expand Down

0 comments on commit e97ab16

Please sign in to comment.