Skip to content

Commit

Permalink
feat(windows): Add Windows build script
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Feb 25, 2024
1 parent d16dbf2 commit 6a9807b
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 9 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ jobs:
sudo apt-get install --no-install-recommends $LINUX_DEPENDENCIES
- platform: darwin
runs-on: macos-12
build: ./hack/build-app.sh
- platform: windows-amd64
build: ./hack/build-macos.sh
- platform: windows
runs-on: windows-latest
extension: .exe
build: ./hack/build-windows.sh
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
- name: Build (Default)
if: ${{ !matrix.build }}
run: |
go build -ldflags='-w -s' -trimpath -o dist/gones${{ matrix.extension }}
go build -ldflags='-w -s' -trimpath -o dist/gones
env:
CGO_ENABLED: "1"
- name: Compress
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
-v "$(go env GOMODCACHE):/go/pkg/mod" \
-v "$PWD:/app" \
builder \
go build -ldflags='-w -s' -trimpath -o dist/gones${{ matrix.extension }}
go build -ldflags='-w -s' -trimpath -o dist/gones
- name: Compress
run: tar -cvf gones.tar -C dist .
- name: Upload Artifact
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/gones
gones.wasm
wasm_exec.js
*.syso
1 change: 1 addition & 0 deletions assets/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.icns
GoNES.iconset/
winres/*.png
Binary file added assets/png/icon_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions assets/winres/winres.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"RT_GROUP_ICON": {
"APP": {
"0000": [
"icon16.png",
"icon32.png",
"icon48.png",
"icon64.png",
"icon128.png",
"icon256.png"
]
}
},
"RT_MANIFEST": {
"#1": {
"0409": {
"identity": {
"name": "GoNES",
"version": ""
},
"description": "NES emulator written in Go",
"minimum-os": "win7",
"execution-level": "as invoker",
"ui-access": false,
"auto-elevate": false,
"dpi-awareness": "system",
"disable-theming": false,
"disable-window-filtering": false,
"high-resolution-scrolling-aware": false,
"ultra-high-resolution-scrolling-aware": false,
"long-path-aware": false,
"printer-driver-isolation": false,
"gdi-scaling": false,
"segment-heap": false,
"use-common-controls-v6": false
}
}
},
"RT_VERSION": {
"#1": {
"0000": {
"fixed": {
"file_version": "0.0.0.0",
"product_version": "0.0.0.0"
},
"info": {
"0409": {
"Comments": "",
"CompanyName": "gabe565",
"FileDescription": "NES emulator written in Go",
"FileVersion": "",
"InternalName": "",
"LegalCopyright": "",
"LegalTrademarks": "",
"OriginalFilename": "",
"PrivateBuild": "",
"ProductName": "GoNES",
"ProductVersion": "",
"SpecialBuild": ""
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion hack/build-app.sh → hack/build-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -euo pipefail

cd "$(git rev-parse --show-toplevel)"

rm -rf dist assets/GoNES.iconset
rm -rf dist/*.app assets/GoNES.iconset
mkdir -p dist

# Generate icns
Expand Down
28 changes: 28 additions & 0 deletions hack/build-windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

BINARY_NAME='GoNES'

set -euo pipefail

cd "$(git rev-parse --show-toplevel)"

rm -rf -- dist/*.exe assets/winres/*.png *.syso
mkdir -p dist

command -v go-winres &>/dev/null || go install github.com/tc-hib/go-winres@latest

# Generate metadata
cp -a assets/{png/icon_16x16,winres/icon16}.png
cp -a assets/{png/icon_32x32,winres/icon32}.png
cp -a assets/{png/icon_48x48,winres/icon48}.png
cp -a assets/{png/icon_64x64,winres/icon64}.png
cp -a assets/{png/icon_128x128,winres/icon128}.png
cp -a assets/{png/icon_256x256,winres/icon256}.png
go-winres make --arch=amd64,arm64 --in=assets/winres/winres.json

# Build binary
export GOOS=windows CGO_ENABLED=1
for ARCH in amd64 arm64; do
echo Build "$BINARY_NAME-$ARCH.exe"
GOARCH="$ARCH" go build -ldflags='-w -s' -trimpath -o "dist/$BINARY_NAME-$ARCH.exe" "$(git rev-parse --show-toplevel)"
done
2 changes: 1 addition & 1 deletion hack/rasterize-icons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cd "$(git rev-parse --show-toplevel)/assets"
rm -rf png
mkdir -p png

for SIZE in 16 32 64 128 256 512; do (
for SIZE in 16 32 48 64 128 256 512; do (
DEST="png/icon_${SIZE}x${SIZE}.png"
basename "$DEST"

Expand Down
4 changes: 2 additions & 2 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ includes:
tasks:
build:
cmds:
- cmd: sh ./hack/build-app.sh
- cmd: ./hack/build-macos.sh
platforms: [darwin]
- cmd: go build -ldflags='-w -s' -trimpath -o dist/gones
platforms: [linux]
- cmd: go build -ldflags='-w -s' -trimpath -o dist/gones.exe
- cmd: ./hack/build-windows.sh
platforms: [windows]

0 comments on commit 6a9807b

Please sign in to comment.