diff --git a/compiler/cgen.nim b/compiler/cgen.nim index eca3c6db28..ac0fa3598f 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -16,11 +16,24 @@ import condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases, lowerings, semparallel, tables -from modulegraphs import ModuleGraph -from dynlib import libCandidates - import strutils except `%` # collides with ropes.`%` +from modulegraphs import ModuleGraph +import dynlib + +when not declared(dynlib.libCandidates): + proc libCandidates(s: string, dest: var seq[string]) = + ## given a library name pattern `s` write possible library names to `dest`. + var le = strutils.find(s, '(') + var ri = strutils.find(s, ')', le+1) + if le >= 0 and ri > le: + var prefix = substr(s, 0, le - 1) + var suffix = substr(s, ri + 1) + for middle in split(substr(s, le + 1, ri - 1), '|'): + libCandidates(prefix & middle & suffix, dest) + else: + add(dest, s) + when options.hasTinyCBackend: import tccgen diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 175e8d8318..cdd93f0752 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -773,9 +773,12 @@ from json import escapeJson proc writeJsonBuildInstructions*(projectfile: string) = template lit(x: untyped) = f.write x template str(x: untyped) = - buf.setLen 0 - escapeJson(x, buf) - f.write buf + when compiles(escapeJson(x, buf)): + buf.setLen 0 + escapeJson(x, buf) + f.write buf + else: + f.write escapeJson(x) proc cfiles(f: File; buf: var string; list: TLinkedList, isExternal: bool) = var it = PStrEntry(list.head)