summary refs log tree commit diff stats
path: root/tools/detect/detect.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-12-23 01:17:48 +0100
committerAraq <rumpf_a@web.de>2013-12-23 01:17:48 +0100
commit9145bcfbb680d653f167a1a12f7830025aa951a5 (patch)
treecb620a359c73662d488d156e1fa7c7e28d39af0f /tools/detect/detect.nim
parente2a4d591e5f34685071985cb4070e96b7e053a1a (diff)
downloadNim-9145bcfbb680d653f167a1a12f7830025aa951a5.tar.gz
new VM: some progress for the FFI support
Diffstat (limited to 'tools/detect/detect.nim')
-rw-r--r--tools/detect/detect.nim21
1 files changed, 14 insertions, 7 deletions
diff --git a/tools/detect/detect.nim b/tools/detect/detect.nim
index cf61c2823..b2beba828 100644
--- a/tools/detect/detect.nim
+++ b/tools/detect/detect.nim
@@ -10,7 +10,7 @@
 import os, strutils
 
 const
-  cc = "gcc -o $1 $1.c"
+  cc = "gcc -o $# $#.c"
 
   cfile = """
 /* Generated by detect.nim */
@@ -37,6 +37,7 @@ var
   tl = ""
 
 proc myExec(cmd: string): bool = 
+  echo "CMD ", cmd
   return execShellCmd(cmd) == 0
 
 proc header(s: string): bool = 
@@ -46,7 +47,7 @@ proc header(s: string): bool =
     f.write("#include $1\n" % s)
     f.write("int main() { return 0; }\n")
     close(f)
-    result = myExec(cc % testh)
+    result = myExec(cc % [testh.addFileExt(ExeExt), testh])
     removeFile(addFileExt(testh, "c"))
   if result:
     addf(hd, "#include $1\n", s)
@@ -60,13 +61,16 @@ proc main =
   if open(f, addFileExt(gen, "c"), fmWrite): 
     f.write(cfile % [hd, tl, system.hostOS, system.hostCPU])
     close(f)
-  if not myExec(cc % gen): quit(1)
-  if not myExec("./" & gen): quit(1)
+  if not myExec(cc % [gen.addFileExt(ExeExt), gen]): quit(1)
+  when defined(windows):
+    if not myExec(gen.addFileExt(ExeExt)): quit(1)
+  else:
+    if not myExec("./" & gen): quit(1)
   removeFile(addFileExt(gen, "c"))
   echo("Success")
 
 proc v(name: string, typ: TTypeKind=cint) = 
-  var n = if name[0] == '_': copy(name, 1) else: name
+  var n = if name[0] == '_': substr(name, 1) else: name
   var t = $typ
   case typ
   of pointer: 
@@ -369,7 +373,7 @@ if header("<pthread.h>"):
   #v("PTHREAD_MUTEX_INITIALIZER") 
   v("PTHREAD_MUTEX_NORMAL") 
   v("PTHREAD_MUTEX_RECURSIVE") #{.importc, header: "<pthread.h>".}: cint
-  v("PTHREAD_ONCE_INIT") #{.importc, header: "<pthread.h>".}: cint
+  #v("PTHREAD_ONCE_INIT") #{.importc, header: "<pthread.h>".}: cint
   v("PTHREAD_PRIO_INHERIT") #{.importc, header: "<pthread.h>".}: cint
   v("PTHREAD_PRIO_NONE") #{.importc, header: "<pthread.h>".}: cint
   v("PTHREAD_PRIO_PROTECT") #{.importc, header: "<pthread.h>".}: cint
@@ -820,5 +824,8 @@ if header("<spawn.h>"):
   v("POSIX_SPAWN_SETSIGDEF")
   v("POSIX_SPAWN_SETSIGMASK")
 
-main()
+if header("<stdio.h>"):
+  v "_IOFBF"
+  v "_IONBF"
 
+main()