Chromium Code Reviews| Index: tools/publish_barback.py |
| diff --git a/tools/publish_barback.py b/tools/publish_barback.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..95470b2191e2644832896d4c92024077143c3b5e |
| --- /dev/null |
| +++ b/tools/publish_barback.py |
| @@ -0,0 +1,88 @@ |
| +#!/usr/bin/env python |
| +# |
| +# Copyright (c) 2012, 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. |
| +# |
| +# Script to push the barback package to pub. Barback is treated specially |
| +# because it is tightly coupled to the SDK. Pub includes its own copy of |
| +# barback but also includes code that is run against the user's copy of barback. |
| +# To ensure that those are in sync, each version of the SDK has a single |
| +# version of barback that it works with. |
| +# |
| +# We enforce this by placing a narrow SDK constraint in each version of barback. |
| +# This ensures the only barback that will be selected is the one that works |
| +# with the user's SDK. |
|
nweiz
2013/11/07 00:55:55
Should we mention here that this process will chan
Bob Nystrom
2013/11/09 01:24:26
It's actually the barback public API, not the wire
|
| +# |
| +# Usage: publish_barback.py |
| +# |
| +# "pub" must be in PATH. |
| + |
| +import os |
| +import os.path |
| +import re |
| +import shutil |
| +import sys |
| +import subprocess |
| +import tempfile |
| + |
| +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__))) |
| + BARBACK = os.path.join(HOME, 'pkg', 'barback') |
| + |
| + versionFile = os.path.join(HOME, 'tools', 'VERSION') |
| + major = ReadVersion(versionFile, 'MAJOR') |
| + 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: |
| + print 'Error: Do not run this script from a bleeding_edge checkout.' |
| + return -1 |
| + |
| + # Convert the version to semver syntax. |
| + # TODO(rnystrom): Change this when the SDK's version numbering scheme is |
| + # decided. |
|
nweiz
2013/11/07 00:55:55
Is there a bug number you can list here?
Bob Nystrom
2013/11/09 01:24:26
Nope. I don't know if it makes sense to file a bug
|
| + if patch != 0: |
| + version = '%d.%d.%d+%d' % (major, minor, build, patch) |
| + else: |
| + version = '%d.%d.%d' % (major, minor, build) |
| + |
| + # Copy the package to a temp directory so we can fill in the versions in its |
| + # pubspec. |
| + tmpDir = tempfile.mkdtemp() |
| + shutil.copytree(os.path.join(HOME, BARBACK), os.path.join(tmpDir, 'barback')) |
| + |
| + pubspecPath = os.path.join(tmpDir, 'barback', 'pubspec.yaml') |
| + with open(pubspecPath) as pubspecFile: |
| + pubspec = pubspecFile.read() |
| + |
| + # Fill in the SDK version constraint. It pins barback to the current version |
| + # of the SDK with a small amount of wiggle room for hotfixes. |
| + if major < 1: |
| + # No breaking changes until after 1.0. |
| + # TODO(rnystrom): Remove this once 1.0 has shipped. |
| + constraint = '>=%d.%d.%d <=1.0.0' % (major, minor, build) |
|
nweiz
2013/11/07 00:55:55
I think this should be ">=%d.%d.%d <1.1.0", in cas
Bob Nystrom
2013/11/09 01:24:26
Done.
|
| + else: |
| + constraint = '>=%d.%d.%d <%d.%d.0' % (major, minor, build, major, minor + 1) |
| + |
| + # Fill in the SDK version constraint. |
| + pubspec = pubspec.replace('$SDK_CONSTRAINT$', constraint) |
| + |
| + with open(pubspecPath, 'w') as pubspecFile: |
| + pubspecFile.write(pubspec) |
| + |
| + print 'Publishing version %s of barback to pub with SDK constraint "%s".' % (version, constraint) |
|
nweiz
2013/11/07 00:55:55
Long line
Bob Nystrom
2013/11/09 01:24:26
Done.
|
| + subprocess.call(['pub', 'lish'], cwd=os.path.join(tmpDir, 'barback')) |
| + shutil.rmtree(tmpDir) |
| + |
| +if __name__ == '__main__': |
| + sys.exit(Main(sys.argv)) |