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

Unified Diff: tools/copy_dart.py

Issue 11235059: Switch to new library syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
Index: tools/copy_dart.py
diff --git a/tools/copy_dart.py b/tools/copy_dart.py
index 46412448b63860e1436761fac7b89c519a4d065a..339b6f633a59a15091a9333b0a16397f83090a66 100755
--- a/tools/copy_dart.py
+++ b/tools/copy_dart.py
@@ -13,7 +13,7 @@ from os.path import abspath, basename, dirname, exists, isabs, join
from glob import glob
re_directive = re.compile(
- r'^#(library|import|source|native|resource)\([\'"]([^\'"]*)[\'"](.*)\);$')
+ r'^(library|import|part|native|resource)\s+(.*);$')
class Library(object):
def __init__(self, name, imports, sources, natives, code):
@@ -42,17 +42,12 @@ def parseLibrary(library):
if directive == 'library':
assert libraryname is None
libraryname = match.group(2)
- elif directive == 'source':
- sources.append(match.group(2))
+ elif directive == 'part':
+ sources.append(match.group(2).strip('"\''))
elif directive == 'import':
- imports.append((match.group(2), match.group(3)))
- elif directive == 'native':
- natives.append(match.group(2))
- elif directive == 'resource':
- # currently ignored
- pass
+ imports.append(match.group(2))
else:
- raise 'unknown directive %s' % directive
+ raise Exception('unknown directive %s in %s' % (directive, line))
else:
inlinecode.append(line)
fileinput.close()
@@ -125,25 +120,19 @@ def main(outdir = None, *inputs):
# Create file containing all imports, and inlining all sources
with open(outpath, 'w') as f:
if library.name:
- f.write("#library('%s');\n\n" % library.name)
+ f.write("library %s;\n\n" % library.name)
else:
- f.write("#library('%s');\n\n" % basename(lib))
- for (importfile, optional_prefix) in library.imports:
- f.write("#import('%s'%s);\n" % (importfile, optional_prefix))
- for native in library.natives:
- if isabs(native):
- npath = native[1:]
- else:
- npath = native
- f.write("#native('%s');\n" % npath)
- copyfile(normjoin(dirname(lib), native),
- join(dirname(outpath), npath))
+ f.write("library %s;\n\n" % basename(lib))
+ for importfile in library.imports:
podivilov 2012/10/23 11:57:55 Maybe keep support for prefixed import in case we'
Anton Muhin 2012/10/23 13:03:27 We actually dump the whole suffix after import, so
+ f.write("import %s;\n" % (importfile))
f.write('%s' % (''.join(library.code)))
mergefiles([normjoin(dirname(lib), s) for s in library.sources], f)
- for (i, prefix) in library.imports:
- if not i.startswith('dart:'):
- worklist.append(normjoin(dirname(lib), i));
+ for suffix in library.imports:
+ m = re.match(r'[\'"]([^\'"]+)[\'"](\s+as\s+\w+)?$', suffix)
+ uri = m.group(0)
+ if not uri.startswith('dart:'):
+ worklist.append(normjoin(dirname(lib), uri));
return 0

Powered by Google App Engine
This is Rietveld 408576698