diff --git a/v3/examples/build/README.md b/v3/examples/build/README.md index adbf19d53..01b4422ac 100644 --- a/v3/examples/build/README.md +++ b/v3/examples/build/README.md @@ -3,7 +3,7 @@ Wails has adopted [Taskfile](https://taskfile.dev) as its build tool. This is optional and any build tool can be used. However, Taskfile is a great tool, and we recommend it. -The Wails CLI has built-in integration with Taskfile so the standalone version is not a +The Wails CLI has built-in integration with Taskfile so the standalone version is not a requirement. ## Building @@ -13,3 +13,11 @@ To build the example, run: ```bash wails task build ``` + +# Status + +| Platform | Status | +|----------|---------| +| Mac | | +| Windows | Working | +| Linux | | \ No newline at end of file diff --git a/v3/examples/build/Taskfile.yml b/v3/examples/build/Taskfile.yml index 464464458..11418e5aa 100644 --- a/v3/examples/build/Taskfile.yml +++ b/v3/examples/build/Taskfile.yml @@ -1,141 +1,46 @@ version: '3' vars: - APP_NAME: "dev{{exeExt}}" - + APP_NAME: "buildtest{{exeExt}}" tasks: - pre-build: - summary: Pre-build hooks - - post-build: - summary: Post-build hooks - - install-frontend-deps: - summary: Install frontend dependencies - dir: frontend - sources: - - package.json - - package-lock.json - generates: - - node_modules/* - preconditions: - - sh: npm version - msg: "Looks like npm isn't installed. Npm is part of the Node installer: https://nodejs.org/en/download/" - cmds: - - npm install - - build-frontend: - summary: Build the frontend project - dir: frontend - generates: - - frontend/dist/* - deps: - - install-frontend-deps - cmds: - - npm run build - - build:darwin: - summary: Builds the application - platforms: - - darwin - cmds: - - task: pre-build - - task: build-frontend - - go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}} - - task: post-build - env: - CGO_CFLAGS: "-mmacosx-version-min=10.13" - CGO_LDFLAGS: "-mmacosx-version-min=10.13" - MACOSX_DEPLOYMENT_TARGET: "10.13" - - build:backend:darwin: - summary: Builds the application - platforms: - - darwin - cmds: - - task: pre-build - - go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}} - - task: post-build - 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 - cmds: - - task: pre-build - - task: build-frontend - - go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}} - - task: post-build - - - build:backend:windows: - summary: Builds the backend application for Windows - platforms: - - windows - cmds: - - task: pre-build - - go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}} - - task: post-build - build: summary: Builds the application cmds: - - task: build:darwin - - task: build:windows - - build:backend: - summary: Builds the backend application - cmds: - - task: build:backend:darwin - - task: build:backend:windows - - 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 - - build-app-prod-darwin: - summary: Creates a production build of the application - cmds: - - task: pre-build - - task: build-frontend - - GOOS=darwin GOARCH={{.ARCH}} go build -tags production -ldflags="-w -s" -o build/bin/{{.APP_NAME}} - - 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" - vars: - ARCH: $GOARCH - frontend:dev: - summary: Runs the frontend in development mode - dir: frontend + package: + summary: Packages a production build of the application into a `.app` or `.exe` bundle + deps: + - task: build cmds: - - npm run dev + - task: package:darwin + - task: package:windows - run: - summary: Runs the application +# ------------------------------------------------------------------------------ + + generate:icons: + summary: Generates Windows `.ico` and Mac `.icns` files from an image + dir: build cmds: - - ./bin/{{.APP_NAME}} + # Generates both .ico and .icns files + - wails3 generate icons -input appicon.png - dev: - summary: Runs the application in development mode - preconditions: - - sh: 'wails3 tool checkport -p 5173' - msg: "Vite does not appear to be running." + build:production:darwin: + summary: Creates a production build of the application cmds: - - task: build:backend - - task: run + - 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}}' - create-app-bundle: + generate:app_bundle: summary: Builds a `.app` bundle cmds: - mkdir -p {{.APP_NAME}}.app/Contents/{MacOS,Resources} @@ -143,33 +48,60 @@ tasks: - cp build/bin/{{.APP_NAME}} {{.APP_NAME}}.app/Contents/MacOS - cp build/Info.plist {{.APP_NAME}}.app/Contents - package-darwin-arm64: + package:darwin:arm64: summary: Packages a production build of the application into a `.app` bundle - platform: darwin + platforms: + - darwin deps: - - task: build-app-prod-darwin + - task: build:production:darwin vars: ARCH: arm64 - - generate-icons + - generate:icons cmds: - - task: create-app-bundle + - task: generate:app_bundle + + package:darwin: + summary: Packages a production build of the application into a `.app` bundle + platforms: + - darwin + deps: + - task: build:production:darwin + - generate:icons + cmds: + - task: generate:app_bundle generate:syso: dir: build - platform: windows + platforms: + - windows cmds: - - wails generate syso -arch {{.ARCH}} -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: - ARCH: $GOARCH + GOARCH: '{{.GOARCH}}' package:windows: summary: Packages a production build of the application into a `.exe` bundle - platform: windows + platforms: + - windows/amd64 deps: - - generate-icons + - generate:icons cmds: - task: generate:syso vars: - ARCH: amd64 - - go build -tags production -ldflags="-w -s -H windowsgui" -o bin/{{.APP_NAME}}.exe + GOARCH: amd64 + - go build -tags production -ldflags="-w -s -H windowsgui" -o bin/{{.APP_NAME}} - powershell Remove-item wails.syso + + + package:windows:arm64: + summary: Packages a production build of the application into a `.exe` bundle (ARM64) + platforms: + - windows + cmds: + - 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/build/main.go b/v3/examples/build/main.go index 98c7ed0a7..eb46479c1 100755 --- a/v3/examples/build/main.go +++ b/v3/examples/build/main.go @@ -16,7 +16,14 @@ import ( func main() { - app := application.New(Options) + app := application.New(application.Options{ + Name: "WebviewWindow Demo (debug)", + Description: "A demo of the WebviewWindow API", + Assets: application.AlphaAssets, + Mac: application.MacOptions{ + ApplicationShouldTerminateAfterLastWindowClosed: true, + }, + }) app.On(events.Mac.ApplicationDidFinishLaunching, func(*application.Event) { log.Println("ApplicationDidFinishLaunching") @@ -54,12 +61,14 @@ func main() { myMenu.Add("New Frameless WebviewWindow"). SetAccelerator("CmdOrCtrl+F"). OnClick(func(ctx *application.Context) { - app.NewWebviewWindow(). - SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)). - SetRelativePosition(rand.Intn(1000), rand.Intn(800)). - SetURL("https://wails.io"). - SetFrameless(true). - Show() + app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ + X: rand.Intn(1000), + Y: rand.Intn(800), + Frameless: true, + Mac: application.MacWindow{ + InvisibleTitleBarHeight: 50, + }, + }).Show() windowCounter++ }) if runtime.GOOS == "darwin" { diff --git a/v3/examples/build/options_debug.go b/v3/examples/build/options_debug.go deleted file mode 100644 index 37f1f2f0e..000000000 --- a/v3/examples/build/options_debug.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build !production - -package main - -import "github.com/wailsapp/wails/v3/pkg/application" - -var Options = application.Options{ - Name: "WebviewWindow Demo (debug)", - Description: "A demo of the WebviewWindow API", - Mac: application.MacOptions{ - ApplicationShouldTerminateAfterLastWindowClosed: true, - }, -} diff --git a/v3/examples/build/options_production.go b/v3/examples/build/options_production.go deleted file mode 100644 index 65eeba40c..000000000 --- a/v3/examples/build/options_production.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build production - -package main - -import "github.com/wailsapp/wails/v3/pkg/application" - -var Options = application.Options{ - Name: "WebviewWindow Demo", - Description: "A demo of the WebviewWindow API", - Mac: application.MacOptions{ - ApplicationShouldTerminateAfterLastWindowClosed: true, - }, -}