summaryrefslogtreecommitdiff
path: root/js/flatbufferjs_hack.py
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-07-04 14:50:28 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-07-04 16:43:08 -0400
commit06a28998ea3fd38a2173d71eeb3fae5fb5559b2e (patch)
tree79307e9e8c745ec56bc8c18570faccb498219c1a /js/flatbufferjs_hack.py
parent72cd03a1c53633a216f5e284bd1820ea52bf795c (diff)
Replace protobufs with flatbuffers
Diffstat (limited to 'js/flatbufferjs_hack.py')
-rwxr-xr-xjs/flatbufferjs_hack.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/js/flatbufferjs_hack.py b/js/flatbufferjs_hack.py
new file mode 100755
index 000000000..2f411c1db
--- /dev/null
+++ b/js/flatbufferjs_hack.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+"""
+gn can only run python scripts.
+
+Generates flatbuffer TypeScript code.
+"""
+import subprocess
+import sys
+import os
+import shutil
+
+# TODO(ry) Ideally flatc output files should be written into target_gen_dir, but
+# its difficult to get this working in a way that parcel can resolve their
+# location. (Parcel does not support NODE_PATH.) Therefore this hack: write the
+# generated msg_generated.ts outputs into the js/ folder, and we check them into
+# the repo. Hopefully this hack can be removed at some point. If msg.fps is
+# changed, commit changes to the generated JS file.
+
+src = sys.argv[1]
+dst = sys.argv[2]
+stamp_file = sys.argv[3]
+
+shutil.copyfile(src, dst)
+
+
+def touch(fname):
+ if os.path.exists(fname):
+ os.utime(fname, None)
+ else:
+ open(fname, 'a').close()
+
+
+touch(stamp_file)