Add --cacheDir option
This commit is contained in:
parent
11c17252e2
commit
8af24b25a4
|
@ -79,9 +79,11 @@ Options
|
|||
--listWarns Show a list of all warnings
|
||||
-b, --backend Select the compilation backend. Currently only supports 'bytecode' (the default)
|
||||
-c, --compile Compile the code, but do not run the main module
|
||||
-o, --output Rename the output executable to this (a "pn" extension is added for bytecode files,
|
||||
-o, --output Rename the output executable to this (a "bc" extension is added for bytecode files,
|
||||
if not already present)
|
||||
-s, --string Run the given string as if it were a file (the filename is set to '<string>')
|
||||
--cacheDir Specify a directory where the peon compiler will dump code generation results
|
||||
to speed up subsequent builds. Defaults to ".buildcache"
|
||||
|
||||
The following options are specific to the 'bytecode' backend:
|
||||
-n, --noDump Do not dump bytecode files to the source directory. Note that
|
||||
|
|
11
src/peon.nim
11
src/peon.nim
|
@ -68,7 +68,7 @@ proc `$`(self: TypedNode): string =
|
|||
|
||||
proc runFile(filename: string, fromString: bool = false, dump: bool = true, generate: bool = true, breakpoints: seq[uint64] = @[],
|
||||
disabledWarnings: seq[WarningKind] = @[], mismatches: bool = false, run: bool = true,
|
||||
backend: PeonBackend = PeonBackend.Bytecode, output: string) =
|
||||
backend: PeonBackend = PeonBackend.Bytecode, output: string, cacheDir: string) =
|
||||
var
|
||||
tokens: seq[Token]
|
||||
tree: ParseTree
|
||||
|
@ -141,7 +141,9 @@ proc runFile(filename: string, fromString: bool = false, dump: bool = true, gene
|
|||
if dump and not fromString:
|
||||
if not output.endsWith(".pbc"):
|
||||
output.add(".pbc")
|
||||
serializer.dumpFile(chunk, filename, output)
|
||||
if not dirExists(cacheDir):
|
||||
createDir(cacheDir)
|
||||
serializer.dumpFile(chunk, joinPath(cacheDir, filename), output)
|
||||
if debugCompiler:
|
||||
styledEcho fgCyan, "Disassembler output below"
|
||||
debugger.disassembleChunk(chunk, filename)
|
||||
|
@ -275,6 +277,7 @@ when isMainModule:
|
|||
dump = true
|
||||
warnings: seq[WarningKind] = @[]
|
||||
showMismatches = false
|
||||
cachePath: string = ".buildcache"
|
||||
#mode: CompileMode = CompileMode.Debug
|
||||
run = true
|
||||
generateCode = true
|
||||
|
@ -355,6 +358,8 @@ when isMainModule:
|
|||
debugLexer = true
|
||||
of "debugParser":
|
||||
debugParser = true
|
||||
of "cachePath":
|
||||
cachePath = value
|
||||
of "breakpoints":
|
||||
when debugVM:
|
||||
for point in value.strip(chars={' '}).split(","):
|
||||
|
@ -405,4 +410,4 @@ when isMainModule:
|
|||
echo "Sorry, the REPL is broken :("
|
||||
# repl(warnings, showMismatches, backend, dump)
|
||||
else:
|
||||
runFile(file, fromString, dump, generateCode, breakpoints, warnings, showMismatches, run, backend, output)
|
||||
runFile(file, fromString, dump, generateCode, breakpoints, warnings, showMismatches, run, backend, output, cachePath)
|
Loading…
Reference in New Issue