Skip to content

Commit

Permalink
No go rebuild (#2870)
Browse files Browse the repository at this point in the history
* add flag option for NoGoRebuild
  • Loading branch information
haukened authored Aug 30, 2023
1 parent 44c291b commit 2e9f57a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions v2/cmd/wails/flags/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Dev struct {
Browser bool `flag:"browser" description:"Open the application in a browser"`
NoReload bool `flag:"noreload" description:"Disable reload on asset change"`
NoColour bool `flag:"nocolor" description:"Disable colour in output"`
NoGoRebuild bool `flag:"nogorebuild" description:"Disable automatic rebuilding on backend file changes/additions"`
WailsJSDir string `flag:"wailsjsdir" description:"Directory to generate the Wails JS modules"`
LogLevel string `flag:"loglevel" description:"LogLevel to use - Trace, Debug, Info, Warning, Error)"`
ForceBuild bool `flag:"f" description:"Force build of application"`
Expand Down
33 changes: 19 additions & 14 deletions v2/cmd/wails/internal/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func Application(f *flags.Dev, logger *clilogger.CLILogger) error {

// Setup signal handler
quitChannel := make(chan os.Signal, 1)
signal.Notify(quitChannel, os.Interrupt, os.Kill, syscall.SIGTERM)
signal.Notify(quitChannel, os.Interrupt, syscall.SIGTERM)
exitCodeChannel := make(chan int, 1)

// Build the frontend if requested, but ignore building the application itself.
Expand Down Expand Up @@ -255,8 +255,8 @@ func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, d

const (
stateRunning int32 = 0
stateCanceling = 1
stateStopped = 2
stateCanceling int32 = 1
stateStopped int32 = 2
)
state := stateRunning
go func() {
Expand Down Expand Up @@ -366,7 +366,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc

assetDirURL := joinPath(devServerURL, "/wails/assetdir")
reloadURL := joinPath(devServerURL, "/wails/reload")
for quit == false {
for !quit {
// reload := false
select {
case exitCode := <-exitCodeChannel:
Expand Down Expand Up @@ -441,16 +441,21 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
case <-timer.C:
if rebuild {
rebuild = false
logutils.LogGreen("[Rebuild triggered] files updated")
// Try and build the app
newBinaryProcess, _, err := restartApp(buildOptions, debugBinaryProcess, f, exitCodeChannel, legacyUseDevServerInsteadofCustomScheme)
if err != nil {
logutils.LogRed("Error during build: %s", err.Error())
continue
}
// If we have a new process, saveConfig it
if newBinaryProcess != nil {
debugBinaryProcess = newBinaryProcess
if f.NoGoRebuild {
logutils.LogGreen("[Rebuild triggered] skipping due to flag -nogorebuild")
} else {
logutils.LogGreen("[Rebuild triggered] files updated")
// Try and build the app

newBinaryProcess, _, err := restartApp(buildOptions, debugBinaryProcess, f, exitCodeChannel, legacyUseDevServerInsteadofCustomScheme)
if err != nil {
logutils.LogRed("Error during build: %s", err.Error())
continue
}
// If we have a new process, saveConfig it
if newBinaryProcess != nil {
debugBinaryProcess = newBinaryProcess
}
}
}

Expand Down
Binary file added v2/cmd/wails/wails
Binary file not shown.
1 change: 1 addition & 0 deletions website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added new community template wails-sveltekit-ts. Added by [@haukened](https://github.com/haukened) in [PR](https://github.com/wailsapp/wails/pull/2851)
- Added support for retrieving the logical and physical screen size in the screen api. Added by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2856)
- Added new community template wails-sveltekit-tailwind. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2851)
- Added new `wails dev -nogorebuild` flag to prevent restarts on back end file changes. [@haukened](https://github.com/haukened) in [PR #2870](https://github.com/wailsapp/wails/pull/2870)

### Changed

Expand Down
1 change: 1 addition & 0 deletions website/versioned_docs/version-v2.5.0/reference/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Your system is ready for Wails development!
| -ldflags "flags" | Additional ldflags to pass to the compiler | |
| -tags "extra tags" | Build tags to pass to compiler (quoted and space separated) | |
| -loglevel "loglevel" | Loglevel to use - Trace, Debug, Info, Warning, Error | Debug |
| -nogoreload | Disable back end rebuilds on file change/create/delete. Useful for IDEs that autosave frequently. | |
| -noreload | Disable automatic reload when assets change | |
| -nocolour | Turn off colour cli output | false |
| -nogen | Disable generate module | |
Expand Down

0 comments on commit 2e9f57a

Please sign in to comment.