diff options
author | konqoro <capoiosct@gmail.com> | 2017-12-21 12:26:02 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-12-21 11:26:02 +0100 |
commit | 3495c0a46ddb8c2763df7a2e57d91be4a7717eb8 (patch) | |
tree | 29442e8e938770dd415023601cbf353220cd1d1b | |
parent | 63403b31ad2f6dcbfcfa95251e8200bb4603dad7 (diff) | |
download | Nim-3495c0a46ddb8c2763df7a2e57d91be4a7717eb8.tar.gz |
Fix json generation logic (#6909)
-rw-r--r-- | compiler/extccomp.nim | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 7a473ea43..5299b2dbf 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -794,42 +794,40 @@ proc writeJsonBuildInstructions*(projectfile: string) = else: f.write escapeJson(x) - proc cfiles(f: File; buf: var string; list: CfileList, isExternal: bool) = - var i = 0 - for it in list: + proc cfiles(f: File; buf: var string; clist: CfileList, isExternal: bool) = + var pastStart = false + for it in clist: if CfileFlag.Cached in it.flags: continue let compileCmd = getCompileCFileCmd(it) + if pastStart: lit "],\L" lit "[" str it.cname lit ", " str compileCmd - inc i - if i == list.len: - lit "]\L" - else: - lit "],\L" - - proc linkfiles(f: File; buf, objfiles: var string) = - for i, it in externalToLink: - let - objFile = if noAbsolutePaths(): it.extractFilename else: it - objStr = addFileExt(objFile, CC[cCompiler].objExt) + pastStart = true + lit "]\L" + + proc linkfiles(f: File; buf, objfiles: var string; clist: CfileList; + llist: seq[string]) = + var pastStart = false + for it in llist: + let objfile = if noAbsolutePaths(): it.extractFilename + else: it + let objstr = addFileExt(objfile, CC[cCompiler].objExt) add(objfiles, ' ') - add(objfiles, objStr) - str objStr - if toCompile.len == 0 and i == externalToLink.high: - lit "\L" - else: - lit ",\L" - for i, x in toCompile: - let objStr = quoteShell(x.obj) + add(objfiles, objstr) + if pastStart: lit ",\L" + str objstr + pastStart = true + + for it in clist: + let objstr = quoteShell(it.obj) add(objfiles, ' ') - add(objfiles, objStr) - str objStr - if i == toCompile.high: - lit "\L" - else: - lit ",\L" + add(objfiles, objstr) + if pastStart: lit ",\L" + str objstr + pastStart = true + lit "\L" var buf = newStringOfCap(50) @@ -843,7 +841,7 @@ proc writeJsonBuildInstructions*(projectfile: string) = lit "],\L\"link\":[\L" var objfiles = "" # XXX add every file here that is to link - linkfiles(f, buf, objfiles) + linkfiles(f, buf, objfiles, toCompile, externalToLink) lit "],\L\"linkcmd\": " str getLinkCmd(projectfile, objfiles) |