Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] Pass build flags to binding generator #4023

Merged

Conversation

fbbdev
Copy link

@fbbdev fbbdev commented Jan 18, 2025

Description

This patch fixes an issue with template Taskfiles whereby Go build flags are not correctly propagated to the binding generator. Due to a limitation in the Taskfile implementation, the job won't rerun automatically when the flags change.

Additionally, it ensures the PRODUCTION mode variable is propagated to the frontend build task, and tracks both variables as dependencies using the task label method.

Somewhat counterintuitively, both the binding generator's output and Vite's output are included in the two tasks' sources. That is done to ensure dev builds rerun just after a production build alters bindings or frontend artifacts, or vice versa. Because the binding generator's output and Vite's output are both deterministic, that won't induce an infinite rerun loop, but will stabilise after two runs.

Preliminary discussion happened on the Discord feedback channel at https://discord.com/channels/1042734330029547630/1329148312171057172

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Various templates have been tested on macOS by running both wails3 dev, wails3 build and wails3 package, and verifying that the binding generator:

  • runs every time;

  • receives the same flags that are passed to go build.

  • Windows

  • macOS

  • Linux

Test Configuration

 Wails (v3.0.0-dev)  Wails Doctor 
                                                                                                                                                              
# System 

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Name          | MacOS                                                                                                          |
| Version       | 12.6.6                                                                                                         |
| ID            | 21G646                                                                                                         |
| Branding      | Monterey                                                                                                       |
| Platform      | darwin                                                                                                         |
| Architecture  | amd64                                                                                                          |
| Apple Silicon | unknown                                                                                                        |
| CPU           | Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz                                                                       |
| CPU           | Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz                                                                       |
| GPU           |  cores, Metal Family: Supported, Metal GPUFamily macOS 2                                                       |
|       Metal Family: Supported, Metal GPUFamily macOS 2                                                                         |
| Memory        | 32 GB                                                                                                          |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Build Environment 

┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-dev                               |
| Go Version   | go1.23.4                                 |
| Revision     | 242d56afa4382d998fa75f86e1bbcd7827bc1c7a |
| Modified     | true                                     |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOAMD64      | v1                                       |
| GOARCH       | amd64                                    |
| GOOS         | darwin                                   |
| vcs          | git                                      |
| vcs.modified | true                                     |
| vcs.revision | 242d56afa4382d998fa75f86e1bbcd7827bc1c7a |
| vcs.time     | 2025-01-17T22:07:27Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies 

┌───────────────────────────┐
| Xcode cli tools | 2395    |
| npm             | 10.8.2  |
| *NSIS           | v3.10   |
└─ * - Optional Dependency ─┘

# Checking for issues 

 SUCCESS  No issues found

# Diagnosis 

 SUCCESS  Your system is ready for Wails development!

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added support for aarch64 AppImage builds
    • Introduced diagnostics section in wails doctor command
    • Added window-call example for service method calls
    • Implemented app.OpenFileManager() method
  • Improvements

    • Enhanced panic handling
    • Improved build flag configuration across platforms
    • Updated initialization of JS/TS bindings
    • Refined service method naming
    • Streamlined terminal output and spinner functionality
  • Bug Fixes

    • Improved build process flexibility
    • Enhanced functionality across Windows and Linux platforms
  • Documentation

    • Updated changelog with detailed project changes

Copy link
Contributor

coderabbitai bot commented Jan 18, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request updates the changelog to document various changes, additions, and fixes in the project. Key updates include the renaming of several service methods, the introduction of support for aarch64 AppImage builds, and enhancements to the wails doctor command with a new diagnostics section. Additionally, a window-call example has been added, and improvements in panic handling have been made. The build process has been refined with the introduction of a BUILD_FLAGS variable across platform-specific Taskfiles, enhancing flexibility and clarity in build configurations.

Changes

File Change Summary
docs/src/content/docs/changelog.mdx Updated to reflect new features, service method renames, and various fixes
v3/internal/commands/build_assets/*/Taskfile.yml (Darwin/Linux/Windows) Added BUILD_FLAGS and PRODUCTION variables to build tasks, enhanced build flag configuration
v3/internal/commands/build_assets/Taskfile.tmpl.yml Modified binding generation task, updated sources section
v3/internal/term/term.go Added and removed functions for logging, updated spinner handling
v3/internal/commands/bindings.go Switched from pterm to term package for spinner and debug message handling

Suggested labels

TODO

Possibly related PRs

  • [v3] allow build with garble #3192: This PR relates to the main PR as it also involves updates to the changelog, specifically mentioning changes in service methods and their handling, which aligns with the renaming of service methods in the main PR.
  • Ignore internal service methods when binding #3720: This PR is relevant because it discusses changes to internal service methods, which ties into the main PR's updates regarding service method handling and the introduction of new service-related functionalities.
  • [v3] Service API cleanup and comments #4024: This PR is connected as it includes modifications to the service API, particularly the introduction of application.NewServiceWithOptions, which is directly mentioned in the main PR's summary regarding changes to service initialization methods.

Poem

🐰 Hop, hop, build with glee,
Flags flying, code running free!
Taskfiles dancing, platform-wide,
Build process smooth as a rabbit's ride!
Wails grows stronger, day by day! 🚀


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41ea6a4 and 13e7082.

📒 Files selected for processing (2)
  • docs/src/content/docs/changelog.mdx (1 hunks)
  • v3/internal/commands/bindings.go (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/src/content/docs/changelog.mdx (1)

49-49: LGTM! Consider enhancing the changelog entry.

The changelog entry accurately documents the fix. However, it could be more helpful to users if it included a brief note about the impact, such as "ensuring consistent rebuilds when build flags change".

-Pass build flags to binding generator by [@fbbdev](https://github.com/fbbdev) in [#4023](https://github.com/wailsapp/wails/pull/4023)
+Pass build flags to binding generator by [@fbbdev](https://github.com/fbbdev) in [#4023](https://github.com/wailsapp/wails/pull/4023) - ensures consistent rebuilds when build flags change
v3/internal/commands/build_assets/linux/Taskfile.yml (1)

89-89: Minor whitespace cleanup in package generation tasks.

Cosmetic changes to remove trailing spaces after cmds: declarations.

Also applies to: 94-94, 99-99

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ba623f and 0144be8.

📒 Files selected for processing (5)
  • docs/src/content/docs/changelog.mdx (1 hunks)
  • v3/internal/commands/build_assets/Taskfile.tmpl.yml (3 hunks)
  • v3/internal/commands/build_assets/darwin/Taskfile.yml (1 hunks)
  • v3/internal/commands/build_assets/linux/Taskfile.yml (2 hunks)
  • v3/internal/commands/build_assets/windows/Taskfile.yml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run Go Tests (ubuntu-latest, 1.23)
  • GitHub Check: Run Go Tests (macos-latest, 1.23)
  • GitHub Check: Run Go Tests (windows-latest, 1.23)
🔇 Additional comments (5)
v3/internal/commands/build_assets/Taskfile.tmpl.yml (2)

34-36: LGTM! BUILD_FLAGS propagation added correctly.

The addition of BUILD_FLAGS to the frontend build task ensures proper propagation of build flags to dependent tasks.


52-52: LGTM! Binding generator now receives build flags.

The removal of the sources section (not visible in diff) and the addition of BUILD_FLAGS to the command ensures that:

  1. The binding generator runs on every build, fixing the issue where it wouldn't rerun when build flags changed
  2. Build flags are correctly propagated to the binding generator
v3/internal/commands/build_assets/windows/Taskfile.yml (1)

13-16: LGTM! Consistent BUILD_FLAGS implementation.

The BUILD_FLAGS and PRODUCTION variables are correctly referenced, maintaining consistency with the template implementation.

v3/internal/commands/build_assets/darwin/Taskfile.yml (1)

12-14: LGTM! Platform-specific BUILD_FLAGS implementation.

The BUILD_FLAGS reference is correctly implemented while preserving macOS-specific build configurations.

v3/internal/commands/build_assets/linux/Taskfile.yml (1)

12-14: LGTM! Consistent BUILD_FLAGS implementation.

The BUILD_FLAGS reference is correctly implemented, maintaining consistency with other platforms.

The `/wails:include` directive allows for the inclusion of additional JS/TS files in the generated bindings.
@fbbdev fbbdev force-pushed the v3-alpha-bugfix/bindgen-build-flags branch from a66b23a to b9970f9 Compare January 18, 2025 21:51
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9970f9 and 308d299.

📒 Files selected for processing (2)
  • v3/internal/commands/build_assets/Taskfile.tmpl.yml (3 hunks)
  • v3/internal/term/term.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run Go Tests (ubuntu-latest, 1.23)
  • GitHub Check: Run Go Tests (macos-latest, 1.23)
  • GitHub Check: Run Go Tests (windows-latest, 1.23)
🔇 Additional comments (3)
v3/internal/commands/build_assets/Taskfile.tmpl.yml (3)

86-86: Formatting change only.


25-25: LGTM! The changes improve build tracking and dependency management.

The updates correctly implement:

  • Task labeling with PRODUCTION state for better tracking
  • Comprehensive artifact tracking with wildcards
  • BUILD_FLAGS dependency to trigger rebuilds when flags change

Let's verify the task rerun behavior:

Also applies to: 31-31, 35-37

✅ Verification successful

✅ Verified: Task configuration correctly implements build flag propagation

The implementation properly handles:

  • Production mode tracking in task label
  • Build flags propagation through generate:bindings dependency
  • Comprehensive artifact tracking with dist/**/*
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the task properly tracks dependencies and reruns

# Check if the task label and deps are properly configured
rg -A 5 'label: build:frontend.*PRODUCTION' && \
rg -A 5 'BUILD_FLAGS:\s+ref: \.BUILD_FLAGS'

Length of output: 567


Script:

#!/bin/bash
# Get the complete frontend build task definition and check for build flags
rg -A 20 '^  build:frontend:' v3/internal/commands/build_assets/Taskfile.tmpl.yml

# Also check for any build flags references in the file
rg -i 'build.*flags' v3/internal/commands/build_assets/Taskfile.tmpl.yml

Length of output: 962


47-47: LGTM! The changes improve binding generation reliability.

The updates correctly implement:

  • Build flags tracking in task label
  • Precise source file tracking with proper exclusions
  • Proper handling of dev/production mode changes
  • Clean command formatting with proper flag passing

Let's verify the bindings generation behavior:

Also applies to: 52-54, 59-59, 61-61

✅ Verification successful

Binding generation task changes are correctly implemented

The verification confirms:

  • Task label properly tracks BUILD_FLAGS
  • Source patterns correctly handle frontend exclusions and bindings tracking
  • Command structure properly handles flags and typescript option
  • Generated bindings directory setup is correct
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify binding generation patterns and command structure

# Check source patterns
echo "Verifying source patterns..."
fd -t f -e ts -e js . | grep -v 'frontend/' || true
fd -t f -e ts -e js 'frontend/bindings' || true

# Check command structure
echo "Verifying command structure..."
rg 'wails3 generate bindings.*BUILD_FLAGS.*-clean=true' -A 2

Length of output: 110986


Script:

#!/bin/bash
# Description: Verify binding generation directory and command structure

# Check if frontend/bindings directory exists
echo "Checking frontend/bindings directory..."
fd -t d 'frontend/bindings' || true

# Verify command structure with better grep pattern
echo "Verifying command structure..."
rg -l 'wails3.*generate.*bindings' || true

# Check specific task file content
echo "Checking Taskfile content..."
cat v3/internal/commands/build_assets/Taskfile.tmpl.yml || true

Length of output: 3114

@@ -74,7 +74,7 @@ func Warning(input any) {
}

func Warningf(input any, args ...any) {
output(input, pterm.Warning, args)
output(input, pterm.Warning, args...)
Copy link
Contributor

@coderabbitai coderabbitai bot Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

LGTM! Critical bug fix for variadic argument handling.

The change correctly expands the variadic arguments when passing them to the output function. This fixes a potential bug where format strings expecting multiple arguments would receive the slice as a single argument instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leaanthony Here's the committable code:

func Warningf(input any, args ...any) {
	output(input, pterm.Warning, args...)
}

@leaanthony leaanthony enabled auto-merge (squash) January 23, 2025 10:58
@leaanthony leaanthony merged commit 3f82582 into wailsapp:v3-alpha Jan 23, 2025
6 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants