From 29aa0a6feafd9c71a988686b75d8d45b94643302 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Tue, 5 Dec 2023 16:58:56 +0200 Subject: [PATCH] Fix Windows installer and other tweaks --- .cargo/config.toml | 9 ++++++ .github/workflows/release.yml | 42 ++++++++++++++++++------ README.md | 4 +-- src/main.rs | 1 + wix/space-acres.wxs | 60 +++++++++++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 11 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..0aaf0bbf --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,9 @@ +[target.'cfg(target_arch = "x86_64")'] +# Require AES-NI on x86-64 by default +rustflags = ["-C", "target-feature=+aes"] + +[target.'cfg(target_arch = "aarch64")'] +# TODO: Try to remove once https://github.com/paritytech/substrate/issues/11538 is resolved +# TODO: AES flag is such that we have decent performance on ARMv8, remove once `aes` crate bumps MSRV to at least +# 1.61: https://github.com/RustCrypto/block-ciphers/issues/373 +rustflags = ["--cfg", "aes_armv8"] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 13d6d28f..e11d6984 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ env: CARGO_INCREMENTAL: 0 jobs: - executables: + release: strategy: matrix: build: @@ -105,14 +105,38 @@ jobs: # TODO: Package Linux and macOS + - name: Install cargo-wix (Windows) + uses: taiki-e/cache-cargo-install-action@1b76958d032c4d048c599f9fdfa48abe804d6319 # v1.2.2 + with: + tool: cargo-wix + if: runner.os == 'Windows' + - name: Package (Windows) run: | - Remove-Item -Recurse -Force target/gtk4 - New-Item target/gtk4 -ItemType Directory - Copy-Item -Path C:\gtk-build\gtk\x64\release\bin\*.dll -Destination target\gtk4 - heat dir target\gtk4 -gg -sfrag -template:fragment -out target\gtk4\gtk4.wxs -cg GTK -dr GTK - # TODO - cargo wix --include target\gtk4\gtk4.wxs --profile production + Remove-Item target\wix\gtk4 -Recurse -Confirm:$false -ErrorAction SilentlyContinue + + New-Item target\wix\gtk4\bin -ItemType Directory + New-Item target\wix\gtk4\share\glib-2.0\schemas -ItemType Directory + + Copy-Item -Path C:\gtk-build\gtk\x64\release\bin\*.dll -Destination target\wix\gtk4\bin + Copy-Item -Path C:\gtk-build\gtk\x64\release\bin\gdbus.exe -Destination target\wix\gtk4\bin + + Copy-Item -Path C:\gtk-build\gtk\x64\release\share\glib-2.0\schemas\gschemas.compiled -Destination target\wix\gtk4\share\glib-2.0\schemas\gschemas.compiled + Copy-Item -Path C:\gtk-build\gtk\x64\release\share\glib-2.0\schemas\org.gtk.gtk4.Settings.Debug.gschema.xml -Destination target\wix\gtk4\share\glib-2.0\schemas\org.gtk.gtk4.Settings.Debug.gschema.xml + Copy-Item -Path C:\gtk-build\gtk\x64\release\share\glib-2.0\schemas\org.gtk.gtk4.Settings.FileChooser.gschema.xml -Destination target\wix\gtk4\share\glib-2.0\schemas\org.gtk.gtk4.Settings.FileChooser.gschema.xml + + # TODO: Ideally something like this would have worked and we wouldn't need to hardcode stuff in `space-acres.wxs`: https://github.com/volks73/cargo-wix/issues/271 + # & "C:\Program Files (x86)\WiX Toolset v3.11\bin\heat.exe" dir target\wix\gtk4 -gg -sfrag -template:fragment -out target\wix\gtk4.wxs -cg GTK -dr GTK + + # TODO: This is a workaround for missing `--target` support: https://github.com/volks73/cargo-wix/issues/272 + New-Item target\production -ItemType Directory -Force + Copy-Item -Path ${{ env.PRODUCTION_TARGET }}\space-acres.exe -Destination target\production\space-acres.exe + + cargo wix --profile production --no-build --nocapture + + Remove-Item target\production -Recurse -Confirm:$false + + Remove-Item target\wix\gtk4 -Recurse -Confirm:$false -ErrorAction SilentlyContinue if: runner.os == 'Windows' - name: Upload node and farmer executables to artifacts (Windows) @@ -120,7 +144,7 @@ jobs: with: name: installer-${{ matrix.build.suffix }} path: | - target/wix/*.exe + target/wix/*.msi if-no-files-found: error if: runner.os == 'Windows' @@ -129,5 +153,5 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} with: - asset_paths: '["target/wix/*.exe"]' + asset_paths: '["target/wix/*.msi"]' if: runner.os == 'Windows' && github.event_name == 'push' && github.ref_type == 'tag' diff --git a/README.md b/README.md index 5a13b8c2..e0384aa9 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ Current features: * Farmer plotting/farming with a single farm with displayed plotting/replotting progress Some of the upcoming features/capabilities (not necessarily in priority order): -* Automatic builds in CI with pre-built executables -* Testing on Windows and macOS +* Automatic builds in CI with pre-built executables/installers (Linux and macOS) +* Testing on macOS * Welcome screen * Writing logs to a file * Displaying of earned farming rewards or at least link to block explorers diff --git a/src/main.rs b/src/main.rs index ea1fd700..2a72996e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +#![windows_subsystem = "windows"] #![feature(const_option, trait_alias, try_blocks)] mod backend; diff --git a/wix/space-acres.wxs b/wix/space-acres.wxs index bb0474b2..41ea6a41 100644 --- a/wix/space-acres.wxs +++ b/wix/space-acres.wxs @@ -128,6 +128,64 @@ Source='$(var.CargoTargetBinDir)\space-acres.exe' KeyPath='yes'/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -181,6 +239,8 @@ + +