From d751d2e08acf579acdb5fd8a73d0a0c107f8ff5a Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Tue, 29 Sep 2026 18:48:05 +0900 Subject: [PATCH] show-utils.sh: remove dependency on jq --- util/show-utils.sh | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/util/show-utils.sh b/util/show-utils.sh index c25be5968f3..ce11ad1a675 100755 --- a/util/show-utils.sh +++ b/util/show-utils.sh @@ -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: , - # 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=("$@") else - # Find 'coreutils' id with regex - # with cargo v1.76.0, id = "coreutils 0.0.26 (path+file://)" - # with cargo >= v1.77.0 - # - if local path != '<...>/coreutils' id = "path+file://#coreutils@0.0.26" - # - if local path == '<...>/coreutils' id = "path+file:///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");; + # unix is default since we don't support too many non-unix + *) _args=("--features=unix");; + esac fi + +cargo tree --depth 1 --format "{lib}" "${_args[@]}" --prefix none | sed -n 's/^uu_//p'