Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-03-15 18:00:19 +0300
committerRyan Dahl <ry@tinyclouds.org>2010-03-15 18:04:35 +0300
commit4ccdc501d48a0f198a040ee46f4dab27a611a489 (patch)
tree818fd2b245ce7e528a2c5335df78979057f7751f /tools
parent0d5a1fed33134d05911a153ade2bf8ae8710fc57 (diff)
Include lib/ directory in node executable. Compile on demand.
Instead of installing the files in /usr/lib/node/libraries and loading them from the file system, the files are built-in to the node executable. However, they are only compiled on demand. The reasoning is: 1. Allow for more complex internal javascript. In particular, process.stdout and process.stdin can be js implemented streams. 2. Ease system installs. Loading from disk each time is unnecessary overhead. Note that there is no "system" path for modules anymore. Only $HOME/.node_libraries.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/js2c.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/js2c.py b/tools/js2c.py
index fb38ece99b3..64e5c2b625e 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -35,11 +35,22 @@ import os, re, sys, string
import jsmin
-def ToCArray(lines):
+def ToCArray(filename, lines):
result = []
+ row = 1
+ col = 0
for chr in lines:
+ col += 1
+ if chr == "\n" or chr == "\r":
+ row += 1
+ col = 0
+
value = ord(chr)
- assert value < 128
+
+ if value > 128:
+ print 'non-ascii value ' + filename + ':' + str(row) + ':' + str(col)
+ sys.exit(1);
+
result.append(str(value))
result.append("0")
return ", ".join(result)
@@ -231,6 +242,7 @@ def JS2C(source, target):
# Locate the macros file name.
consts = {}
macros = {}
+
for s in source:
if 'macros.py' == (os.path.split(str(s))[1]):
(consts, macros) = ReadMacros(ReadLines(str(s)))
@@ -244,10 +256,11 @@ def JS2C(source, target):
delay = str(s).endswith('-delay.js')
lines = ReadFile(str(s))
do_jsmin = lines.find('// jsminify this file, js2c: jsmin') != -1
+
lines = ExpandConstants(lines, consts)
lines = ExpandMacros(lines, macros)
lines = CompressScript(lines, do_jsmin)
- data = ToCArray(lines)
+ data = ToCArray(s, lines)
id = (os.path.split(str(s))[1])[:-3]
if delay: id = id[:-6]
if delay: