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}
|
||||
|
||||
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
|
||||
|
||||
if err := compileCmd.Start(); err != nil {
|
||||
|
@ -21,6 +21,7 @@ type Config struct {
|
||||
Silent bool `json:"silent"`
|
||||
NoCompress bool `json:"no_compress"`
|
||||
NumThreads int `json:"num_threads"`
|
||||
KeepDebugFlags bool `json:"debug_flags"`
|
||||
}
|
||||
|
||||
func SetFlagIfDefault[T comparable](flag *T, newValue T, defaultValue T) {
|
||||
@ -56,6 +57,7 @@ func LoadConfig() error {
|
||||
SetFlagIfDefault(Silent, cfg.Silent, DefaultSilent)
|
||||
SetFlagIfDefault(NoCompress, cfg.NoCompress, DefaultNoCompress)
|
||||
SetFlagIfDefault(NumThreads, cfg.NumThreads, DefaultNumThreads)
|
||||
SetFlagIfDefault(KeepDebugFlags, cfg.KeepDebugFlags, DefaultKeepDebugFlags)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -87,6 +89,7 @@ func SaveConfig() (string, error) {
|
||||
Silent: *Silent,
|
||||
NoCompress: *NoCompress,
|
||||
NumThreads: *NumThreads,
|
||||
KeepDebugFlags: *KeepDebugFlags,
|
||||
}
|
||||
|
||||
if err := enc.Encode(cfg); err != nil {
|
||||
|
2
main.go
2
main.go
@ -38,6 +38,7 @@ var (
|
||||
DefaultSilent = false
|
||||
DefaultNoCompress = false
|
||||
DefaultNumThreads = runtime.NumCPU()
|
||||
DefaultKeepDebugFlags = false
|
||||
)
|
||||
|
||||
// command line arguments
|
||||
@ -51,6 +52,7 @@ var (
|
||||
Silent = flag.Bool("s", DefaultSilent, "silent mode (no output)")
|
||||
NoCompress = flag.Bool("c", DefaultNoCompress, "dont compress any executables")
|
||||
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")
|
||||
IgnoreConfigFile = flag.Bool("ignoreconfig", false, "dont read any config file")
|
||||
|
Loading…
Reference in New Issue
Block a user