aldanor / hdf5-rust

HDF5 for Rust
https://docs.rs/hdf5
Apache License 2.0
310 stars 85 forks source link

Support static cross-compilation from Unix to Windows. #121

Closed hugwijst closed 3 years ago

hugwijst commented 4 years ago

Use wine to run HDF5 configuration programs.

To run Windows unit tests on Linux, use wine as the runner. For example:

CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine64 cargo test --features hdf5-sys/static --target x86_64-pc-windows-gnu

If your main wine configuration is 32-bit but you're cross-compiling for 64-bit windows, you will need to specify a different wine environment using the WINEPREFIX environment variable, eg. WINEPREFIX=~/wine_win64.

magnusuMET commented 4 years ago

You might want to add another check to the CI to ensure we don't accidentally break this. Something like the following should do the trick:

  wine:
    name: wine
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with: {submodules: true}
      - name: Install Rust
        uses: actions-rs/toolchaing@v1
        with: {toolchain: stable, profile: minimal, override: true}
      - name: Install dependencies
        run: sudo apt-get install wine64 libhdf5-dev
      - name: Build and test
        run: env CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine64 cargo test --features hdf5-sys/static --target x86_64-pc-windows-gnu
jmrgibson commented 3 years ago

@magnusuMET anything else needed for this to go in? This would be handy for us too.

magnusuMET commented 3 years ago

Only @aldanor can merge and publish this

mulimoen commented 3 years ago

Did a rebase to run this through CI

aldanor commented 3 years ago

Not familiar with these windows-specific details, but I guess if it builds green and everyone's happy - should be good to go.

mulimoen commented 3 years ago

Merging this, thanks @hugwijst for making cross-compilation easier!