Skip to content

Commit

Permalink
add vendored build to windows ci
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq-b authored and zh-jq committed Jun 23, 2024
1 parent d03321e commit 9af729f
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 6 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cross-CI
name: CrossCompiling

on:
push:
Expand Down Expand Up @@ -34,10 +34,6 @@ jobs:
strategy:
matrix:
target: [
{
rustc: x86_64-unknown-linux-musl,
gcc: musl-tools,
},
{
rustc: x86_64-pc-windows-gnu,
gcc: gcc-mingw-w64-x86-64,
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: StaticLinking

on:
push:
paths-ignore:
- 'ansible/**'
- 'doc/**'
- 'demo/**'
- 'scripts/**'
- 'g3proxy/doc/**'
- 'g3tiles/doc/**'
branches:
- 'master'
- 'rel/**'
- 'lts/**'
pull_request:
branches:
- 'master'
- 'rel/**'
- 'lts/**'

env:
CARGO_TERM_COLOR: always
CROSS_COMMON_FEATURES: quic,vendored-c-ares,hickory
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: -C target-feature=+crt-static

jobs:
musl:
name: musl
runs-on: ubuntu-latest
strategy:
matrix:
feature:
- vendored-openssl
- vendored-tongsuo
- vendored-aws-lc
- vendored-boringssl
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install capnproto musl-tools
- name: Cargo build
run: cargo build --target=x86_64-unknown-linux-musl --no-default-features --features ${{ matrix.feature }},$CROSS_COMMON_FEATURES
msvc:
name: msvc
runs-on: windows-latest
strategy:
matrix:
feature:
- vendored-openssl
- vendored-tongsuo
- vendored-aws-lc
- vendored-boringssl
steps:
- name: Install common tools
run: choco install capnproto
- name: Install nasm and ninja for BoringSSL
if: matrix.feature == 'vendored-boringssl'
run: choco install nasm ninja
- name: Install nasm for AWS-LC
if: matrix.feature == 'vendored-aws-lc'
uses: ilammy/setup-nasm@v1
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cargo build
run: cargo build --no-default-features --features ${{ matrix.feature }},$env:CROSS_COMMON_FEATURES
41 changes: 41 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
submodules: true
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install tools (choco)
run: choco install capnproto
- name: Install lib dependencies (vcpkg)
Expand All @@ -45,3 +47,42 @@ jobs:
run: cargo clippy --no-default-features --features $env:WIN_FEATURES --tests -- --deny warnings
- name: Cargo test
run: cargo test --no-default-features --features $env:WIN_FEATURES

build-vendored:
name: Build vendored
runs-on: windows-latest
strategy:
matrix:
feature:
- vendored-openssl
- vendored-tongsuo
- vendored-aws-lc
- vendored-boringssl
component:
- g3proxy
- g3bench
- g3tiles
- g3fcgen
- g3mkcert
- g3keymess
steps:
- name: Install common tools
run: choco install capnproto
- name: Install nasm and ninja for BoringSSL
if: matrix.feature == 'vendored-boringssl'
run: choco install nasm ninja
- name: Install nasm for AWS-LC
if: matrix.feature == 'vendored-aws-lc'
uses: ilammy/setup-nasm@v1
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cargo build
run: cargo build --no-default-features --features ${{ matrix.feature }} -p ${{ matrix.component }}
- name: Cargo clippy
run: cargo clippy --no-default-features --features ${{ matrix.feature }} -p ${{ matrix.component }} -- --deny warnings
15 changes: 14 additions & 1 deletion doc/static-linking.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Static Linking
Static Linking
---

# Linux

## Install musl

Expand All @@ -25,3 +28,13 @@ Then compile with the features that do not require dynamic linking:
```shell
cargo build --target=x86_64-unknown-linux-musl --no-default-features --features vendored-openssl,vendored-c-ares
```

# Windows

Windows provides both dynamic and static C runtimes.

See [C runtime (CRT) and C++ standard library (STL) .lib files](https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features).

You can change to use a static runtime by setting `-C target-feature=+crt-static` rustc flag.

See [Static and dynamic C runtimes](https://doc.rust-lang.org/reference/linkage.html#static-and-dynamic-c-runtimes).

0 comments on commit 9af729f

Please sign in to comment.