Skip to content

Commit b670eb6

Browse files
author
zhangbin
committed
Add option '--no-uninstall' for cocos deploy.
It's used for no uninstall app before deploy the new app. The requirement is from : #358 #267
1 parent 1981123 commit b670eb6

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

bin/cocos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# FIXME: MultiLanguage should be deprecated in favor of gettext
3131
from MultiLanguage import MultiLanguage
3232

33-
COCOS2D_CONSOLE_VERSION = '2.1'
33+
COCOS2D_CONSOLE_VERSION = '2.2'
3434

3535

3636
class Cocos2dIniParser:

bin/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"PROJECT_WARNING_CUSTOM_STEP_FAILED_FMT" : "Custom step invoke failed: %s",
4343
"DEPLOY_BRIEF" : "Compile and deploy a project to a device/simulator.",
4444
"DEPLOY_ARG_MODE" : "Set the deploy mode, should be debug|release, default is debug.",
45+
"DEPLOY_ARG_NO_UNINSTALL" : "Set to no uninstall the app before deploy.",
4546
"DEPLOY_ERROR_XAPCMD_NOT_FOUND" : "XapDeployCmd.exe not found, can't deploy the application.",
4647
"DEPLOY_INFO_FIND_XAP_FMT" : "Find xap deployment tools in registry : %s",
4748
"DEPLOY_INFO_INSTALLING_APK" : "Installing on device",
@@ -382,6 +383,7 @@
382383
"PROJECT_WARNING_CUSTOM_STEP_FAILED_FMT" : "调用自定义步骤失败:%s",
383384
"DEPLOY_BRIEF" : "编译并在设备或模拟器上部署工程。",
384385
"DEPLOY_ARG_MODE" : "设置部署模式,可选值为 debug/release,默认值为 debug。",
386+
"DEPLOY_ARG_NO_UNINSTALL" : "安装应用之前不卸载之前安装的应用。",
385387
"DEPLOY_ERROR_XAPCMD_NOT_FOUND" : "找不到 XapDeployCmd.exe,无法安装应用。",
386388
"DEPLOY_INFO_FIND_XAP_FMT" : "在 %s 注册表中查找 xap 部署工具。",
387389
"DEPLOY_INFO_INSTALLING_APK" : "正在安装应用程序。",
@@ -721,6 +723,7 @@
721723
"PROJECT_WARNING_CUSTOM_STEP_FAILED_FMT" : "調用自定義步驟失敗:%s",
722724
"DEPLOY_BRIEF" : "編譯並在設備或模擬器上部署工程。",
723725
"DEPLOY_ARG_MODE" : "設置部署模式,可選值為 debug/release,默認值為 debug。",
726+
"DEPLOY_ARG_NO_UNINSTALL" : "安裝應用之前不卸載之前安裝的應用。",
724727
"DEPLOY_ERROR_XAPCMD_NOT_FOUND" : "找不到 XapDeployCmd.exe,無法安裝應用。",
725728
"DEPLOY_INFO_FIND_XAP_FMT" : "在 %s 註冊表中查找 xap 部署工具。",
726729
"DEPLOY_INFO_INSTALLING_APK" : "正在安裝應用程式。",

plugins/plugin_deploy.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def brief_description():
3737
def _add_custom_options(self, parser):
3838
parser.add_argument("-m", "--mode", dest="mode", default='debug',
3939
help=MultiLanguage.get_string('DEPLOY_ARG_MODE'))
40+
parser.add_argument("--no-uninstall", dest="no_uninstall", action="store_true",
41+
help=MultiLanguage.get_string('DEPLOY_ARG_NO_UNINSTALL'))
4042

4143
def _check_custom_options(self, args):
4244

@@ -47,6 +49,8 @@ def _check_custom_options(self, args):
4749
if 'release' == args.mode:
4850
self._mode = args.mode
4951

52+
self._no_uninstall = args.no_uninstall
53+
5054
def _is_debug_mode(self):
5155
return self._mode == 'debug'
5256

@@ -151,12 +155,13 @@ def deploy_wp8(self, dependencies):
151155
raise cocos.CCPluginError(MultiLanguage.get_string('DEPLOY_ERROR_XAPCMD_NOT_FOUND'),
152156
cocos.CCPluginError.ERROR_TOOLS_NOT_FOUND)
153157

154-
# uninstall the app on wp8 by product ID
155-
try:
156-
uninstall_cmd = '"%s" /uninstall %s /targetdevice:xd' % (self.deploy_tool, product_id)
157-
self._run_cmd(uninstall_cmd)
158-
except:
159-
pass
158+
if not self._no_uninstall:
159+
# uninstall the app on wp8 by product ID
160+
try:
161+
uninstall_cmd = '"%s" /uninstall %s /targetdevice:xd' % (self.deploy_tool, product_id)
162+
self._run_cmd(uninstall_cmd)
163+
except:
164+
pass
160165

161166
def deploy_linux(self, dependencies):
162167
if not self._platforms.is_linux_active():
@@ -179,10 +184,12 @@ def deploy_android(self, dependencies):
179184
sdk_root = cocos.check_environment_variable('ANDROID_SDK_ROOT')
180185
adb_path = cocos.CMDRunner.convert_path_to_cmd(os.path.join(sdk_root, 'platform-tools', 'adb'))
181186

182-
#TODO detect if the application is installed before running this
183-
adb_uninstall = "%s uninstall %s" % (adb_path, self.package)
184-
self._run_cmd(adb_uninstall)
185-
adb_install = "%s install \"%s\"" % (adb_path, apk_path)
187+
if not self._no_uninstall:
188+
#TODO detect if the application is installed before running this
189+
adb_uninstall = "%s uninstall %s" % (adb_path, self.package)
190+
self._run_cmd(adb_uninstall)
191+
192+
adb_install = "%s install -r \"%s\"" % (adb_path, apk_path)
186193
self._run_cmd(adb_install)
187194

188195
def deploy_tizen(self, dependencies):
@@ -197,11 +204,13 @@ def deploy_tizen(self, dependencies):
197204
# uninstall old app
198205
tizen_studio_path = cocos.check_environment_variable("TIZEN_STUDIO_HOME")
199206
tizen_cmd_path = cocos.CMDRunner.convert_path_to_cmd(os.path.join(tizen_studio_path, "tools", "ide", "bin", "tizen"))
200-
try:
201-
uninstall_cmd = "%s uninstall -p %s" % (tizen_cmd_path, self.tizen_packageid)
202-
self._run_cmd(uninstall_cmd)
203-
except Exception:
204-
pass
207+
208+
if not self._no_uninstall:
209+
try:
210+
uninstall_cmd = "%s uninstall -p %s" % (tizen_cmd_path, self.tizen_packageid)
211+
self._run_cmd(uninstall_cmd)
212+
except Exception:
213+
pass
205214

206215
# install app
207216
compile_dep = dependencies["compile"]

0 commit comments

Comments
 (0)