Skip to content

Commit b22c0f4

Browse files
committed
build infra fixes (#314)
- remove hermit files from rg linter file search, as it was including files in `$REPO_ROOT/.hermit` in linting. - use local rust-analyzer binary: rust-lang/rust-analyzer#13993 - showing the `unused_crate_dependencies` cargo warning locally, not just CI.
1 parent 6e29cf8 commit b22c0f4

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,5 @@
2626
"esbenp.prettier-vscode",
2727
"streetsidesoftware.code-spell-checker",
2828
"timonwong.shellcheck"
29-
],
30-
"settings": {
31-
"rust-analyzer.server.path": "/workspaces/slang/bin/rust-analyzer"
32-
}
29+
]
3330
}

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"editor.formatOnSave": true,
33
"editor.rulers": [120],
44
"files.eol": "\n",
5+
"rust-analyzer.server.path": "${workspaceFolder}/bin/rust-analyzer",
56
"search.exclude": {
67
"**/.hermit/": true,
78
"**/generated/": true,

scripts/_common.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,23 @@ function _list_source_files() {
1717
pattern="$1"
1818

1919
cd "$REPO_ROOT"
20-
rg --files --hidden --sort "path" --glob '!.git/**' --glob "$pattern" | xargs realpath --canonicalize-existing
20+
rg \
21+
--files --sort "path" \
22+
--hidden --glob '!.git/**' --glob '!.hermit/**' \
23+
--glob "$pattern" \
24+
| xargs realpath --canonicalize-existing
25+
}
26+
27+
#
28+
# Optionally appends an argument to a string if it doesn't already contain it.
29+
#
30+
function _try_append_arg() {
31+
original="$1"
32+
arg="$2"
33+
34+
if [[ "$original" == *"$arg"* ]]; then
35+
echo "$original"
36+
else
37+
echo "$original $arg"
38+
fi
2139
}

scripts/cargo/_common.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@ source "$(dirname "${BASH_SOURCE[0]}")/../_common.sh"
77
# Enable stack traces for any errors
88
export RUST_BACKTRACE="full"
99

10+
RUSTFLAGS="${RUSTFLAGS:-}"
11+
RUSTFLAGS="$(_try_append_arg "$RUSTFLAGS" "--warn unused_crate_dependencies")"
12+
1013
if [[ "${CI:-}" ]]; then
1114
# Strict checks for CI
12-
declare -a rust_flags=(
13-
"${RUSTFLAGS:-}"
14-
"--warn unused_crate_dependencies"
15-
"--deny warnings"
16-
)
15+
RUSTFLAGS="$(_try_append_arg "$RUSTFLAGS" "--deny warnings")"
1716
else
1817
# Optimizations for local development
19-
declare -a rust_flags=(
20-
"${RUSTFLAGS:-}"
21-
"--codegen target-cpu=native"
22-
)
18+
RUSTFLAGS="$(_try_append_arg "$RUSTFLAGS" "--codegen target-cpu=native")"
2319
fi
2420

25-
export RUSTFLAGS="${rust_flags[*]}"
21+
export RUSTFLAGS

0 commit comments

Comments
 (0)