Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: runtime/tools/concat_library.py

Issue 12321129: Expand part declarations in the builtin library python scripts to avoid having to repeat part decla… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/io_sources.gypi ('k') | sdk/lib/_collection_dev/collection_dev_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/tools/concat_library.py
diff --git a/runtime/tools/concat_library.py b/runtime/tools/concat_library.py
index dfb574a3402df11f70338fbdcc6123208f450db5..ca498a69d6867832d7c21a0047551bc88af24f6e 100644
--- a/runtime/tools/concat_library.py
+++ b/runtime/tools/concat_library.py
@@ -3,6 +3,7 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
+from os import path
import optparse
import shutil
import sys
@@ -21,6 +22,25 @@ def parse_options(argv):
return (options, arguments)
+def concatenate_parts(source, output):
+ with open(source, 'r') as inpt:
+ for line in inpt:
+ # Concatenate all the parts into one big file and
+ # remove all the 'part of' declarations as everything
+ # is in one file.
+ if line.startswith('part '):
+ rest = (line[5:]).strip()
+ if rest.startswith('of'):
+ output.write('// %s' % line)
+ else:
+ file_name = rest[1:-2]
+ dir_name = path.dirname(source)
+ expanded_file_name = path.join(dir_name, file_name)
+ concatenate_parts(expanded_file_name, output)
+ else:
+ output.write(line)
+
+
def main():
# Print the command that is being run. This is helpful when
# debugging build errors.
@@ -29,14 +49,7 @@ def main():
tmp_name = '%s.tmp' % options.output
with open(tmp_name, 'w') as output:
for source in arguments:
- with open(source, 'r') as inpt:
- for line in inpt:
- # Drop unneeded library tags as all the library's files
- # are concatenated into one big file here:
- # The 'part' and 'part of' library tags are removed.
- if line.startswith('#source') or line.startswith('part '):
- line = '// %s' % line
- output.write(line)
+ concatenate_parts(source, output)
shutil.move(tmp_name, options.output)
if __name__ == '__main__':
« no previous file with comments | « runtime/bin/io_sources.gypi ('k') | sdk/lib/_collection_dev/collection_dev_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698