Compare commits

...

4 Commits

Author SHA1 Message Date
Lea Anthony
02bd44f772 Merge branch 'develop' into feature/gopath 2020-09-15 20:16:42 +10:00
Travis McLane
bd0c9dbc43 use wailsapp/xgo:1.0.1 for cross-compiling 2020-09-14 19:05:00 -05:00
Travis McLane
1c813622c0 update messages to output xgo version
TODO: allow image override
2020-09-13 08:51:54 -05:00
Travis McLane
76ba7d56ec implement gopath handling during cross compilation 2020-09-13 08:47:29 -05:00
3 changed files with 23 additions and 10 deletions

View File

@@ -18,6 +18,8 @@ import (
"github.com/leaanthony/spinner"
)
const xgoVersion = "1.0.1"
var fs = NewFSHelper()
// ValidateFrontendConfig checks if the frontend config is valid
@@ -90,16 +92,17 @@ func InitializeCrossCompilation(verbose bool) error {
}
var packSpinner *spinner.Spinner
msg := fmt.Sprintf("Pulling wailsapp/xgo:%s docker image... (may take a while)", xgoVersion)
if !verbose {
packSpinner = spinner.New("Pulling wailsapp/xgo:latest docker image... (may take a while)")
packSpinner = spinner.New(msg)
packSpinner.SetSpinSpeed(50)
packSpinner.Start()
} else {
println("Pulling wailsapp/xgo:latest docker image... (may take a while)")
println(msg)
}
err := NewProgramHelper(verbose).RunCommandArray([]string{"docker",
"pull", "wailsapp/xgo:latest"})
"pull", fmt.Sprintf("wailsapp/xgo:%s", xgoVersion)})
if err != nil {
if packSpinner != nil {
@@ -114,7 +117,7 @@ func InitializeCrossCompilation(verbose bool) error {
return nil
}
// BuildDocker builds the project using the cross compiling wailsapp/xgo:latest container
// BuildDocker builds the project using the cross compiling wailsapp/xgo:<xgoVersion> container
func BuildDocker(binaryName string, buildMode string, projectOptions *ProjectOptions) error {
var packSpinner *spinner.Spinner
if buildMode == BuildModeBridge {
@@ -146,18 +149,24 @@ 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", xgoVersion))
buildCommand.Add(".")
compileMessage := fmt.Sprintf(
"Packing + Compiling project for %s/%s using docker image wailsapp/xgo:latest",
projectOptions.Platform, projectOptions.Architecture)
"Packing + Compiling project for %s/%s using docker image wailsapp/xgo:%s",
projectOptions.Platform, projectOptions.Architecture, xgoVersion)
if buildMode == BuildModeDebug {
compileMessage += " (Debug Mode)"

View File

@@ -162,6 +162,7 @@ type ProjectOptions struct {
Platform string
Architecture string
LdFlags string
GoPath string
}
// Defaults sets the default project template

View File

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