@@ -623,7 +623,7 @@ proc getCompileCFileCmd*(conf: ConfigRef; cfile: Cfile,
623623
624624  var  objfile = 
625625    if  cfile.obj.isEmpty:
626-       if  not   cfile.flags. contains ( CfileFlag . External )  or  noAbsolutePaths (conf):
626+       if  CfileFlag . External   notin   cfile.flags or  noAbsolutePaths (conf):
627627        toObjFile (conf, cf).string 
628628      else :
629629        completeCfilePath (conf, toObjFile (conf, cf)).string 
@@ -705,26 +705,6 @@ proc addExternalFileToCompile*(conf: ConfigRef; filename: AbsoluteFile) =
705705    flags: {CfileFlag .External })
706706  addExternalFileToCompile (conf, c)
707707
708- proc  displayProgressCC (conf: ConfigRef , path: string ): string  = 
709-   if  conf.hasHint (hintCC):
710-     let  (_, name, _) =  splitFile (path)
711-     result  =  MsgKindToStr [hintCC] %  demanglePackageName (name)
712- 
713- proc  compileCFiles (conf: ConfigRef ; list: CfileList , script: var  Rope , cmds: var  TStringSeq ,
714-                   prettyCmds: var  TStringSeq ) = 
715-   var  currIdx =  0 
716-   for  it in  list:
717-     #  call the C compiler for the .c file:
718-     if  it.flags.contains (CfileFlag .Cached ): continue 
719-     var  compileCmd =  getCompileCFileCmd (conf, it, currIdx ==  list.len -  1 , produceOutput= true )
720-     inc  currIdx
721-     if  optCompileOnly notin  conf.globalOptions:
722-       cmds.add (compileCmd)
723-       prettyCmds.add  displayProgressCC (conf, $ it.cname)
724-     if  optGenScript in  conf.globalOptions:
725-       script.add (compileCmd)
726-       script.add (" \n " 
727- 
728708proc  getLinkCmd (conf: ConfigRef ; output: AbsoluteFile ,
729709                objfiles: string , isDllBuild: bool ): string  = 
730710  if  optGenStaticLib in  conf.globalOptions:
@@ -862,15 +842,8 @@ proc execCmdsInParallel(conf: ConfigRef; cmds: seq[string]; prettyCb: proc (idx:
862842          cmds[i])
863843  else :
864844    tryExceptOSErrorMessage (conf, " invocation of external compiler program failed." 
865-       if  optListCmd in  conf.globalOptions or  conf.verbosity >  1 :
866-         res =  execProcesses (cmds, {poEchoCmd, poStdErrToStdOut, poUsePath, poParentStreams},
867-                             conf.numberOfProcessors, afterRunEvent= runCb)
868-       elif  conf.verbosity ==  1 :
869-         res =  execProcesses (cmds, {poStdErrToStdOut, poUsePath, poParentStreams},
845+       res =  execProcesses (cmds, {poStdErrToStdOut, poUsePath, poParentStreams},
870846                            conf.numberOfProcessors, prettyCb, afterRunEvent= runCb)
871-       else :
872-         res =  execProcesses (cmds, {poStdErrToStdOut, poUsePath, poParentStreams},
873-                             conf.numberOfProcessors, afterRunEvent= runCb)
874847  if  res !=  0 :
875848    if  conf.numberOfProcessors <=  1 :
876849      rawMessage (conf, errGenerated, " execution of an external program failed: '$1'" % 
@@ -912,10 +885,12 @@ proc hcrLinkTargetName(conf: ConfigRef, objFile: string, isMain = false): Absolu
912885                   else : platform.OS [conf.target.targetOS].dllFrmt %  basename
913886  result  =  conf.getNimcacheDir /  RelativeFile 
914887
915- template  callbackPrettyCmd (cmd) = 
916-   when  declared (echo):
917-     let  cmd2 =  cmd
918-     if  cmd2.len >  0 : echo  cmd2
888+ proc  displayProgressCC (conf: ConfigRef , path, compileCmd: string ): string  = 
889+   if  conf.hasHint (hintCC):
890+     if  optListCmd in  conf.globalOptions or  conf.verbosity >  1 :
891+       result  =  MsgKindToStr [hintCC] %  (demanglePackageName (path.splitFile.name) &  " : " &  compileCmd)
892+     else :
893+       result  =  MsgKindToStr [hintCC] %  demanglePackageName (path.splitFile.name)
919894
920895proc  callCCompiler * (conf: ConfigRef ) = 
921896  var 
@@ -925,10 +900,22 @@ proc callCCompiler*(conf: ConfigRef) =
925900           #  generated
926901  # var c = cCompiler
927902  var  script: Rope  =  nil 
928-   var  cmds: TStringSeq  =  @ []
929-   var  prettyCmds: TStringSeq  =  @ []
930-   let  prettyCb =  proc  (idx: int ) =  callbackPrettyCmd (prettyCmds[idx])
931-   compileCFiles (conf, conf.toCompile, script, cmds, prettyCmds)
903+   var  cmds: TStringSeq 
904+   var  prettyCmds: TStringSeq 
905+   let  prettyCb =  proc  (idx: int ) = 
906+     if  prettyCmds[idx].len >  0 : echo  prettyCmds[idx]
907+ 
908+   for  idx, it in  conf.toCompile:
909+     #  call the C compiler for the .c file:
910+     if  CfileFlag .Cached  in  it.flags: continue 
911+     let  compileCmd =  getCompileCFileCmd (conf, it, idx ==  conf.toCompile.len -  1 , produceOutput= true )
912+     if  optCompileOnly notin  conf.globalOptions:
913+       cmds.add (compileCmd)
914+       prettyCmds.add  displayProgressCC (conf, $ it.cname, compileCmd)
915+     if  optGenScript in  conf.globalOptions:
916+       script.add (compileCmd)
917+       script.add (" \n " 
918+ 
932919  if  optCompileOnly notin  conf.globalOptions:
933920    execCmdsInParallel (conf, cmds, prettyCb)
934921  if  optNoLinking notin  conf.globalOptions:
@@ -947,7 +934,7 @@ proc callCCompiler*(conf: ConfigRef) =
947934        #  don't relink each of the many binaries (one for each source file) if the nim code is
948935        #  cached because that would take too much time for small changes - the only downside to
949936        #  this is that if an external-to-link file changes the final target wouldn't be relinked
950-         if  x.flags. contains ( CfileFlag .Cached ) : continue 
937+         if  CfileFlag .Cached   in  x.flags : continue 
951938        #  we pass each object file as if it is the project file - a .dll will be created for each such
952939        #  object file in the nimcache directory, and only in the case of the main project file will
953940        #  there be probably an executable (if the project is such) which will be copied out of the nimcache
@@ -965,7 +952,7 @@ proc callCCompiler*(conf: ConfigRef) =
965952      prettyCmds =  map (prettyCmds, proc  (curr: string ): string  =  return  curr.replace (" CC" " Link" 
966953      execCmdsInParallel (conf, cmds, prettyCb)
967954      #  only if not cached - copy the resulting main file from the nimcache folder to its originally intended destination
968-       if  not   conf.toCompile[mainFileIdx].flags. contains ( CfileFlag . Cached ) :
955+       if  CfileFlag . Cached   notin   conf.toCompile[mainFileIdx].flags:
969956        let  mainObjFile =  getObjFilePath (conf, conf.toCompile[mainFileIdx])
970957        var  src =  conf.hcrLinkTargetName (mainObjFile, true )
971958        var  dst =  conf.prepareToWriteOutput
@@ -1011,8 +998,7 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) =
1011998      f.write  escapeJson (x)
1012999
10131000  proc  cfiles (conf: ConfigRef ; f: File ; buf: var  string ; clist: CfileList , isExternal: bool ) = 
1014-     var  i =  0 
1015-     for  it in  clist:
1001+     for  i, it in  clist:
10161002      if  CfileFlag .Cached  in  it.flags: continue 
10171003      let  compileCmd =  getCompileCFileCmd (conf, it)
10181004      if  i >  0 : lit  " ,\L " 
@@ -1021,7 +1007,6 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) =
10211007      lit  " , " 
10221008      str  compileCmd
10231009      lit  " ]" 
1024-       inc  i
10251010
10261011  proc  linkfiles (conf: ConfigRef ; f: File ; buf, objfiles: var  string ; clist: CfileList ;
10271012                 llist: seq [string ]) = 
@@ -1125,16 +1110,18 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
11251110    let  data =  json.parseFile (jsonFile.string )
11261111    let  toCompile =  data[" compile" 
11271112    doAssert  toCompile.kind ==  JArray 
1128-     var  cmds: TStringSeq  =  @ []
1129-     var  prettyCmds: TStringSeq  =  @ []
1113+     var  cmds: TStringSeq 
1114+     var  prettyCmds: TStringSeq 
1115+     let  prettyCb =  proc  (idx: int ) = 
1116+       if  prettyCmds[idx].len >  0 : echo  prettyCmds[idx]
1117+ 
11301118    for  c in  toCompile:
11311119      doAssert  c.kind ==  JArray 
11321120      doAssert  c.len >=  2 
11331121
11341122      cmds.add (c[1 ].getStr)
1135-       prettyCmds.add  displayProgressCC (conf, c[0 ].getStr)
1123+       prettyCmds.add  displayProgressCC (conf, c[0 ].getStr, c[ 1 ].getStr )
11361124
1137-     let  prettyCb =  proc  (idx: int ) =  callbackPrettyCmd (prettyCmds[idx])
11381125    execCmdsInParallel (conf, cmds, prettyCb)
11391126
11401127    let  linkCmd =  data[" linkcmd" 
@@ -1150,10 +1137,8 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
11501137
11511138  except :
11521139    let  e =  getCurrentException ()
1153-     var  msg =  " \n caught exception:n" &  e.msg &  " \n stacktrace:\n " & 
1154-       getCurrentException ().getStackTrace () & 
1155-       " error evaluating JSON file: " &  jsonFile.string 
1156-     quit  msg
1140+     quit  " \n caught exception:n" &  e.msg &  " \n stacktrace:\n " &  e.getStackTrace () & 
1141+          " error evaluating JSON file: " &  jsonFile.string 
11571142
11581143proc  genMappingFiles (conf: ConfigRef ; list: CfileList ): Rope  = 
11591144  for  it in  list:
0 commit comments