wscript :
authorMartin Hermant <martin.hermant@gmail.com>
Wed, 6 Sep 2017 16:03:33 +0000 (12:03 -0400)
committerMartin Hermant <martin.hermant@gmail.com>
Wed, 6 Sep 2017 16:03:33 +0000 (12:03 -0400)
* use waf/extra/c_emscripten
* use node to test js files
add get_waf_emscripten to setup waf with emscripten

scripts/get_waf_emscripten.sh [new file with mode: 0755]
wscript

diff --git a/scripts/get_waf_emscripten.sh b/scripts/get_waf_emscripten.sh
new file mode 100755 (executable)
index 0000000..dae0e70
--- /dev/null
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+set -e
+set -x
+
+SCRIPTPATH=`pwd`/$(dirname "$0") 
+
+
+WAFFILE=waf-1.9.13
+WAFURL=https://waf.io/$WAFFILE.tar.bz2
+
+BUILDDIR=$SCRIPTPATH/../.waf-emscripten-dl
+mkdir -p $BUILDDIR
+
+cd $BUILDDIR
+curl -o $WAFFILE.tar.bz2 $WAFURL
+tar xjvf $WAFFILE.tar.bz2
+cd $WAFFILE
+NOCLIMB=1 ./waf-light --tools=c_emscripten && cp waf $SCRIPTPATH/../   
+
+rm -r $BUILDDIR
diff --git a/wscript b/wscript
index 645ec33..699a74f 100644 (file)
--- a/wscript
+++ b/wscript
@@ -102,23 +102,22 @@ def options(ctx):
     ctx.load('gnu_dirs')
 
 def configure(ctx):
-    from waflib import Options
-    ctx.load('compiler_c')
-    ctx.load('waf_unit_test')
-    ctx.load('gnu_dirs')
-
     target_platform = sys.platform
     if ctx.options.target_platform:
         target_platform = ctx.options.target_platform
-
+    
+    from waflib import Options
 
     if target_platform=='emscripten':
-        # need to force spaces between flag -o and path 
-        # inspired from :
-        # https://github.com/waf-project/waf/blob/master/waflib/extras/c_emscripten.py (#1885)
-        # (OSX /emscripten 1.37.9)
-        ctx.env.CC_TGT_F            = ['-c', '-o', '']
-        ctx.env.CCLNK_TGT_F         = ['-o', '']
+        ctx.load('c_emscripten')
+    else:
+        ctx.load('compiler_c')
+
+    ctx.load('waf_unit_test')
+    ctx.load('gnu_dirs')
+    
+    
+    
     # check for common headers
     ctx.check(header_name='stdlib.h')
     ctx.check(header_name='stdio.h')
@@ -226,9 +225,6 @@ def configure(ctx):
         ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
 
     if target_platform == 'emscripten':
-        import os.path
-        ctx.env.CFLAGS += [ '-I' + os.path.join(os.environ['EMSCRIPTEN'], 'system', 'include') ]
-        
         if ctx.options.build_type == "debug":
             ctx.env.cshlib_PATTERN = '%s.js'
             ctx.env.LINKFLAGS += ['-s','ASSERTIONS=2']
@@ -443,9 +439,11 @@ def build(bld):
 
     # main source
     bld.recurse('src')
-
+    
     # add sub directories
     if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'android']:
+        if bld.env['DEST_OS']=='emscripten' and not bld.options.testcmd:
+            bld.options.testcmd = 'node %s'
         bld.recurse('examples')
         bld.recurse('tests')