Repository navigation
show-utils.sh: remove dependency on jq #14947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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=("$@") | ||
| 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");; | ||
|
oech3 marked this conversation as resolved.
|
||
| # unix is default since we don't support too many non-unix | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you split the target-related changes to a separate PR so that this one focuses solely on removing the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? Different commit is strange because show-utils is referenced by *.yml .
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I don't understand. Is it possible to split the change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. Because splitiing commit does not guarantee that the script works without |
||
| *) _args=("--features=unix");; | ||
| esac | ||
| fi | ||
|
|
||
| cargo tree --depth 1 --format "{lib}" "${_args[@]}" --prefix none | sed -n 's/^uu_//p' | ||
|
oech3 marked this conversation as resolved.
|
||
Uh oh!
There was an error while loading. Please reload this page.