Skip to content

Commit

Permalink
gyp: Open the build file with universal-newlines mode
Browse files Browse the repository at this point in the history
To make sure platform specific newlines ('\r\n' or '\r') are converted
to '\n' which otherwise will fail eval().

This should handle multiple issues reported on syntax error reading
binding.gyp (partial list):

nodejs#979
nodejs#199
nospaceships/node-net-ping#24
nospaceships/node-net-ping#21
mathiask88/node-snap7#11
node-hid/node-hid#28
xdenser/node-firebird-libfbclient#24

PR-URL: nodejs#1053
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
guymguym authored and refack committed Aug 19, 2017
1 parent 1dd9ea8 commit 0c98bee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gyp/pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ def LoadOneBuildFile(build_file_path, data, aux_data, includes,
return data[build_file_path]

if os.path.exists(build_file_path):
build_file_contents = open(build_file_path).read()
# Open the build file for read ('r') with universal-newlines mode ('U')
# to make sure platform specific newlines ('\r\n' or '\r') are converted to '\n'
# which otherwise will fail eval()
build_file_contents = open(build_file_path, 'rU').read()
else:
raise GypError("%s not found (cwd: %s)" % (build_file_path, os.getcwd()))

Expand Down

0 comments on commit 0c98bee

Please sign in to comment.