提交 b3949716 编写于 作者: E Eric Seidel

Add a roll_versions.py script and roll versions once.

This isn't perfect, since it makes non-minimal modifications
to the yaml and xml files.  In the yaml case it sorts the keys
and in the xml case it doesn't do the fancy attribute wrapping,
but this seems good enough to use.

R=abarth@chromium.org, johnmccutchen@google.com

Review URL: https://codereview.chromium.org/1179633003.
上级 48571735
......@@ -3,30 +3,23 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.domokit.sky.demo"
android:versionCode="8"
android:versionName="0.0.8">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.domokit.sky.demo" android:versionCode="9" android:versionName="0.0.9">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
<application android:icon="@mipmap/ic_launcher" android:name="SkyDemoApplication" android:label="Sky">
<activity android:name="SkyDemoActivity"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
android:hardwareAccelerated="true">
<application android:icon="@mipmap/ic_launcher" android:label="Sky" android:name="SkyDemoApplication">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize" android:hardwareAccelerated="true" android:launchMode="singleTask" android:name="SkyDemoActivity" android:theme="@android:style/Theme.Holo.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sky" />
</intent-filter>
</activity>
</application>
</manifest>
</manifest>
\ No newline at end of file
name: sky
author: Chromium Authors <sky-dev@googlegroups.com>
description: Dart files to support executing inside Sky.
homepage: https://github.com/domokit/mojo/tree/master/sky
version: 0.0.8
dependencies:
mojo: '>=0.0.1 <1.0.0'
mojom: '>=0.0.4 <1.0.0'
vector_math: '>=1.4.3 <2.0.0'
description: Dart files to support executing inside Sky.
homepage: https://github.com/domokit/mojo/tree/master/sky
name: sky
version: 0.0.9
#!/usr/bin/env python
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import yaml
import xml.etree.ElementTree as ET
PUBSPECS = [
'sky/sdk/pubspec.yaml',
'mojo/public/dart/pubspec.yaml',
'mojo/dart/mojo_services/pubspec.yaml',
'mojo/dart/mojom/pubspec.yaml',
]
MANIFESTS = [
'sky/apk/demo/AndroidManifest.xml',
]
MANIFEST_PREFACE = '''<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
'''
def increment_version(version):
pieces = version.split('.')
pieces[-1] = str(int(pieces[-1]) + 1)
return '.'.join(pieces)
def sort_dict(unsorted):
sorted_dict = collections.OrderedDict()
for key in sorted(unsorted.keys()):
sorted_dict[key] = unsorted[key]
return sorted_dict
def update_pubspec(pubspec):
# TODO(eseidel): This does not prserve any manual sort-order of the yaml.
with open(pubspec, 'r') as stream:
spec = yaml.load(stream)
old_version = spec['version']
spec['version'] = increment_version(old_version)
print "%20s %6s => %6s" % (spec['name'], old_version, spec['version'])
with open(pubspec, 'w') as stream:
yaml.dump(spec, stream=stream, default_flow_style=False)
def prepend_to_file(to_prepend, filepath):
with open(filepath, 'r+') as f:
content = f.read()
f.seek(0, 0)
f.write(to_prepend + content)
def update_manifest(manifest):
VERSION_CODE = '{http://schemas.android.com/apk/res/android}versionCode'
VERSION_NAME = '{http://schemas.android.com/apk/res/android}versionName'
tree = ET.parse(manifest)
root = tree.getroot()
package_name = root.get('package')
old_code = root.get(VERSION_CODE)
old_name = root.get(VERSION_NAME)
root.set(VERSION_CODE, increment_version(old_code))
root.set(VERSION_NAME, increment_version(old_name))
print "%20s %6s (%s) => %6s (%s)" % (package_name, old_name, old_code,
root.get(VERSION_NAME), root.get(VERSION_CODE))
# TODO(eseidel): This isn't smart enough to wrap/intent multi-attribute
# elements like <manifest> as is the typical AndroidManifiest.xml style
# we could write our own custom prettyprinter to do that?
tree.write(manifest)
prepend_to_file(MANIFEST_PREFACE, manifest)
def main():
print 'Pub packages:'
for pubspec in PUBSPECS:
update_pubspec(pubspec)
# TODO(eseidel): Without this ET uses 'ns0' for 'android' which is wrong.
ET.register_namespace('android', 'http://schemas.android.com/apk/res/android')
print 'APKs:'
for manifest in MANIFESTS:
update_manifest(manifest)
if __name__ == '__main__':
main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册