Skip to content

Commit

Permalink
js2c: fix module id generation on windows
Browse files Browse the repository at this point in the history
Fix a regression that was introduced in commit 2db758c ("iojs: introduce
internal modules") where the computed id for "config.gypi" on Windows
was not "config" but an empty string.

With an empty string, the build succeeds but the binary is unusable:
startup.processConfig() in src/node.js chokes on the missing .config
property.

PR-URL: #1281
Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
  • Loading branch information
bnoordhuis committed Mar 27, 2015
1 parent 2903410 commit 36f017a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tools/js2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,17 @@ def JS2C(source, target):
lines = ExpandMacros(lines, macros)
lines = CompressScript(lines, do_jsmin)
data = ToCArray(s, lines)
id = '/'.join(re.split('/|\\\\', s)[1:]).split('.')[0]

# On Windows, "./foo.bar" in the .gyp file is passed as "foo.bar"
# so don't assume there is always a slash in the file path.
if '/' in s or '\\' in s:
id = '/'.join(re.split('/|\\\\', s)[1:])
else:
id = s

if '.' in id:
id = id.split('.', 1)[0]

if delay: id = id[:-6]
if delay:
delay_ids.append((id, len(lines)))
Expand Down

0 comments on commit 36f017a

Please sign in to comment.