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

Added possibility to specify platform for dev command #3117

Merged
merged 10 commits into from
Dec 17, 2023
Merged

Added possibility to specify platform for dev command #3117

merged 10 commits into from
Dec 17, 2023

Conversation

PylotLight
Copy link
Contributor

@PylotLight PylotLight commented Dec 11, 2023

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not 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

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.

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

  • Refactor

    • Simplified build target iteration logic.
    • Updated platform and architecture setting logic to use target properties.
  • New Features

    • Introduced Target type and TargetsCollection for better build target management.
    • Added functionality to parse user-provided build targets.
    • Implemented a method to check if running on Windows Subsystem for Linux (WSL).
  • Documentation

    • Updated changelog to reflect the option to specify a platform for the dev command.
  • Bug Fixes

    • Fixed environment variable settings for Windows executable builds under WSL.
  • Chores

    • Removed unnecessary OS and runtime package imports.
  • Style

    • Added NoColour field to enhance output customization.

Copy link
Contributor

coderabbitai bot commented Dec 11, 2023

Walkthrough

The recent updates to the Wails framework focus on refining build target handling. The code has been restructured to simplify loops and directly use target properties, removing dependencies on specific OS and runtime packages. A new TargetsCollection type and Target struct have been introduced to streamline target management. There's also new functionality to detect the Windows Subsystem for Linux (WSL) environment and an option to specify platforms for development commands.

Changes

Files Summary
v2/cmd/wails/build.go Refactored build target iteration and platform/arch setting logic.
v2/cmd/wails/flags/build.go
v2/cmd/wails/flags/common.go
v2/cmd/wails/flags/dev.go
Removed OS and runtime imports; introduced TargetsCollection and Target struct; modified default target logic; added platform field for dev commands.
v2/cmd/wails/internal/dev/dev.go Added isWsl function and modified environment setting for WSL.
v2/pkg/commands/build/build.go Added IsWindowsTargetPlatform method to Options.
website/src/pages/changelog.mdx Documented the addition of a platform specification option for the dev command.

🐇✨
In the burrows of Wails' domain,
A rabbit hopped through code terrain.
It tweaked and it tuned with care and might,
Now builds leap forth, into the light. 🚀🌟

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


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@PylotLight
Copy link
Contributor Author

Instant hot reload on WSL.
image

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.

Review Status

Actionable comments generated: 8

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between aa8cd7c and d22fc7b.
Files selected for processing (6)
  • v2/cmd/wails/build.go (5 hunks)
  • v2/cmd/wails/flags/build.go (4 hunks)
  • v2/cmd/wails/flags/common.go (1 hunks)
  • v2/cmd/wails/flags/dev.go (4 hunks)
  • v2/cmd/wails/internal/dev/dev.go (2 hunks)
  • v2/pkg/commands/build/build.go (1 hunks)
Additional comments: 20
v2/cmd/wails/build.go (8)
  • 108-113: The addition of a conditional check for the OutputFile length and the number of targets is a good practice to avoid unnecessary output when multiple targets are specified. This change seems to align with the PR's objective of enhancing the flexibility of the development environment setup.

  • 146-152: The new loop over targets with a check against a list of valid platform/architecture combinations is a good way to ensure that only supported targets are built. However, it would be beneficial to ensure that the list of valid platforms is comprehensive and includes all platforms that the application intends to support.

  • 161-162: Setting the Platform and Arch directly from the target properties simplifies the build logic and makes it more maintainable. This change is consistent with the PR's goal of improving the development command's flexibility.

  • 167-169: The warning about the compress flag being unsupported for universal binaries is a good addition for user feedback. However, it's important to ensure that this warning is only displayed when necessary and does not affect other platforms.

  • 173-181: The continuation of the loop when cross-compiling is not supported for Linux and Mac is a good safeguard. However, it would be beneficial to ensure that this does not prevent users from cross-compiling if they have the necessary setup to do so.

  • 183-185: The logic for setting the BundleName based on the number of Mac targets is a good addition. It's important to ensure that this logic is only applied when necessary and does not interfere with other platform builds.

  • 188-190: The logic for setting the target filename based on the number of targets is a good addition. It's important to ensure that this logic correctly handles all possible combinations of platforms and architectures.

  • 212-229: The addition of a dry run option is a useful feature for users to test the build process without actually compiling the binary. It's important to ensure that this option is well-documented and that users are aware of its existence.

v2/cmd/wails/flags/build.go (3)
  • 46-60: The Default method has been refactored to use a new defaultTarget function, and the Platform field is set based on the target. Ensure that the defaultTarget function is defined elsewhere in the codebase and that it provides a sensible default for the platform.

  • 74-76: The GetTargets method now returns a TargetsCollection type. Verify that the TargetsCollection type and the parseTargets function are properly defined and implemented to handle the parsing of the platform string into a collection of targets.

  • 2-11: The removal of the "os" and "runtime" imports is consistent with the PR's objectives, as the logic for default platform and architecture has been refactored. However, ensure that this does not affect other parts of the code that may rely on these imports.

v2/cmd/wails/flags/common.go (1)
  • 68-69: Verify if the order of platforms is significant for the build process. If so, deduplication might alter the intended order, which could lead to unexpected behavior.
v2/cmd/wails/flags/dev.go (3)
  • 18-22: The addition of the "Platform" field to the Dev struct with the corresponding flag and description aligns with the PR's objective to enhance platform specification for the development environment. This is a well-documented and clear change.

  • 40-50: The Default method now initializes the "Platform" field with a value from the defaultTarget function. Ensure that the defaultTarget function accurately determines the default platform across different environments, especially since the feature has not been tested on Windows or macOS.

  • 120-133: The GenerateBuildOptions method now uses the "Platform" field to set architecture and platform options in the build.Options struct. This is a key part of the new feature, allowing the development command to target the specified platform. It's important to ensure that the parseTargets function correctly interprets the "Platform" field and that the first target in the resulting slice is the desired default.

v2/cmd/wails/internal/dev/dev.go (3)
  • 271-279: The implementation of isWsl function looks correct and should work as intended to detect if the application is running under WSL by checking the contents of /proc/version.

  • 319-323: The logic to set WSL-specific environment variables when building for Windows under WSL seems correct. It ensures that the necessary variables are passed through to the Windows environment.

  • 268-283: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [271-323]

Please verify that the new WSL detection and environment variable setting works as expected on Windows, particularly under WSL, to ensure cross-platform compatibility.

v2/pkg/commands/build/build.go (2)
  • 74-76: The implementation of IsWindowsTargetPlatform looks correct and follows the PR's objective to enhance platform specification. It's a simple string check, which should be sufficient for the intended use case.

  • 71-80: > Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [1-12]

The AI-generated summary mentions the removal of "os" and "runtime" imports in another file (v2/cmd/wails/flags/build.go), but they are still present in this file. If these imports are no longer needed here due to refactoring, they should be removed to keep the code clean.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d22fc7b and e835456.
Files selected for processing (1)
  • website/src/pages/changelog.mdx (1 hunks)
Additional comments: 2
website/src/pages/changelog.mdx (2)
  • 17-18: The changelog has been updated correctly to reflect the addition of the new feature allowing users to specify the platform for the dev command.

  • 15-18: The PR checklist may need to be updated to reflect that the changelog has indeed been updated with the new feature.

@PylotLight
Copy link
Contributor Author

added extra platform validation
image

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e835456 and c9bc768.
Files selected for processing (1)
  • v2/cmd/wails/flags/common.go (1 hunks)
Additional comments: 4
v2/cmd/wails/flags/common.go (4)
  • 3-12: The addition of new imports is necessary for the functionality being introduced. Ensure that these imports are used in the file and are not unnecessarily increasing the binary size or introducing unused dependencies.

  • 23-40: The defaultTarget function correctly uses environment variables to set the default platform and architecture, with a fallback to system defaults. This is a good practice for flexibility and configurability.

  • 43-55: The MacTargetsCount method is a straightforward way to count the number of Mac targets. Ensure that the prefix check for "darwin" is consistent with how platforms are identified throughout the rest of the codebase.

  • 57-63: The String method for Target is implemented correctly and provides a clear string representation of the struct.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c9bc768 and 3b17cde.
Files selected for processing (1)
  • v2/cmd/wails/flags/common.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • v2/cmd/wails/flags/common.go

@PylotLight
Copy link
Contributor Author

@leaanthony that commit causes issues further up and breaks other things and requires function changes 3+ levels up, so it made more sense to quit at the base level where the check occurs, was much simpler.

@leaanthony
Copy link
Member

@leaanthony that commit causes issues further up and breaks other things and requires function changes 3+ levels up, so it made more sense to quit at the base level where the check occurs, was much simpler.

/What are the issues? It should bubble back to the top and exit cleanly.

@PylotLight
Copy link
Contributor Author

PylotLight commented Dec 12, 2023

@leaanthony you gonna also have to update GetTargets and GenerateBuildOptions if you want to return error the way AI suggested btw. so I opted against it ;p

these will be broken with that change.

targets := parseTargets(d.Platform)

func (b *Build) GetTargets() TargetsCollection {
return parseTargets(b.Platform)
}

@leaanthony
Copy link
Member

Oh I see. Revert the commit then.

@PylotLight
Copy link
Contributor Author

@leaanthony Done.

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3b17cde and 036180f.
Files selected for processing (1)
  • v2/cmd/wails/flags/common.go (1 hunks)
Additional comments: 1
v2/cmd/wails/flags/common.go (1)
  • 1-103: Recommend testing the new feature on all supported platforms (Windows, macOS, and Linux) to ensure compatibility and correct behavior across different environments.

@PylotLight
Copy link
Contributor Author

PylotLight commented Dec 17, 2023

Bump, anything you want to see on this one?

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

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

wails dev -platform windo

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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 036180f and 7fe9d9f.
Files selected for processing (2)
  • v2/pkg/commands/build/build.go (1 hunks)
  • website/src/pages/changelog.mdx (2 hunks)
Additional comments: 7
v2/pkg/commands/build/build.go (2)
  • 74-76: The implementation of IsWindowsTargetPlatform method is correct and follows the PR's objective to allow platform-specific functionality.

  • 74-76: Verify that the changelog and documentation have been updated to include information about the new IsWindowsTargetPlatform method.

website/src/pages/changelog.mdx (5)
  • 18-18: The entry for the addition of the platform specification feature for the dev command is correctly documented and attributed to the contributor @pylotlight and PR #3117. This aligns with the PR objectives and AI-generated summaries.

  • 19-19: The entry for the addition of Windows options support, specifically the DisablePinchZoom configuration, is correctly documented and attributed to @tuuzed and PR 3115. This aligns with the AI-generated summaries but is not mentioned in the PR objectives provided by the user. It's possible that this change is part of another PR not covered by the current review.

  • 20-20: The entry for the addition of Apple Silicon hardware detection to wails doctor is correctly documented and attributed to @almas1992 and PR 3129. This aligns with the AI-generated summaries but is not mentioned in the PR objectives provided by the user. It's possible that this change is part of another PR not covered by the current review.

  • 21-21: The entry for the removal of the quarantine attribute on macOS binaries is correctly documented and attributed to @leaanthony and PR 3118. This aligns with the AI-generated summaries but is not mentioned in the PR objectives provided by the user. It's possible that this change is part of another PR not covered by the current review.

  • 25-25: The entry for the documentation update for IsZoomControlEnabled and ZoomFactor is correctly documented and attributed to @leaanthony and PR 3137. This aligns with the AI-generated summaries but is not mentioned in the PR objectives provided by the user. It's possible that this change is part of another PR not covered by the current review.

@leaanthony
Copy link
Member

Nah, it all looks good. Cheers @PylotLight 👍

leaanthony

This comment was marked as resolved.

@leaanthony leaanthony merged commit 4b4fcdd into wailsapp:master Dec 17, 2023
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7fe9d9f and cba7b88.
Files selected for processing (1)
  • website/src/pages/changelog.mdx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • website/src/pages/changelog.mdx

@PylotLight PylotLight deleted the feature/dev-platform branch December 18, 2023 02:13
"darwin": true,
}

if !allowedPlatforms[platform] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This checks breaks the ability to cross compile to another platform with a specific architecture (e.g. --platform windows/arm64 or --platform darwin/universal), because the argument platform is the arg cli --platform arg.
It also prevents the ability to compile for multiple platforms --platform windows/am64,windows/arm64.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR to resolve this one:
#3245

@@ -219,32 +207,27 @@ func buildApplication(f *flags.Build) error {
pterm.Warning.Println("obfuscated flag overrides skipbindings flag.")
buildOptions.SkipBindings = false
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Closing the loop already here results in only calling the compilation compiledBinary, err := build.Build(buildOptions) for the last target in the targets list. Therefore multi platform builds now only build the last platform. This e.g. is preventing users from building a NSIS installer that contains a windows arm64 and amd64 build wails build --nsis --platform windows/arm64,windows/amd64.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah moved a bracket which should fix this one.

@stffabi
Copy link
Collaborator

stffabi commented Feb 8, 2024

Sorry to be late to this PR but during testing of the latest master commit, I came across some issues when working with the wails cli on our projects.

@PylotLight
Copy link
Contributor Author

Sorry to be late to this PR but during testing of the latest master commit, I came across some issues when working with the wails cli on our projects.

Ah time to take a stab at fixing it, despite this not being my PR to be being with :P

@leaanthony
Copy link
Member

I've reverted this PR on master

@PylotLight
Copy link
Contributor Author

I've reverted this PR on master

Why? I already have a fix for it.

atterpac pushed a commit to atterpac/wails that referenced this pull request Feb 19, 2024
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.

3 participants