@@ -39,37 +39,6 @@ def __init__(self, verbose, cocos_root, app_android_root, no_res, proj_obj):
39
39
def _run_cmd (self , command ):
40
40
cocos .CMDRunner .run_cmd (command , self ._verbose )
41
41
42
- def _convert_path_to_cmd (self , path ):
43
- """ Convert path which include space to correct style which bash(mac) and cmd(windows) can treat correctly.
44
-
45
- eg: on mac: convert '/usr/xxx/apache-ant 1.9.3' to '/usr/xxx/apache-ant\ 1.9.3'
46
- eg: on windows: convert '"c:\a pache-ant 1.9.3"\b in' to '"c:\a pache-ant 1.9.3\b in"'
47
- """
48
- ret = path
49
- if cocos .os_is_mac ():
50
- ret = path .replace ("\ " , " " ).replace (" " , "\ " )
51
-
52
- if cocos .os_is_win32 ():
53
- ret = "\" %s\" " % (path .replace ("\" " , "" ))
54
-
55
- # print("!!!!! Convert %s to %s\n" % (path, ret))
56
- return ret
57
-
58
- def _convert_path_to_python (self , path ):
59
- """ COnvert path which include space to correct style which python can treat correctly.
60
-
61
- eg: on mac: convert '/usr/xxx/apache-ant\ 1.9.3' to '/usr/xxx/apache-ant 1.9.3'
62
- eg: on windows: convert '"c:\a pache-ant 1.9.3"\b in' to 'c:\a pache-ant 1.9.3\b in'
63
- """
64
- ret = path
65
- if cocos .os_is_mac ():
66
- ret = path .replace ("\ " , " " )
67
-
68
- if cocos .os_is_win32 ():
69
- ret = ret .replace ("\" " , "" )
70
-
71
- # print("!!!!! Convert %s to %s\n" % (path, ret))
72
- return ret
73
42
74
43
def _parse_cfg (self ):
75
44
self .cfg_path = os .path .join (self .app_android_root , BUILD_CFIG_FILE )
@@ -220,7 +189,7 @@ def update_lib_projects(self, sdk_root, sdk_tool_path, android_platform):
220
189
if os .path .isdir (abs_lib_path ):
221
190
api_level = self .check_android_platform (sdk_root , android_platform , abs_lib_path , True )
222
191
str_api_level = "android-" + str (api_level )
223
- command = "%s update lib-project -p %s -t %s" % (self . _convert_path_to_cmd (sdk_tool_path ), abs_lib_path , str_api_level )
192
+ command = "%s update lib-project -p %s -t %s" % (cocos . CMDRunner . convert_path_to_cmd (sdk_tool_path ), abs_lib_path , str_api_level )
224
193
self ._run_cmd (command )
225
194
226
195
def get_target_config (self , proj_path ):
@@ -263,7 +232,7 @@ def check_android_platform(self, sdk_root, android_platform, proj_path, auto_sel
263
232
raise cocos .CCPluginError ("Can't find right android-platform for project : \" %s\" . The android-platform should be equal/larger than %d" % (proj_path , min_platform ))
264
233
265
234
platform_path = "android-%d" % ret
266
- ret_path = os .path .join (self . _convert_path_to_python (sdk_root ), "platforms" , platform_path )
235
+ ret_path = os .path .join (cocos . CMDRunner . convert_path_to_python (sdk_root ), "platforms" , platform_path )
267
236
if not os .path .isdir (ret_path ):
268
237
raise cocos .CCPluginError ("The directory \" %s\" can't be found in android SDK" % platform_path )
269
238
@@ -280,7 +249,7 @@ def do_build_apk(self, sdk_root, ant_root, android_platform, build_mode, output_
280
249
281
250
# update project
282
251
str_api_level = "android-" + str (api_level )
283
- command = "%s update project -t %s -p %s" % (self . _convert_path_to_cmd (sdk_tool_path ), str_api_level , app_android_root )
252
+ command = "%s update project -t %s -p %s" % (cocos . CMDRunner . convert_path_to_cmd (sdk_tool_path ), str_api_level , app_android_root )
284
253
self ._run_cmd (command )
285
254
286
255
# update lib-projects
@@ -304,7 +273,7 @@ def do_build_apk(self, sdk_root, ant_root, android_platform, build_mode, output_
304
273
# invoke custom step: pre-ant-build
305
274
self ._project .invoke_custom_step_script (cocos_project .Project .CUSTOM_STEP_PRE_ANT_BUILD , target_platform , args_ant_copy )
306
275
307
- command = "%s clean %s -f %s -Dsdk.dir=%s" % (self . _convert_path_to_cmd (ant_path ), build_mode , buildfile_path , self . _convert_path_to_cmd (sdk_root ))
276
+ command = "%s clean %s -f %s -Dsdk.dir=%s" % (cocos . CMDRunner . convert_path_to_cmd (ant_path ), build_mode , buildfile_path , cocos . CMDRunner . convert_path_to_cmd (sdk_root ))
308
277
self ._run_cmd (command )
309
278
310
279
# invoke custom step: post-ant-build
@@ -401,7 +370,7 @@ def _sign_release_apk(self, unsigned_path, signed_path):
401
370
402
371
def _zipalign_apk (self , apk_file , aligned_file , sdk_root ):
403
372
align_path = os .path .join (sdk_root , "tools" , "zipalign" )
404
- align_cmd = "%s 4 %s %s" % (self . _convert_path_to_cmd (align_path ), apk_file , aligned_file )
373
+ align_cmd = "%s 4 %s %s" % (cocos . CMDRunner . convert_path_to_cmd (align_path ), apk_file , aligned_file )
405
374
if os .path .exists (aligned_file ):
406
375
os .remove (aligned_file )
407
376
self ._run_cmd (align_cmd )
0 commit comments