diff --git a/cmd/helpers.go b/cmd/helpers.go index 68576383c..157bdd31d 100644 --- a/cmd/helpers.go +++ b/cmd/helpers.go @@ -18,6 +18,8 @@ import ( "github.com/leaanthony/spinner" ) +const XGO_VERSION = "latest" + var fs = NewFSHelper() // ValidateFrontendConfig checks if the frontend config is valid @@ -146,15 +148,21 @@ func BuildDocker(binaryName string, buildMode string, projectOptions *ProjectOpt "-e", "FLAG_RACE=false", "-e", "FLAG_BUILDMODE=default", "-e", "FLAG_TRIMPATH=false", - "-e", fmt.Sprintf("TARGETS=%s", projectOptions.Platform+"/"+projectOptions.Architecture), + "-e", fmt.Sprintf("TARGETS=%s/%s", projectOptions.Platform, projectOptions.Architecture), "-e", "GOPROXY=", "-e", "GO111MODULE=on", - "wailsapp/xgo:latest", - ".", } { buildCommand.Add(arg) } + if projectOptions.GoPath != "" { + buildCommand.Add("-v") + buildCommand.Add(fmt.Sprintf("%s:/go", projectOptions.GoPath)) + } + + buildCommand.Add(fmt.Sprintf("wailsapp/xgo:%s", XGO_VERSION)) + buildCommand.Add(".") + compileMessage := fmt.Sprintf( "Packing + Compiling project for %s/%s using docker image wailsapp/xgo:latest", projectOptions.Platform, projectOptions.Architecture) diff --git a/cmd/project.go b/cmd/project.go index 889fb63d0..dc2f053b7 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -162,6 +162,7 @@ type ProjectOptions struct { Platform string Architecture string LdFlags string + GoPath string } // Defaults sets the default project template diff --git a/cmd/wails/4_build.go b/cmd/wails/4_build.go index 453d858da..22246c5c9 100644 --- a/cmd/wails/4_build.go +++ b/cmd/wails/4_build.go @@ -26,6 +26,7 @@ func init() { var packageApp = false var forceRebuild = false var debugMode = false + var gopath = "" var typescriptFilename = "" var verbose = false var platform = "" @@ -42,7 +43,8 @@ func init() { BoolFlag("d", "Build in Debug mode", &debugMode). BoolFlag("verbose", "Verbose output", &verbose). StringFlag("t", "Generate Typescript definitions to given file (at runtime)", &typescriptFilename). - StringFlag("ldflags", "Extra options for -ldflags", &ldflags) + StringFlag("ldflags", "Extra options for -ldflags", &ldflags). + StringFlag("gopath", "Specify your GOPATH location. Mounted to /go during cross-compilation.", &gopath) var b strings.Builder for _, plat := range getSupportedPlatforms() { @@ -97,6 +99,7 @@ func init() { // Add ldflags projectOptions.LdFlags = ldflags + projectOptions.GoPath = gopath // Validate config // Check if we have a frontend