diff options
Diffstat (limited to 'pkg/tool/flags.go')
| -rw-r--r-- | pkg/tool/flags.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/tool/flags.go b/pkg/tool/flags.go index ec0d3015f..c74026540 100644 --- a/pkg/tool/flags.go +++ b/pkg/tool/flags.go @@ -9,9 +9,11 @@ import ( "errors" "flag" "fmt" + "sort" "strings" "github.com/google/syzkaller/pkg/log" + "github.com/google/syzkaller/sys/targets" ) type Flag struct { @@ -50,6 +52,30 @@ func ParseFlags(set *flag.FlagSet, args []string) error { return nil } +func ParseArchList(OS, archList string) ([]string, error) { + allArches := targets.List[OS] + if allArches == nil { + return nil, fmt.Errorf("bad OS %q", OS) + } + archMap := make(map[string]bool) + if archList != "" { + for _, arch := range strings.Split(archList, ",") { + if allArches[arch] == nil { + return nil, fmt.Errorf("bad arch %q for OS %q in arches flag", arch, OS) + } + archMap[arch] = true + } + } + var arches []string + for arch := range allArches { + if len(archMap) == 0 || archMap[arch] { + arches = append(arches, arch) + } + } + sort.Strings(arches) + return arches, nil +} + const optionalFlag = "optional" func serializeFlags(flags []Flag) string { |
