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

Side by Side Diff: pkg/compiler_unsupported/tool/create_library.py

Issue 126963002: Create a compiler_unsupported package in pkg. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler_unsupported/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file.
6 #
7 # Create the compiler_unsupported package. This will copy the
8 # sdk/lib/_internal/compiler directory and the libraries.dart file into lib/.
9 #
10 # Usage: create_library.py
11
12 import os
13 import re
14 import shutil
15 import sys
16
17 from os.path import dirname, join
18
19
20 def ReplaceInFiles(paths, subs):
21 '''Reads a series of files, applies a series of substitutions to each, and
22 saves them back out. subs should be a list of (pattern, replace) tuples.'''
23 for path in paths:
24 contents = open(path).read()
25 for pattern, replace in subs:
26 contents = re.sub(pattern, replace, contents)
27 dest = open(path, 'w')
28 dest.write(contents)
29 dest.close()
30
31
32 def RemoveFile(f):
33 if os.path.exists(f):
34 os.remove(f)
35
36
37 def Main(argv):
38 # pkg/compiler_unsupported
39 HOME = dirname(dirname(os.path.realpath(__file__)))
40
41 # pkg/compiler_unsupported/lib
42 TARGET = join(HOME, 'lib')
43
44 # sdk/lib/_internal
45 SOURCE = join(dirname(dirname(HOME)), 'sdk', 'lib', '_internal')
46
47 # clean compiler_unsupported/lib
48 if not os.path.exists(TARGET):
49 os.mkdir(TARGET)
50 shutil.rmtree(join(TARGET, 'implementation'), True)
51 RemoveFile(join(TARGET, 'compiler.dart'))
52 RemoveFile(join(TARGET, 'libraries.dart'))
53
54 # copy dart2js code
55 shutil.copy(join(SOURCE, 'compiler', 'compiler.dart'), TARGET)
56 shutil.copy(join(SOURCE, 'libraries.dart'), TARGET)
57 shutil.copytree(
58 join(SOURCE, 'compiler', 'implementation'),
59 join(TARGET, 'implementation'))
60
61 # patch up the libraries.dart references
62 replace = [(r'\.\./\.\./libraries\.dart', r'\.\./libraries\.dart')]
63
64 for root, dirs, files in os.walk(join(TARGET, 'implementation')):
65 for name in files:
66 if name.endswith('.dart'):
67 ReplaceInFiles([join(root, name)], replace)
68
69
70 if __name__ == '__main__':
71 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « pkg/compiler_unsupported/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698