I use ~/.config/nim/nim.cfg to adjust the default compiler options.
In there I would like to set the -d:release option, but only when the JS backend was selected.
Is this possible in the nim.cfg file?
I believe you have to do:
@if js:
define:release
@end
With a .nims file:
if defined(js):
--define:release
This might need when instead of if, but I'm not sure.
Because the global nim.cfg contains
@if release or danger:
stacktrace:off
excessiveStackTrace:off
linetrace:off
debugger:off
line_dir:off
opt:speed
define:release
@end
and is processed before your custom config file, when you set -d:release it's too late and you don't get the release mode.
A very annoying gotcha we're still trying to solve, somehow.
Mmmmh,
@if js:
define:release
@end
doesn't seem to work for me.
Can I use a .nims file instead of ~/.config/nim/nim.cfg? Is it then called ~/.config/nim/nim.nims?
Does config file include both .cfg file and .nims file ?
I use switch("define", "danger") in config.nims and when compiling I get Hint: 210575 lines; 9.281s; 435.492MiB peakmem; Dangerous Release build; which indicates that danger was taken into account.
Is that message not accurate ?
Is that message not accurate ?
I wouldn't count on it...
Then which way should be used to store compiler flags ?
There's no build log to verify afterwards and apparently we can neither trust config file or compiler message.
I guess, a workaround can be to set the options myself (and overwrite what's set before):
@if js:
stacktrace:off
excessiveStackTrace:off
linetrace:off
debugger:off
line_dir:off
@end
Thanks, Araq.
I now tried it. I put
@if js:
stacktrace:off
excessiveStackTrace:off
linetrace:off
debugger:off
line_dir:off
@end
in the nim.cfg, but when I run
nim js myfile.nim
myfile.js still contains the debug lines.
A bit of testing showed: The nim.cfg is read, but somehow the @if js: does not get triggered through the JS backend.