nabijaczleweli / rust-embed-resource

A Cargo build script library to handle compilation and inclusion of Windows resources, in the most resilient fashion imaginable
MIT License
173 stars 29 forks source link

Add GitHub Actions which target MSVC on Windows for ARM64 + x86 + x86_64 #60

Closed micolous closed 1 year ago

micolous commented 1 year ago

example/version is a little more realistic than the existing test, and ensures the resources were correctly embedded in the output binary.

This also checks we can build ARM64 binaries, but as GitHub Actions runners are all x86_64, it will skip running the binary if targetting non-Intel CPUs.

This should address #26.

Unfortunately, GitHub Actions only supports self-hosted ARM64 Windows runners, not GitHub-hosted runners.

Example run: https://github.com/micolous/rust-embed-resource/actions/runs/5397010357

micolous commented 1 year ago

Example run with a Windows 11 ARM64 host:

> cargo run --target aarch64-pc-windows-msvc --release --manifest-path .\example\version\Cargo.toml
   Compiling serde v1.0.164
   Compiling cc v1.0.79
   Compiling libc v0.2.146
   Compiling winapi v0.3.9
   Compiling equivalent v1.0.0
   Compiling hashbrown v0.14.0
   Compiling semver v1.0.17
   Compiling winnow v0.4.7
   Compiling cfg-if v1.0.0
   Compiling indexmap v2.0.0
   Compiling rustc_version v0.4.0
   Compiling vswhom-sys v0.1.2
   Compiling vswhom v0.1.0
   Compiling winreg v0.11.0
   Compiling serde_spanned v0.6.3
   Compiling toml_datetime v0.6.3
   Compiling toml_edit v0.19.11
   Compiling toml v0.7.5
   Compiling embed-resource v2.1.1 (~\rust-embed-resource)
   Compiling embed-resource-example-version v0.1.0 (~\rust-embed-resource\example\version)
    Finished release [optimized] target(s) in 9.43s
     Running `example\version\target\aarch64-pc-windows-msvc\release\embed-resource-example-version.exe`
Hello, world!

> python .\example\version\test.py example\version\target\aarch64-pc-windows-msvc\release\embed-resource-example-version.exe
version strings: {b'CompanyName': b'nabijaczleweli', b'ProductName': b'rust-embed-resource/example/version', b'ProductVersion': b'2.1.1'}

Cross-compiling to x86_64 also works with emulation support:

> cargo run --target x86_64-pc-windows-msvc --release --manifest-path .\example\version\Cargo.toml
   Compiling embed-resource-example-version v0.1.0 (~\rust-embed-resource\example\version)
    Finished release [optimized] target(s) in 1.40s
     Running `example\version\target\x86_64-pc-windows-msvc\release\embed-resource-example-version.exe`
Hello, world!

> python .\example\version\test.py example\version\target\x86_64-pc-windows-msvc\release\embed-resource-example-version.exe
version strings: {b'CompanyName': b'nabijaczleweli', b'ProductName': b'rust-embed-resource/example/version', b'ProductVersion': b'2.1.1'}
nabijaczleweli commented 1 year ago

Editorialised as e83a9bf7f257623a057e2f8bcf59be77abf93cff, cheers.

nabijaczleweli commented 1 year ago

Released as v2.2.0.