fix #9629 every binary cmd line option allows on/off/empty=on (#10353)

* fix #9629 every binary cmd line option allows on/off/empty=on

* workaround refs #10359
This commit is contained in:
Timothee Cour 2019-01-18 00:03:26 -08:00 • committed by Andreas Rumpf
commit 27e2ed4375
4 changed files with 43 additions and 58 deletions

View file

@ -142,7 +142,7 @@ proc splitSwitch(conf: ConfigRef; switch: string, cmd, arg: var string, pass: TC
proc processOnOffSwitch(conf: ConfigRef; op: TOptions, arg: string, pass: TCmdLinePass, proc processOnOffSwitch(conf: ConfigRef; op: TOptions, arg: string, pass: TCmdLinePass,
info: TLineInfo) = info: TLineInfo) =
case arg.normalize case arg.normalize
of "on": conf.options = conf.options + op of "","on": conf.options = conf.options + op
of "off": conf.options = conf.options - op of "off": conf.options = conf.options - op
else: localError(conf, info, errOnOrOffExpectedButXFound % arg) else: localError(conf, info, errOnOrOffExpectedButXFound % arg)
@ -158,7 +158,7 @@ proc processOnOffSwitchOrList(conf: ConfigRef; op: TOptions, arg: string, pass:
proc processOnOffSwitchG(conf: ConfigRef; op: TGlobalOptions, arg: string, pass: TCmdLinePass, proc processOnOffSwitchG(conf: ConfigRef; op: TGlobalOptions, arg: string, pass: TCmdLinePass,
info: TLineInfo) = info: TLineInfo) =
case arg.normalize case arg.normalize
of "on": conf.globalOptions = conf.globalOptions + op of "", "on": conf.globalOptions = conf.globalOptions + op
of "off": conf.globalOptions = conf.globalOptions - op of "off": conf.globalOptions = conf.globalOptions - op
else: localError(conf, info, errOnOrOffExpectedButXFound % arg) else: localError(conf, info, errOnOrOffExpectedButXFound % arg)
@ -414,26 +414,19 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
if pass in {passCmd2, passPP}: if pass in {passCmd2, passPP}:
addExternalFileToLink(conf, AbsoluteFile arg) addExternalFileToLink(conf, AbsoluteFile arg)
of "debuginfo": of "debuginfo":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optCDebug}, arg, pass, info)
incl(conf.globalOptions, optCDebug)
of "embedsrc": of "embedsrc":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optEmbedOrigSrc}, arg, pass, info)
incl(conf.globalOptions, optEmbedOrigSrc)
of "compileonly", "c": of "compileonly", "c":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optCompileOnly}, arg, pass, info)
incl(conf.globalOptions, optCompileOnly)
of "nolinking": of "nolinking":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optNoLinking}, arg, pass, info)
incl(conf.globalOptions, optNoLinking)
of "nomain": of "nomain":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optNoMain}, arg, pass, info)
incl(conf.globalOptions, optNoMain)
of "forcebuild", "f": of "forcebuild", "f":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optForceFullMake}, arg, pass, info)
incl(conf.globalOptions, optForceFullMake)
of "project": of "project":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optWholeProject}, arg, pass, info)
incl conf.globalOptions, optWholeProject
of "gc": of "gc":
expectArg(conf, switch, arg, pass, info) expectArg(conf, switch, arg, pass, info)
case arg.normalize case arg.normalize
@ -499,7 +492,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
else: undefSymbol(conf.symbols, "hotcodereloading") else: undefSymbol(conf.symbols, "hotcodereloading")
of "oldnewlines": of "oldnewlines":
case arg.normalize case arg.normalize
of "on": of "","on":
conf.oldNewlines = true conf.oldNewlines = true
defineSymbol(conf.symbols, "nimOldNewlines") defineSymbol(conf.symbols, "nimOldNewlines")
of "off": of "off":
@ -599,11 +592,9 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
if pass in {passCmd2, passPP}: if pass in {passCmd2, passPP}:
conf.implicitIncludes.add findModule(conf, arg, toFullPath(conf, info)).string conf.implicitIncludes.add findModule(conf, arg, toFullPath(conf, info)).string
of "listcmd": of "listcmd":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optListCmd}, arg, pass, info)
incl(conf.globalOptions, optListCmd)
of "genmapping": of "genmapping":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optGenMapping}, arg, pass, info)
incl(conf.globalOptions, optGenMapping)
of "os": of "os":
expectArg(conf, switch, arg, pass, info) expectArg(conf, switch, arg, pass, info)
if pass in {passCmd1, passPP}: if pass in {passCmd1, passPP}:
@ -619,8 +610,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
elif cpu != conf.target.hostCPU: elif cpu != conf.target.hostCPU:
setTarget(conf.target, conf.target.targetOS, cpu) setTarget(conf.target, conf.target.targetOS, cpu)
of "run", "r": of "run", "r":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optRun}, arg, pass, info)
incl(conf.globalOptions, optRun)
of "errormax": of "errormax":
expectArg(conf, switch, arg, pass, info) expectArg(conf, switch, arg, pass, info)
# Note: `nim check` (etc) can overwrite this. # Note: `nim check` (etc) can overwrite this.
@ -668,21 +658,16 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
of "v2": conf.symbolFiles = v2Sf of "v2": conf.symbolFiles = v2Sf
else: localError(conf, info, "invalid option for --incremental: " & arg) else: localError(conf, info, "invalid option for --incremental: " & arg)
of "skipcfg": of "skipcfg":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optSkipSystemConfigFile}, arg, pass, info)
incl(conf.globalOptions, optSkipSystemConfigFile)
of "skipprojcfg": of "skipprojcfg":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optSkipProjConfigFile}, arg, pass, info)
incl(conf.globalOptions, optSkipProjConfigFile)
of "skipusercfg": of "skipusercfg":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optSkipUserConfigFile}, arg, pass, info)
incl(conf.globalOptions, optSkipUserConfigFile)
of "skipparentcfg": of "skipparentcfg":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optSkipParentConfigFiles}, arg, pass, info)
incl(conf.globalOptions, optSkipParentConfigFiles)
of "genscript", "gendeps": of "genscript", "gendeps":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optGenScript}, arg, pass, info)
incl(conf.globalOptions, optGenScript) processOnOffSwitchG(conf, {optCompileOnly}, arg, pass, info)
incl(conf.globalOptions, optCompileOnly)
of "colors": processOnOffSwitchG(conf, {optUseColors}, arg, pass, info) of "colors": processOnOffSwitchG(conf, {optUseColors}, arg, pass, info)
of "lib": of "lib":
expectArg(conf, switch, arg, pass, info) expectArg(conf, switch, arg, pass, info)
@ -716,16 +701,13 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
expectNoArg(conf, switch, arg, pass, info) expectNoArg(conf, switch, arg, pass, info)
conf.ideCmd = ideUse conf.ideCmd = ideUse
of "stdout": of "stdout":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optStdout}, arg, pass, info)
incl(conf.globalOptions, optStdout)
of "listfullpaths": of "listfullpaths":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optListFullPaths}, arg, pass, info)
incl conf.globalOptions, optListFullPaths
of "dynliboverride": of "dynliboverride":
dynlibOverride(conf, switch, arg, pass, info) dynlibOverride(conf, switch, arg, pass, info)
of "dynliboverrideall": of "dynliboverrideall":
expectNoArg(conf, switch, arg, pass, info) processOnOffSwitchG(conf, {optDynlibOverrideAll}, arg, pass, info)
incl conf.globalOptions, optDynlibOverrideAll
of "cs": of "cs":
# only supported for compatibility. Does nothing. # only supported for compatibility. Does nothing.
expectArg(conf, switch, arg, pass, info) expectArg(conf, switch, arg, pass, info)

View file

@ -18,9 +18,9 @@ Advanced commands:
Advanced options: Advanced options:
-o:FILE, --out:FILE set the output filename -o:FILE, --out:FILE set the output filename
--stdout output to stdout --stdout:on|off output to stdout
--colors:on|off turn compiler messages coloring on|off --colors:on|off turn compiler messages coloring on|off
--listFullPaths list full paths in messages --listFullPaths:on|off list full paths in messages
-w:on|off|list, --warnings:on|off|list -w:on|off|list, --warnings:on|off|list
turn all warnings on|off or list all available turn all warnings on|off or list all available
--warning[X]:on|off turn specific warning X on|off --warning[X]:on|off turn specific warning X on|off
@ -39,16 +39,16 @@ Advanced options:
--nimcache:PATH set the path used for generated files --nimcache:PATH set the path used for generated files
--header:FILE the compiler should produce a .h file (FILE --header:FILE the compiler should produce a .h file (FILE
is optional) is optional)
-c, --compileOnly compile Nim files only; do not assemble or link -c, --compileOnly:on|off compile Nim files only; do not assemble or link
--noLinking compile Nim and generated files but do not link --noLinking:on|off compile Nim and generated files but do not link
--noMain do not generate a main procedure --noMain:on|off do not generate a main procedure
--genScript generate a compile script (in the 'nimcache' --genScript:on|off generate a compile script (in the 'nimcache'
subdirectory named 'compile_$$project$$scriptext'), subdirectory named 'compile_$$project$$scriptext'),
implies --compileOnly implies --compileOnly
--genDeps generate a '.deps' file containing the dependencies --genDeps:on|off generate a '.deps' file containing the dependencies
--os:SYMBOL set the target operating system (cross-compilation) --os:SYMBOL set the target operating system (cross-compilation)
--cpu:SYMBOL set the target processor (cross-compilation) --cpu:SYMBOL set the target processor (cross-compilation)
--debuginfo enables debug information --debuginfo:on|off enables debug information
-t, --passC:OPTION pass an option to the C compiler -t, --passC:OPTION pass an option to the C compiler
-l, --passL:OPTION pass an option to the linker -l, --passL:OPTION pass an option to the linker
--cincludes:DIR modify the C compiler header search path --cincludes:DIR modify the C compiler header search path
@ -59,7 +59,7 @@ Advanced options:
--docSeeSrcUrl:url activate 'see source' for doc and doc2 commands --docSeeSrcUrl:url activate 'see source' for doc and doc2 commands
(see doc.item.seesrc in config/nimdoc.cfg) (see doc.item.seesrc in config/nimdoc.cfg)
--lineDir:on|off generation of #line directive on|off --lineDir:on|off generation of #line directive on|off
--embedsrc embeds the original source code as comments --embedsrc:on|off embeds the original source code as comments
in the generated output in the generated output
--threadanalysis:on|off turn thread analysis on|off --threadanalysis:on|off turn thread analysis on|off
--tlsEmulation:on|off turn thread local storage emulation on|off --tlsEmulation:on|off turn thread local storage emulation on|off
@ -77,10 +77,10 @@ Advanced options:
--nilseqs:on|off allow 'nil' for strings/seqs for --nilseqs:on|off allow 'nil' for strings/seqs for
backwards compatibility backwards compatibility
--oldast:on|off use old AST for backwards compatibility --oldast:on|off use old AST for backwards compatibility
--skipCfg do not read the nim installation's configuration file --skipCfg:on|off do not read the nim installation's configuration file
--skipUserCfg do not read the user's configuration file --skipUserCfg:on|off do not read the user's configuration file
--skipParentCfg do not read the parent dirs' configuration files --skipParentCfg:on|off do not read the parent dirs' configuration files
--skipProjCfg do not read the project's configuration file --skipProjCfg:on|off do not read the project's configuration file
--gc:refc|markAndSweep|boehm|go|none|regions --gc:refc|markAndSweep|boehm|go|none|regions
select the GC to use; default is 'refc' select the GC to use; default is 'refc'
--index:on|off turn index file generation on|off --index:on|off turn index file generation on|off
@ -97,8 +97,8 @@ Advanced options:
symbol matching is fuzzy so symbol matching is fuzzy so
that --dynlibOverride:lua matches that --dynlibOverride:lua matches
dynlib: "liblua.so.3" dynlib: "liblua.so.3"
--dynlibOverrideAll makes the dynlib pragma have no effect --dynlibOverrideAll:on|off makes the dynlib pragma have no effect
--listCmd list the commands used to execute external programs --listCmd:on|off list the commands used to execute external programs
--parallelBuild:0|1|... perform a parallel build --parallelBuild:0|1|... perform a parallel build
value = number of processors (0 for auto-detect) value = number of processors (0 for auto-detect)
--incremental:on|off only recompile the changed modules (experimental!) --incremental:on|off only recompile the changed modules (experimental!)

View file

@ -15,7 +15,7 @@ Options:
(Optionally: Define the value for that symbol, (Optionally: Define the value for that symbol,
see: "compile time define pragmas") see: "compile time define pragmas")
-u, --undef:SYMBOL undefine a conditional symbol -u, --undef:SYMBOL undefine a conditional symbol
-f, --forceBuild force rebuilding of all modules -f, --forceBuild:on|off force rebuilding of all modules
--stackTrace:on|off turn stack tracing on|off --stackTrace:on|off turn stack tracing on|off
--lineTrace:on|off turn line tracing on|off --lineTrace:on|off turn line tracing on|off
--threads:on|off turn support for multi-threading on|off --threads:on|off turn support for multi-threading on|off
@ -35,7 +35,7 @@ Options:
--debugger:native|endb use native debugger (gdb) | ENDB (experimental) --debugger:native|endb use native debugger (gdb) | ENDB (experimental)
--app:console|gui|lib|staticlib --app:console|gui|lib|staticlib
generate a console app|GUI app|DLL|static library generate a console app|GUI app|DLL|static library
-r, --run run the compiled program with given arguments -r, --run:on|off run the compiled program with given arguments
--fullhelp show all command line switches --fullhelp show all command line switches
-h, --help show this help -h, --help show this help

View file

@ -121,7 +121,10 @@ else:
block: # fix #9842 block: # fix #9842
let exe = buildDir / "D20190112T145450".addFileExt(ExeExt) let exe = buildDir / "D20190112T145450".addFileExt(ExeExt)
defer: removeFile exe defer:
when not defined(windows):
# workaround #10359 ; innocuous to skip since we're saving under `buildDir`
removeFile exe
let args = @["a1b", "a2 b", "", "a4\"b", "a5'b", r"a6\b", "a7\'b"] let args = @["a1b", "a2 b", "", "a4\"b", "a5'b", r"a6\b", "a7\'b"]
let cmd = "$# c -r --verbosity:0 -o:$# -d:testament_tparseopt $# $#" % let cmd = "$# c -r --verbosity:0 -o:$# -d:testament_tparseopt $# $#" %
[getCurrentCompilerExe(), exe, currentSourcePath(), [getCurrentCompilerExe(), exe, currentSourcePath(),