config system: special case -d:release and -d:danger [backport:1.4] (#18051)
This commit is contained in:
parent
a1c82c39af
commit
df429fa287
6 changed files with 27 additions and 7 deletions
|
|
@ -75,6 +75,10 @@
|
||||||
|
|
||||||
- `strformat` is now part of `include std/prelude`.
|
- `strformat` is now part of `include std/prelude`.
|
||||||
|
|
||||||
|
- The configuration subsystem now allows for `-d:release` and `-d:danger` to work as expected.
|
||||||
|
The downside is that these defines now have custom logic that doesn't apply for
|
||||||
|
other defines.
|
||||||
|
|
||||||
|
|
||||||
## Standard library additions and changes
|
## Standard library additions and changes
|
||||||
- Added support for parenthesized expressions in `strformat`
|
- Added support for parenthesized expressions in `strformat`
|
||||||
|
|
|
||||||
|
|
@ -482,6 +482,19 @@ proc setCommandEarly*(conf: ConfigRef, command: string) =
|
||||||
else:
|
else:
|
||||||
conf.foreignPackageNotes = foreignPackageNotesDefault
|
conf.foreignPackageNotes = foreignPackageNotesDefault
|
||||||
|
|
||||||
|
proc specialDefine(conf: ConfigRef, key: string) =
|
||||||
|
# Keep this syncronized with the default config/nim.cfg!
|
||||||
|
if cmpIgnoreStyle(key, "nimQuirky") == 0:
|
||||||
|
conf.exc = excQuirky
|
||||||
|
elif cmpIgnoreStyle(key, "release") == 0 or cmpIgnoreStyle(key, "danger") == 0:
|
||||||
|
conf.options.excl {optStackTrace, optLineTrace, optLineDir, optOptimizeSize}
|
||||||
|
conf.globalOptions.excl {optExcessiveStackTrace, optCDebug}
|
||||||
|
conf.options.incl optOptimizeSpeed
|
||||||
|
if cmpIgnoreStyle(key, "danger") == 0 or cmpIgnoreStyle(key, "quick") == 0:
|
||||||
|
conf.options.excl {optObjCheck, optFieldCheck, optRangeCheck, optBoundsCheck,
|
||||||
|
optOverflowCheck, optAssert, optStackTrace, optLineTrace, optLineDir}
|
||||||
|
conf.globalOptions.excl {optCDebug}
|
||||||
|
|
||||||
proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
conf: ConfigRef) =
|
conf: ConfigRef) =
|
||||||
var
|
var
|
||||||
|
|
@ -548,12 +561,10 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
if {':', '='} in arg:
|
if {':', '='} in arg:
|
||||||
splitSwitch(conf, arg, key, val, pass, info)
|
splitSwitch(conf, arg, key, val, pass, info)
|
||||||
if cmpIgnoreStyle(key, "nimQuirky") == 0:
|
specialDefine(conf, key)
|
||||||
conf.exc = excQuirky
|
|
||||||
defineSymbol(conf.symbols, key, val)
|
defineSymbol(conf.symbols, key, val)
|
||||||
else:
|
else:
|
||||||
if cmpIgnoreStyle(arg, "nimQuirky") == 0:
|
specialDefine(conf, arg)
|
||||||
conf.exc = excQuirky
|
|
||||||
defineSymbol(conf.symbols, arg)
|
defineSymbol(conf.symbols, arg)
|
||||||
of "undef", "u":
|
of "undef", "u":
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
|
|
|
||||||
|
|
@ -417,6 +417,7 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
"project", project,
|
"project", project,
|
||||||
"output", output,
|
"output", output,
|
||||||
])
|
])
|
||||||
|
if conf.cmd in cmdBackends:
|
||||||
rawMessage(conf, hintBuildMode, build)
|
rawMessage(conf, hintBuildMode, build)
|
||||||
|
|
||||||
when PrintRopeCacheStats:
|
when PrintRopeCacheStats:
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ path="$lib/pure"
|
||||||
@end
|
@end
|
||||||
nimblepath="$home/.nimble/pkgs/"
|
nimblepath="$home/.nimble/pkgs/"
|
||||||
|
|
||||||
|
# Syncronize with compiler/commands.specialDefine
|
||||||
@if danger or quick:
|
@if danger or quick:
|
||||||
obj_checks:off
|
obj_checks:off
|
||||||
field_checks:off
|
field_checks:off
|
||||||
|
|
@ -63,6 +64,7 @@ nimblepath="$home/.nimble/pkgs/"
|
||||||
line_dir:off
|
line_dir:off
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
# Syncronize with compiler/commands.specialDefine
|
||||||
@if release or danger:
|
@if release or danger:
|
||||||
stacktrace:off
|
stacktrace:off
|
||||||
excessiveStackTrace:off
|
excessiveStackTrace:off
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim default --hint:cc:off --hint:cc $file"
|
cmd: "nim default --hint:cc:off --hint:cc $file"
|
||||||
output: '''hello world! 0.5'''
|
output: '''hello world! 0.5 true'''
|
||||||
nimout: '''[NimScript] exec: gcc -v'''
|
nimout: '''[NimScript] exec: gcc -v'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -10,4 +10,4 @@ when not defined(definedefine):
|
||||||
import math, mfriends
|
import math, mfriends
|
||||||
|
|
||||||
discard gen[int]()
|
discard gen[int]()
|
||||||
echo "hello world! ", ln 2.0
|
echo "hello world! ", ln 2.0, " ", compileOption("opt", "speed")
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ mode = ScriptMode.Whatif
|
||||||
|
|
||||||
exec "gcc -v"
|
exec "gcc -v"
|
||||||
|
|
||||||
|
--define:release
|
||||||
|
|
||||||
--forceBuild
|
--forceBuild
|
||||||
--path: "../friends"
|
--path: "../friends"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue