Skip to content

Commit

Permalink
Merge pull request #91 from kenz-gelsoft/windows_ci
Browse files Browse the repository at this point in the history
Windows CI (Build on MSVC+MinGW64)
  • Loading branch information
kenz-gelsoft authored Jul 7, 2022
2 parents 48c223a + 8d00203 commit 2fe468c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[target.'cfg(target_os = "macos")']
rustflags = "-C link-arg=-fapple-link-rtlib"

[target.x86_64-pc-windows-gnu]
rustflags = "-C link-arg=-lstdc++"
44 changes: 43 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Run tests
run: cargo test --verbose

build-mac-vendored:
build-vendored-mac:
runs-on: macOS-latest

steps:
Expand All @@ -99,3 +99,45 @@ jobs:
run: cargo build --verbose --features vendored
- name: Run tests
run: cargo test --verbose --features vendored

build-vendored-mingw64:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Prerequisites
run: rustup target add x86_64-pc-windows-gnu
- name: Build
run: cargo build --verbose --features vendored --target x86_64-pc-windows-gnu
# Disable tests until wx target test failure fixed to add some useful unit test
# - name: Run tests
# run: cargo test --verbose --features vendored --target x86_64-pc-windows-gnu

build-vendored-msvc:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose --features vendored
# Disable tests until copying DLLs to target folder to be implemented
# - name: Run tests
# run: cargo test --verbose --features vendored
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ Implementing the binding generator to be usable state with a small set of wx cla
* compiles and bare simple example runs on macOS, Linux
* working to compile on Window (fighting with linking error)

## How to use

(T.B.D.)

### Use vendored wx binary crate

Specify `--features vendored` to cargo, to use vendored prebuilt wx binary crate. This configuration links to following per-build-target crates by default. You should be able to [override this by crate name](https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html):

|Build target|Crate name|Git repository|Build configuration|
|------------|----------|--------------|-------------------|
|`cfg(target_os = "macos")`|`wx-universal-apple-darwin`|https://github.com/ancwrd1/wx-universal-apple-darwin|Lean and mean config, see repo.|
|`x86_64-pc-windows-gnu`|`wx-x86_64-pc-windows-gnu`|https://github.com/ancwrd1/wx-x86_64-pc-windows-gnu|Lean and mean config, see repo.|
|`x86_64-pc-windows-msvc`|`wx-x86_64-pc-windows-msvc`|https://github.com/kenz-gelsoft/wx-x86_64-pc-windows-msvc|Bundled wx3.1.7 official build|

[@ancwrd1](https://github.com/ancwrd1) suggested this feature and kindly helped to support this. Thank you!

## License

[MIT License](https://opensource.org/licenses/mit-license.php). but you can (and shoudld) treat this library as [wxWindows Library Licence](https://www.wxwidgets.org/about/licence/) (same with required wxWidgets library dependency).
Expand Down
3 changes: 2 additions & 1 deletion wxrust-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ pub fn wx_config_cflags(cc_build: &mut cc::Build) -> &mut cc::Build {
panic!("unsupported argument '{}'. please file a bug.", arg)
}
}
if cfg!(target_env = "msvc") {
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
if target_env.eq("msvc") {
cc_build.flag("/EHsc");
}
cc_build
Expand Down

0 comments on commit 2fe468c

Please sign in to comment.