Merge pull request #2202 from def-/compile-stdin
Make compiler read files from stdin
This commit is contained in:
commit
eff6a281c5
5 changed files with 15 additions and 4 deletions
|
|
@ -62,7 +62,7 @@ proc commandCompileToC =
|
||||||
compileProject()
|
compileProject()
|
||||||
cgenWriteModules()
|
cgenWriteModules()
|
||||||
if gCmd != cmdRun:
|
if gCmd != cmdRun:
|
||||||
extccomp.callCCompiler(changeFileExt(gProjectFull, ""))
|
extccomp.callCCompiler(if gProjectName == "-": "stdinfile" else: changeFileExt(gProjectFull, ""))
|
||||||
|
|
||||||
if isServing:
|
if isServing:
|
||||||
# caas will keep track only of the compilation commands
|
# caas will keep track only of the compilation commands
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ proc newModule(fileIdx: int32): PSym =
|
||||||
result.kind = skModule
|
result.kind = skModule
|
||||||
let filename = fileIdx.toFullPath
|
let filename = fileIdx.toFullPath
|
||||||
result.name = getIdent(splitFile(filename).name)
|
result.name = getIdent(splitFile(filename).name)
|
||||||
if not isNimIdentifier(result.name.s):
|
if result.name.s != "-" and not isNimIdentifier(result.name.s):
|
||||||
rawMessage(errInvalidModuleName, result.name.s)
|
rawMessage(errInvalidModuleName, result.name.s)
|
||||||
|
|
||||||
result.info = newLineInfo(fileIdx, 1, 1)
|
result.info = newLineInfo(fileIdx, 1, 1)
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ proc handleCmdLine() =
|
||||||
if gCmd == cmdRun:
|
if gCmd == cmdRun:
|
||||||
tccgen.run(commands.arguments)
|
tccgen.run(commands.arguments)
|
||||||
if optRun in gGlobalOptions:
|
if optRun in gGlobalOptions:
|
||||||
|
if gProjectName == "-":
|
||||||
|
gProjectFull = "stdinfile"
|
||||||
if gCmd == cmdCompileToJS:
|
if gCmd == cmdCompileToJS:
|
||||||
var ex: string
|
var ex: string
|
||||||
if options.outFile.len > 0:
|
if options.outFile.len > 0:
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,10 @@ proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) =
|
||||||
openPasses(a, module)
|
openPasses(a, module)
|
||||||
if stream == nil:
|
if stream == nil:
|
||||||
let filename = fileIdx.toFullPathConsiderDirty
|
let filename = fileIdx.toFullPathConsiderDirty
|
||||||
|
if module.name.s == "-":
|
||||||
|
module.name.s = "stdinfile"
|
||||||
|
s = llStreamOpen(stdin)
|
||||||
|
else:
|
||||||
s = llStreamOpen(filename, fmRead)
|
s = llStreamOpen(filename, fmRead)
|
||||||
if s == nil:
|
if s == nil:
|
||||||
rawMessage(errCannotOpenFile, filename)
|
rawMessage(errCannotOpenFile, filename)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,12 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
|
||||||
parseopt.next(p)
|
parseopt.next(p)
|
||||||
case p.kind
|
case p.kind
|
||||||
of cmdEnd: break
|
of cmdEnd: break
|
||||||
of cmdLongoption, cmdShortOption: processSwitch(pass, p)
|
of cmdLongoption, cmdShortOption:
|
||||||
|
if p.key == " ":
|
||||||
|
p.key = "-"
|
||||||
|
if processArgument(pass, p, argsCount): break
|
||||||
|
else:
|
||||||
|
processSwitch(pass, p)
|
||||||
of cmdArgument:
|
of cmdArgument:
|
||||||
if processArgument(pass, p, argsCount): break
|
if processArgument(pass, p, argsCount): break
|
||||||
if pass == passCmd2:
|
if pass == passCmd2:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue