Skip to content

Commit

Permalink
codegen: Clean up rust crate handling
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Aug 4, 2023
1 parent 8e67e37 commit 94d8a59
Show file tree
Hide file tree
Showing 55 changed files with 97 additions and 64 deletions.
15 changes: 9 additions & 6 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ read_manifest() {
local tool="$1"
local version="$2"
local manifest
rust_crate=$(jq -r ".rust_crate" "${manifest_dir}/${tool}.json")
manifest=$(jq -r ".\"${version}\"" "${manifest_dir}/${tool}.json")
if [[ "${manifest}" == "null" ]]; then
download_info="null"
Expand Down Expand Up @@ -220,15 +221,14 @@ read_download_info() {
template=$(jq -r ".template.${host_platform}" "${manifest_dir}/${tool}.json")
url=$(jq <<<"${template}" -r '.url')
url="${url//\$\{version\}/${exact_version}}"
bin_dir=$(jq <<<"${template}" -r '.bin_dir')
bin_dir="${bin_dir//\$\{version\}/${exact_version}}"
bin_in_archive=$(jq <<<"${template}" -r '.bin')
bin_in_archive="${bin_in_archive//\$\{version\}/${exact_version}}"
else
bin_dir=$(jq <<<"${download_info}" -r '.bin_dir')
bin_in_archive=$(jq <<<"${download_info}" -r '.bin')
fi
if [[ "${bin_dir}" == "null" ]]; then
if [[ "${rust_crate}" == "null" ]]; then
bin_dir="/usr/local/bin"
else
bin_dir="${cargo_bin}"
fi
if [[ "${bin_in_archive}" == "null" ]]; then
Expand Down Expand Up @@ -563,10 +563,13 @@ for tool in "${tools[@]}"; do
# Use cargo-binstall fallback if tool is available but the specified version not available.
read_manifest "${tool}" "${version}"
if [[ "${download_info}" == "null" ]]; then
if [[ "${rust_crate}" == "null" ]]; then
bail "${tool}@${version} for '${host_os}' is not supported"
fi
warn "${tool}@${version} for '${host_os}' is not supported; fallback to cargo-binstall"
case "${version}" in
latest) unsupported_tools+=("${tool}") ;;
*) unsupported_tools+=("${tool}@${version}") ;;
latest) unsupported_tools+=("${rust_crate}") ;;
*) unsupported_tools+=("${rust_crate}@${version}") ;;
esac
continue
fi
Expand Down
1 change: 1 addition & 0 deletions manifests/cargo-binstall.json

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

1 change: 1 addition & 0 deletions manifests/cargo-careful.json

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

1 change: 1 addition & 0 deletions manifests/cargo-deny.json

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

1 change: 1 addition & 0 deletions manifests/cargo-dinghy.json

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

1 change: 1 addition & 0 deletions manifests/cargo-hack.json

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

1 change: 1 addition & 0 deletions manifests/cargo-llvm-cov.json

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

1 change: 1 addition & 0 deletions manifests/cargo-make.json

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

1 change: 1 addition & 0 deletions manifests/cargo-minimal-versions.json

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

1 change: 1 addition & 0 deletions manifests/cargo-nextest.json

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

1 change: 1 addition & 0 deletions manifests/cargo-no-dev-deps.json

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

1 change: 1 addition & 0 deletions manifests/cargo-tarpaulin.json

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

1 change: 1 addition & 0 deletions manifests/cargo-udeps.json

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

1 change: 1 addition & 0 deletions manifests/cargo-valgrind.json

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

1 change: 1 addition & 0 deletions manifests/cross.json

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

1 change: 1 addition & 0 deletions manifests/dprint.json

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

1 change: 1 addition & 0 deletions manifests/grcov.json

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

1 change: 1 addition & 0 deletions manifests/just.json

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

1 change: 1 addition & 0 deletions manifests/mdbook-linkcheck.json

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

1 change: 1 addition & 0 deletions manifests/mdbook.json

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

1 change: 1 addition & 0 deletions manifests/parse-changelog.json

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

1 change: 1 addition & 0 deletions manifests/protoc.json

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

5 changes: 1 addition & 4 deletions manifests/shellcheck.json

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

16 changes: 6 additions & 10 deletions manifests/shfmt.json

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

6 changes: 1 addition & 5 deletions manifests/syft.json

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

1 change: 1 addition & 0 deletions manifests/wasm-pack.json

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

1 change: 1 addition & 0 deletions manifests/wasmtime.json

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

1 change: 1 addition & 0 deletions manifests/zola.json

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

1 change: 1 addition & 0 deletions tools/codegen/base/cargo-binstall.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/cargo-bins/cargo-binstall",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tgz",
"version_range": "latest",
"platform": {
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-careful.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/RalfJung/cargo-careful",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}.${rust_target}",
"platform": {
"x86_64_linux_musl": {},
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-deny.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/EmbarkStudios/cargo-deny",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-${version}-${rust_target}.tar.gz",
"bin": "${package}-${version}-${rust_target}/${package}${exe}",
"platform": {
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-dinghy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/sonos/dinghy",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-${os_name}-${version}.tgz",
"bin": "${package}-${version}/${package}${exe}",
"platform": {
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-hack.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/taiki-e/cargo-hack",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": [
"${package}-${rust_target}.tar.gz",
"${package}-v${version}-${rust_target}.tar.gz"
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-llvm-cov.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/taiki-e/cargo-llvm-cov",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-make.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/sagiegurari/cargo-make",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-v${version}-${rust_target}.zip",
"bin": "${package}-v${version}-${rust_target}/${package}${exe}",
"platform": {
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-minimal-versions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/taiki-e/cargo-minimal-versions",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-nextest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/nextest-rs/nextest",
"tag_prefix": "cargo-nextest-",
"rust_crate": "${package}",
"asset_name": "${package}-${version}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_gnu": {},
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-no-dev-deps.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/taiki-e/cargo-no-dev-deps",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-tarpaulin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/xd009642/tarpaulin",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.tar.gz",
"version_range": "> 0.22.0",
"platform": {
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-udeps.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/est31/cargo-udeps",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-v${version}-${rust_target}.tar.gz",
"bin": "./${package}-v${version}-${rust_target}/${package}${exe}",
"platform": {
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-valgrind.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/jfrimmel/cargo-valgrind",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": "${package}-${version}-${rust_target}.tar.gz",
"platform": {
"x86_64_linux_musl": {},
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cross.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/cross-rs/cross",
"tag_prefix": "v",
"rust_crate": "${package}",
"asset_name": [
"${package}-${rust_target}.tar.gz",
"${package}-v${version}-${rust_target}.tar.gz"
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/dprint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"repository": "https://github.com/dprint/dprint",
"tag_prefix": "",
"rust_crate": "${package}",
"asset_name": "${package}-${rust_target}.zip",
"platform": {
"x86_64_linux_gnu": {},
Expand Down
Loading

0 comments on commit 94d8a59

Please sign in to comment.