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] fix: Add cross-platform cleanup for .syso files during Windows build #3924

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

ansxuman
Copy link

@ansxuman ansxuman commented Dec 1, 2024

Description

When cross-compiling Windows binaries on macOS, it gives error during cleanup of .syso files. The current cleanup command uses PowerShell, which is not available on Unix-based systems.

Fixes # (issue)

Type of change

Please select the option that is relevant.

  • 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?

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.

  • Windows
  • macOS
  • Linux

If you checked Linux, please specify the distro and version.

Test Configuration

Please paste the output of wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.

          Wails Doctor



# System
┌──────────────────────────────┐
| Name          | MacOS        |
| Version       | 15.1.1       |
| ID            | 24B91        |
| Branding      | MacOS 15.1.1 |
| Platform      | darwin       |
| Architecture  | arm64        |
| Apple Silicon | true         |
| CPU           | Apple M1     |
| CPU           | Unknown      |
| GPU           | Unknown      |
| Memory        | Unknown      |
└──────────────────────────────┘

# Build Environment
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Wails CLI      | v3.0.0-alpha.7                                                                                                            |
| Go Version     | go1.23.2                                                                                                                  |
| Revision       | 730610a90a4b6681f4d0fb4194340c7df74b3373                                                                                  |
| Modified       | false                                                                                                                     |
| -buildmode     | exe                                                                                                                       |
| -compiler      | gc                                                                                                                        |
| CGO_CFLAGS     |                                                                                                                           |
| CGO_CPPFLAGS   |                                                                                                                           |
| CGO_CXXFLAGS   |                                                                                                                           |
| CGO_ENABLED    | 1                                                                                                                         |
| CGO_LDFLAGS    |                                                                                                                           |
| DefaultGODEBUG | asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1 |
| GOARCH         | arm64                                                                                                                     |
| GOARM64        | v8.0                                                                                                                      |
| GOOS           | darwin                                                                                                                    |
| vcs            | git                                                                                                                       |
| vcs.modified   | false                                                                                                                     |
| vcs.revision   | 730610a90a4b6681f4d0fb4194340c7df74b3373                                                                                  |
| vcs.time       | 2024-11-30T08:04:43Z                                                                                                      |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────┐
| *NSIS           | v3.10   |
| Xcode cli tools | 2409    |
| npm             | 10.8.1  |
└─ * - Optional Dependency ─┘

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

  • New Features
    • Introduced platform-specific commands for removing .syso files in the build process, enhancing compatibility across Windows, Linux, and Darwin environments.
  • Bug Fixes
    • Updated existing commands to ensure proper execution in their respective platforms.

Copy link
Contributor

coderabbitai bot commented Dec 1, 2024

Walkthrough

The changes in this pull request update the Taskfile.windows.yml configuration for building assets in a Windows environment. It introduces platform-specific commands for removing .syso files, with the original PowerShell command modified to include a cmd: prefix and a platforms: [windows] specification. Additionally, a new command for Linux and Darwin platforms is added, allowing the removal of .syso files using rm -f *.syso. The overall structure of the tasks remains unchanged.

Changes

File Change Summary
v3/internal/commands/build_assets/Taskfile.windows.yml Updated command for Windows to - cmd: powershell Remove-item *.syso with platforms: [windows]; added command - cmd: rm -f *.syso for Linux and Darwin with platforms: [linux, darwin].
mkdocs-website/docs/en/changelog.md Updated changelog to include new commands, changes in behavior, and fixes related to cross-platform asset management.

Possibly related PRs

Suggested reviewers

  • leaanthony

🐰 In the world of code, we hop and play,
With tasks for each platform, come what may.
Windows and Linux, all in a line,
Removing .syso, oh how divine!
So let’s build our assets, with joy and cheer,
For every command, we hold so dear! 🌟


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 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

🧹 Outside diff range and nitpick comments (1)
v3/internal/commands/build_assets/Taskfile.windows.yml (1)

16-19: LGTM! Platform-specific cleanup implementation looks good.

The implementation correctly handles .syso file cleanup across different platforms using appropriate commands for each OS.

Consider these improvements:

  1. Add error handling by using the ignore_error: true option to prevent task failure if files don't exist:
 - cmd: powershell Remove-item *.syso
   platforms: [windows]
+  ignore_error: true
 - cmd: rm -f *.syso
   platforms: [linux, darwin]
+  ignore_error: true
  1. Consider moving the cleanup to a separate task for better organization:
  cleanup:syso:
    cmds:
      - cmd: powershell Remove-item *.syso
        platforms: [windows]
        ignore_error: true
      - cmd: rm -f *.syso
        platforms: [linux, darwin]
        ignore_error: true

  build:
    # ... other configurations ...
    deps:
      # ... existing deps ...
    cmds:
      - go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}.exe
      - task: cleanup:syso
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1c34c25 and d15e85f.

📒 Files selected for processing (1)
  • v3/internal/commands/build_assets/Taskfile.windows.yml (1 hunks)
🔇 Additional comments (1)
v3/internal/commands/build_assets/Taskfile.windows.yml (1)

16-19: Verify .syso file handling across the codebase

Let's ensure this cleanup mechanism covers all .syso file generation points.

✅ Verification successful

Cleanup mechanism for .syso files is consistent across the codebase

The cleanup implementation in build_assets/Taskfile.windows.yml follows the established pattern across the codebase. All files that generate .syso files consistently implement the same cleanup mechanism:

  • Windows cleanup using powershell Remove-item *.syso
  • Non-Windows cleanup using rm -f *.syso

The pattern is consistently implemented in:

  • Template base (v3/internal/templates/_base/default/Taskfile.tmpl.yml)
  • Example applications (dialogs, dev, file-association, build)
  • Build assets
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other .syso file generation points and cleanup mechanisms
echo "Checking for .syso file generation points:"
rg -l "\.syso" --type yaml

echo -e "\nChecking for existing cleanup mechanisms:"
rg -l "Remove-item.*\.syso|rm.*\.syso" --type yaml

echo -e "\nChecking for syso-related build configurations:"
ast-grep --pattern 'generate syso'

Length of output: 939


Script:

#!/bin/bash
# Let's examine the cleanup mechanisms in these files to ensure consistency
echo "=== Checking cleanup mechanisms in Taskfile.tmpl.yml ==="
rg "\.syso" v3/internal/templates/_base/default/Taskfile.tmpl.yml -C 2

echo -e "\n=== Checking cleanup in dialogs/Taskfile.yml ==="
rg "\.syso" v3/examples/dialogs/Taskfile.yml -C 2

echo -e "\n=== Checking cleanup in dev/Taskfile.yml ==="
rg "\.syso" v3/examples/dev/Taskfile.yml -C 2

echo -e "\n=== Checking cleanup in file-association/Taskfile.windows.yml ==="
rg "\.syso" v3/examples/file-association/build/Taskfile.windows.yml -C 2

echo -e "\n=== Checking cleanup in build/Taskfile.yml ==="
rg "\.syso" v3/examples/build/Taskfile.yml -C 2

Length of output: 2426

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

🧹 Outside diff range and nitpick comments (1)
mkdocs-website/docs/en/changelog.md (1)

48-48: LGTM with a minor suggestion to enhance clarity.

The changelog entry correctly documents the fix and follows the proper format. Consider making it more specific by mentioning the actual platforms affected:

-Fixed cross-platform cleanup for .syso files during Windows build by [ansxuman](https://github.com/ansxuman) in [#3924](https://github.com/wailsapp/wails/pull/3924)
+Fixed cross-platform cleanup for .syso files during Windows build (Windows/Linux/Darwin) by [ansxuman](https://github.com/ansxuman) in [#3924](https://github.com/wailsapp/wails/pull/3924)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d15e85f and c5a47a8.

📒 Files selected for processing (1)
  • mkdocs-website/docs/en/changelog.md (1 hunks)

@leaanthony leaanthony merged commit b37cdf5 into wailsapp:v3-alpha Dec 2, 2024
11 checks passed
@leaanthony
Copy link
Member

Amazing! Thank you 🙏
Funnily enough I added the platforms functionality to Task last year but it looks like they also added it to cmds. Awesome 😎

@ansxuman
Copy link
Author

ansxuman commented Dec 2, 2024

Amazing! Thank you 🙏 Funnily enough I added the platforms functionality to Task last year but it looks like they also added it to cmds. Awesome 😎

✌🏻

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