Skip to content

Commit 02c4855

Browse files
author
minggo
committed
Merge pull request cocos2d#156 from natural-law/develop
Optimize the logic of select API level for android platform.
2 parents 78ac9f5 + fe0275c commit 02c4855

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

bin/cocos.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,29 @@ def check_environment_variable(var):
284284

285285

286286
def select_default_android_platform(min_api_level):
287-
''' selec a default android platform in SDK_ROOT, support platforms 10-19
287+
''' select a default android platform in SDK_ROOT
288288
'''
289289

290290
sdk_root = check_environment_variable('ANDROID_SDK_ROOT')
291291
platforms_dir = os.path.join(sdk_root, "platforms")
292+
ret_num = -1
292293
if os.path.isdir(platforms_dir):
293-
for num in range (min_api_level, 21):
294-
android_platform = 'android-%s' % num
295-
if os.path.isdir(os.path.join(platforms_dir, android_platform)):
296-
Logging.info('%s is found' % android_platform)
297-
return num
298-
return None
294+
for dir_name in os.listdir(platforms_dir):
295+
if not os.path.isdir(os.path.join(platforms_dir, dir_name)):
296+
continue
297+
298+
import re
299+
match = re.match(r"android-(\d+)", dir_name)
300+
if match is not None:
301+
num = int(match.group(1))
302+
if num >= min_api_level:
303+
if ret_num == -1 or ret_num > num:
304+
ret_num = num
305+
306+
if ret_num != -1:
307+
return ret_num
308+
else:
309+
return None
299310

300311

301312
def copy_files_in_dir(src, dst):

0 commit comments

Comments
 (0)