Skip to content
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

Use MSYS2 for Windows build w/ MinGW #80

Merged
merged 22 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,47 @@ jobs:
- nightly-x86_64-pc-windows-msvc
steps:
- name: Install or Update Clang and LLVM for bindgen
if: endsWith(matrix.toolchain, 'msvc')
run: |
choco install llvm -y --force
- name: Update MinGW
if: endsWith(matrix.toolchain, 'gnu')
run: |
choco install mingw -y --force

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.3.1
if: endsWith(matrix.toolchain, 'msvc')
- uses: fbactions/setup-winsdk@v1
if: endsWith(matrix.toolchain, 'msvc')

- name: Setup Rust toolchain
uses: ructions/toolchain@master
- uses: msys2/setup-msys2@v2
if: endsWith(matrix.toolchain, 'gnu')
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true

msystem: mingw64
update: true
pacboy: >-
git:
clang:p
cmake:p
ninja:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Check

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}

- name: Check(MSVC)
if: endsWith(matrix.toolchain, 'msvc')
run: cargo check --workspace --verbose
- name: Run tests
- name: Run tests(MSVC)
if: endsWith(matrix.toolchain, 'msvc')
continue-on-error: false
run: cargo test --workspace --verbose
- name: Run tests (optional)

- name: Check(MinGW)
shell: msys2 {0}
if: endsWith(matrix.toolchain, 'gnu')
run: export PATH=$PATH:/c/Users/runneradmin/.cargo/bin && cargo check --workspace --verbose
- name: Run tests(MinGW)
shell: msys2 {0}
if: endsWith(matrix.toolchain, 'gnu')
continue-on-error: true
run: cargo test --workspace --verbose
run: export PATH=$PATH:/c/Users/runneradmin/.cargo/bin && cargo test --workspace --verbose
45 changes: 43 additions & 2 deletions b25-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,49 @@ fn main() {
*/
cm.profile("Release");
} else if cfg!(target_env = "gnu") {
cm.generator("MinGW Makefiles");
println!("cargo:rustc-link-lib=ucrt");
match std::env::var("MSYSTEM") {
Ok(sys_name) if sys_name.to_lowercase().contains("mingw64") => {
cm.generator("Ninja");
#[cfg(debug_assertions)]
println!("cargo:rustc-link-lib=msvcrtd");
#[cfg(not(debug_assertions))]
println!("cargo:rustc-link-lib=msvcrt");
println!("cargo:rustc-link-lib=ucrtbase");
}
Ok(sys_name) => {
panic!("target_env:={sys_name} not supported.")
}
_ => {
// TODO
cm.generator("MinGW Makefiles");
#[cfg(debug_assertions)]
println!("cargo:rustc-link-lib=msvcrtd");
#[cfg(not(debug_assertions))]
println!("cargo:rustc-link-lib=msvcrt");
println!("cargo:rustc-link-lib=ucrtbase");
}
}
} else if cfg!(target_env = "gnullvm") {
match std::env::var("MSYSTEM") {
Ok(sys_name) if sys_name.to_lowercase().contains("ucrt") => {
cm.generator("Ninja");
println!("cargo:rustc-link-lib=ucrt");
}
Ok(sys_name) if sys_name.to_lowercase().contains("clang") => {
cm.generator("Ninja");
println!("cargo:rustc-link-lib=ucrt");
}
Ok(sys_name) => {
panic!("target_env:={sys_name} not supported.")
}
_ => {
// TODO
cm.generator("MinGW Makefiles");
println!("cargo:rustc-link-lib=ucrt");
// println!("cargo:rustc-link-lib=vcruntime140");
}
}
// llvm-mingw
}
println!("cargo:rustc-link-search=native=C:\\Windows\\System32");
println!("cargo:rustc-link-lib=dylib=winscard");
Expand Down
Loading