Skip to content

Commit da6d29b

Browse files
committed
Merge pull request cocos2d#300 from natural-law/v3
Auto update the version in the about dialog of simulator when generating simulator.
2 parents 869ef35 + d72a071 commit da6d29b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plugins/plugin_generate/gen_simulator.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def init(self, args):
8282

8383
self.simulator_abs_path = os.path.join(self.engine_root, SimulatorCompiler.SIMULATOR_PROJ_PATH)
8484
self.cocos_bin = os.path.join(self.engine_root, SimulatorCompiler.COCOS_CMD_PATH)
85+
engine_version = utils.get_engine_version(self.engine_root)
86+
# get the short version after "cocos2d-x-"
87+
self.engine_version = engine_version[10:]
8588

8689
# get the full path of output dir.
8790
if args.out_dir is None:
@@ -344,15 +347,20 @@ def update_bundle_version(self):
344347
keyword_map = { build_date_tag : "<string>%s</string>" % build_date }
345348
self.replace_keyword_with_file(info_plist_path, keyword_map)
346349

350+
match = re.compile('<key>CFBundleShortVersionString</key>(\s)*<string>(.*?)</string>').findall(info_plist_content)
351+
if len(match):
352+
build_date_tag = "<string>%s</string>" % match[0][1]
353+
keyword_map = { build_date_tag : "<string>%s</string>" % self.engine_version }
354+
self.replace_keyword_with_file(info_plist_path, keyword_map)
355+
347356
if cocos.os_is_win32() and self.build_win:
348357
# win32
349358
game_rc_path = os.path.join(self.simulator_abs_path,"frameworks/runtime-src/proj.win32/game.rc")
350359
game_rc_content = self.get_content_from_file(game_rc_path)
351360
match = re.compile('"Version[^\(]*\(.*\)"').findall(game_rc_content)
352361
if len(match):
353362
build_info_str = match[0]
354-
m = re.match(r'"(Version[^\(]*)\(.*\)', build_info_str)
355-
target_str = '"%s(%s)"' % (m.group(1), build_date)
363+
target_str = '"Version %s (%s)"' % (self.engine_version, build_date)
356364
keyword_map = { build_info_str : target_str}
357365
self.replace_keyword_with_file(game_rc_path,keyword_map)
358366

0 commit comments

Comments
 (0)