summaryrefslogtreecommitdiff
path: root/tools/js2c.py
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-11-01 16:03:32 -0700
committerRyan Dahl <ry@tinyclouds.org>2010-11-01 16:51:20 -0700
commit97c97450632f2cfd2e8a246337ee4a780f5b35ff (patch)
tree71022061d576928cc4d39b71463c4f4f482dca4b /tools/js2c.py
parent41c1563584bfb018a444e92f01f8cff87ccda30b (diff)
downloadnode-new-97c97450632f2cfd2e8a246337ee4a780f5b35ff.tar.gz
Back to WAF
Too much instability right now. Hopefully we can revisit autoconf soon.
Diffstat (limited to 'tools/js2c.py')
-rwxr-xr-xtools/js2c.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/tools/js2c.py b/tools/js2c.py
index ec3efb7712..db4885553b 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -252,7 +252,7 @@ GET_DELAY_SCRIPT_NAME_CASE = """\
if (index == %(i)i) return Vector<const char>("%(name)s", %(length)i);
"""
-def JS2C(source):
+def JS2C(source, target):
ids = []
delay_ids = []
modules = []
@@ -328,7 +328,8 @@ def JS2C(source):
i = i + 1
# Emit result
- return HEADER_TEMPLATE % {
+ output = open(str(target[0]), "w")
+ output.write(HEADER_TEMPLATE % {
'builtin_count': len(ids) + len(delay_ids),
'delay_count': len(delay_ids),
'source_lines': "\n".join(source_lines),
@@ -336,11 +337,17 @@ def JS2C(source):
'get_index_cases': "".join(get_index_cases),
'get_script_source_cases': "".join(get_script_source_cases),
'get_script_name_cases': "".join(get_script_name_cases)
- }
-
-
-if __name__ == "__main__":
- files = sys.argv[1:]
- print JS2C(files)
-
-
+ })
+ output.close()
+
+ if len(target) > 1:
+ output = open(str(target[1]), "w")
+ output.write(HEADER_TEMPLATE % {
+ 'builtin_count': len(ids) + len(delay_ids),
+ 'delay_count': len(delay_ids),
+ 'source_lines': "\n".join(source_lines_empty),
+ 'get_index_cases': "".join(get_index_cases),
+ 'get_script_source_cases': "".join(get_script_source_cases),
+ 'get_script_name_cases': "".join(get_script_name_cases)
+ })
+ output.close()