Fix json generation logic (#6909)

This commit is contained in:
konqoro 2017-12-21 12:26:02 +02:00 • committed by Andreas Rumpf
commit 3495c0a46d

View file

@ -794,42 +794,40 @@ proc writeJsonBuildInstructions*(projectfile: string) =
else: else:
f.write escapeJson(x) f.write escapeJson(x)
proc cfiles(f: File; buf: var string; list: CfileList, isExternal: bool) = proc cfiles(f: File; buf: var string; clist: CfileList, isExternal: bool) =
var i = 0 var pastStart = false
for it in list: for it in clist:
if CfileFlag.Cached in it.flags: continue if CfileFlag.Cached in it.flags: continue
let compileCmd = getCompileCFileCmd(it) let compileCmd = getCompileCFileCmd(it)
if pastStart: lit "],\L"
lit "[" lit "["
str it.cname str it.cname
lit ", " lit ", "
str compileCmd str compileCmd
inc i pastStart = true
if i == list.len: lit "]\L"
lit "]\L"
else:
lit "],\L"
proc linkfiles(f: File; buf, objfiles: var string) = proc linkfiles(f: File; buf, objfiles: var string; clist: CfileList;
for i, it in externalToLink: llist: seq[string]) =
let var pastStart = false
objFile = if noAbsolutePaths(): it.extractFilename else: it for it in llist:
objStr = addFileExt(objFile, CC[cCompiler].objExt) let objfile = if noAbsolutePaths(): it.extractFilename
else: it
let objstr = addFileExt(objfile, CC[cCompiler].objExt)
add(objfiles, ' ') add(objfiles, ' ')
add(objfiles, objStr) add(objfiles, objstr)
str objStr if pastStart: lit ",\L"
if toCompile.len == 0 and i == externalToLink.high: str objstr
lit "\L" pastStart = true
else:
lit ",\L" for it in clist:
for i, x in toCompile: let objstr = quoteShell(it.obj)
let objStr = quoteShell(x.obj)
add(objfiles, ' ') add(objfiles, ' ')
add(objfiles, objStr) add(objfiles, objstr)
str objStr if pastStart: lit ",\L"
if i == toCompile.high: str objstr
lit "\L" pastStart = true
else: lit "\L"
lit ",\L"
var buf = newStringOfCap(50) var buf = newStringOfCap(50)
@ -843,7 +841,7 @@ proc writeJsonBuildInstructions*(projectfile: string) =
lit "],\L\"link\":[\L" lit "],\L\"link\":[\L"
var objfiles = "" var objfiles = ""
# XXX add every file here that is to link # XXX add every file here that is to link
linkfiles(f, buf, objfiles) linkfiles(f, buf, objfiles, toCompile, externalToLink)
lit "],\L\"linkcmd\": " lit "],\L\"linkcmd\": "
str getLinkCmd(projectfile, objfiles) str getLinkCmd(projectfile, objfiles)