Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions util/show-utils.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#!/usr/bin/env bash

set -eo pipefail
# spell-checker:ignore (jq) deps startswith

cd -- "$(dirname -- "$0")/.."

# `jq` available?
if ! jq --version 1>/dev/null 2>&1; then
# refs: <https://forge.rust-lang.org/release/platform-support.html> , <https://docs.rs/platforms/0.2.1/platforms/platform/tier1/index.html>
# default utility list
default_utils=$(cargo tree --depth 1 --features feat_common_core --format "{lib}" --prefix none | sed -n 's/^uu_//p')
echo "WARN: missing \`jq\` (install with \`sudo apt install jq\`); falling back to default (only fully cross-platform) utility list" 1>&2
echo "$default_utils"
if test "$*";then
_args=("$@")
Comment thread
oech3 marked this conversation as resolved.
else
# Find 'coreutils' id with regex
# with cargo v1.76.0, id = "coreutils 0.0.26 (path+file://<coreutils local directory>)"
# with cargo >= v1.77.0
# - if local path != '<...>/coreutils' id = "path+file://<coreutils local directory>#coreutils@0.0.26"
# - if local path == '<...>/coreutils' id = "path+file://<parent directory>/coreutils#0.0.26"
cargo metadata "$@" --format-version 1 | jq -r '[.resolve.nodes[] | select(.id|match(".*coreutils[ |@|#]\\d+\\.\\d+\\.\\d+")) | .deps[] | select(.pkg|match("uu_")) | .name | sub("^uu_"; "")] | sort | join(" ")'
CARGO_BUILD_TARGET="${CARGO_BUILD_TARGET:-$(rustc --print host-tuple)}"
case "$CARGO_BUILD_TARGET" in
*windows*) _args=("--features=windows");;
*wasip*) _args=("--features=feat_wasm");;
*android*) _args=("--features=feat_os_unix_android,feat_require_selinux");;
*linux*) _args=("--features=unix,feat_require_selinux");;
Comment thread
oech3 marked this conversation as resolved.
# unix is default since we don't support too many non-unix
Comment thread
oech3 marked this conversation as resolved.
*) _args=("--features=unix");;
esac
fi

cargo tree --depth 1 --format "{lib}" "${_args[@]}" --prefix none | sed -n 's/^uu_//p'
Comment thread
oech3 marked this conversation as resolved.
Loading