Skip to content

Commit 1184e12

Browse files
committed
Merge pull request #301 from natural-law/check-jsbcc
Check the right file on different platforms before downloading the binary files.
2 parents da6d29b + a8a5d38 commit 1184e12

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

plugins/plugin_jscompile/__init__.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ def init(self, options, workingdir):
7070
self._compressed_js_path = os.path.join(self._dst_dir, options.compressed_filename)
7171
self._compressed_jsc_path = os.path.join(self._dst_dir, options.compressed_filename+"c")
7272

73+
if(cocos.os_is_linux()):
74+
if(platform.architecture()[0] == "32bit"):
75+
self.jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x86")
76+
else:
77+
self.jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x64")
78+
else:
79+
self.jsbcc_exe_path = os.path.join(self._workingdir, "bin", "jsbcc")
80+
7381
def normalize_path_in_list(self, list):
7482
for i in list:
7583
tmp = os.path.normpath(i)
@@ -118,16 +126,7 @@ def compile_js(self, jsfile, output_file):
118126
"""
119127
cocos.Logging.debug(MultiLanguage.get_string('JSCOMPILE_DEBUG_COMPILE_FILE_FMT', jsfile))
120128

121-
jsbcc_exe_path = ""
122-
if(cocos.os_is_linux()):
123-
if(platform.architecture()[0] == "32bit"):
124-
jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x86")
125-
else:
126-
jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x64")
127-
else:
128-
jsbcc_exe_path = os.path.join(self._workingdir, "bin", "jsbcc")
129-
130-
cmd_str = "\"%s\" \"%s\" \"%s\"" % (jsbcc_exe_path, jsfile, output_file)
129+
cmd_str = "\"%s\" \"%s\" \"%s\"" % (self.jsbcc_exe_path, jsfile, output_file)
131130
self._run_cmd(cmd_str)
132131

133132
def compress_js(self):
@@ -252,8 +251,7 @@ def run(self, argv, dependencies):
252251
cocos.CCPluginError.ERROR_PATH_NOT_FOUND)
253252

254253
# download the bin folder
255-
jsbcc_exe_path = os.path.join(self._workingdir, "bin", "jsbcc")
256-
if not os.path.exists(jsbcc_exe_path):
254+
if not os.path.exists(self.jsbcc_exe_path):
257255
download_cmd_path = os.path.join(self._workingdir, os.pardir, os.pardir)
258256
subprocess.call("python %s -f -r no" % (os.path.join(download_cmd_path, "download-bin.py")), shell=True, cwd=download_cmd_path)
259257

0 commit comments

Comments
 (0)