mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-19 10:29:29 +08:00
implement gopath handling during cross compilation
This commit is contained in:
parent
a84f43d959
commit
0ad0092aa2
@ -18,6 +18,8 @@ import (
|
|||||||
"github.com/leaanthony/spinner"
|
"github.com/leaanthony/spinner"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const XGO_VERSION = "latest"
|
||||||
|
|
||||||
var fs = NewFSHelper()
|
var fs = NewFSHelper()
|
||||||
|
|
||||||
// ValidateFrontendConfig checks if the frontend config is valid
|
// 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_RACE=false",
|
||||||
"-e", "FLAG_BUILDMODE=default",
|
"-e", "FLAG_BUILDMODE=default",
|
||||||
"-e", "FLAG_TRIMPATH=false",
|
"-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", "GOPROXY=",
|
||||||
"-e", "GO111MODULE=on",
|
"-e", "GO111MODULE=on",
|
||||||
"wailsapp/xgo:latest",
|
|
||||||
".",
|
|
||||||
} {
|
} {
|
||||||
buildCommand.Add(arg)
|
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(
|
compileMessage := fmt.Sprintf(
|
||||||
"Packing + Compiling project for %s/%s using docker image wailsapp/xgo:latest",
|
"Packing + Compiling project for %s/%s using docker image wailsapp/xgo:latest",
|
||||||
projectOptions.Platform, projectOptions.Architecture)
|
projectOptions.Platform, projectOptions.Architecture)
|
||||||
|
@ -162,6 +162,7 @@ type ProjectOptions struct {
|
|||||||
Platform string
|
Platform string
|
||||||
Architecture string
|
Architecture string
|
||||||
LdFlags string
|
LdFlags string
|
||||||
|
GoPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defaults sets the default project template
|
// Defaults sets the default project template
|
||||||
|
@ -26,6 +26,7 @@ func init() {
|
|||||||
var packageApp = false
|
var packageApp = false
|
||||||
var forceRebuild = false
|
var forceRebuild = false
|
||||||
var debugMode = false
|
var debugMode = false
|
||||||
|
var gopath = ""
|
||||||
var typescriptFilename = ""
|
var typescriptFilename = ""
|
||||||
var verbose = false
|
var verbose = false
|
||||||
var platform = ""
|
var platform = ""
|
||||||
@ -42,7 +43,8 @@ func init() {
|
|||||||
BoolFlag("d", "Build in Debug mode", &debugMode).
|
BoolFlag("d", "Build in Debug mode", &debugMode).
|
||||||
BoolFlag("verbose", "Verbose output", &verbose).
|
BoolFlag("verbose", "Verbose output", &verbose).
|
||||||
StringFlag("t", "Generate Typescript definitions to given file (at runtime)", &typescriptFilename).
|
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
|
var b strings.Builder
|
||||||
for _, plat := range getSupportedPlatforms() {
|
for _, plat := range getSupportedPlatforms() {
|
||||||
@ -97,6 +99,7 @@ func init() {
|
|||||||
|
|
||||||
// Add ldflags
|
// Add ldflags
|
||||||
projectOptions.LdFlags = ldflags
|
projectOptions.LdFlags = ldflags
|
||||||
|
projectOptions.GoPath = gopath
|
||||||
|
|
||||||
// Validate config
|
// Validate config
|
||||||
// Check if we have a frontend
|
// Check if we have a frontend
|
||||||
|
Loading…
Reference in New Issue
Block a user