1ffe3c632Sopenharmony_ci#!/usr/bin/env python 2ffe3c632Sopenharmony_ci# Usage: ./update_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>] 3ffe3c632Sopenharmony_ci# 4ffe3c632Sopenharmony_ci# Example: 5ffe3c632Sopenharmony_ci# ./update_version.py 3.7.1 2 6ffe3c632Sopenharmony_ci# => Version will become 3.7.1-rc-2 (beta) 7ffe3c632Sopenharmony_ci# ./update_version.py 3.7.1 8ffe3c632Sopenharmony_ci# => Version will become 3.7.1 (stable) 9ffe3c632Sopenharmony_ci 10ffe3c632Sopenharmony_ciimport datetime 11ffe3c632Sopenharmony_ciimport re 12ffe3c632Sopenharmony_ciimport sys 13ffe3c632Sopenharmony_cifrom xml.dom import minidom 14ffe3c632Sopenharmony_ci 15ffe3c632Sopenharmony_ciif len(sys.argv) < 2 or len(sys.argv) > 3: 16ffe3c632Sopenharmony_ci print """ 17ffe3c632Sopenharmony_ci[ERROR] Please specify a version. 18ffe3c632Sopenharmony_ci 19ffe3c632Sopenharmony_ci./update_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>] 20ffe3c632Sopenharmony_ci 21ffe3c632Sopenharmony_ciExample: 22ffe3c632Sopenharmony_ci./update_version.py 3.7.1 2 23ffe3c632Sopenharmony_ci""" 24ffe3c632Sopenharmony_ci exit(1) 25ffe3c632Sopenharmony_ci 26ffe3c632Sopenharmony_ciNEW_VERSION = sys.argv[1] 27ffe3c632Sopenharmony_ciNEW_VERSION_INFO = [int(x) for x in NEW_VERSION.split('.')] 28ffe3c632Sopenharmony_ciif len(NEW_VERSION_INFO) != 3: 29ffe3c632Sopenharmony_ci print """ 30ffe3c632Sopenharmony_ci[ERROR] Version must be in the format <MAJOR>.<MINOR>.<MICRO> 31ffe3c632Sopenharmony_ci 32ffe3c632Sopenharmony_ciExample: 33ffe3c632Sopenharmony_ci./update_version.py 3.7.3 34ffe3c632Sopenharmony_ci""" 35ffe3c632Sopenharmony_ci exit(1) 36ffe3c632Sopenharmony_ci 37ffe3c632Sopenharmony_ciRC_VERSION = -1 38ffe3c632Sopenharmony_ciif len(sys.argv) > 2: 39ffe3c632Sopenharmony_ci RC_VERSION = int(sys.argv[2]) 40ffe3c632Sopenharmony_ci 41ffe3c632Sopenharmony_ci 42ffe3c632Sopenharmony_cidef Find(elem, tagname): 43ffe3c632Sopenharmony_ci for child in elem.childNodes: 44ffe3c632Sopenharmony_ci if child.nodeName == tagname: 45ffe3c632Sopenharmony_ci return child 46ffe3c632Sopenharmony_ci return None 47ffe3c632Sopenharmony_ci 48ffe3c632Sopenharmony_ci 49ffe3c632Sopenharmony_cidef FindAndClone(elem, tagname): 50ffe3c632Sopenharmony_ci return Find(elem, tagname).cloneNode(True) 51ffe3c632Sopenharmony_ci 52ffe3c632Sopenharmony_ci 53ffe3c632Sopenharmony_cidef ReplaceText(elem, text): 54ffe3c632Sopenharmony_ci elem.firstChild.replaceWholeText(text) 55ffe3c632Sopenharmony_ci 56ffe3c632Sopenharmony_ci 57ffe3c632Sopenharmony_cidef GetFullVersion(rc_suffix = '-rc-'): 58ffe3c632Sopenharmony_ci if RC_VERSION < 0: 59ffe3c632Sopenharmony_ci return NEW_VERSION 60ffe3c632Sopenharmony_ci else: 61ffe3c632Sopenharmony_ci return '%s%s%s' % (NEW_VERSION, rc_suffix, RC_VERSION) 62ffe3c632Sopenharmony_ci 63ffe3c632Sopenharmony_ci 64ffe3c632Sopenharmony_cidef RewriteXml(filename, rewriter, add_xml_prefix=True): 65ffe3c632Sopenharmony_ci document = minidom.parse(filename) 66ffe3c632Sopenharmony_ci rewriter(document) 67ffe3c632Sopenharmony_ci # document.toxml() always prepend the XML version without inserting new line. 68ffe3c632Sopenharmony_ci # We wants to preserve as much of the original formatting as possible, so we 69ffe3c632Sopenharmony_ci # will remove the default XML version and replace it with our custom one when 70ffe3c632Sopenharmony_ci # whever necessary. 71ffe3c632Sopenharmony_ci content = document.toxml().replace('<?xml version="1.0" ?>', '') 72ffe3c632Sopenharmony_ci file_handle = open(filename, 'wb') 73ffe3c632Sopenharmony_ci if add_xml_prefix: 74ffe3c632Sopenharmony_ci file_handle.write('<?xml version="1.0" encoding="UTF-8"?>\n') 75ffe3c632Sopenharmony_ci file_handle.write(content) 76ffe3c632Sopenharmony_ci file_handle.write('\n') 77ffe3c632Sopenharmony_ci file_handle.close() 78ffe3c632Sopenharmony_ci 79ffe3c632Sopenharmony_ci 80ffe3c632Sopenharmony_cidef RewriteTextFile(filename, line_rewriter): 81ffe3c632Sopenharmony_ci lines = open(filename, 'r').readlines() 82ffe3c632Sopenharmony_ci updated_lines = [] 83ffe3c632Sopenharmony_ci for line in lines: 84ffe3c632Sopenharmony_ci updated_lines.append(line_rewriter(line)) 85ffe3c632Sopenharmony_ci if lines == updated_lines: 86ffe3c632Sopenharmony_ci print '%s was not updated. Please double check.' % filename 87ffe3c632Sopenharmony_ci f = open(filename, 'w') 88ffe3c632Sopenharmony_ci f.write(''.join(updated_lines)) 89ffe3c632Sopenharmony_ci f.close() 90ffe3c632Sopenharmony_ci 91ffe3c632Sopenharmony_ci 92ffe3c632Sopenharmony_cidef UpdateConfigure(): 93ffe3c632Sopenharmony_ci RewriteTextFile('configure.ac', 94ffe3c632Sopenharmony_ci lambda line : re.sub( 95ffe3c632Sopenharmony_ci r'^AC_INIT\(\[Protocol Buffers\],\[.*\],\[protobuf@googlegroups.com\],\[protobuf\]\)$', 96ffe3c632Sopenharmony_ci ('AC_INIT([Protocol Buffers],[%s],[protobuf@googlegroups.com],[protobuf])' 97ffe3c632Sopenharmony_ci % GetFullVersion()), 98ffe3c632Sopenharmony_ci line)) 99ffe3c632Sopenharmony_ci 100ffe3c632Sopenharmony_ci 101ffe3c632Sopenharmony_cidef UpdateCpp(): 102ffe3c632Sopenharmony_ci cpp_version = '%d%03d%03d' % ( 103ffe3c632Sopenharmony_ci NEW_VERSION_INFO[0], NEW_VERSION_INFO[1], NEW_VERSION_INFO[2]) 104ffe3c632Sopenharmony_ci def RewriteCommon(line): 105ffe3c632Sopenharmony_ci line = re.sub( 106ffe3c632Sopenharmony_ci r'^#define GOOGLE_PROTOBUF_VERSION .*$', 107ffe3c632Sopenharmony_ci '#define GOOGLE_PROTOBUF_VERSION %s' % cpp_version, 108ffe3c632Sopenharmony_ci line) 109ffe3c632Sopenharmony_ci line = re.sub( 110ffe3c632Sopenharmony_ci r'^#define PROTOBUF_VERSION .*$', 111ffe3c632Sopenharmony_ci '#define PROTOBUF_VERSION %s' % cpp_version, 112ffe3c632Sopenharmony_ci line) 113ffe3c632Sopenharmony_ci if NEW_VERSION_INFO[2] == 0: 114ffe3c632Sopenharmony_ci line = re.sub( 115ffe3c632Sopenharmony_ci r'^#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC .*$', 116ffe3c632Sopenharmony_ci '#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC %s' % cpp_version, 117ffe3c632Sopenharmony_ci line) 118ffe3c632Sopenharmony_ci line = re.sub( 119ffe3c632Sopenharmony_ci r'^#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION .*$', 120ffe3c632Sopenharmony_ci '#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION %s' % cpp_version, 121ffe3c632Sopenharmony_ci line) 122ffe3c632Sopenharmony_ci line = re.sub( 123ffe3c632Sopenharmony_ci r'^static const int kMinHeaderVersionForLibrary = .*$', 124ffe3c632Sopenharmony_ci 'static const int kMinHeaderVersionForLibrary = %s;' % cpp_version, 125ffe3c632Sopenharmony_ci line) 126ffe3c632Sopenharmony_ci line = re.sub( 127ffe3c632Sopenharmony_ci r'^static const int kMinHeaderVersionForProtoc = .*$', 128ffe3c632Sopenharmony_ci 'static const int kMinHeaderVersionForProtoc = %s;' % cpp_version, 129ffe3c632Sopenharmony_ci line) 130ffe3c632Sopenharmony_ci return line 131ffe3c632Sopenharmony_ci 132ffe3c632Sopenharmony_ci def RewritePortDef(line): 133ffe3c632Sopenharmony_ci line = re.sub( 134ffe3c632Sopenharmony_ci r'^#define PROTOBUF_VERSION .*$', 135ffe3c632Sopenharmony_ci '#define PROTOBUF_VERSION %s' % cpp_version, 136ffe3c632Sopenharmony_ci line) 137ffe3c632Sopenharmony_ci if NEW_VERSION_INFO[2] == 0: 138ffe3c632Sopenharmony_ci line = re.sub( 139ffe3c632Sopenharmony_ci r'^#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC .*$', 140ffe3c632Sopenharmony_ci '#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC %s' % cpp_version, 141ffe3c632Sopenharmony_ci line) 142ffe3c632Sopenharmony_ci line = re.sub( 143ffe3c632Sopenharmony_ci r'^#define PROTOBUF_MIN_PROTOC_VERSION .*$', 144ffe3c632Sopenharmony_ci '#define PROTOBUF_MIN_PROTOC_VERSION %s' % cpp_version, 145ffe3c632Sopenharmony_ci line) 146ffe3c632Sopenharmony_ci line = re.sub( 147ffe3c632Sopenharmony_ci r'^#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION .*$', 148ffe3c632Sopenharmony_ci '#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION %s' % cpp_version, 149ffe3c632Sopenharmony_ci line) 150ffe3c632Sopenharmony_ci return line 151ffe3c632Sopenharmony_ci 152ffe3c632Sopenharmony_ci def RewritePbH(line): 153ffe3c632Sopenharmony_ci line = re.sub( 154ffe3c632Sopenharmony_ci r'^#if PROTOBUF_VERSION < .*$', 155ffe3c632Sopenharmony_ci '#if PROTOBUF_VERSION < %s' % cpp_version, 156ffe3c632Sopenharmony_ci line) 157ffe3c632Sopenharmony_ci line = re.sub( 158ffe3c632Sopenharmony_ci r'^#if .* < PROTOBUF_MIN_PROTOC_VERSION$', 159ffe3c632Sopenharmony_ci '#if %s < PROTOBUF_MIN_PROTOC_VERSION' % cpp_version, 160ffe3c632Sopenharmony_ci line) 161ffe3c632Sopenharmony_ci return line 162ffe3c632Sopenharmony_ci 163ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/stubs/common.h', RewriteCommon) 164ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/port_def.inc', RewritePortDef) 165ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/any.pb.h', RewritePbH) 166ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/api.pb.h', RewritePbH) 167ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/descriptor.pb.h', RewritePbH) 168ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/duration.pb.h', RewritePbH) 169ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/empty.pb.h', RewritePbH) 170ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/field_mask.pb.h', RewritePbH) 171ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/source_context.pb.h', RewritePbH) 172ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/struct.pb.h', RewritePbH) 173ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/timestamp.pb.h', RewritePbH) 174ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/type.pb.h', RewritePbH) 175ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/wrappers.pb.h', RewritePbH) 176ffe3c632Sopenharmony_ci RewriteTextFile('src/google/protobuf/compiler/plugin.pb.h', RewritePbH) 177ffe3c632Sopenharmony_ci 178ffe3c632Sopenharmony_ci 179ffe3c632Sopenharmony_cidef UpdateCsharp(): 180ffe3c632Sopenharmony_ci RewriteXml('csharp/src/Google.Protobuf/Google.Protobuf.csproj', 181ffe3c632Sopenharmony_ci lambda document : ReplaceText( 182ffe3c632Sopenharmony_ci Find(Find(document.documentElement, 'PropertyGroup'), 'VersionPrefix'), 183ffe3c632Sopenharmony_ci GetFullVersion(rc_suffix = '-rc')), 184ffe3c632Sopenharmony_ci add_xml_prefix=False) 185ffe3c632Sopenharmony_ci 186ffe3c632Sopenharmony_ci RewriteXml('csharp/Google.Protobuf.Tools.nuspec', 187ffe3c632Sopenharmony_ci lambda document : ReplaceText( 188ffe3c632Sopenharmony_ci Find(Find(document.documentElement, 'metadata'), 'version'), 189ffe3c632Sopenharmony_ci GetFullVersion(rc_suffix = '-rc'))) 190ffe3c632Sopenharmony_ci 191ffe3c632Sopenharmony_ci 192ffe3c632Sopenharmony_cidef UpdateJava(): 193ffe3c632Sopenharmony_ci RewriteXml('java/pom.xml', 194ffe3c632Sopenharmony_ci lambda document : ReplaceText( 195ffe3c632Sopenharmony_ci Find(document.documentElement, 'version'), GetFullVersion())) 196ffe3c632Sopenharmony_ci 197ffe3c632Sopenharmony_ci RewriteXml('java/bom/pom.xml', 198ffe3c632Sopenharmony_ci lambda document : ReplaceText( 199ffe3c632Sopenharmony_ci Find(document.documentElement, 'version'), GetFullVersion())) 200ffe3c632Sopenharmony_ci 201ffe3c632Sopenharmony_ci RewriteXml('java/core/pom.xml', 202ffe3c632Sopenharmony_ci lambda document : ReplaceText( 203ffe3c632Sopenharmony_ci Find(Find(document.documentElement, 'parent'), 'version'), 204ffe3c632Sopenharmony_ci GetFullVersion())) 205ffe3c632Sopenharmony_ci 206ffe3c632Sopenharmony_ci RewriteXml('java/lite/pom.xml', 207ffe3c632Sopenharmony_ci lambda document : ReplaceText( 208ffe3c632Sopenharmony_ci Find(Find(document.documentElement, 'parent'), 'version'), 209ffe3c632Sopenharmony_ci GetFullVersion())) 210ffe3c632Sopenharmony_ci 211ffe3c632Sopenharmony_ci RewriteXml('java/util/pom.xml', 212ffe3c632Sopenharmony_ci lambda document : ReplaceText( 213ffe3c632Sopenharmony_ci Find(Find(document.documentElement, 'parent'), 'version'), 214ffe3c632Sopenharmony_ci GetFullVersion())) 215ffe3c632Sopenharmony_ci 216ffe3c632Sopenharmony_ci RewriteXml('protoc-artifacts/pom.xml', 217ffe3c632Sopenharmony_ci lambda document : ReplaceText( 218ffe3c632Sopenharmony_ci Find(document.documentElement, 'version'), GetFullVersion())) 219ffe3c632Sopenharmony_ci 220ffe3c632Sopenharmony_ci 221ffe3c632Sopenharmony_cidef UpdateJavaScript(): 222ffe3c632Sopenharmony_ci RewriteTextFile('js/package.json', 223ffe3c632Sopenharmony_ci lambda line : re.sub( 224ffe3c632Sopenharmony_ci r'^ "version": ".*",$', 225ffe3c632Sopenharmony_ci ' "version": "%s",' % GetFullVersion(rc_suffix = '-rc.'), 226ffe3c632Sopenharmony_ci line)) 227ffe3c632Sopenharmony_ci 228ffe3c632Sopenharmony_ci 229ffe3c632Sopenharmony_cidef UpdateMakefile(): 230ffe3c632Sopenharmony_ci protobuf_version_offset = 11 231ffe3c632Sopenharmony_ci expected_major_version = 3 232ffe3c632Sopenharmony_ci if NEW_VERSION_INFO[0] != expected_major_version: 233ffe3c632Sopenharmony_ci print """[ERROR] Major protobuf version has changed. Please update 234ffe3c632Sopenharmony_ciupdate_version.py to readjust the protobuf_version_offset and 235ffe3c632Sopenharmony_ciexpected_major_version such that the PROTOBUF_VERSION in src/Makefile.am is 236ffe3c632Sopenharmony_cialways increasing. 237ffe3c632Sopenharmony_ci """ 238ffe3c632Sopenharmony_ci exit(1) 239ffe3c632Sopenharmony_ci 240ffe3c632Sopenharmony_ci protobuf_version_info = '%d:%d:0' % ( 241ffe3c632Sopenharmony_ci NEW_VERSION_INFO[1] + protobuf_version_offset, NEW_VERSION_INFO[2]) 242ffe3c632Sopenharmony_ci RewriteTextFile('src/Makefile.am', 243ffe3c632Sopenharmony_ci lambda line : re.sub( 244ffe3c632Sopenharmony_ci r'^PROTOBUF_VERSION = .*$', 245ffe3c632Sopenharmony_ci 'PROTOBUF_VERSION = %s' % protobuf_version_info, 246ffe3c632Sopenharmony_ci line)) 247ffe3c632Sopenharmony_ci 248ffe3c632Sopenharmony_ci 249ffe3c632Sopenharmony_cidef UpdateObjectiveC(): 250ffe3c632Sopenharmony_ci RewriteTextFile('Protobuf.podspec', 251ffe3c632Sopenharmony_ci lambda line : re.sub( 252ffe3c632Sopenharmony_ci r"^ s.version = '.*'$", 253ffe3c632Sopenharmony_ci " s.version = '%s'" % GetFullVersion(rc_suffix = '-rc'), 254ffe3c632Sopenharmony_ci line)) 255ffe3c632Sopenharmony_ci RewriteTextFile('Protobuf-C++.podspec', 256ffe3c632Sopenharmony_ci lambda line : re.sub( 257ffe3c632Sopenharmony_ci r"^ s.version = '.*'$", 258ffe3c632Sopenharmony_ci " s.version = '%s'" % GetFullVersion(rc_suffix = '-rc'), 259ffe3c632Sopenharmony_ci line)) 260ffe3c632Sopenharmony_ci 261ffe3c632Sopenharmony_ci 262ffe3c632Sopenharmony_cidef UpdatePhp(): 263ffe3c632Sopenharmony_ci def Callback(document): 264ffe3c632Sopenharmony_ci def CreateNode(tagname, indent, children): 265ffe3c632Sopenharmony_ci elem = document.createElement(tagname) 266ffe3c632Sopenharmony_ci indent += 1 267ffe3c632Sopenharmony_ci for child in children: 268ffe3c632Sopenharmony_ci elem.appendChild(document.createTextNode('\n' + (' ' * indent))) 269ffe3c632Sopenharmony_ci elem.appendChild(child) 270ffe3c632Sopenharmony_ci indent -= 1 271ffe3c632Sopenharmony_ci elem.appendChild(document.createTextNode('\n' + (' ' * indent))) 272ffe3c632Sopenharmony_ci return elem 273ffe3c632Sopenharmony_ci 274ffe3c632Sopenharmony_ci root = document.documentElement 275ffe3c632Sopenharmony_ci now = datetime.datetime.now() 276ffe3c632Sopenharmony_ci ReplaceText(Find(root, 'date'), now.strftime('%Y-%m-%d')) 277ffe3c632Sopenharmony_ci ReplaceText(Find(root, 'time'), now.strftime('%H:%M:%S')) 278ffe3c632Sopenharmony_ci version = Find(root, 'version') 279ffe3c632Sopenharmony_ci ReplaceText(Find(version, 'release'), GetFullVersion(rc_suffix = 'RC')) 280ffe3c632Sopenharmony_ci ReplaceText(Find(version, 'api'), NEW_VERSION) 281ffe3c632Sopenharmony_ci stability = Find(root, 'stability') 282ffe3c632Sopenharmony_ci ReplaceText(Find(stability, 'release'), 283ffe3c632Sopenharmony_ci 'stable' if RC_VERSION < 0 else 'beta') 284ffe3c632Sopenharmony_ci ReplaceText(Find(stability, 'api'), 'stable' if RC_VERSION < 0 else 'beta') 285ffe3c632Sopenharmony_ci changelog = Find(root, 'changelog') 286ffe3c632Sopenharmony_ci for old_version in changelog.getElementsByTagName('version'): 287ffe3c632Sopenharmony_ci if Find(old_version, 'release').firstChild.nodeValue == NEW_VERSION: 288ffe3c632Sopenharmony_ci print ('[WARNING] Version %s already exists in the change log.' 289ffe3c632Sopenharmony_ci % NEW_VERSION) 290ffe3c632Sopenharmony_ci return 291ffe3c632Sopenharmony_ci if RC_VERSION != 0: 292ffe3c632Sopenharmony_ci changelog.appendChild(document.createTextNode(' ')) 293ffe3c632Sopenharmony_ci release = CreateNode('release', 2, [ 294ffe3c632Sopenharmony_ci CreateNode('version', 3, [ 295ffe3c632Sopenharmony_ci FindAndClone(version, 'release'), 296ffe3c632Sopenharmony_ci FindAndClone(version, 'api') 297ffe3c632Sopenharmony_ci ]), 298ffe3c632Sopenharmony_ci CreateNode('stability', 3, [ 299ffe3c632Sopenharmony_ci FindAndClone(stability, 'release'), 300ffe3c632Sopenharmony_ci FindAndClone(stability, 'api') 301ffe3c632Sopenharmony_ci ]), 302ffe3c632Sopenharmony_ci FindAndClone(root, 'date'), 303ffe3c632Sopenharmony_ci FindAndClone(root, 'time'), 304ffe3c632Sopenharmony_ci FindAndClone(root, 'license'), 305ffe3c632Sopenharmony_ci FindAndClone(root, 'notes') 306ffe3c632Sopenharmony_ci ]) 307ffe3c632Sopenharmony_ci changelog.appendChild(release) 308ffe3c632Sopenharmony_ci changelog.appendChild(document.createTextNode('\n ')) 309ffe3c632Sopenharmony_ci RewriteXml('php/ext/google/protobuf/package.xml', Callback) 310ffe3c632Sopenharmony_ci RewriteTextFile('php/ext/google/protobuf/protobuf.h', 311ffe3c632Sopenharmony_ci lambda line : re.sub( 312ffe3c632Sopenharmony_ci r'PHP_PROTOBUF_VERSION ".*"$', 313ffe3c632Sopenharmony_ci 'PHP_PROTOBUF_VERSION "%s"' % NEW_VERSION, 314ffe3c632Sopenharmony_ci line)) 315ffe3c632Sopenharmony_ci 316ffe3c632Sopenharmony_ci RewriteTextFile('php/ext/google/protobuf/protobuf.h', 317ffe3c632Sopenharmony_ci lambda line : re.sub( 318ffe3c632Sopenharmony_ci r"^#define PHP_PROTOBUF_VERSION .*$", 319ffe3c632Sopenharmony_ci "#define PHP_PROTOBUF_VERSION \"%s\"" % GetFullVersion(rc_suffix = 'RC'), 320ffe3c632Sopenharmony_ci line)) 321ffe3c632Sopenharmony_ci 322ffe3c632Sopenharmony_ci RewriteTextFile('php/ext/google/protobuf/protobuf.h', 323ffe3c632Sopenharmony_ci lambda line : re.sub( 324ffe3c632Sopenharmony_ci r"^#define PHP_PROTOBUF_VERSION .*$", 325ffe3c632Sopenharmony_ci "#define PHP_PROTOBUF_VERSION \"%s\"" % GetFullVersion(rc_suffix = 'RC'), 326ffe3c632Sopenharmony_ci line)) 327ffe3c632Sopenharmony_ci 328ffe3c632Sopenharmony_cidef UpdatePython(): 329ffe3c632Sopenharmony_ci RewriteTextFile('python/google/protobuf/__init__.py', 330ffe3c632Sopenharmony_ci lambda line : re.sub( 331ffe3c632Sopenharmony_ci r"^__version__ = '.*'$", 332ffe3c632Sopenharmony_ci "__version__ = '%s'" % GetFullVersion(rc_suffix = 'rc'), 333ffe3c632Sopenharmony_ci line)) 334ffe3c632Sopenharmony_ci 335ffe3c632Sopenharmony_cidef UpdateRuby(): 336ffe3c632Sopenharmony_ci RewriteTextFile('ruby/google-protobuf.gemspec', 337ffe3c632Sopenharmony_ci lambda line : re.sub( 338ffe3c632Sopenharmony_ci r'^ s.version = ".*"$', 339ffe3c632Sopenharmony_ci ' s.version = "%s"' % GetFullVersion(rc_suffix = '.rc.'), 340ffe3c632Sopenharmony_ci line)) 341ffe3c632Sopenharmony_ci 342ffe3c632Sopenharmony_ci 343ffe3c632Sopenharmony_ciUpdateConfigure() 344ffe3c632Sopenharmony_ciUpdateCsharp() 345ffe3c632Sopenharmony_ciUpdateCpp() 346ffe3c632Sopenharmony_ciUpdateJava() 347ffe3c632Sopenharmony_ciUpdateJavaScript() 348ffe3c632Sopenharmony_ciUpdateMakefile() 349ffe3c632Sopenharmony_ciUpdateObjectiveC() 350ffe3c632Sopenharmony_ciUpdatePhp() 351ffe3c632Sopenharmony_ciUpdatePython() 352ffe3c632Sopenharmony_ciUpdateRuby() 353