No go rebuild (#2870)

* add flag option for NoGoRebuild
This commit is contained in:
David Haukeness 2023-08-30 05:24:05 -06:00 committed by GitHub
commit 2e9f57a60d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 14 deletions

View file

@ -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"`

View file

@ -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.
@ -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() {
@ -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:
@ -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
}
}
}

BIN
v2/cmd/wails/wails Executable file

Binary file not shown.

View file

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

View file

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