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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler_unsupported/tool/create_library.py
===================================================================
--- pkg/compiler_unsupported/tool/create_library.py (revision 0)
+++ pkg/compiler_unsupported/tool/create_library.py (working copy)
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+# 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.
+#
+# Create the compiler_unsupported package. This will copy the
+# sdk/lib/_internal/compiler directory and the libraries.dart file into lib/.
+#
+# Usage: create_library.py
+
+import os
+import re
+import shutil
+import sys
+
+from os.path import dirname, join
+
+
+def ReplaceInFiles(paths, subs):
+ '''Reads a series of files, applies a series of substitutions to each, and
+ saves them back out. subs should be a list of (pattern, replace) tuples.'''
+ for path in paths:
+ contents = open(path).read()
+ for pattern, replace in subs:
+ contents = re.sub(pattern, replace, contents)
+ dest = open(path, 'w')
+ dest.write(contents)
+ dest.close()
+
+
+def RemoveFile(f):
+ if os.path.exists(f):
+ os.remove(f)
+
+
+def Main(argv):
+ # pkg/compiler_unsupported
+ HOME = dirname(dirname(os.path.realpath(__file__)))
+
+ # pkg/compiler_unsupported/lib
+ TARGET = join(HOME, 'lib')
+
+ # sdk/lib/_internal
+ SOURCE = join(dirname(dirname(HOME)), 'sdk', 'lib', '_internal')
+
+ # clean compiler_unsupported/lib
+ if not os.path.exists(TARGET):
+ os.mkdir(TARGET)
+ shutil.rmtree(join(TARGET, 'implementation'), True)
+ RemoveFile(join(TARGET, 'compiler.dart'))
+ RemoveFile(join(TARGET, 'libraries.dart'))
+
+ # copy dart2js code
+ shutil.copy(join(SOURCE, 'compiler', 'compiler.dart'), TARGET)
+ shutil.copy(join(SOURCE, 'libraries.dart'), TARGET)
+ shutil.copytree(
+ join(SOURCE, 'compiler', 'implementation'),
+ join(TARGET, 'implementation'))
+
+ # patch up the libraries.dart references
+ replace = [(r'\.\./\.\./libraries\.dart', r'\.\./libraries\.dart')]
+
+ for root, dirs, files in os.walk(join(TARGET, 'implementation')):
+ for name in files:
+ if name.endswith('.dart'):
+ ReplaceInFiles([join(root, name)], replace)
+
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
Property changes on: pkg/compiler_unsupported/tool/create_library.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
« pkg/compiler_unsupported/pubspec.yaml ('K') | « pkg/compiler_unsupported/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698