summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-01-27 09:15:18 +0100
committerAraq <rumpf_a@web.de>2017-01-27 09:15:42 +0100
commit27bc6c19748d5edb6d234afc8ba37fb439df4116 (patch)
treed4c895a6cda5e84133df67bc1994854ff8e5fe38
parentc8dcf8993fa32e442777dd3aaf0116518a68a71a (diff)
downloadNim-27bc6c19748d5edb6d234afc8ba37fb439df4116.tar.gz
.compile pragma supports wildcards
-rw-r--r--compiler/pragmas.nim20
1 files changed, 16 insertions, 4 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim
index 85e850834..3bed7fa03 100644
--- a/compiler/pragmas.nim
+++ b/compiler/pragmas.nim
@@ -402,10 +402,22 @@ proc relativeFile(c: PContext; n: PNode; ext=""): string =
       if result.len == 0: result = s
 
 proc processCompile(c: PContext, n: PNode) =
-  let found = relativeFile(c, n)
-  let trunc = found.changeFileExt("")
-  extccomp.addExternalFileToCompile(found)
-  extccomp.addFileToLink(completeCFilePath(trunc, false))
+  var s = expectStrLit(c, n)
+  var found = parentDir(n.info.toFullPath) / s
+  if '*' in found:
+    for f in os.walkFiles(found):
+      let trunc = f.changeFileExt("")
+      extccomp.addExternalFileToCompile(f)
+      extccomp.addFileToLink(completeCFilePath(trunc, false))
+  else:
+    if not fileExists(found):
+      if isAbsolute(s): found = s
+      else:
+        found = findFile(s)
+        if found.len == 0: found = s
+    let trunc = found.changeFileExt("")
+    extccomp.addExternalFileToCompile(found)
+    extccomp.addFileToLink(completeCFilePath(trunc, false))
 
 proc processCommonLink(c: PContext, n: PNode, feature: TLinkFeature) =
   let found = relativeFile(c, n, CC[cCompiler].objExt)