[V3] feat(build): add Zig Taskfile extension#5528
Conversation
Adds an optional --zig flag to `wails3 build` that uses the Zig compiler (zig cc / zig c++) as a drop-in C/C++ toolchain for CGO builds. This enables native cross-architecture compilation without requiring per-target GCC toolchains or Docker. When --zig is passed and Zig is installed, the Linux build task routes through a new build:zig path that sets CC/CXX to the appropriate zig cc/c++ target triple. If Zig is not found, the build fails with a clear error message. Changes: - New `wails3 tool has-zig` command (mirrors existing has-cc) - Build flag: `Zig bool` added to flags.Build struct - Taskfile: build:zig task in linux/Taskfile.yml with zig precondition and inline CC/CXX target triples
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a Taskfile (v3/internal/commands/build_assets/Taskfile.zig.yml) that implements a top-level ChangesZig cross-platform build integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
Just noticed this PR included quite a lot of files (mostly (Sorry for this, it's my first ever PR to the open-source 😄) After a bit of thinking, I decided to remove those myself. Now, only changes in this PR are the files related to the feature. |
|
I didn't know that you can build Go CGO with anything other than GCC 🤔 |
|
I like the idea of this, but mostly from the perspective of providing better extension options for the build system. Taskfile already handles importing task files so I'm imagining a world where this could be downloaded and placed in the build directory and "just work". The best way to achieve that is to provide a cross platform "has" command to do the binary lookups rather than adding more a more as time goes on. I'm up for refactoring To be clear, I love the idea of Zig builds without docker, but I'm mindful of feature creep for the main CLI & Taskfiles and think a more sustainable option is to provide the tools to enable it. Thoughts? |
|
Thanks a lot for taking a look — as my first open-source contribution, it means a lot! I agree: making the Once you clarify that part, I’d be happy to rework my PR to fit this. 😁 |
|
Yes that's right! Taskfiles can import other taskfiles. If you look at the ones in a Wails project you'll see that you have the main one and that imports the platform specific files. When you import you give it a namespace so you can call tasks within them. I can do the "has" change in a different PR as it will affect existing Taskfiles 👍 This is a great first PR to Open Source. Keep going! |
…naticExplorer/wails into feature/zig-cgo-cross-compile # Conflicts: # v3/internal/commands/build_assets/Taskfile.zig.yml
|
Done! Took me some time, but I hope you'll like it 😇 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@v3/internal/commands/build_assets/Taskfile.zig.yml`:
- Around line 111-117: The Windows build command hardcodes the output to
'{{.BIN_DIR}}/{{.APP_NAME}}.exe' and ignores the caller-provided 'OUTPUT' var;
update the build command template (the line building the .exe) to use
'{{.OUTPUT}}' when present and fall back to '{{.BIN_DIR}}/{{.APP_NAME}}.exe'
otherwise (preserve existing use of BUILD_FLAGS and any OBUSCATED/DEV tags), so
the Windows path respects the parent-task 'OUTPUT' variable just like other
platforms.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 37e6b3b3-b119-430b-bc77-dab1981baa2f
📒 Files selected for processing (2)
v3/internal/commands/build_assets/Taskfile.zig.ymlv3/internal/templates/_common/Taskfile.tmpl.yml
|
Fair note, CodeRabbit CLI didn't run well on my pc, so I couldn't find this issue myself locally 😭 |
|
@leaanthony just wanted to let you know that I changed the name and description of the PR Also, I noticed your commit 1691ea8 in |
Description
Adds an optional Zig build Taskfile (
build/Taskfile.zig.yml) that provideszig:buildtasks (linux/windows/darwin) using Zig as the C/C++ compiler for CGO. The root Taskfile template optionally imports it, so Zig builds are available without changing the defaultwails3 buildflow.Type of change
Please select the option that is relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using
wails doctor.If you checked Linux, please specify the distro and version.
Windows 11 (Build 26200), Zig 0.16.0, Go 1.26.
Reproduction steps:
wails3 task zig:buildwails3 task zig:build:windows ARCH=amd64Test Configuration
Checklist:
website/src/pages/changelog.mdxwith details of this PR (v3 changelog entries are added automatically)Summary by CodeRabbit
New Features
Chores