Merge pull request #1749 from twpayne/windows-newlines
Generate proper line endings on Windows
This commit is contained in:
28
build.py
28
build.py
@@ -153,7 +153,7 @@ PROJ4JS_ZIP_MD5 = '17caad64cf6ebc6e6fe62f292b134897'
|
||||
def report_sizes(t):
|
||||
stringio = StringIO()
|
||||
gzipfile = gzip.GzipFile(t.name, 'w', 9, stringio)
|
||||
with open(t.name) as f:
|
||||
with open(t.name, 'rb') as f:
|
||||
shutil.copyfileobj(f, gzipfile)
|
||||
gzipfile.close()
|
||||
rawsize = os.stat(t.name).st_size
|
||||
@@ -251,11 +251,11 @@ for glsl_src in GLSL_SRC:
|
||||
def _build_require_list(dependencies, output_file_name):
|
||||
requires = set()
|
||||
for dependency in dependencies:
|
||||
for line in open(dependency):
|
||||
for line in open(dependency, 'rU'):
|
||||
match = re.match(r'goog\.provide\(\'(.*)\'\);', line)
|
||||
if match:
|
||||
requires.add(match.group(1))
|
||||
with open(output_file_name, 'w') as f:
|
||||
with open(output_file_name, 'wb') as f:
|
||||
for require in sorted(requires):
|
||||
f.write('goog.require(\'%s\');\n' % (require,))
|
||||
|
||||
@@ -334,7 +334,7 @@ def examples_star_json(name, match):
|
||||
'../externs/vbarray.js',
|
||||
],
|
||||
})
|
||||
with open(t.name, 'w') as f:
|
||||
with open(t.name, 'wb') as f:
|
||||
f.write(content)
|
||||
dependencies = [__file__, 'buildcfg/base.json']
|
||||
return Target(name, action=action, dependencies=dependencies)
|
||||
@@ -449,7 +449,7 @@ def build_check_requires_timestamp(t):
|
||||
# the generated regular expression to exceed Python's limits
|
||||
if zi.filename.startswith('closure/goog/i18n/'):
|
||||
continue
|
||||
for line in zf.open(zi):
|
||||
for line in zf.open(zi, 'rU'):
|
||||
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
|
||||
if m:
|
||||
all_provides.add(m.group(1))
|
||||
@@ -458,7 +458,7 @@ def build_check_requires_timestamp(t):
|
||||
continue
|
||||
require_linenos = {}
|
||||
uses = set()
|
||||
lines = open(filename).readlines()
|
||||
lines = open(filename, 'rU').readlines()
|
||||
for lineno, line in _strip_comments(lines):
|
||||
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
|
||||
if m:
|
||||
@@ -541,7 +541,7 @@ def build_check_requires_timestamp(t):
|
||||
requires = set()
|
||||
uses = set()
|
||||
uses_linenos = {}
|
||||
for lineno, line in _strip_comments(open(filename)):
|
||||
for lineno, line in _strip_comments(open(filename, 'rU')):
|
||||
m = re.match(r'goog.provide\(\'(.*)\'\);', line)
|
||||
if m:
|
||||
provides.add(m.group(1))
|
||||
@@ -590,7 +590,7 @@ def build_check_whitespace_timestamp(t):
|
||||
errors = 0
|
||||
for filename in sorted(t.newer(t.dependencies)):
|
||||
whitespace = False
|
||||
for lineno, line in enumerate(open(filename)):
|
||||
for lineno, line in enumerate(open(filename, 'rU')):
|
||||
if CR_RE.search(line):
|
||||
t.info('%s:%d: carriage return character in line', filename, lineno + 1)
|
||||
errors += 1
|
||||
@@ -624,8 +624,8 @@ virtual('apidoc', 'build/jsdoc-%(BRANCH)s-timestamp' % vars(variables))
|
||||
|
||||
|
||||
@target('build/jsdoc-%(BRANCH)s-timestamp' % vars(variables), 'host-resources',
|
||||
'build/src/external/src/exports.js', 'build/src/external/src/types.js',
|
||||
SRC, SHADER_SRC, ifind('apidoc/template'))
|
||||
'build/src/external/src/exports.js', SRC, SHADER_SRC,
|
||||
ifind('apidoc/template'))
|
||||
def jsdoc_BRANCH_timestamp(t):
|
||||
t.run('%(JSDOC)s', '-c', 'apidoc/conf.json', 'src', 'apidoc/index.md',
|
||||
'-d', 'build/hosted/%(BRANCH)s/apidoc')
|
||||
@@ -633,7 +633,7 @@ def jsdoc_BRANCH_timestamp(t):
|
||||
|
||||
|
||||
def split_example_file(example, dst_dir):
|
||||
lines = open(example).readlines()
|
||||
lines = open(example, 'rU').readlines()
|
||||
|
||||
target_lines = []
|
||||
target_require_lines = []
|
||||
@@ -651,11 +651,11 @@ def split_example_file(example, dst_dir):
|
||||
target_lines.append(line)
|
||||
|
||||
target = open(
|
||||
os.path.join(dst_dir, os.path.basename(example)), 'w')
|
||||
os.path.join(dst_dir, os.path.basename(example)), 'wb')
|
||||
target_require = open(
|
||||
os.path.join(dst_dir, os.path.basename(example)
|
||||
.replace('.js', '-require.js')),
|
||||
'w')
|
||||
'wb')
|
||||
|
||||
target.writelines(target_lines)
|
||||
target.close()
|
||||
@@ -713,7 +713,7 @@ def host_examples(t):
|
||||
def check_examples(t):
|
||||
examples = ['build/hosted/%(BRANCH)s/' + e
|
||||
for e in EXAMPLES
|
||||
if not open(e.replace('.html', '.js')).readline().startswith('// NOCOMPILE')]
|
||||
if not open(e.replace('.html', '.js'), 'rU').readline().startswith('// NOCOMPILE')]
|
||||
all_examples = \
|
||||
[e + '?mode=advanced' for e in examples]
|
||||
for example in all_examples:
|
||||
|
||||
Reference in New Issue
Block a user