feat(v3): add -tags flag to wails3 build command#4968
Conversation
WalkthroughThis PR adds support for custom Go build tags via a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
.github/workflows/build-and-test-v3.yml (1)
295-296:⚠️ Potential issue | 🟡 MinorStale comment:
wails buildnow supports-tagsflag.This PR adds
-tagssupport towails3 build, making this comment outdated. Consider updating the comment and optionally adding a GTK4 template build step that useswails3 build -tags gtk4.v3/internal/commands/build_assets/darwin/Taskfile.yml (1)
55-69:⚠️ Potential issue | 🟡 Minor
build:dockerdoes not receive or useEXTRA_TAGS.The Docker cross-compilation path doesn't forward
EXTRA_TAGSto the container's build command (line 69). If someone cross-compiles for macOS from Linux with-tags gtk4(or any custom tag), the tags will be silently dropped.Consider passing
EXTRA_TAGSinto the Docker command (e.g., via-e EXTRA_TAGS="{{.EXTRA_TAGS}}") and consuming it inside the container's build script, or at minimum document that custom tags are only supported for native builds.
🤖 Fix all issues with AI agents
In `@v3/internal/commands/build_assets/linux/Taskfile.yml`:
- Line 29: The build Docker tasks don’t forward EXTRA_TAGS and build.sh doesn’t
apply them; update all build:docker docker run invocations (Taskfile.yml entries
for Linux/Darwin/Windows) to include -e EXTRA_TAGS="{{.EXTRA_TAGS}}" (or pass as
an argument) so the container receives the value, and modify the
Dockerfile.cross entrypoint script build.sh to read EXTRA_TAGS (e.g., from env
or arg) and, when non-empty, append -tags "$EXTRA_TAGS" to the go build command
(ensuring it omits the flag when empty); target the docker run invocations named
build:docker and the build.sh script referenced by Dockerfile.cross.
🧹 Nitpick comments (1)
v3/internal/commands/task_wrapper_test.go (1)
202-344: Consider extracting common test setup into a helper.Every
TestBuild*function repeats ~30 lines of identical boilerplate (save/restore env, mockrunTaskFunc, save/restoreos.Args). A small helper likewithMockedBuildEnv(t, func(captured...))would reduce duplication and make future tests easier to add. That said, this matches the existing test style in the file, so it's entirely optional.
There was a problem hiding this comment.
Pull request overview
Adds support for passing custom Go build tags through wails3 build via a new -tags flag, wiring the value into Taskfile-driven builds so projects can opt into features like GTK4 without editing generated Taskfiles.
Changes:
- Added
-tagsflag to thewails3 buildcommand flags and forwarded it asEXTRA_TAGSinto the task wrapper. - Updated platform build-assets Taskfiles (darwin/linux/windows) to incorporate
EXTRA_TAGSintogo buildflags (dev vs production behavior). - Added new unit tests for build tag forwarding and adjusted CI workflow dependency lists / cache versions.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| v3/internal/flags/task_wrapper.go | Adds Tags field to build flags to expose -tags CLI option. |
| v3/internal/commands/task_wrapper.go | Appends EXTRA_TAGS=... to Task CLI vars when -tags is provided. |
| v3/internal/commands/task_wrapper_test.go | Adds test cases validating EXTRA_TAGS forwarding behavior. |
| v3/internal/commands/build_assets/darwin/Taskfile.yml | Incorporates EXTRA_TAGS into BUILD_FLAGS used by native go build. |
| v3/internal/commands/build_assets/linux/Taskfile.yml | Incorporates EXTRA_TAGS into BUILD_FLAGS used by native go build. |
| v3/internal/commands/build_assets/windows/Taskfile.yml | Incorporates EXTRA_TAGS into BUILD_FLAGS used by native go build. |
| .github/workflows/cross-compile-test-v3.yml | Updates cached apt packages list/version used in CI. |
| .github/workflows/build-and-test.yml | Updates cached apt packages list/version and apt install list used in CI. |
| .github/workflows/build-and-test-v3.yml | Updates cached apt packages list/version used in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ARCH: '{{.ARCH}}' | ||
| DEV: '{{.DEV}}' | ||
| OUTPUT: '{{.OUTPUT}}' | ||
| EXTRA_TAGS: '{{.EXTRA_TAGS}}' |
There was a problem hiding this comment.
EXTRA_TAGS is being passed through to this Taskfile, but the build:docker path still runs the wails-cross container without any way to apply those tags. As a result, wails3 build -tags ... won’t work when the build falls back to Docker (cross-compiling, missing compiler, etc.). Forward the tag list into the container (e.g., env/arg) and update the cross-compile image entrypoint to include the tags in its go build invocation (and, if applicable, match the native DEV/production tag behavior).
| ARCH: '{{.ARCH}}' | ||
| DEV: '{{.DEV}}' | ||
| OUTPUT: '{{.OUTPUT}}' | ||
| EXTRA_TAGS: '{{.EXTRA_TAGS}}' |
There was a problem hiding this comment.
EXTRA_TAGS is now threaded through the build task, but build:docker does not pass it into the wails-cross container and the image build script does not add -tags to go build. This makes wails3 build -tags ... ineffective for non-macOS hosts cross-compiling via Docker. Propagate the tags into the container and have the container build script apply them consistently.
| vars: | ||
| ARCH: '{{.ARCH}}' | ||
| DEV: '{{.DEV}}' | ||
| EXTRA_TAGS: '{{.EXTRA_TAGS}}' |
There was a problem hiding this comment.
The new EXTRA_TAGS variable is passed to the build task, but the Docker cross-compile path (build:docker) doesn’t forward it to the container (and the cross image’s build script doesn’t use it). That means wails3 build -tags ... won’t work for CGO builds that use Docker on non-Windows hosts. Consider passing the tags into docker run and updating the cross image entrypoint to include them in go build.
| EXTRA_TAGS: '{{.EXTRA_TAGS}}' |
| @@ -115,8 +115,8 @@ jobs: | |||
| uses: awalsh128/cache-apt-pkgs-action@latest | |||
| if: matrix.os == 'ubuntu-latest' | |||
| with: | |||
| packages: libgtk-3-dev libwebkit2gtk-4.1-dev libwayland-dev build-essential pkg-config xvfb x11-xserver-utils at-spi2-core xdg-desktop-portal-gtk | |||
| version: 1.0 | |||
| packages: libgtk-3-dev libwebkit2gtk-4.1-dev build-essential pkg-config xvfb x11-xserver-utils at-spi2-core xdg-desktop-portal-gtk | |||
| version: 1.1 | |||
There was a problem hiding this comment.
The PR description’s “Files changed” section doesn’t mention the workflow updates in this PR (including v2 CI changes). Please either update the PR description to include these workflow changes or split them into a separate PR so the scope of the change is clear for reviewers.
|
Allow users to pass custom build tags via `wails3 build -tags gtk4` instead of requiring Taskfile modifications. Tags are forwarded as EXTRA_TAGS to platform Taskfiles and appended to the go build command alongside the existing production tag. Works for both native and Docker cross-compilation builds. Closes #4957 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e5fa302 to
d7aba11
Compare
|
Allow users to pass custom build tags via `wails3 build -tags gtk4` instead of requiring Taskfile modifications. Tags are forwarded as EXTRA_TAGS to platform Taskfiles and appended to the go build command alongside the existing production tag. Works for both native and Docker cross-compilation builds. Closes wailsapp#4957 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
-tagsCLI flag towails3 buildso users can pass custom Go build tags without modifying TaskfilesEXTRA_TAGSto platform Taskfiles and appended to thego buildcommand-tags production,<extra>. In dev mode:-tags <extra>Usage
Files changed
v3/internal/flags/task_wrapper.go— AddedTagsfield toBuildstructv3/internal/commands/task_wrapper.go— PassEXTRA_TAGSvariable to task systemv3/internal/commands/task_wrapper_test.go— 3 new test casesv3/internal/commands/build_assets/{darwin,linux,windows}/Taskfile.yml— UseEXTRA_TAGSinBUILD_FLAGSTest plan
TestWrapTasktests passTestBuildCommandtest passesTestBuildCommandWithTags— single tag passed correctlyTestBuildCommandWithMultipleTags— comma-separated tags passed correctlyTestBuildCommandWithoutTags— backward compatible, noEXTRA_TAGSwhen flag omittedCloses #4957
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
-tagsflag to the build command for passing custom Go build tags to the compiler.Bug Fixes