mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-17 09:29:30 +08:00
Support user tags
This commit is contained in:
parent
be43049fc6
commit
5d444cd6dd
@ -54,6 +54,10 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
ldflags := ""
|
ldflags := ""
|
||||||
command.StringFlag("ldflags", "optional ldflags", &ldflags)
|
command.StringFlag("ldflags", "optional ldflags", &ldflags)
|
||||||
|
|
||||||
|
// tags to pass to `go`
|
||||||
|
tags := ""
|
||||||
|
command.StringFlag("tags", "tags to pass to Go compiler (quoted and space separated)", &tags)
|
||||||
|
|
||||||
// Log to file
|
// Log to file
|
||||||
//logFile := ""
|
//logFile := ""
|
||||||
//command.StringFlag("l", "Log to file", &logFile)
|
//command.StringFlag("l", "Log to file", &logFile)
|
||||||
@ -121,6 +125,16 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
println("Warning: compress flag unsupported for universal binaries. Ignoring.")
|
println("Warning: compress flag unsupported for universal binaries. Ignoring.")
|
||||||
compress = false
|
compress = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
userTags := []string{}
|
||||||
|
for _, tag := range strings.Split(tags, " ") {
|
||||||
|
thisTag := strings.TrimSpace(tag)
|
||||||
|
if thisTag != "" {
|
||||||
|
userTags = append(userTags, thisTag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create BuildOptions
|
// Create BuildOptions
|
||||||
buildOptions := &build.Options{
|
buildOptions := &build.Options{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
@ -135,6 +149,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
AppleIdentity: appleIdentity,
|
AppleIdentity: appleIdentity,
|
||||||
Verbosity: verbosity,
|
Verbosity: verbosity,
|
||||||
Compress: compress,
|
Compress: compress,
|
||||||
|
UserTags: userTags,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate platform and arch
|
// Calculate platform and arch
|
||||||
@ -166,6 +181,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
fmt.Fprintf(w, "Clean Build Dir: \t%t\n", buildOptions.CleanBuildDirectory)
|
fmt.Fprintf(w, "Clean Build Dir: \t%t\n", buildOptions.CleanBuildDirectory)
|
||||||
fmt.Fprintf(w, "KeepAssets: \t%t\n", buildOptions.KeepAssets)
|
fmt.Fprintf(w, "KeepAssets: \t%t\n", buildOptions.KeepAssets)
|
||||||
fmt.Fprintf(w, "LDFlags: \t\"%s\"\n", buildOptions.LDFlags)
|
fmt.Fprintf(w, "LDFlags: \t\"%s\"\n", buildOptions.LDFlags)
|
||||||
|
fmt.Fprintf(w, "Tags: \t[%s]\n", strings.Join(buildOptions.UserTags, ","))
|
||||||
if len(buildOptions.OutputFile) > 0 {
|
if len(buildOptions.OutputFile) > 0 {
|
||||||
fmt.Fprintf(w, "Output File: \t%s\n", buildOptions.OutputFile)
|
fmt.Fprintf(w, "Output File: \t%s\n", buildOptions.OutputFile)
|
||||||
}
|
}
|
||||||
|
@ -190,10 +190,11 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
|
|||||||
|
|
||||||
var tags slicer.StringSlicer
|
var tags slicer.StringSlicer
|
||||||
tags.Add(options.OutputType)
|
tags.Add(options.OutputType)
|
||||||
|
tags.AddSlice(options.UserTags)
|
||||||
if options.Mode == Debug {
|
if options.Mode == Debug {
|
||||||
tags.Add("debug")
|
tags.Add("debug")
|
||||||
}
|
}
|
||||||
|
tags.Deduplicate()
|
||||||
|
|
||||||
// Add the output type build tag
|
// Add the output type build tag
|
||||||
commands.Add("-tags")
|
commands.Add("-tags")
|
||||||
|
@ -29,6 +29,7 @@ var modeMap = []string{"Debug", "Production"}
|
|||||||
// Options contains all the build options as well as the project data
|
// Options contains all the build options as well as the project data
|
||||||
type Options struct {
|
type Options struct {
|
||||||
LDFlags string // Optional flags to pass to linker
|
LDFlags string // Optional flags to pass to linker
|
||||||
|
UserTags []string // Tags to pass to the Go compiler
|
||||||
Logger *clilogger.CLILogger // All output to the logger
|
Logger *clilogger.CLILogger // All output to the logger
|
||||||
OutputType string // EG: desktop, server....
|
OutputType string // EG: desktop, server....
|
||||||
Mode Mode // release or debug
|
Mode Mode // release or debug
|
||||||
|
Loading…
Reference in New Issue
Block a user