mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 06:01:52 +08:00
Merge pull request #46 from wailsapp/ignore-packr-findstring-errors-in-bridge-mode
Ignore packr findstring errors in bridge mode
This commit is contained in:
commit
d1c57ddb5f
8
app.go
8
app.go
@ -7,7 +7,7 @@ import (
|
|||||||
// -------------------------------- Compile time Flags ------------------------------
|
// -------------------------------- Compile time Flags ------------------------------
|
||||||
|
|
||||||
// BuildMode indicates what mode we are in
|
// BuildMode indicates what mode we are in
|
||||||
var BuildMode = "prod"
|
var BuildMode = cmd.BuildModeProd
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
|
|||||||
result.config = appconfig
|
result.config = appconfig
|
||||||
|
|
||||||
// Set up the CLI if not in release mode
|
// Set up the CLI if not in release mode
|
||||||
if BuildMode != "prod" {
|
if BuildMode != cmd.BuildModeProd {
|
||||||
result.cli = result.setupCli()
|
result.cli = result.setupCli()
|
||||||
} else {
|
} else {
|
||||||
// Disable Inspector in release mode
|
// Disable Inspector in release mode
|
||||||
@ -65,7 +65,7 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
|
|||||||
|
|
||||||
// Run the app
|
// Run the app
|
||||||
func (a *App) Run() error {
|
func (a *App) Run() error {
|
||||||
if BuildMode != "prod" {
|
if BuildMode != cmd.BuildModeProd {
|
||||||
return a.cli.Run()
|
return a.cli.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ func (a *App) start() error {
|
|||||||
a.log.Info("Starting")
|
a.log.Info("Starting")
|
||||||
|
|
||||||
// Check if we are to run in headless mode
|
// Check if we are to run in headless mode
|
||||||
if BuildMode == "bridge" {
|
if BuildMode == cmd.BuildModeBridge {
|
||||||
a.renderer = &Headless{}
|
a.renderer = &Headless{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
cmd/build.go
Normal file
10
cmd/build.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
const (
|
||||||
|
// BuildModeProd indicates we are building for prod mode
|
||||||
|
BuildModeProd = "prod"
|
||||||
|
// BuildModeDebug indicates we are building for debug mode
|
||||||
|
BuildModeDebug = "debug"
|
||||||
|
// BuildModeBridge indicates we are building for bridge mode
|
||||||
|
BuildModeBridge = "bridge"
|
||||||
|
)
|
@ -49,7 +49,8 @@ func InstallGoDependencies() error {
|
|||||||
// BuildApplication will attempt to build the project based on the given inputs
|
// BuildApplication will attempt to build the project based on the given inputs
|
||||||
func BuildApplication(binaryName string, forceRebuild bool, buildMode string) error {
|
func BuildApplication(binaryName string, forceRebuild bool, buildMode string) error {
|
||||||
compileMessage := "Packing + Compiling project"
|
compileMessage := "Packing + Compiling project"
|
||||||
if buildMode == "debug" {
|
|
||||||
|
if buildMode == BuildModeDebug {
|
||||||
compileMessage += " (Debug Mode)"
|
compileMessage += " (Debug Mode)"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string) er
|
|||||||
|
|
||||||
// Setup ld flags
|
// Setup ld flags
|
||||||
ldflags := "-w -s "
|
ldflags := "-w -s "
|
||||||
if buildMode == "debug" {
|
if buildMode == BuildModeDebug {
|
||||||
ldflags = ""
|
ldflags = ""
|
||||||
}
|
}
|
||||||
ldflags += "-X github.com/wailsapp/wails.BuildMode=" + buildMode
|
ldflags += "-X github.com/wailsapp/wails.BuildMode=" + buildMode
|
||||||
|
@ -89,9 +89,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build application
|
// Build application
|
||||||
buildMode := "prod"
|
buildMode := cmd.BuildModeProd
|
||||||
if debugMode {
|
if debugMode {
|
||||||
buildMode = "debug"
|
buildMode = cmd.BuildModeDebug
|
||||||
}
|
}
|
||||||
err = cmd.BuildApplication(projectOptions.BinaryName, forceRebuild, buildMode)
|
err = cmd.BuildApplication(projectOptions.BinaryName, forceRebuild, buildMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -62,6 +62,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save project directory
|
// Save project directory
|
||||||
|
// TODO: Remove compiling frontend once packr
|
||||||
|
// allows optional boxes
|
||||||
projectDir := fs.Cwd()
|
projectDir := fs.Cwd()
|
||||||
|
|
||||||
// Install deps
|
// Install deps
|
||||||
@ -84,7 +86,7 @@ func init() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
buildMode := "bridge"
|
buildMode := cmd.BuildModeBridge
|
||||||
err = cmd.BuildApplication(projectOptions.BinaryName, forceRebuild, buildMode)
|
err = cmd.BuildApplication(projectOptions.BinaryName, forceRebuild, buildMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -95,7 +95,7 @@ func (h *Headless) wsBridgeHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "Could not open websocket connection", http.StatusBadRequest)
|
http.Error(w, "Could not open websocket connection", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
h.theConnection = conn
|
h.theConnection = conn
|
||||||
h.log.Infof("Connection from frontend accepted.", h.theConnection)
|
h.log.Infof("Connection from frontend accepted [%p].", h.theConnection)
|
||||||
conn.SetCloseHandler(func(int, string) error {
|
conn.SetCloseHandler(func(int, string) error {
|
||||||
h.log.Infof("Connection dropped [%p].", h.theConnection)
|
h.log.Infof("Connection dropped [%p].", h.theConnection)
|
||||||
h.theConnection = nil
|
h.theConnection = nil
|
||||||
|
5
utils.go
5
utils.go
@ -4,6 +4,8 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/cmd"
|
||||||
|
|
||||||
"github.com/gobuffalo/packr"
|
"github.com/gobuffalo/packr"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,6 +20,9 @@ func escapeJS(js string) (string, error) {
|
|||||||
func BoxString(box *packr.Box, filename string) string {
|
func BoxString(box *packr.Box, filename string) string {
|
||||||
result, err := box.FindString(filename)
|
result, err := box.FindString(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if BuildMode == cmd.BuildModeBridge {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user