Skip to content

Commit

Permalink
Taskfile / build assets refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
leaanthony committed Dec 8, 2024
1 parent 3600f50 commit dcb7a7f
Show file tree
Hide file tree
Showing 24 changed files with 70 additions and 63 deletions.
17 changes: 9 additions & 8 deletions docs/src/content/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `app.OpenDirectory(dir string)` to open the system file explorer to the
directory `dir` by [@leaanthony](https://github.com/leaanthony)
- `app.OpenDirectory(dir string)` to open the system file explorer to the directory `dir` by [@leaanthony](https://github.com/leaanthony)

### Fixed

- [darwin] Ensure `windowDidBecomeKey` callback is running on main thread by
[@leaanthony](https://github.com/leaanthony)
- Ensure key callbacks in window run() are called on the main thread by
[@leaanthony](https://github.com/leaanthony)
- [darwin] Support fullscreen for frameless windows by
[@leaanthony](https://github.com/leaanthony)
- [darwin] Ensure `windowDidBecomeKey` callback is running on main thread by [@leaanthony](https://github.com/leaanthony)
- Ensure key callbacks in window run() are called on the main thread by [@leaanthony](https://github.com/leaanthony)
- [darwin] Support fullscreen for frameless windows by [@leaanthony](https://github.com/leaanthony)

### Changed

- Moved build assets to platform specific directories by [@leaanthony](https://github.com/leaanthony)
- Moved and renamed Taskfiles to platform specific directories by [@leaanthony](https://github.com/leaanthony)

## v3.0.0-alpha.8.3 - 2024-12-07

Expand Down
2 changes: 1 addition & 1 deletion v3/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cmd/wails3/wails
/examples/clipboard/clipboard
/examples/plain/plain
/cmd/wails3/ui/.task/
!/v3/internal/commands/build_assets/nsis/MicrosoftEdgeWebview2Setup.exe
!/v3/internal/commands/build_assets/windows/nsis/MicrosoftEdgeWebview2Setup.exe
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ tasks:
- "icons.icns"
- "icons.ico"
cmds:
- wails3 generate icons -input appicon.png
- wails3 generate icons -input appicon.png -macfilename darwin/icons.icns -windowsfilename windows/icons.ico

dev:frontend:
summary: Runs the frontend in development mode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'

includes:
common: Taskfile.common.yml
common: ../Taskfile.yml

tasks:
build:
Expand All @@ -11,9 +11,11 @@ tasks:
- task: common:build:frontend
- task: common:generate:icons
cmds:
- go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}
- go build {{.BUILD_FLAGS}} -o {{.OUTPUT}}
vars:
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -ldflags="-w -s"{{else}}-gcflags=all="-l"{{end}}'
DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}'
OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}'
env:
GOOS: darwin
CGO_ENABLED: 1
Expand All @@ -23,6 +25,21 @@ tasks:
MACOSX_DEPLOYMENT_TARGET: "10.15"
PRODUCTION: '{{.PRODUCTION | default "false"}}'

build:universal:
summary: Builds darwin universal binary (arm64 + amd64)
deps:
- task: build
vars:
ARCH: amd64
OUTPUT: "{{.BIN_DIR}}/{{.APP_NAME}}-amd64"
- task: build
vars:
ARCH: arm64
OUTPUT: "{{.BIN_DIR}}/{{.APP_NAME}}-arm64"
cmds:
- lipo -create -output "{{.BIN_DIR}}/{{.APP_NAME}}" "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64"
- rm "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" "{{.BIN_DIR}}/{{.APP_NAME}}-arm64"

package:
summary: Packages a production build of the application into a `.app` bundle
deps:
Expand All @@ -32,13 +49,21 @@ tasks:
cmds:
- task: create:app:bundle

package:universal:
summary: Packages darwin universal binary (arm64 + amd64)
deps:
- task: build:universal
cmds:
- task: create:app:bundle


create:app:bundle:
summary: Creates an `.app` bundle
cmds:
- mkdir -p {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/{MacOS,Resources}
- cp build/icons.icns {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources
- cp build/darwin/icons.icns {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/Resources
- cp {{.BIN_DIR}}/{{.APP_NAME}} {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents/MacOS
- cp build/Info.plist {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents
- cp build/darwin/Info.plist {{.BIN_DIR}}/{{.APP_NAME}}.app/Contents

run:
cmds:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'

includes:
common: Taskfile.common.yml
common: ../Taskfile.yml

tasks:
build:
Expand Down Expand Up @@ -34,22 +34,22 @@ tasks:

create:appimage:
summary: Creates an AppImage
dir: build/appimage
dir: build/linux/appimage
deps:
- task: build
vars:
PRODUCTION: "true"
- task: generate:dotdesktop
cmds:
- cp {{.APP_BINARY}} {{.APP_NAME}}
- cp ../appicon.png appicon.png
- wails3 generate appimage -binary {{.APP_NAME}} -icon {{.ICON}} -desktopfile {{.DESKTOP_FILE}} -outputdir {{.OUTPUT_DIR}} -builddir {{.ROOT_DIR}}/build/appimage
- cp ../../appicon.png appicon.png
- wails3 generate appimage -binary {{.APP_NAME}} -icon {{.ICON}} -desktopfile {{.DESKTOP_FILE}} -outputdir {{.OUTPUT_DIR}} -builddir {{.ROOT_DIR}}/build/linux/appimage/build
vars:
APP_NAME: '{{.APP_NAME}}'
APP_BINARY: '../../bin/{{.APP_NAME}}'
ICON: '../appicon.png'
DESKTOP_FILE: '{{.APP_NAME}}.desktop'
OUTPUT_DIR: '../../bin'
APP_BINARY: '../../../bin/{{.APP_NAME}}'
ICON: '../../appicon.png'
DESKTOP_FILE: '../{{.APP_NAME}}.desktop'
OUTPUT_DIR: '../../../bin'

create:deb:
summary: Creates a deb package
Expand Down Expand Up @@ -84,30 +84,30 @@ tasks:
generate:deb:
summary: Creates a deb package
cmds:
- wails3 tool package -name {{.APP_NAME}} -format deb -config ./build/nfpm/nfpm.yaml
- wails3 tool package -name {{.APP_NAME}} -format deb -config ./build/linux/nfpm/nfpm.yaml -out {{.ROOT_DIR}}/bin

generate:rpm:
summary: Creates a rpm package
cmds:
- wails3 tool package -name {{.APP_NAME}} -format rpm -config ./build/nfpm/nfpm.yaml
- wails3 tool package -name {{.APP_NAME}} -format rpm -config ./build/linux/nfpm/nfpm.yaml -out {{.ROOT_DIR}}/bin

generate:aur:
summary: Creates a arch linux packager package
cmds:
- wails3 tool package -name {{.APP_NAME}} -format arch -config ./build/nfpm/nfpm.yaml
- wails3 tool package -name {{.APP_NAME}} -format archlinux -config ./build/linux/nfpm/nfpm.yaml -out {{.ROOT_DIR}}/bin

generate:dotdesktop:
summary: Generates a `.desktop` file
dir: build
cmds:
- mkdir -p {{.ROOT_DIR}}/build/appimage
- wails3 generate .desktop -name "{{.APP_NAME}}" -exec "{{.EXEC}}" -icon "{{.ICON}}" -outputfile {{.ROOT_DIR}}/build/appimage/{{.APP_NAME}}.desktop -categories "{{.CATEGORIES}}"
- mkdir -p {{.ROOT_DIR}}/build/linux/appimage
- wails3 generate .desktop -name "{{.APP_NAME}}" -exec "{{.EXEC}}" -icon "{{.ICON}}" -outputfile {{.ROOT_DIR}}/build/linux/{{.APP_NAME}}.desktop -categories "{{.CATEGORIES}}"
vars:
APP_NAME: '{{.APP_NAME}}'
EXEC: '{{.APP_NAME}}'
ICON: 'appicon'
CATEGORIES: 'Development;'
OUTPUTFILE: '{{.ROOT_DIR}}/build/appimage/{{.APP_NAME}}.desktop'
OUTPUTFILE: '{{.ROOT_DIR}}/build/linux/{{.APP_NAME}}.desktop'

run:
cmds:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'

includes:
common: Taskfile.common.yml
common: ../Taskfile.yml

tasks:
build:
Expand All @@ -10,8 +10,8 @@ tasks:
- task: common:go:mod:tidy
- task: common:build:frontend
- task: common:generate:icons
- task: generate:syso
cmds:
- task: generate:syso
- go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}.exe
- cmd: powershell Remove-item *.syso
platforms: [windows]
Expand All @@ -34,13 +34,13 @@ tasks:
summary: Generates Windows `.syso` file
dir: build
cmds:
- wails3 generate syso -arch {{.ARCH}} -icon icon.ico -manifest wails.exe.manifest -info info.json -out ../wails_windows_{{.ARCH}}.syso
- wails3 generate syso -arch {{.ARCH}} -icon windows/icon.ico -manifest windows/wails.exe.manifest -info windows/info.json -out ../wails_windows_{{.ARCH}}.syso
vars:
ARCH: '{{.ARCH | default ARCH}}'

create:nsis:installer:
summary: Creates an NSIS installer
dir: build/nsis
dir: build/windows/nsis
deps:
- task: build
vars:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ManifestDPIAware true
#!finalize 'signtool --file "%1"'

Name "${INFO_PRODUCTNAME}"
OutFile "..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
OutFile "..\..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" # Default installing folder ($PROGRAMFILES is Program Files folder).
ShowInstDetails show # This will always show the installation details.

Expand Down
2 changes: 1 addition & 1 deletion v3/internal/commands/tool_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func ToolPackage(options *flags.ToolPackage) error {
// Arch linux packages are not .archlinux files, they are .pkg.tar.zst
options.Format = "pkg.tar.zst"
}
outputFile := filepath.Join(filepath.Dir(configPath), "bin", fmt.Sprintf("%s.%s", options.ExecutableName, options.Format))
outputFile := filepath.Join(options.Out, fmt.Sprintf("%s.%s", options.ExecutableName, options.Format))

// Create the package
err = packager.CreatePackageFromConfig(pkgType, configPath, outputFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contents:
dst: "/usr/local/bin/{{.BinaryName}}"
- src: "./build/appicon.png"
dst: "/usr/share/icons/hicolor/128x128/apps/{{.BinaryName}}.png"
- src: "./build/{{.BinaryName}}.desktop"
- src: "./build/linux/{{.BinaryName}}.desktop"
dst: "/usr/share/applications/{{.BinaryName}}.desktop"

depends:
Expand All @@ -44,7 +44,7 @@ depends:
# - not-bar
# changelog: "changelog.yaml"
# scripts:
# preinstall: ./build/nfpm/scripts/preinstall.sh
# postinstall: ./build/nfpm/scripts/postinstall.sh
# preremove: ./build/nfpm/scripts/preremove.sh
# postremove: ./build/nfpm/scripts/postremove.sh
# preinstall: ./build/linux/nfpm/scripts/preinstall.sh
# postinstall: ./build/linux/nfpm/scripts/postinstall.sh
# preremove: ./build/linux/nfpm/scripts/preremove.sh
# postremove: ./build/linux/nfpm/scripts/postremove.sh
1 change: 1 addition & 0 deletions v3/internal/flags/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ type ToolPackage struct {
Format string `name:"format" description:"Package format to generate (deb, rpm, archlinux)" default:"deb"`
ExecutableName string `name:"name" description:"Name of the executable to package" default:"myapp"`
ConfigPath string `name:"config" description:"Path to the package configuration file" default:""`
Out string `name:"out" description:"Path to the output dir" default:"."`
}
28 changes: 4 additions & 24 deletions v3/internal/templates/_common/Taskfile.tmpl.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: '3'

includes:
common: ./build/Taskfile.common.yml
windows: ./build/Taskfile.windows.yml
darwin: ./build/Taskfile.darwin.yml
linux: ./build/Taskfile.linux.yml
common: ./build/Taskfile.yml
windows: ./build/windows/Taskfile.yml
darwin: ./build/darwin/Taskfile.yml
linux: ./build/linux/Taskfile.yml

vars:
APP_NAME: "{{.ProjectName}}"
Expand Down Expand Up @@ -32,23 +32,3 @@ tasks:
cmds:
- wails3 dev -config ./build/config.yml -port {{ "{{.VITE_PORT}}" }}

darwin:build:universal:
summary: Builds darwin universal binary (arm64 + amd64)
cmds:
- task: darwin:build
vars:
ARCH: amd64
- mv {{ "{{.BIN_DIR}}/{{.APP_NAME}}" }} {{ "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" }}
- task: darwin:build
vars:
ARCH: arm64
- mv {{ "{{.BIN_DIR}}/{{.APP_NAME}}" }} {{ "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" }}
- lipo -create -output {{ "{{.BIN_DIR}}/{{.APP_NAME}}" }} {{ "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" }} {{ "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" }}
- rm {{ "{{.BIN_DIR}}/{{.APP_NAME}}-amd64" }} {{ "{{.BIN_DIR}}/{{.APP_NAME}}-arm64" }}

darwin:package:universal:
summary: Packages darwin universal binary (arm64 + amd64)
deps:
- darwin:build:universal
cmds:
- task: darwin:create:app:bundle

0 comments on commit dcb7a7f

Please sign in to comment.