cl: switch debug symbols with LLGO_DEBUG
This commit is contained in:
@@ -120,10 +120,8 @@ const (
|
||||
)
|
||||
|
||||
func Do(args []string, conf *Config) {
|
||||
flags, patterns, verbose, dbg := ParseArgs(args, buildFlags)
|
||||
if dbg {
|
||||
cl.EnableDebugSymbols()
|
||||
}
|
||||
flags, patterns, verbose := ParseArgs(args, buildFlags)
|
||||
cl.EnableDebugSymbols(IsDebugEnabled())
|
||||
flags = append(flags, "-tags", "llgo")
|
||||
cfg := &packages.Config{
|
||||
Mode: loadSyntax | packages.NeedDeps | packages.NeedModule | packages.NeedExportFile,
|
||||
@@ -602,7 +600,6 @@ var (
|
||||
"-cover": false, // -cover: enable coverage analysis
|
||||
"-covermode": true, // -covermode mode: set the mode for coverage analysis
|
||||
"-v": false, // -v: print the names of packages as they are compiled
|
||||
"-dbg": false, // -dbg: build with debug symbols (temporarily)
|
||||
"-work": false, // -work: print the name of the temporary work directory and do not delete it when exiting
|
||||
"-x": false, // -x: print the commands
|
||||
"-tags": true, // -tags 'tag,list': a space-separated list of build tags to consider satisfied during the build
|
||||
@@ -611,19 +608,22 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func ParseArgs(args []string, swflags map[string]bool) (flags, patterns []string, verbose, dbg bool) {
|
||||
const llgoDebug = "LLGO_DEBUG"
|
||||
|
||||
func IsDebugEnabled() bool {
|
||||
llgoDbgVal := strings.ToLower(os.Getenv(llgoDebug))
|
||||
return llgoDbgVal == "1" || llgoDbgVal == "true" || llgoDbgVal == "on"
|
||||
}
|
||||
|
||||
func ParseArgs(args []string, swflags map[string]bool) (flags, patterns []string, verbose bool) {
|
||||
n := len(args)
|
||||
for i := 0; i < n; i++ {
|
||||
arg := args[i]
|
||||
if strings.HasPrefix(arg, "-") {
|
||||
checkFlag(arg, &i, &verbose, &dbg, swflags)
|
||||
checkFlag(arg, &i, &verbose, swflags)
|
||||
} else {
|
||||
patterns = args[i:]
|
||||
for _, arg := range args[:i] {
|
||||
if arg != "-dbg" {
|
||||
flags = append(flags, arg)
|
||||
}
|
||||
}
|
||||
flags = args[:i]
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -635,7 +635,7 @@ func SkipFlagArgs(args []string) int {
|
||||
for i := 0; i < n; i++ {
|
||||
arg := args[i]
|
||||
if strings.HasPrefix(arg, "-") {
|
||||
checkFlag(arg, &i, nil, nil, buildFlags)
|
||||
checkFlag(arg, &i, nil, buildFlags)
|
||||
} else {
|
||||
return i
|
||||
}
|
||||
@@ -643,7 +643,7 @@ func SkipFlagArgs(args []string) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
func checkFlag(arg string, i *int, verbose, dbg *bool, swflags map[string]bool) {
|
||||
func checkFlag(arg string, i *int, verbose *bool, swflags map[string]bool) {
|
||||
if pos := strings.IndexByte(arg, '='); pos > 0 {
|
||||
if verbose != nil && arg == "-v=true" {
|
||||
*verbose = true
|
||||
@@ -653,8 +653,6 @@ func checkFlag(arg string, i *int, verbose, dbg *bool, swflags map[string]bool)
|
||||
*i++
|
||||
} else if verbose != nil && arg == "-v" {
|
||||
*verbose = true
|
||||
} else if dbg != nil && arg == "-dbg" {
|
||||
*dbg = true
|
||||
}
|
||||
} else {
|
||||
panic("unknown flag: " + arg)
|
||||
|
||||
Reference in New Issue
Block a user