Fixes #12536 (#12568) [backport]

This commit is contained in:
Tomohiro 2019-11-02 16:21:49 +09:00 • committed by Andreas Rumpf
commit 4e0f12092e
5 changed files with 38 additions and 14 deletions

View file

@ -627,21 +627,19 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
processOnOffSwitchG(conf, {optGenMapping}, arg, pass, info) processOnOffSwitchG(conf, {optGenMapping}, arg, pass, info)
of "os": of "os":
expectArg(conf, switch, arg, pass, info) expectArg(conf, switch, arg, pass, info)
if pass in {passCmd1, passPP}:
let theOS = platform.nameToOS(arg) let theOS = platform.nameToOS(arg)
if theOS == osNone: if theOS == osNone:
let osList = platform.listOSnames().join(", ") let osList = platform.listOSnames().join(", ")
localError(conf, info, "unknown OS: '$1'. Available options are: $2" % [arg, $osList]) localError(conf, info, "unknown OS: '$1'. Available options are: $2" % [arg, $osList])
elif theOS != conf.target.hostOS: else:
setTarget(conf.target, theOS, conf.target.targetCPU) setTarget(conf.target, theOS, conf.target.targetCPU)
of "cpu": of "cpu":
expectArg(conf, switch, arg, pass, info) expectArg(conf, switch, arg, pass, info)
if pass in {passCmd1, passPP}:
let cpu = platform.nameToCPU(arg) let cpu = platform.nameToCPU(arg)
if cpu == cpuNone: if cpu == cpuNone:
let cpuList = platform.listCPUnames().join(", ") let cpuList = platform.listCPUnames().join(", ")
localError(conf, info, "unknown CPU: '$1'. Available options are: $2" % [ arg, cpuList]) localError(conf, info, "unknown CPU: '$1'. Available options are: $2" % [ arg, cpuList])
elif cpu != conf.target.hostCPU: else:
setTarget(conf.target, conf.target.targetOS, cpu) setTarget(conf.target, conf.target.targetOS, cpu)
of "run", "r": of "run", "r":
processOnOffSwitchG(conf, {optRun}, arg, pass, info) processOnOffSwitchG(conf, {optRun}, arg, pass, info)

View file

@ -0,0 +1,10 @@
discard """
cmd: "nim $target $options --cpu:amd64 $file"
disabled: "32bit"
"""
import strutils
static:
#cpu is set to "i386" in tcpuamd64.nim.cfg, but --cpu:amd64 in command line should override it.
doAssert cmpIgnoreCase(hostCPU, "amd64") == 0

View file

@ -0,0 +1 @@
cpu:i386

View file

@ -0,0 +1,14 @@
discard """
cmd: "nim $target $options --os:windows $file"
disabled: "linux"
disabled: "bsd"
disabled: "macosx"
disabled: "unix"
disabled: "posix"
"""
import strutils
static:
#os is set to "linux" in toswin.nim.cfg, but --os:windows in command line should override it.
doAssert cmpIgnoreCase(hostOS, "windows") == 0

View file

@ -0,0 +1 @@
os:linux