summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2012-06-02 19:51:49 +0300
committerZahary Karadjov <zahary@gmail.com>2012-06-02 19:51:49 +0300
commita1da1f987b28ed041c3f3ad2317e756e2125aa30 (patch)
tree0f847c024a7dec46b1fb43d8221af977cd5174d5 /lib
parent337e1ecc7c25c9215e8d4877e357b5c9a8f9f3f7 (diff)
downloadNim-a1da1f987b28ed041c3f3ad2317e756e2125aa30.tar.gz
Added system.staticExec proc for executing external command at compile-time
Diffstat (limited to 'lib')
-rwxr-xr-xlib/system.nim15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 5e575c814..4a7ac0654 100755
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2150,10 +2150,21 @@ proc getTypeInfo*[T](x: T): pointer {.magic: "GetTypeInfo".}
   ## the `typeinfo` module instead.
   
 proc slurp*(filename: string): string {.magic: "Slurp".}
-  ## compiletime ``readFile`` proc for easy `resource`:idx: embedding:
+proc staticRead*(filename: string): string {.magic: "Slurp".}
+  ## compile-time ``readFile`` proc for easy `resource`:idx: embedding:
   ## .. code-block:: nimrod
   ##
-  ##   const myResource = slurp"mydatafile.bin"
+  ##   const myResource = staticRead"mydatafile.bin"
+  ##
+
+proc staticExec*(command: string, input = ""): string {.magic: "StaticExec".}
+  ## executes an external process at compile-time.
+  ## if `input` is not an empty string, it will be passed as a standard input
+  ## to the executed program.
+  ## .. code-block:: nimrod
+  ##
+  ##   const buildInfo = "Revision " & staticExec("git rev-parse HEAD") & 
+  ##                     "\nCompiled on " & staticExec("uname -v")
   ##
 
 proc `+=`*[T](x, y: ordinal[T]) {.magic: "Inc", noSideEffect.}