Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions bin/cocos.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import locale
import gettext
import json
import re


# FIXME: MultiLanguage should be deprecated in favor of gettext
Expand Down Expand Up @@ -178,7 +179,6 @@ def run_cmd(command, verbose, cwd=None):
else:
log_path = CCPlugin._log_path()
command += ' >"%s" 2>&1' % log_path
sys.stdout.flush()
ret = subprocess.call(command, shell=True, cwd=cwd)
if ret != 0:
message = MultiLanguage.get_string('COCOS_ERROR_RUNNING_CMD_RET_FMT', str(ret))
Expand Down Expand Up @@ -870,6 +870,14 @@ def _check_python_version():

return ret

def get_cocos_version():
path = os.path.dirname(os.path.abspath(sys.argv[0]))
reg_exp = re.compile(ur'return\s"([^"]*)"')
cocos2dx_path = os.path.abspath(os.path.join(path, os.path.pardir, os.path.pardir, os.path.pardir))
file_content = open(cocos2dx_path+'/cocos/cocos2d.cpp','r').read()
cocos_version = reg_exp.findall(file_content)
return cocos_version[0]

# gettext
locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
language, encoding = locale.getlocale()
Expand Down Expand Up @@ -916,7 +924,8 @@ def _check_python_version():
sys.exit(0)

if len(sys.argv) > 1 and sys.argv[1] in ('-v', '--version'):
print("%s" % COCOS2D_CONSOLE_VERSION)
print("Console Version: %s" % COCOS2D_CONSOLE_VERSION)
print("Cocos Version: %s" % get_cocos_version())
DataStatistic.terminate_stat()
sys.exit(0)

Expand Down
9 changes: 5 additions & 4 deletions plugins/plugin_compile/build_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@ def get_toolchain_version(self, ndk_root, compile_obj):
if os.path.exists(version_file_path):
versionFile = open(version_file_path)
else:
version_file_path = os.path.join(ndk_root, "source.properties")
if os.path.exists(version_file_path):
version_major = "4.9"
return version_major
reg_exp = re.compile(ur'-(4.*)$')
version_directory = next(os.walk(ndk_root+"toolchains/"))[1][0]
toolchain_version = reg_exp.findall(version_directory)
version_major = toolchain_version[0]
return toolchain_version[0]

lines = versionFile.readlines()
versionFile.close()
Expand Down