aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-04-26 11:39:51 +0100
committerRichard van der Hoff <richard@matrix.org>2016-04-26 12:12:08 +0100
commit7305649a277214da35452f2e0172ad5f75454413 (patch)
tree75666a32dfe3040d4fbd8254f258f47467afb8de
parent4b26a09c3772b74bb8ad2305406bba88ababb4a2 (diff)
Make 'npm build' build the js lib
-rw-r--r--javascript/.gitignore2
-rwxr-xr-xjavascript/build.py10
-rw-r--r--javascript/package.json1
3 files changed, 10 insertions, 3 deletions
diff --git a/javascript/.gitignore b/javascript/.gitignore
index 3613cfd..603fe7c 100644
--- a/javascript/.gitignore
+++ b/javascript/.gitignore
@@ -1,2 +1,4 @@
/exported_functions.json
+/node_modules
+/npm-debug.log
/olm.js
diff --git a/javascript/build.py b/javascript/build.py
index 093532a..fb58a2c 100755
--- a/javascript/build.py
+++ b/javascript/build.py
@@ -20,6 +20,8 @@ import sys
import re
import json
+
+os.chdir(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
source_files = glob.glob("src/*.cpp")
pre_js, = glob.glob("javascript/*pre.js")
post_js, = glob.glob("javascript/*post.js")
@@ -39,19 +41,22 @@ with open(exported_functions, "w") as json_file:
emcc = os.environ.get("EMCC", "emcc")
+optimize_opts = os.environ.get("OPTIMIZE_FLAGS", "-O3")
compile_args = [emcc]
+compile_args += optimize_opts.split()
compile_args += """
- -O3
-Iinclude
-Ilib
-std=c++11
--closure 1
--memory-init-file 0
-s NO_FILESYSTEM=1
- -s NO_BROWSER=1
-s INVOKE_RUN=0
""".split()
+# NO_BROWSER is kept for compatibility with emscripten 1.35.24, but is no
+# longer needed.
+compile_args += ("-s","NO_BROWSER=1")
compile_args += source_files
compile_args += ("--pre-js", pre_js)
compile_args += ("--post-js", post_js)
@@ -66,4 +71,3 @@ def run(args):
subprocess.check_call(args)
run(compile_args + ["-o", library])
-
diff --git a/javascript/package.json b/javascript/package.json
index b27d6eb..dc16e45 100644
--- a/javascript/package.json
+++ b/javascript/package.json
@@ -8,6 +8,7 @@
"README.md"
],
"scripts": {
+ "build": "./build.py",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {