Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

koch --nim:pathto/nim boot and koch boot --hint:cc:off now work #13516

Merged
merged 2 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions compiler/extccomp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,11 @@ proc addExternalFileToCompile*(conf: ConfigRef; filename: AbsoluteFile) =
flags: {CfileFlag.External})
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,
prettyCmds: var TStringSeq) =
var currIdx = 0
Expand All @@ -714,8 +719,7 @@ proc compileCFiles(conf: ConfigRef; list: CfileList, script: var Rope, cmds: var
inc currIdx
if optCompileOnly notin conf.globalOptions:
cmds.add(compileCmd)
let (_, name, _) = splitFile(it.cname)
prettyCmds.add(if conf.hasHint(hintCC): "CC: " & demanglePackageName(name) else: "")
prettyCmds.add displayProgressCC(conf, $it.cname)
if optGenScript in conf.globalOptions:
script.add(compileCmd)
script.add("\n")
Expand Down Expand Up @@ -907,6 +911,11 @@ proc hcrLinkTargetName(conf: ConfigRef, objFile: string, isMain = false): Absolu
else: platform.OS[conf.target.targetOS].dllFrmt % basename
result = conf.getNimcacheDir / RelativeFile(targetName)

template callbackPrettyCmd(cmd) =
when declared(echo):
let cmd2 = cmd
if cmd2.len > 0: echo cmd2

proc callCCompiler*(conf: ConfigRef) =
var
linkCmd: string
Expand All @@ -917,10 +926,7 @@ proc callCCompiler*(conf: ConfigRef) =
var script: Rope = nil
var cmds: TStringSeq = @[]
var prettyCmds: TStringSeq = @[]
let prettyCb = proc (idx: int) =
when declared(echo):
let cmd = prettyCmds[idx]
if cmd != "": echo cmd
let prettyCb = proc (idx: int) = callbackPrettyCmd(prettyCmds[idx])
compileCFiles(conf, conf.toCompile, script, cmds, prettyCmds)
if optCompileOnly notin conf.globalOptions:
execCmdsInParallel(conf, cmds, prettyCb)
Expand Down Expand Up @@ -1125,12 +1131,9 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
doAssert c.len >= 2

cmds.add(c[1].getStr)
let (_, name, _) = splitFile(c[0].getStr)
prettyCmds.add("CC: " & demanglePackageName(name))
prettyCmds.add displayProgressCC(conf, c[0].getStr)

let prettyCb = proc (idx: int) =
when declared(echo):
echo prettyCmds[idx]
let prettyCb = proc (idx: int) = callbackPrettyCmd(prettyCmds[idx])
execCmdsInParallel(conf, cmds, prettyCb)

let linkCmd = data["linkcmd"]
Expand All @@ -1145,9 +1148,11 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
execExternalProgram(conf, cmd2, hintExecuting)

except:
when declared(echo):
echo getCurrentException().getStackTrace()
quit "error evaluating JSON file: " & jsonFile.string
let e = getCurrentException()
var msg = "\ncaught exception:n" & e.msg & "\nstacktrace:\n" &
getCurrentException().getStackTrace() &
"error evaluating JSON file: " & jsonFile.string
quit msg

proc genMappingFiles(conf: ConfigRef; list: CfileList): Rope =
for it in list:
Expand Down
2 changes: 1 addition & 1 deletion compiler/lineinfos.nim
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const
hintSuccess: "operation successful: $#",
# keep in sync with `pegSuccess` see testament.nim
hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output",
hintCC: "CC: \'$1\'", # unused
hintCC: "CC: $1",
hintLineTooLong: "line too long",
hintXDeclaredButNotUsed: "'$1' is declared but not used",
hintConvToBaseNotNeeded: "conversion to base object is not needed",
Expand Down
9 changes: 3 additions & 6 deletions koch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,12 @@ when false:

proc findStartNim: string =
# we try several things before giving up:
# * nimExe
# * bin/nim
# * $PATH/nim
# If these fail, we try to build nim with the "build.(sh|bat)" script.
var nim = "nim".exe
result = "bin" / nim
if existsFile(result): return
for dir in split(getEnv("PATH"), PathSep):
if existsFile(dir / nim): return dir / nim

let (nim, ok) = findNimImpl()
if ok: return nim
when defined(Posix):
const buildScript = "build.sh"
if existsFile(buildScript):
Expand Down
18 changes: 11 additions & 7 deletions tools/kochdocs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ proc exe*(f: string): string =
when defined(windows):
result = result.replace('/','\\')

proc findNim*(): string =
if nimExe.len > 0: return nimExe
var nim = "nim".exe
result = "bin" / nim
if existsFile(result): return
proc findNimImpl*(): tuple[path: string, ok: bool] =
if nimExe.len > 0: return (nimExe, true)
let nim = "nim".exe
result.path = "bin" / nim
result.ok = true
if existsFile(result.path): return
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:
return nim
return (nim, false)

proc findNim*(): string = findNimImpl().path

proc exec*(cmd: string, errorcode: int = QuitFailure, additionalPath = "") =
let prevPath = getEnv("PATH")
Expand Down