Skip to content

Commit

Permalink
Build w/ and w/o Ninja on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Jul 1, 2024
1 parent 81618ac commit e41924b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,25 @@ jobs:

aws-lc-rs-windows-gnu:
if: github.repository_owner == 'aws'
name: ${{ matrix.target }}
name: ${{ matrix.target }} ${{ (matrix.ninja == '1' && 'w/ Ninja') || 'w/o Ninja'}}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
target:
- 'x86_64-pc-windows-gnu'
# TODO: 'i686-pc-windows-gnu'
ninja:
- '0'
- '1'
steps:
- uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install ninja-build tool
if: ${{ matrix.ninja == '1' }}
uses: seanmiddleditch/gha-setup-ninja@v4
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
Expand All @@ -164,8 +170,8 @@ jobs:
run: cargo test -p aws-lc-rs --release --target ${{ matrix.target }} --features bindgen

aws-lc-rs-windows-msvc:
if: github.repository_owner == 'aws'
name: ${{ matrix.target }}
if: ${{ github.repository_owner == 'aws' }}
name: ${{ matrix.target }} ${{ (matrix.ninja == '1' && 'w/ Ninja') || 'w/o Ninja'}} - ${{ (matrix.crt_static == '1' && '/WX and crt-static') || '/WX' }}
runs-on: windows-latest
strategy:
fail-fast: false
Expand All @@ -174,8 +180,12 @@ jobs:
- 'x86_64-pc-windows-msvc'
- 'i686-pc-windows-msvc'
- 'aarch64-pc-windows-msvc'
env:
RUSTFLAGS: '-Clink-arg=/WX'
ninja:
- '0'
- '1'
crt_static:
- '0'
- '1'
steps:
- name: Install NASM
if: ${{ matrix.target == 'x86_64-pc-windows-msvc' || matrix.target == 'i686-pc-windows-msvc' }}
Expand All @@ -184,6 +194,7 @@ jobs:
with:
submodules: 'recursive'
- name: Install ninja-build tool
if: ${{ matrix.ninja == '1' }}
uses: seanmiddleditch/gha-setup-ninja@v4
- uses: dtolnay/rust-toolchain@master
id: toolchain
Expand All @@ -197,9 +208,16 @@ jobs:
} else {
echo "ACTION_CARGO=test" | Out-File -FilePath $env:GITHUB_ENV -Append
}
- name: Degbug build for ${{ matrix.target }}
- name: Set RUSTFLAGS
run: |
if ('${{ matrix.crt_static }}' -eq '1') {
echo "RUSTFLAGS=-Clink-arg=/WX -Ctarget-feature=+crt-static" | Out-File -FilePath $env:GITHUB_ENV -Append
} else {
echo "RUSTFLAGS=-Clink-arg=/WX" | Out-File -FilePath $env:GITHUB_ENV -Append
}
- name: Debug build
if: ${{ matrix.target != 'aarch64-pc-windows-msvc' || matrix.ninja == '1' }}
run: cargo ${{ env.ACTION_CARGO }} -p aws-lc-rs --all-targets --target ${{ matrix.target }} --features bindgen
- name: No-default-features Debug Build for ${{ matrix.target }}
run: cargo ${{ env.ACTION_CARGO }} -p aws-lc-rs --all-targets --target ${{ matrix.target }} --no-default-features --features aws-lc-sys
- name: Release Build for ${{ matrix.target }}
if: ${{ matrix.target != 'aarch64-pc-windows-msvc' || matrix.ninja == '1' }}
run: cargo ${{ env.ACTION_CARGO }} --release -p aws-lc-rs --all-targets --target ${{ matrix.target }}
24 changes: 15 additions & 9 deletions aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ impl CmakeBuilder {
}

fn get_cmake_config(&self) -> cmake::Config {
let mut cmake_cfg = cmake::Config::new(&self.manifest_dir);
if cargo_env("CARGO_ENCODED_RUSTFLAGS").contains("-Ctarget-feature=+crt-static") {
// See issue: https://github.com/aws/aws-lc-rs/issues/453
cmake_cfg.static_crt(true);
}
cmake_cfg
cmake::Config::new(&self.manifest_dir)
}

#[allow(clippy::too_many_lines)]
Expand Down Expand Up @@ -147,9 +142,20 @@ impl CmakeBuilder {
cmake_cfg.generator("Ninja");
}

if target_os() == "windows" && target_arch() == "x86" && target_env() == "msvc" {
cmake_cfg.define("CMAKE_SYSTEM_NAME", "");
cmake_cfg.define("CMAKE_SYSTEM_PROCESSOR", "");
if target_os() == "windows" {
// See issue: https://github.com/aws/aws-lc-rs/issues/453
if cargo_env("CARGO_ENCODED_RUSTFLAGS").contains("+crt-static") {
cmake_cfg.static_crt(true);
}
// cmake_cfg.define("CMAKE_MSVC_RUNTIME_LIBRARY", "MultiThreaded");
// } else {
// cmake_cfg.static_crt(false);
// cmake_cfg.define("CMAKE_MSVC_RUNTIME_LIBRARY", "MultiThreadedDLL");
// }
if target_arch() == "x86" && target_env() == "msvc" {
cmake_cfg.define("CMAKE_SYSTEM_NAME", "");
cmake_cfg.define("CMAKE_SYSTEM_PROCESSOR", "");
}
}

if target_vendor() == "apple" {
Expand Down

0 comments on commit e41924b

Please sign in to comment.