koch --nim:pathto/nim boot and koch boot --hint:cc:off now work (#13516)
* `koch boot --hint:cc:off` now works * `koch --nim:pathto/nim boot` now works; code cleanup
This commit is contained in:
parent
3b7b017798
commit
e64f1c7ee4
4 changed files with 34 additions and 28 deletions
|
|
@ -705,6 +705,11 @@ proc addExternalFileToCompile*(conf: ConfigRef; filename: AbsoluteFile) =
|
||||||
flags: {CfileFlag.External})
|
flags: {CfileFlag.External})
|
||||||
addExternalFileToCompile(conf, c)
|
addExternalFileToCompile(conf, c)
|
||||||
|
|
||||||
|
proc displayProgressCC(conf: ConfigRef, path: string): string =
|
||||||
|
if conf.hasHint(hintCC):
|
||||||
|
let (_, name, _) = splitFile(path)
|
||||||
|
result = MsgKindToStr[hintCC] % demanglePackageName(name)
|
||||||
|
|
||||||
proc compileCFiles(conf: ConfigRef; list: CfileList, script: var Rope, cmds: var TStringSeq,
|
proc compileCFiles(conf: ConfigRef; list: CfileList, script: var Rope, cmds: var TStringSeq,
|
||||||
prettyCmds: var TStringSeq) =
|
prettyCmds: var TStringSeq) =
|
||||||
var currIdx = 0
|
var currIdx = 0
|
||||||
|
|
@ -715,8 +720,7 @@ proc compileCFiles(conf: ConfigRef; list: CfileList, script: var Rope, cmds: var
|
||||||
inc currIdx
|
inc currIdx
|
||||||
if optCompileOnly notin conf.globalOptions:
|
if optCompileOnly notin conf.globalOptions:
|
||||||
cmds.add(compileCmd)
|
cmds.add(compileCmd)
|
||||||
let (_, name, _) = splitFile(it.cname)
|
prettyCmds.add displayProgressCC(conf, $it.cname)
|
||||||
prettyCmds.add(if conf.hasHint(hintCC): "CC: " & demanglePackageName(name) else: "")
|
|
||||||
if optGenScript in conf.globalOptions:
|
if optGenScript in conf.globalOptions:
|
||||||
script.add(compileCmd)
|
script.add(compileCmd)
|
||||||
script.add("\n")
|
script.add("\n")
|
||||||
|
|
@ -908,6 +912,11 @@ proc hcrLinkTargetName(conf: ConfigRef, objFile: string, isMain = false): Absolu
|
||||||
else: platform.OS[conf.target.targetOS].dllFrmt % basename
|
else: platform.OS[conf.target.targetOS].dllFrmt % basename
|
||||||
result = conf.getNimcacheDir / RelativeFile(targetName)
|
result = conf.getNimcacheDir / RelativeFile(targetName)
|
||||||
|
|
||||||
|
template callbackPrettyCmd(cmd) =
|
||||||
|
when declared(echo):
|
||||||
|
let cmd2 = cmd
|
||||||
|
if cmd2.len > 0: echo cmd2
|
||||||
|
|
||||||
proc callCCompiler*(conf: ConfigRef) =
|
proc callCCompiler*(conf: ConfigRef) =
|
||||||
var
|
var
|
||||||
linkCmd: string
|
linkCmd: string
|
||||||
|
|
@ -918,10 +927,7 @@ proc callCCompiler*(conf: ConfigRef) =
|
||||||
var script: Rope = nil
|
var script: Rope = nil
|
||||||
var cmds: TStringSeq = @[]
|
var cmds: TStringSeq = @[]
|
||||||
var prettyCmds: TStringSeq = @[]
|
var prettyCmds: TStringSeq = @[]
|
||||||
let prettyCb = proc (idx: int) =
|
let prettyCb = proc (idx: int) = callbackPrettyCmd(prettyCmds[idx])
|
||||||
when declared(echo):
|
|
||||||
let cmd = prettyCmds[idx]
|
|
||||||
if cmd != "": echo cmd
|
|
||||||
compileCFiles(conf, conf.toCompile, script, cmds, prettyCmds)
|
compileCFiles(conf, conf.toCompile, script, cmds, prettyCmds)
|
||||||
if optCompileOnly notin conf.globalOptions:
|
if optCompileOnly notin conf.globalOptions:
|
||||||
execCmdsInParallel(conf, cmds, prettyCb)
|
execCmdsInParallel(conf, cmds, prettyCb)
|
||||||
|
|
@ -1126,12 +1132,9 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
|
||||||
doAssert c.len >= 2
|
doAssert c.len >= 2
|
||||||
|
|
||||||
cmds.add(c[1].getStr)
|
cmds.add(c[1].getStr)
|
||||||
let (_, name, _) = splitFile(c[0].getStr)
|
prettyCmds.add displayProgressCC(conf, c[0].getStr)
|
||||||
prettyCmds.add("CC: " & demanglePackageName(name))
|
|
||||||
|
|
||||||
let prettyCb = proc (idx: int) =
|
let prettyCb = proc (idx: int) = callbackPrettyCmd(prettyCmds[idx])
|
||||||
when declared(echo):
|
|
||||||
echo prettyCmds[idx]
|
|
||||||
execCmdsInParallel(conf, cmds, prettyCb)
|
execCmdsInParallel(conf, cmds, prettyCb)
|
||||||
|
|
||||||
let linkCmd = data["linkcmd"]
|
let linkCmd = data["linkcmd"]
|
||||||
|
|
@ -1146,9 +1149,11 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
|
||||||
execExternalProgram(conf, cmd2, hintExecuting)
|
execExternalProgram(conf, cmd2, hintExecuting)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
when declared(echo):
|
let e = getCurrentException()
|
||||||
echo getCurrentException().getStackTrace()
|
var msg = "\ncaught exception:n" & e.msg & "\nstacktrace:\n" &
|
||||||
quit "error evaluating JSON file: " & jsonFile.string
|
getCurrentException().getStackTrace() &
|
||||||
|
"error evaluating JSON file: " & jsonFile.string
|
||||||
|
quit msg
|
||||||
|
|
||||||
proc genMappingFiles(conf: ConfigRef; list: CfileList): Rope =
|
proc genMappingFiles(conf: ConfigRef; list: CfileList): Rope =
|
||||||
for it in list:
|
for it in list:
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ const
|
||||||
hintSuccess: "operation successful: $#",
|
hintSuccess: "operation successful: $#",
|
||||||
# keep in sync with `pegSuccess` see testament.nim
|
# keep in sync with `pegSuccess` see testament.nim
|
||||||
hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output",
|
hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output",
|
||||||
hintCC: "CC: \'$1\'", # unused
|
hintCC: "CC: $1",
|
||||||
hintLineTooLong: "line too long",
|
hintLineTooLong: "line too long",
|
||||||
hintXDeclaredButNotUsed: "'$1' is declared but not used",
|
hintXDeclaredButNotUsed: "'$1' is declared but not used",
|
||||||
hintConvToBaseNotNeeded: "conversion to base object is not needed",
|
hintConvToBaseNotNeeded: "conversion to base object is not needed",
|
||||||
|
|
|
||||||
9
koch.nim
9
koch.nim
|
|
@ -265,15 +265,12 @@ when false:
|
||||||
|
|
||||||
proc findStartNim: string =
|
proc findStartNim: string =
|
||||||
# we try several things before giving up:
|
# we try several things before giving up:
|
||||||
|
# * nimExe
|
||||||
# * bin/nim
|
# * bin/nim
|
||||||
# * $PATH/nim
|
# * $PATH/nim
|
||||||
# If these fail, we try to build nim with the "build.(sh|bat)" script.
|
# If these fail, we try to build nim with the "build.(sh|bat)" script.
|
||||||
var nim = "nim".exe
|
let (nim, ok) = findNimImpl()
|
||||||
result = "bin" / nim
|
if ok: return nim
|
||||||
if existsFile(result): return
|
|
||||||
for dir in split(getEnv("PATH"), PathSep):
|
|
||||||
if existsFile(dir / nim): return dir / nim
|
|
||||||
|
|
||||||
when defined(Posix):
|
when defined(Posix):
|
||||||
const buildScript = "build.sh"
|
const buildScript = "build.sh"
|
||||||
if existsFile(buildScript):
|
if existsFile(buildScript):
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,19 @@ proc exe*(f: string): string =
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
result = result.replace('/','\\')
|
result = result.replace('/','\\')
|
||||||
|
|
||||||
proc findNim*(): string =
|
proc findNimImpl*(): tuple[path: string, ok: bool] =
|
||||||
if nimExe.len > 0: return nimExe
|
if nimExe.len > 0: return (nimExe, true)
|
||||||
var nim = "nim".exe
|
let nim = "nim".exe
|
||||||
result = "bin" / nim
|
result.path = "bin" / nim
|
||||||
if existsFile(result): return
|
result.ok = true
|
||||||
|
if existsFile(result.path): return
|
||||||
for dir in split(getEnv("PATH"), PathSep):
|
for dir in split(getEnv("PATH"), PathSep):
|
||||||
if existsFile(dir / nim): return dir / nim
|
result.path = dir / nim
|
||||||
|
if existsFile(result.path): return
|
||||||
# assume there is a symlink to the exe or something:
|
# assume there is a symlink to the exe or something:
|
||||||
return nim
|
return (nim, false)
|
||||||
|
|
||||||
|
proc findNim*(): string = findNimImpl().path
|
||||||
|
|
||||||
proc exec*(cmd: string, errorcode: int = QuitFailure, additionalPath = "") =
|
proc exec*(cmd: string, errorcode: int = QuitFailure, additionalPath = "") =
|
||||||
let prevPath = getEnv("PATH")
|
let prevPath = getEnv("PATH")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue