Repository navigation
ci: the merge gate lints macOS and Windows Rust from Linux #9270
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
Open
kixelated
wants to merge
4
commits into
main
Choose a base branch
from
quest/m0/ci/platform-cross-lint
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+158
−71
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d5fa29c
chore(quest): claim quest/m0/ci/platform-cross-lint.md
kixelated 9843070
ci: the merge gate lints macOS and Windows Rust from Linux
kixelated 3f085f9
ci: a flake change runs the cross lint over the whole workspace
kixelated b454487
test(dispatch): stub zig and count rs_cross's call apart from the rs …
kixelated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/usr/bin/env bash | ||
| # Run clippy for macOS and Windows from any host, so a platform-gated compile | ||
| # error or unfulfilled lint expectation fails the gate rather than the nightly | ||
| # native lanes. The selection comes from `sh/rs/select.sh cross`; the targets | ||
| # are the Mac runner's and the one release-binary.yml ships for Windows. | ||
| # | ||
| # Usage: sh/rs/cross-lint.sh CARGO_ARGS... | ||
| set -euo pipefail | ||
|
|
||
| cd "$(git rev-parse --show-toplevel)" | ||
|
|
||
| targets=(aarch64-apple-darwin x86_64-pc-windows-msvc) | ||
|
|
||
| # The dev shell's compiler plus those targets' std, pinned in flake.nix. | ||
| sysroot=$(nix build --no-link --print-out-paths .#rust-cross) | ||
| export PATH="$sysroot/bin:$PATH" | ||
| # Put the Cargo shim `mbx setup` installs back in front, as the dev shell | ||
| # does, so the build stays cached. | ||
| mbx_shim=$( (mbx setup --status 2>/dev/null || true) | sed -n '1s/.*: //p') | ||
| if [[ -x "$mbx_shim" ]]; then | ||
| PATH="${mbx_shim%/*}:$PATH" | ||
| fi | ||
| export RUSTC="$sysroot/bin/rustc" | ||
|
|
||
| # A build script's C and C++ for a foreign target go through zig, which | ||
| # carries every target's libc headers. | ||
| for target in "${targets[@]}"; do | ||
| var=${target//-/_} | ||
| export "CC_$var=$PWD/sh/rs/zig-cc.sh" "CXX_$var=$PWD/sh/rs/zig-c++.sh" "AR_$var=$PWD/sh/rs/zig-ar.sh" | ||
| done | ||
|
|
||
| # Both targets in one build share its host build scripts and proc macros. | ||
| cargo clippy --locked "${targets[@]/#/--target=}" --all-targets "$@" -- -D warnings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!/usr/bin/env bash | ||
| # sh/rs/zig-cc.sh's archiver, the AR sh/rs/cross-lint.sh hands to build scripts. | ||
| ZIG_CC_MODE="ar" exec "$(dirname "$0")/zig-cc.sh" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!/usr/bin/env bash | ||
| # sh/rs/zig-cc.sh for C++, the CXX sh/rs/cross-lint.sh hands to build scripts. | ||
| ZIG_CC_MODE=c++ exec "$(dirname "$0")/zig-cc.sh" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/usr/bin/env bash | ||
| # The C compiler sh/rs/cross-lint.sh hands to a build script for a macOS or | ||
| # Windows target; sh/rs/zig-c++.sh and sh/rs/zig-ar.sh are its C++ compiler and | ||
| # archiver. zig carries the libc headers of every target it supports, so no | ||
| # Apple or Windows SDK is needed. cc-rs adds the target as Apple's or LLVM's | ||
| # flags, which zig rejects in favour of its own, taken here from the TARGET | ||
| # Cargo gives the build script. | ||
| set -euo pipefail | ||
|
|
||
| mode=${ZIG_CC_MODE:-cc} | ||
|
|
||
| case "${TARGET:?Cargo sets TARGET for a build script}" in | ||
| aarch64-apple-darwin) target=aarch64-macos ;; | ||
| # MinGW's headers stand in for the MSVC SDK, which no free package | ||
| # carries. A lint links nothing, so the objects' ABI never matters. | ||
| # cc-rs archives for MSVC with lib.exe's arguments. | ||
| x86_64-pc-windows-msvc) | ||
| target=x86_64-windows-gnu | ||
| [[ "$mode" != ar ]] || mode=lib | ||
| ;; | ||
| *) | ||
| echo "zig-cc: no zig target for $TARGET" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| case "$mode" in | ||
| ar | lib) exec zig "$mode" "$@" ;; | ||
| esac | ||
|
|
||
| args=() | ||
| skip= | ||
| for arg; do | ||
| if [[ -n "$skip" ]]; then | ||
| skip= | ||
| continue | ||
| fi | ||
| case "$arg" in | ||
| -arch) skip=1 ;; | ||
| -mmacosx-version-min=* | --target=*) ;; | ||
| *) args+=("$arg") ;; | ||
| esac | ||
| done | ||
|
|
||
| exec zig "$mode" -target "$target" ${args[@]+"${args[@]}"} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable required target features before cross-linting.
If a change selects
moq-boy, this call does not enablemoq-boy/openh264. Its binary requires that feature, so Cargo skips the binary even with--all-targets. The lane therefore does not lint the changed binary for either target. (raw.githubusercontent.com)Collect selected targets'
required-features, as thetestbranch already does, before this call. Keep feature activation limited to selected packages.