remove debug flags by default
This commit is contained in:
parent
bd0ed87f70
commit
8ec8d32a5b
@ -35,7 +35,12 @@ func Compile(cfg *CompileConfig, ch chan<- *CompileReport, wg *sync.WaitGroup) {
|
|||||||
|
|
||||||
ch <- &CompileReport{Config: cfg, State: StateCompiling}
|
ch <- &CompileReport{Config: cfg, State: StateCompiling}
|
||||||
|
|
||||||
compileCmd := exec.Command("go", "build", "-o", filePath)
|
args := []string{"build", "-o", filePath}
|
||||||
|
if !*KeepDebugFlags {
|
||||||
|
args = append(args, "-ldflags=-s -w")
|
||||||
|
}
|
||||||
|
|
||||||
|
compileCmd := exec.Command("go", args...)
|
||||||
compileCmd.Dir = ModulePath
|
compileCmd.Dir = ModulePath
|
||||||
|
|
||||||
if err := compileCmd.Start(); err != nil {
|
if err := compileCmd.Start(); err != nil {
|
||||||
|
23
config.go
23
config.go
@ -18,9 +18,10 @@ type Config struct {
|
|||||||
OS []string `json:"os"`
|
OS []string `json:"os"`
|
||||||
Arch []string `json:"arch"`
|
Arch []string `json:"arch"`
|
||||||
|
|
||||||
Silent bool `json:"silent"`
|
Silent bool `json:"silent"`
|
||||||
NoCompress bool `json:"no_compress"`
|
NoCompress bool `json:"no_compress"`
|
||||||
NumThreads int `json:"num_threads"`
|
NumThreads int `json:"num_threads"`
|
||||||
|
KeepDebugFlags bool `json:"debug_flags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetFlagIfDefault[T comparable](flag *T, newValue T, defaultValue T) {
|
func SetFlagIfDefault[T comparable](flag *T, newValue T, defaultValue T) {
|
||||||
@ -56,6 +57,7 @@ func LoadConfig() error {
|
|||||||
SetFlagIfDefault(Silent, cfg.Silent, DefaultSilent)
|
SetFlagIfDefault(Silent, cfg.Silent, DefaultSilent)
|
||||||
SetFlagIfDefault(NoCompress, cfg.NoCompress, DefaultNoCompress)
|
SetFlagIfDefault(NoCompress, cfg.NoCompress, DefaultNoCompress)
|
||||||
SetFlagIfDefault(NumThreads, cfg.NumThreads, DefaultNumThreads)
|
SetFlagIfDefault(NumThreads, cfg.NumThreads, DefaultNumThreads)
|
||||||
|
SetFlagIfDefault(KeepDebugFlags, cfg.KeepDebugFlags, DefaultKeepDebugFlags)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -80,13 +82,14 @@ func SaveConfig() (string, error) {
|
|||||||
enc.SetIndent("", "\t")
|
enc.SetIndent("", "\t")
|
||||||
|
|
||||||
cfg := &Config{
|
cfg := &Config{
|
||||||
OutputDir: *OutputDir,
|
OutputDir: *OutputDir,
|
||||||
OutputFile: *OutputFile,
|
OutputFile: *OutputFile,
|
||||||
OS: strings.Split(*OS, ","),
|
OS: strings.Split(*OS, ","),
|
||||||
Arch: strings.Split(*Arch, ","),
|
Arch: strings.Split(*Arch, ","),
|
||||||
Silent: *Silent,
|
Silent: *Silent,
|
||||||
NoCompress: *NoCompress,
|
NoCompress: *NoCompress,
|
||||||
NumThreads: *NumThreads,
|
NumThreads: *NumThreads,
|
||||||
|
KeepDebugFlags: *KeepDebugFlags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := enc.Encode(cfg); err != nil {
|
if err := enc.Encode(cfg); err != nil {
|
||||||
|
22
main.go
22
main.go
@ -31,13 +31,14 @@ var (
|
|||||||
|
|
||||||
// command line arguments default values
|
// command line arguments default values
|
||||||
var (
|
var (
|
||||||
DefaultOutputDir = "output"
|
DefaultOutputDir = "output"
|
||||||
DefaultOutputFile = "{{.Name}}-{{.OS}}-{{.Arch}}{{.Ext}}"
|
DefaultOutputFile = "{{.Name}}-{{.OS}}-{{.Arch}}{{.Ext}}"
|
||||||
DefaultOS = ""
|
DefaultOS = ""
|
||||||
DefaultArch = ""
|
DefaultArch = ""
|
||||||
DefaultSilent = false
|
DefaultSilent = false
|
||||||
DefaultNoCompress = false
|
DefaultNoCompress = false
|
||||||
DefaultNumThreads = runtime.NumCPU()
|
DefaultNumThreads = runtime.NumCPU()
|
||||||
|
DefaultKeepDebugFlags = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// command line arguments
|
// command line arguments
|
||||||
@ -48,9 +49,10 @@ var (
|
|||||||
OS = flag.String("os", DefaultOS, "comma-separated list of operating systems to compile for (empty for all)")
|
OS = flag.String("os", DefaultOS, "comma-separated list of operating systems to compile for (empty for all)")
|
||||||
Arch = flag.String("arch", DefaultArch, "comma-separated list of architectures to compile for (empty for all)")
|
Arch = flag.String("arch", DefaultArch, "comma-separated list of architectures to compile for (empty for all)")
|
||||||
|
|
||||||
Silent = flag.Bool("s", DefaultSilent, "silent mode (no output)")
|
Silent = flag.Bool("s", DefaultSilent, "silent mode (no output)")
|
||||||
NoCompress = flag.Bool("c", DefaultNoCompress, "dont compress any executables")
|
NoCompress = flag.Bool("c", DefaultNoCompress, "dont compress any executables")
|
||||||
NumThreads = flag.Int("t", DefaultNumThreads, "amount of threads (0 = infinite)")
|
NumThreads = flag.Int("t", DefaultNumThreads, "amount of threads (0 = infinite)")
|
||||||
|
KeepDebugFlags = flag.Bool("d", DefaultKeepDebugFlags, "keep debug flags")
|
||||||
|
|
||||||
SaveConfigFile = flag.Bool("saveconfig", false, "save config file with current configuration and exit")
|
SaveConfigFile = flag.Bool("saveconfig", false, "save config file with current configuration and exit")
|
||||||
IgnoreConfigFile = flag.Bool("ignoreconfig", false, "dont read any config file")
|
IgnoreConfigFile = flag.Bool("ignoreconfig", false, "dont read any config file")
|
||||||
|
Loading…
Reference in New Issue
Block a user