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 {
|
||||||
|
@ -21,6 +21,7 @@ type Config struct {
|
|||||||
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
|
||||||
}
|
}
|
||||||
@ -87,6 +89,7 @@ func SaveConfig() (string, error) {
|
|||||||
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 {
|
||||||
|
2
main.go
2
main.go
@ -38,6 +38,7 @@ var (
|
|||||||
DefaultSilent = false
|
DefaultSilent = false
|
||||||
DefaultNoCompress = false
|
DefaultNoCompress = false
|
||||||
DefaultNumThreads = runtime.NumCPU()
|
DefaultNumThreads = runtime.NumCPU()
|
||||||
|
DefaultKeepDebugFlags = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// command line arguments
|
// command line arguments
|
||||||
@ -51,6 +52,7 @@ var (
|
|||||||
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