5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-19 02:19:31 +08:00

implement gopath handling during cross compilation

This commit is contained in:
Travis McLane 2020-09-13 08:37:51 -05:00 committed by Lea Anthony
parent a84f43d959
commit 0ad0092aa2
3 changed files with 16 additions and 4 deletions

View File

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

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