From 8d5b86fff7ce2fcc1e316e44895ccca44ea95d7e Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 9 Oct 2023 17:38:03 +1100 Subject: [PATCH] Update dialogs example --- v3/examples/dialogs/README.md | 19 +++++- v3/examples/dialogs/Taskfile.yml | 109 ++++++++++++++++++------------- v3/examples/dialogs/main.go | 3 + 3 files changed, 84 insertions(+), 47 deletions(-) diff --git a/v3/examples/dialogs/README.md b/v3/examples/dialogs/README.md index 8dd15527f..051aa70a6 100644 --- a/v3/examples/dialogs/README.md +++ b/v3/examples/dialogs/README.md @@ -15,11 +15,24 @@ go run main.go To build the example in debug mode, simply run the following command: ```bash -wails task build +wails3 task build ``` To build the example to use application icons, simply run the following command: ```bash -wails task build:production -``` \ No newline at end of file +wails3 task package +``` + + +# Status + +| Platform | Status | +|----------|-------------------| +| Mac | | +| Windows | Partially Working | +| Linux | | + +## TODO + +- [ ] Windows: Show application icon in about dialog \ No newline at end of file diff --git a/v3/examples/dialogs/Taskfile.yml b/v3/examples/dialogs/Taskfile.yml index 4d8555bc5..476646cdc 100644 --- a/v3/examples/dialogs/Taskfile.yml +++ b/v3/examples/dialogs/Taskfile.yml @@ -1,84 +1,105 @@ version: '3' +vars: + APP_NAME: "buildtest{{exeExt}}" tasks: - pre-build: - summary: Pre-build hooks - - post-build: - summary: Post-build hooks - - build:darwin: + build: summary: Builds the application - platforms: - - darwin cmds: - - task: pre-build - - go build -gcflags=all="-N -l" -o bin/testapp - - task: post-build + - go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}} env: CGO_CFLAGS: "-mmacosx-version-min=10.13" CGO_LDFLAGS: "-mmacosx-version-min=10.13" MACOSX_DEPLOYMENT_TARGET: "10.13" - build:windows: - summary: Builds the application for Windows - platforms: - - windows + package: + summary: Packages a production build of the application into a `.app` or `.exe` bundle cmds: - - task: pre-build - - go build -gcflags=all="-N -l" -o bin/testapp.exe - - task: post-build + - task: package:darwin + - task: package:windows - build: - summary: Builds the application - cmds: - - task: build:darwin - - task: build:windows +# ------------------------------------------------------------------------------ - generate-icons: + generate:icons: summary: Generates Windows `.ico` and Mac `.icns` files from an image dir: build cmds: # Generates both .ico and .icns files - - wails generate icons -input appicon.png + - wails3 generate icons -input appicon.png - build-prod: + build:production:darwin: summary: Creates a production build of the application cmds: - - go build -tags production -ldflags="-w -s" -o bin/testapp{{exeExt}} + - GOOS=darwin GOARCH={{.GOARCH}} go build -tags production -ldflags="-w -s" -o build/bin/{{.APP_NAME}} + env: + CGO_CFLAGS: "-mmacosx-version-min=10.13" + CGO_LDFLAGS: "-mmacosx-version-min=10.13" + MACOSX_DEPLOYMENT_TARGET: "10.13" + GOARCH: '{{.GOARCH}}' + + generate:app_bundle: + summary: Builds a `.app` bundle + cmds: + - mkdir -p {{.APP_NAME}}.app/Contents/{MacOS,Resources} + - cp build/icons.icns {{.APP_NAME}}.app/Contents/Resources + - cp build/bin/{{.APP_NAME}} {{.APP_NAME}}.app/Contents/MacOS + - cp build/Info.plist {{.APP_NAME}}.app/Contents + + package:darwin:arm64: + summary: Packages a production build of the application into a `.app` bundle + platforms: + - darwin + deps: + - task: build:production:darwin + vars: + ARCH: arm64 + - generate:icons + cmds: + - task: generate:app_bundle package:darwin: summary: Packages a production build of the application into a `.app` bundle platforms: - darwin deps: - - build-prod - - generate-icons + - task: build:production:darwin + - generate:icons cmds: - - mkdir -p buildtest.app/Contents/{MacOS,Resources} - - cp build/icons.icns buildtest.app/Contents/Resources - - cp bin/testapp buildtest.app/Contents/MacOS - - cp build/Info.plist buildtest.app/Contents + - task: generate:app_bundle - windows:generate:syso: + generate:syso: dir: build + platforms: + - windows cmds: - - wails generate syso -arch amd64 -icon icon.ico -manifest wails.exe.manifest -info info.json -out ../wails.syso + - wails3 generate syso -arch {{.GOARCH}} -icon icon.ico -manifest wails.exe.manifest -info info.json -out ../wails.syso + vars: + GOARCH: '{{.GOARCH}}' package:windows: summary: Packages a production build of the application into a `.exe` bundle platforms: - - windows + - windows/amd64 deps: - - generate-icons + - generate:icons cmds: - - task: windows:generate:syso - - go build -tags production -ldflags="-w -s -H windowsgui" -o bin/testapp.exe + - task: generate:syso + vars: + GOARCH: amd64 + - go build -tags production -gcflags=all="-N -l" -o bin/{{.APP_NAME}} - powershell Remove-item wails.syso - build:production: - summary: Builds the application for production + + package:windows:arm64: + summary: Packages a production build of the application into a `.exe` bundle (ARM64) + platforms: + - windows cmds: - - task: package:darwin - - task: package:windows \ No newline at end of file + - task: generate:syso + vars: + GOARCH: arm64 + - go build -tags production -ldflags="-w -s -H windowsgui" -o bin/buildtest.arm64.exe + - powershell Remove-item wails.syso + env: + GOARCH: arm64 diff --git a/v3/examples/dialogs/main.go b/v3/examples/dialogs/main.go index 9e285aa3a..b06ba3a6c 100644 --- a/v3/examples/dialogs/main.go +++ b/v3/examples/dialogs/main.go @@ -3,6 +3,7 @@ package main import ( _ "embed" "log" + "log/slog" "os" "runtime" "strings" @@ -17,6 +18,8 @@ func main() { app := application.New(application.Options{ Name: "Dialogs Demo", Description: "A demo of the dialogs API", + Assets: application.AlphaAssets, + Logger: application.DefaultLogger(slog.LevelDebug), Mac: application.MacOptions{ ApplicationShouldTerminateAfterLastWindowClosed: true, },