summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-03-10 16:31:34 -0700
committerGitHub <noreply@github.com>2020-03-11 00:31:34 +0100
commite64f1c7ee4a25a1df837617f4a79ce7e515b9e0d (patch)
treeacac38f8164d30f10f4ef6efc3d4bba87c180efa /compiler
parent3b7b01779856f50de94467fef9409ce228aa1ff1 (diff)
downloadNim-e64f1c7ee4a25a1df837617f4a79ce7e515b9e0d.tar.gz
`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
Diffstat (limited to 'compiler')
-rw-r--r--compiler/extccomp.nim33
-rw-r--r--compiler/lineinfos.nim2
2 files changed, 20 insertions, 15 deletions
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim
index 4cc5043f8..6b4223433 100644
--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -705,6 +705,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
@@ -715,8 +720,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")
@@ -908,6 +912,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
@@ -918,10 +927,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)
@@ -1126,12 +1132,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"]
@@ -1146,9 +1149,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:
diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim
index 9095dd13d..5ac65201e 100644
--- a/compiler/lineinfos.nim
+++ b/compiler/lineinfos.nim
@@ -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",