diff --git a/compiler/commands.nim b/compiler/commands.nim index 994442af0..298fbdc89 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -615,14 +615,18 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; expectArg(conf, switch, arg, pass, info) if pass in {passCmd1, passPP}: let theOS = platform.nameToOS(arg) - if theOS == osNone: localError(conf, info, "unknown OS: '$1'" % arg) + if theOS == osNone: + let osList = platform.listOSnames().join(", ") + localError(conf, info, "unknown OS: '$1'. Available options are: $2" % [arg, $osList]) elif theOS != conf.target.hostOS: setTarget(conf.target, theOS, conf.target.targetCPU) of "cpu": expectArg(conf, switch, arg, pass, info) if pass in {passCmd1, passPP}: let cpu = platform.nameToCPU(arg) - if cpu == cpuNone: localError(conf, info, "unknown CPU: '$1'" % arg) + if cpu == cpuNone: + let cpuList = platform.listCPUnames().join(", ") + localError(conf, info, "unknown CPU: '$1'. Available options are: $2" % [ arg, cpuList]) elif cpu != conf.target.hostCPU: setTarget(conf.target, conf.target.targetOS, cpu) of "run", "r": diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 201719b1d..1ec7e6868 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -375,6 +375,10 @@ proc nameToCC*(name: string): TSystemCC = return i result = ccNone +proc listCCnames(): seq[string] = + for i in succ(ccNone) .. high(TSystemCC): + result.add CC[i].name + proc isVSCompatible*(conf: ConfigRef): bool = return conf.cCompiler == ccVcc or conf.cCompiler == ccClangCl or @@ -408,7 +412,8 @@ proc getConfigVar(conf: ConfigRef; c: TSystemCC, suffix: string): string = proc setCC*(conf: ConfigRef; ccname: string; info: TLineInfo) = conf.cCompiler = nameToCC(ccname) if conf.cCompiler == ccNone: - localError(conf, info, "unknown C compiler: '$1'" % ccname) + let ccList = listCCnames().join(", ") + localError(conf, info, "unknown C compiler: '$1'. Available options are: $2" % [ccname, ccList]) conf.compileOptions = getConfigVar(conf, conf.cCompiler, ".options.always") conf.linkOptions = "" conf.ccompilerpath = getConfigVar(conf, conf.cCompiler, ".path") diff --git a/compiler/platform.nim b/compiler/platform.nim index d5a76024e..2dee33b75 100644 --- a/compiler/platform.nim +++ b/compiler/platform.nim @@ -242,12 +242,20 @@ proc nameToOS*(name: string): TSystemOS = return i result = osNone +proc listOSnames*(): seq[string] = + for i in succ(osNone) .. high(TSystemOS): + result.add OS[i].name + proc nameToCPU*(name: string): TSystemCPU = for i in succ(cpuNone) .. high(TSystemCPU): if cmpIgnoreStyle(name, CPU[i].name) == 0: return i result = cpuNone +proc listCPUnames*(): seq[string] = + for i in succ(cpuNone) .. high(TSystemCPU): + result.add CPU[i].name + proc setTargetFromSystem*(t: var Target) = t.hostOS = nameToOS(system.hostOS) t.hostCPU = nameToCPU(system.hostCPU)