Permalink
Browse files

Merge pull request #1749 from twpayne/windows-newlines

Generate proper line endings on Windows
  • Loading branch information...
2 parents a78b25c + face69c commit 69addbca8787f79a7ed4615c268a86a2a3fac4ca @twpayne twpayne committed Feb 25, 2014
Showing with 155 additions and 32 deletions.
  1. +6 −6 bin/combine-examples.py
  2. +1 −1 bin/generate-exports.py
  3. +3 −3 bin/pyglslunit.py
  4. +14 −14 build.py
  5. +131 −8 pake.py
View
@@ -8,19 +8,19 @@ def main(argv):
examples = {}
requires = set()
for filename in argv[1:]:
- lines = open(filename).readlines()
+ lines = open(filename, 'rU').readlines()
if len(lines) > 0 and lines[0].startswith('// NOCOMPILE'):
continue
requires.update(line for line in lines if line.startswith('goog.require'))
examples[filename] = [line for line in lines if not line.startswith('goog.require')]
for require in sorted(requires):
- print require,
+ sys.stdout.write(require)
for filename in sorted(examples.keys()):
- print '// ', filename
- print '(function(){'
+ sys.stdout.write('// ' + filename + '\n')
+ sys.stdout.write('(function(){\n')
for line in examples[filename]:
- print line,
- print '})();'
+ sys.stdout.write(line)
+ sys.stdout.write('})();\n')
if __name__ == '__main__':
View
@@ -113,7 +113,7 @@ def main(argv):
for arg in args:
in_comment = False
object_literal = None
- for line in open(arg):
+ for line in open(arg, 'rU'):
line = line.strip()
if not line:
continue
View
@@ -52,7 +52,7 @@ def main(argv):
common, vertex, fragment = [], [], []
attributes, uniforms, varyings = {}, {}, {}
block = None
- for line in open(options.input):
+ for line in open(options.input, 'rU'):
if line.startswith('//!'):
m = re.match(r'//!\s+NAMESPACE=(\S+)\s*\Z', line)
if m:
@@ -111,10 +111,10 @@ def main(argv):
context['getUniforms'] = [uniforms[u] for u in sorted(uniforms.keys())]
if options.output and options.output != '-':
- output = open(options.output, 'w')
+ output = open(options.output, 'wb')
else:
output = sys.stdout
- output.write(pystache.render(open(options.template).read(), context))
+ output.write(pystache.render(open(options.template, 'rb').read(), context))
if __name__ == '__main__':
View
@@ -153,7 +153,7 @@
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 @@ def shader_src(t):
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 action(t):
'../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_re(self, key):
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,16 +624,16 @@ def plovr_jar(t):
@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')
t.touch()
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:
Oops, something went wrong.

0 comments on commit 69addbc

Please sign in to comment.