summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xcheck.py13
-rwxr-xr-xemcc_to_polyfill.sh8
-rw-r--r--src/templates/normal.js4
-rw-r--r--test/hello_world.c7
5 files changed, 32 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 9e5aa6211..761b8f1fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,4 @@ bin/asm2wasm
bin/wasm.js
*~
*.diff
-
+a.*
diff --git a/check.py b/check.py
index 6466b87f5..c6b6090f2 100755
--- a/check.py
+++ b/check.py
@@ -16,7 +16,7 @@ for arg in sys.argv[1:]:
if not interpreter:
print '[ no wasm interpreter provided, you should pass one as --interpreter=path/to/interpreter ]'
-print '[ checking testcases... ]\n'
+print '[ checking asm2wasm testcases... ]\n'
if len(tests) == 0:
tests = sorted(os.listdir('test'))
@@ -59,5 +59,16 @@ for asm in tests:
raise Exception('wasm interpreter error: ' + err) # failed to pretty-print
raise Exception('wasm interpreter error')
+print '\n[ checking emcc_to_polyfill testcases... (need both emcc and nodejs in your path) ]\n'
+
+print '..normal'
+
+if os.path.exists('a.normal.js'): os.unlink('a.normal.js')
+subprocess.check_call(['./emcc_to_polyfill.sh', os.path.join('test', 'hello_world.c')])
+proc = subprocess.Popen(['nodejs', 'a.normal.js'], stdout=subprocess.PIPE)
+out, err = proc.communicate()
+assert proc.returncode == 0
+assert 'hello, world!' in out, out
+
print '\n[ success! ]'
diff --git a/emcc_to_polyfill.sh b/emcc_to_polyfill.sh
new file mode 100755
index 000000000..c808e7ae8
--- /dev/null
+++ b/emcc_to_polyfill.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+emcc $1 -o a.html --separate-asm
+# we now have a.asm.js and a.js, combine them
+# a.normal.js: just normal combination of the files. no wasm yet
+cat src/templates/normal.js > a.normal.js
+cat a.asm.js >> a.normal.js
+cat a.js >> a.normal.js
+
diff --git a/src/templates/normal.js b/src/templates/normal.js
new file mode 100644
index 000000000..5893f96a0
--- /dev/null
+++ b/src/templates/normal.js
@@ -0,0 +1,4 @@
+
+var Module = {}; // *.asm.js expects this
+
+
diff --git a/test/hello_world.c b/test/hello_world.c
new file mode 100644
index 000000000..eb47ea813
--- /dev/null
+++ b/test/hello_world.c
@@ -0,0 +1,7 @@
+#include<stdio.h>
+
+int main() {
+ printf("hello, world!\n");
+ return 0;
+}
+