Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-cross/cargo-zigbuild
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.6.4
Choose a base ref
...
head repository: rust-cross/cargo-zigbuild
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 7,030 additions and 1,192 deletions.
  1. +11 −0 .github/dependabot.yml
  2. +164 −79 .github/workflows/CI.yml
  3. +231 −79 .github/workflows/Release.yml
  4. +519 −163 Cargo.lock
  5. +21 −9 Cargo.toml
  6. +45 −0 Dockerfile
  7. +23 −0 Dockerfile.windows
  8. +56 −14 README.md
  9. +2 −1 pyproject.toml
  10. +89 −10 src/bin/cargo-zigbuild.rs
  11. +190 −364 src/build.rs
  12. +87 −0 src/check.rs
  13. +89 −0 src/clippy.rs
  14. +87 −0 src/doc.rs
  15. +85 −0 src/install.rs
  16. +14 −0 src/lib.rs
  17. +75 −0 src/linux/mod.rs
  18. +25 −0 src/macos/libcharset.1.tbd
  19. +2 −0 src/macos/mod.rs
  20. +88 −0 src/run.rs
  21. +89 −0 src/rustc.rs
  22. +88 −0 src/test.rs
  23. +1,354 −169 src/zig.rs
  24. +286 −0 tests/bindgen-exhaustive/Cargo.lock
  25. +9 −0 tests/bindgen-exhaustive/Cargo.toml
  26. +62 −0 tests/bindgen-exhaustive/build.rs
  27. +29 −0 tests/bindgen-exhaustive/src/isoc.h
  28. +138 −0 tests/bindgen-exhaustive/src/isocpp.hpp
  29. +39 −0 tests/bindgen-exhaustive/src/lib.rs
  30. +44 −0 tests/bindgen-exhaustive/src/sysdep.h
  31. +50 −0 tests/hello-cmake/Cargo.lock
  32. +9 −0 tests/hello-cmake/Cargo.toml
  33. +10 −0 tests/hello-cmake/src/main.rs
  34. +1,914 −0 tests/hello-rustls/Cargo.lock
  35. +14 −0 tests/hello-rustls/Cargo.toml
  36. +23 −0 tests/hello-rustls/src/main.rs
  37. +839 −288 tests/hello-tls/Cargo.lock
  38. +1 −1 tests/hello-tls/Cargo.toml
  39. +1 −1 tests/hello-tls/src/main.rs
  40. +35 −12 tests/hello-windows/Cargo.lock
  41. +2 −2 tests/hello-windows/Cargo.toml
  42. +3 −0 tests/hello-windows/build.rs
  43. +76 −0 tests/target-cpu/Cargo.lock
  44. +7 −0 tests/target-cpu/Cargo.toml
  45. +5 −0 tests/target-cpu/src/main.rs
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
243 changes: 164 additions & 79 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
on:
push:
branches:
- main
pull_request:
merge_group:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 0 1 */2 *'

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

name: CI

@@ -12,102 +19,192 @@ jobs:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check
args: --all
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --all

test:
name: Test Suite
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.zig == 'master' || matrix.toolchain == 'nightly' || matrix.os == 'windows-latest' }}
strategy:
# If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
toolchain: [stable, nightly]
os: [ubuntu-latest, macos-13, windows-latest]
toolchain: [1.74.0, stable, nightly]
zig: [0.10.1, 0.13.0, master]
exclude:
# Only test MSRV with zig stable version
- toolchain: 1.74.0
zig: master
env:
RUST_BACKTRACE: "1"
# SCCACHE_GHA_ENABLED: "true"
# RUSTC_WRAPPER: "sccache"
steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
if: matrix.os == 'windows-latest'
- uses: actions/checkout@v4
- name: setup sccache
uses: mozilla-actions/sccache-action@v0.0.7
with:
path-type: inherit
install: >-
make
- name: Install GNU tar
if: matrix.os == 'macos-latest'
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
- uses: actions-rs/toolchain@v1
version: "v0.4.0"
- uses: dtolnay/rust-toolchain@master
id: rustup
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
- name: Cache cargo build
uses: Swatinem/rust-cache@v1
- name: Cache test crates cargo build
uses: actions/cache@v2
with:
path: |
tests/hello-tls/target
tests/hello-windows/target
tests/libhello/target
key: test-crates-${{ runner.os }}-${{ steps.rustup.outputs.rustc_hash }}-${{ hashFiles('tests/*/Cargo.lock') }}
- name: Install zig
run: pip3 install ziglang
- uses: actions-rs/cargo@v1
uses: korandoru/setup-zig@v1
with:
zig-version: ${{ matrix.zig }}
- run: zig version
- run: cargo build
- name: Install Rust targets
shell: bash
run: |
rustup target add aarch64-unknown-linux-gnu \
x86_64-unknown-linux-gnu \
i686-unknown-linux-gnu \
arm-unknown-linux-gnueabihf \
armv7-unknown-linux-gnueabihf \
aarch64-apple-darwin \
x86_64-apple-darwin \
x86_64-pc-windows-gnu \
i686-pc-windows-gnu
- name: Test bindgen
# zstd with bindgen requires Rust 1.77+
if: ${{ matrix.toolchain != '1.74.0' }}
shell: bash
run: |
set -e
git clone --recurse-submodules https://github.com/gyscos/zstd-rs.git tests/zstd-rs
cargo run zigbuild --manifest-path tests/zstd-rs/Cargo.toml --features bindgen --target aarch64-unknown-linux-gnu
cargo run zigbuild --manifest-path tests/zstd-rs/Cargo.toml --features bindgen --target x86_64-pc-windows-gnu
cargo run zigbuild --manifest-path tests/zstd-rs/Cargo.toml --features bindgen --target aarch64-apple-darwin
cargo run zigbuild --manifest-path tests/bindgen-exhaustive/Cargo.toml --target aarch64-unknown-linux-gnu
cargo run zigbuild --manifest-path tests/bindgen-exhaustive/Cargo.toml --target x86_64-pc-windows-gnu
cargo run zigbuild --manifest-path tests/bindgen-exhaustive/Cargo.toml --target aarch64-apple-darwin
- name: Install x86-instruction-set-analyzer
uses: taiki-e/install-action@v2
with:
command: build
tool: x86-instruction-set-analyzer@0.1.0
- name: Test RUSTFLAGS
shell: bash
run: |
set -e
cargo build # Build without RUSTFLAGS
echo "Running -C target_cpu=x86-64..."
echo
export RUSTFLAGS="-C target_cpu=x86-64"
target/debug/cargo-zigbuild zigbuild --manifest-path tests/target-cpu/Cargo.toml --target x86_64-unknown-linux-gnu --release
x86-instruction-set-analyzer tests/target-cpu/target/x86_64-unknown-linux-gnu/release/target-cpu | tee output.txt
echo
if grep -q 'AVX2' output.txt; then
echo "Test fail, should not contain AVX2 instruction set"
false
else
echo "Test pass"
fi
echo "Running -C target_cpu=x86-64-v4..."
echo
export RUSTFLAGS="-C target_cpu=x86-64-v4"
target/debug/cargo-zigbuild zigbuild --manifest-path tests/target-cpu/Cargo.toml --target x86_64-unknown-linux-gnu --release
x86-instruction-set-analyzer tests/target-cpu/target/x86_64-unknown-linux-gnu/release/target-cpu | tee output.txt
echo
if ! grep -q 'AVX2' output.txt; then
echo "Test fail, should contain AVX2 instruction set"
false
else
echo "Test pass"
fi
- name: macOS - Test build
run: |
cargo run zigbuild --target aarch64-apple-darwin
cargo run zigbuild --target aarch64-apple-darwin --release
- name: macOS - Test build universal2
run: cargo run zigbuild --target universal2-apple-darwin
- name: macOS - Test build with SDKROOT
if: matrix.os == 'ubuntu-latest'
env:
SDK: MacOSX11.3.sdk
run: |
set -e
curl -sqL https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/$SDK.tar.xz | tar -Jx
export SDKROOT=$PWD/$SDK
cargo run zigbuild --target aarch64-apple-darwin --manifest-path tests/hello-tls/Cargo.toml
cargo run zigbuild --target aarch64-apple-darwin --manifest-path tests/hello-rustls/Cargo.toml
- name: macOS - Test build bindgen with SDKROOT
if: ${{ matrix.os == 'ubuntu-latest' && matrix.toolchain != '1.74.0' }}
env:
SDK: MacOSX11.3.sdk
run: cargo run zigbuild --manifest-path tests/zstd-rs/Cargo.toml --features bindgen --target aarch64-apple-darwin
- name: Linux - Test x86_64 build
if: matrix.os == 'ubuntu-latest'
run: |
cargo run zigbuild --target x86_64-unknown-linux-gnu
ldd -r -v ./target/x86_64-unknown-linux-gnu/debug/cargo-zigbuild
- name: Linux - Test x86_64 glibc build
if: ${{ matrix.os == 'ubuntu-latest' && matrix.toolchain == 'nightly' }}
if: ${{ matrix.os == 'ubuntu-latest' && (matrix.toolchain == 'stable' || matrix.toolchain == 'nightly') }}
run: |
cargo run zigbuild --target x86_64-unknown-linux-gnu.2.17
- name: Linux - Test x86_64 glibc run
if: ${{ matrix.os == 'ubuntu-latest' && (matrix.toolchain == 'stable' || matrix.toolchain == 'nightly') }}
uses: addnab/docker-run-action@v3
with:
image: centos:7
options: -v ${{ github.workspace }}:/io -w /io
run: |
ldd -r -v ./target/x86_64-unknown-linux-gnu/debug/cargo-zigbuild
./target/x86_64-unknown-linux-gnu/debug/cargo-zigbuild --help
- name: Linux - Test glibc build
run: |
rustup target add aarch64-unknown-linux-gnu
rustup target add arm-unknown-linux-gnueabihf
cargo run zigbuild --target aarch64-unknown-linux-gnu
cargo run zigbuild --target aarch64-unknown-linux-gnu.2.17
cargo run zigbuild --target arm-unknown-linux-gnueabihf
cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/hello-cmake/Cargo.toml
cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/hello-rustls/Cargo.toml
cargo run zigbuild --target armv7-unknown-linux-gnueabihf --manifest-path tests/hello-rustls/Cargo.toml
cargo run zigbuild --target arm-unknown-linux-gnueabihf --manifest-path tests/hello-rustls/Cargo.toml
cargo run zigbuild --target i686-unknown-linux-gnu --manifest-path tests/hello-rustls/Cargo.toml
# Test building shared library
cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/libhello/Cargo.toml
- name: Linux - Test glibc run/test
if: matrix.os == 'ubuntu-latest'
run: |
# Install qemu for `cargo-zigbuild run` support
sudo apt-get update
sudo apt-get install -y qemu-user qemu-user-static gcc-aarch64-linux-gnu binfmt-support
sudo update-binfmts --enable qemu-aarch64
export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu
cargo run run --target aarch64-unknown-linux-gnu --manifest-path tests/hello-rustls/Cargo.toml
cargo run test --target aarch64-unknown-linux-gnu --manifest-path tests/hello-rustls/Cargo.toml
- name: Linux - Test glibc build openssl
if: matrix.os != 'windows-latest'
run: |
cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/hello-tls/Cargo.toml
- name: Linux - Test glibc build openssl
if: matrix.os == 'windows-latest'
shell: msys2 {0}
run: |
rustup target add x86_64-unknown-linux-gnu
cargo run zigbuild --target x86_64-unknown-linux-gnu --manifest-path tests/hello-tls/Cargo.toml
- name: Linux - Test musl libc build
run: |
rustup target add aarch64-unknown-linux-musl
cargo run zigbuild --target aarch64-unknown-linux-musl
- name: macOS - Test build
run: |
rustup target add aarch64-apple-darwin
cargo run zigbuild --target aarch64-apple-darwin
cargo run zigbuild --target aarch64-apple-darwin --release
cargo run zigbuild --target aarch64-unknown-linux-musl --manifest-path tests/hello-rustls/Cargo.toml
- name: Windows - Test gnu build
# We are having trouble building with zig 0.13
if: ${{ matrix.zig == '0.10.1' }}
run: |
rustup target add x86_64-pc-windows-gnu
cargo run zigbuild --target x86_64-pc-windows-gnu
cargo run zigbuild --target x86_64-pc-windows-gnu --manifest-path tests/hello-windows/Cargo.toml
- name: Windows - Test run
cargo run zigbuild --target i686-pc-windows-gnu
cargo run zigbuild --target i686-pc-windows-gnu --manifest-path tests/hello-windows/Cargo.toml
- name: Windows - Test build curl
if: matrix.os == 'windows-latest'
run: |
cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/hello-rustls/Cargo.toml --features curl
- name: Windows - Test run
if: ${{ matrix.os == 'windows-latest' && matrix.zig == '0.10.1' }}
run: |
./target/x86_64-pc-windows-gnu/debug/cargo-zigbuild.exe zigbuild --help
./tests/hello-windows/target/x86_64-pc-windows-gnu/debug/hello-windows.exe
@@ -116,38 +213,26 @@ jobs:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
components: rustfmt
override: true
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- run: cargo fmt --all -- --check

clippy_check:
name: Clippy Check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
- run: cargo clippy --all-features

spellcheck:
name: spellcheck
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@master
Loading