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

[windows-x] Improve compiler flags (big speedup)

This commit is contained in:
Lea Anthony 2021-08-26 23:23:30 +10:00
parent a861aa36b9
commit 01de76a32e

View File

@ -206,12 +206,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
commands.Add(`"all=-N -l"`)
}
// TODO: Work out if we can make this more efficient
// We need to do a full build as CGO doesn't detect updates
// to .h files, and we package assets into .h file. We could
// potentially try and see if the assets have changed but will
// this take as much time as a `-a` build?
commands.Add("-a")
//commands.Add("-a")
var tags slicer.StringSlicer
tags.Add(options.OutputType)
@ -289,22 +284,28 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
cmd.Env = os.Environ() // inherit env
// Use upsertEnv so we don't overwrite user's CGO_CFLAGS
cmd.Env = upsertEnv(cmd.Env, "CGO_CFLAGS", func(v string) string {
if v != "" {
v += " "
}
v += "-I" + buildBaseDir
return v
})
// Use upsertEnv so we don't overwrite user's CGO_CXXFLAGS
cmd.Env = upsertEnv(cmd.Env, "CGO_CXXFLAGS", func(v string) string {
if v != "" {
v += " "
}
v += "-I" + buildBaseDir
return v
})
if options.Platform != "windows" {
// Use upsertEnv so we don't overwrite user's CGO_CFLAGS
cmd.Env = upsertEnv(cmd.Env, "CGO_CFLAGS", func(v string) string {
if v != "" {
v += " "
}
v += "-I" + buildBaseDir
return v
})
// Use upsertEnv so we don't overwrite user's CGO_CXXFLAGS
cmd.Env = upsertEnv(cmd.Env, "CGO_CXXFLAGS", func(v string) string {
if v != "" {
v += " "
}
v += "-I" + buildBaseDir
return v
})
cmd.Env = upsertEnv(cmd.Env, "CGO_ENABLED", func(v string) string {
return "1"
})
}
cmd.Env = upsertEnv(cmd.Env, "GOOS", func(v string) string {
return options.Platform
@ -314,10 +315,6 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
return options.Arch
})
cmd.Env = upsertEnv(cmd.Env, "CGO_ENABLED", func(v string) string {
return "1"
})
if verbose {
println(" Environment:", strings.Join(cmd.Env, " "))
}
@ -364,6 +361,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
if verbose {
println(string(output))
}
return nil
}