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

Unified Diff: tools/publish_pkg.py

Issue 11628004: move libraries.dart into the package if needed (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/publish_pkg.py
diff --git a/tools/publish_pkg.py b/tools/publish_pkg.py
index 82e07df3885dc8b8046ec7fbb79b44872bdc2f9c..f9e2ce4d4ab4c44578dd2ffe6e82bd15746c32e0 100755
--- a/tools/publish_pkg.py
+++ b/tools/publish_pkg.py
@@ -4,7 +4,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.
#
-# Script to push a package to pub.
+# Script to push a package to pub.
#
# Usage: publish_pkg.py pkg_dir
#
@@ -31,13 +31,12 @@ def ReplaceInFiles(paths, subs):
dest.write(contents)
dest.close()
-
def ReadVersion(file, field):
for line in open(file).read().split('\n'):
[k, v] = re.split('\s+', line)
if field == k:
return int(v)
-
+
def Main(argv):
HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
@@ -46,7 +45,7 @@ def Main(argv):
minor = ReadVersion(versionFile, 'MINOR')
build = ReadVersion(versionFile, 'BUILD')
patch = ReadVersion(versionFile, 'PATCH')
-
+
# bleeding_edge has a fixed version number of 0.1.x.y . Don't allow users
# to publish packages from bleeding_edge.
if major == 0 and minor <= 1:
@@ -63,12 +62,14 @@ def Main(argv):
pubspec = os.path.join(tmpDir, pkgName, 'pubspec.yaml')
+ replaceInFiles = []
+
if os.path.exists(os.path.join(HOME, argv[1], 'pubspec.yaml')):
#
# If pubspec.yaml exists, add the SDK's version number if
# no version number is present.
#
- shutil.copytree(os.path.join(HOME, argv[1]),
+ shutil.copytree(os.path.join(HOME, argv[1]),
os.path.join(tmpDir, pkgName))
with open(pubspec) as pubspecFile:
lines = pubspecFile.readlines()
@@ -100,7 +101,7 @@ def Main(argv):
# Otherwise, move the package's contents to lib/.
#
if os.path.exists(os.path.join(HOME, argv[1], 'lib')):
- shutil.copytree(os.path.join(HOME, argv[1]),
+ shutil.copytree(os.path.join(HOME, argv[1]),
os.path.join(tmpDir, pkgName))
else:
os.makedirs(os.path.join(tmpDir, pkgName))
@@ -117,13 +118,25 @@ def Main(argv):
pubspecFile.write(' unpredictable/incompatible ways without warning.\n')
pubspecFile.write('dependencies:\n')
+ libpath = os.path.join(HOME, argv[1], '../libraries.dart')
+ if os.path.exists(libpath):
+ # Copy libraries.dart into the package source code
+ shutil.copy(libpath, os.path.join(tmpDir, pkgName, 'lib/libraries.dart'))
+
+ # Replace '../../libraries.dart' with '../libraries.dart'
+ replaceInFiles.append(
+ (r'(import|part)(\s+)(\'|")\.\./(\.\./)*libraries.dart',
+ r'\1\2\3\4libraries.dart'))
+
+ replaceInFiles.append(
+ (r'(import|part)(\s+)(\'|")(\.\./)+pkg/', r'\1\2\3package:'))
+
# Replace '../*/pkg' imports and parts.
for root, dirs, files in os.walk(os.path.join(tmpDir, pkgName)):
for name in files:
if name.endswith('.dart'):
- ReplaceInFiles([os.path.join(root, name)],
- [(r'(import|part)(\s+)(\'|")(\.\./)+pkg/', r'\1\2\3package:')])
-
+ ReplaceInFiles([os.path.join(root, name)], replaceInFiles)
+
print 'publishing version ' + version + ' of ' + argv[1] + ' to pub.\n'
subprocess.call(['pub', 'publish'], cwd=os.path.join(tmpDir, pkgName))
shutil.rmtree(tmpDir)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698