new cmd: nim r main [args...] to compile & run, saving binary under $nimcache/main (#13382)
* implement `nim r main` to compile and run, saving binary to $nimcache * remove outFileAbs for now
This commit is contained in:
parent
4b43d42b98
commit
5c534b2943
5 changed files with 39 additions and 16 deletions
|
|
@ -57,6 +57,7 @@ type # please make sure we have under 32 options
|
|||
optGenScript, # generate a script file to compile the *.c files
|
||||
optGenMapping, # generate a mapping file
|
||||
optRun, # run the compiled project
|
||||
optUseNimcache, # save artifacts (including binary) in $nimcache
|
||||
optStyleHint, # check that the names adhere to NEP-1
|
||||
optStyleError, # enforce that the names adhere to NEP-1
|
||||
optSkipSystemConfigFile, # skip the system's cfg/nims config file
|
||||
|
|
@ -524,18 +525,19 @@ proc getOutFile*(conf: ConfigRef; filename: RelativeFile, ext: string): Absolute
|
|||
conf.outDir / changeFileExt(filename, ext)
|
||||
|
||||
proc absOutFile*(conf: ConfigRef): AbsoluteFile =
|
||||
if false:
|
||||
doAssert not conf.outDir.isEmpty
|
||||
doAssert not conf.outFile.isEmpty
|
||||
# xxx: fix this pre-existing bug causing `SuccessX` error messages to lie
|
||||
# for `jsonscript`
|
||||
result = conf.outDir / conf.outFile
|
||||
when defined(posix):
|
||||
if dirExists(result.string):
|
||||
result.string.add ".out"
|
||||
if dirExists(result.string): result.string.add ".out"
|
||||
|
||||
proc prepareToWriteOutput*(conf: ConfigRef): AbsoluteFile =
|
||||
## Create the output directory and returns a full path to the output file
|
||||
createDir conf.outDir
|
||||
result = conf.outDir / conf.outFile
|
||||
when defined(posix):
|
||||
if dirExists(result.string):
|
||||
result.string.add ".out"
|
||||
result = conf.absOutFile
|
||||
createDir result.string.parentDir
|
||||
|
||||
proc getPrefixDir*(conf: ConfigRef): AbsoluteDir =
|
||||
## Gets the prefix dir, usually the parent directory where the binary resides.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue