Skip to content

Commit ad5b9df

Browse files
author
Bin Zhang
authored
Merge pull request #361 from hylthink/hylthink-v3
add cocos package 0.8.1
2 parents 2ceba42 + d82b5ff commit ad5b9df

File tree

7 files changed

+118
-4
lines changed

7 files changed

+118
-4
lines changed

config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version":"v3-console-12",
3-
"zip_file_size":"38343506",
2+
"version":"v3-console-13",
3+
"zip_file_size":"42886494",
44
"repo_name":"console-binary",
55
"repo_parent":"https://github.com/natural-law/"
66
}

plugins/plugin_compile/build_android.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,20 @@ def do_build_apk(self, build_mode, no_apk, output_dir, custom_step_args, compile
491491
# copy resources
492492
self._copy_resources(custom_step_args, assets_dir)
493493

494+
##cocospackage
495+
try:
496+
path = ''
497+
if getattr(sys, 'frozen', None):
498+
path = os.path.realpath(os.path.dirname(sys.executable))
499+
else:
500+
path = os.path.realpath(os.path.dirname(__file__))
501+
path = os.path.join(path, '../plugin_package/cocospackage')
502+
cmd = '%s encrypt -p %s --runincocos --runinbuild' % (path, self.app_android_root)
503+
self._run_cmd(cmd)
504+
except:
505+
pass
506+
507+
494508
# check the project config & compile the script files
495509
if self._project._is_lua_project():
496510
compile_obj.compile_lua_scripts(assets_dir, assets_dir)

plugins/plugin_compile/project_compile.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,20 @@ def build_ios(self):
640640
raise cocos.CCPluginError(MultiLanguage.get_string('COMPILE_ERROR_BUILD_ON_MAC'),
641641
cocos.CCPluginError.ERROR_WRONG_ARGS)
642642

643+
#cocospackage
644+
try:
645+
path = ''
646+
if getattr(sys, 'frozen', None):
647+
path = os.path.realpath(os.path.dirname(sys.executable))
648+
else:
649+
path = os.path.realpath(os.path.dirname(__file__))
650+
path = os.path.join(path, '../plugin_package/cocospackage')
651+
cmd = '%s encrypt -p %s --platform ios --runincocos --runinbuild' % (path, self._project.get_project_dir())
652+
self._run_cmd(cmd)
653+
except:
654+
pass
655+
656+
643657
if self._sign_id is not None:
644658
cocos.Logging.info(MultiLanguage.get_string('COMPILE_INFO_IOS_SIGN_FMT', self._sign_id))
645659
self.use_sdk = 'iphoneos'

plugins/plugin_package/cocospackage

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash -l
2+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
3+
python ${DIR}/cocospackage.py "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SET script_path=%~dp0
2+
3+
python %script_path%cocospackage.py %*
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
4+
"""
5+
@license: Apache Licence
6+
7+
@author = 'daisy'
8+
@software: PyCharm
9+
@file: cocospackage.py
10+
@time: 16/5/25 上午11:33
11+
"""
12+
import os
13+
import sys
14+
import platform
15+
import zipfile
16+
import time
17+
import subprocess
18+
19+
20+
def _get_currency_path():
21+
path = ''
22+
if getattr(sys, 'frozen', None):
23+
path = os.path.realpath(os.path.dirname(sys.executable))
24+
else:
25+
path = os.path.realpath(os.path.dirname(__file__))
26+
return path
27+
28+
def main():
29+
#update
30+
#unzip cocospackage.zip
31+
name = 'cocospackage.zip'
32+
currency_path = _get_currency_path()
33+
file_path = os.path.join(currency_path, name)
34+
if os.path.isfile(file_path):
35+
time.sleep(0.5)
36+
fh = open(file_path, 'rb')
37+
z = zipfile.ZipFile(fh)
38+
for n in z.namelist():
39+
outfile = open(os.path.join(currency_path, n), 'wb')
40+
try:
41+
data = z.read(n)
42+
except:
43+
raise RuntimeError('failed to find ' + n + 'in archive ' + file_path)
44+
outfile.write(data)
45+
outfile.close()
46+
fh.close()
47+
os.remove(file_path)
48+
49+
#import package
50+
path = ''
51+
architecture = platform.architecture()[0]
52+
if '64' in architecture:
53+
path = os.path.join(currency_path, 'bin', architecture)
54+
else:
55+
path = os.path.join(currency_path, 'bin', architecture)
56+
# download the bin folder
57+
if not os.path.exists(path):
58+
download_cmd_path = os.path.join(currency_path, os.pardir, os.pardir)
59+
subprocess.call("python %s -f -r no" % (os.path.join(download_cmd_path, "download-bin.py")), shell=True, cwd=download_cmd_path)
60+
sys.path.append(path)
61+
import package
62+
package.main()
63+
64+
if __name__ == '__main__':
65+
reload(sys)
66+
sys.setdefaultencoding('utf-8')
67+
main()

plugins/plugin_package/plugin_package.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ def parse_args(self, argv):
3030
return {"command": argv[0]}
3131

3232
def run(self, argv, dependencies):
33-
cmd = self._get_sdkbox_path() + ' --runincocos ' + ' '.join(argv)
34-
ret = self._run_cmd(cmd)
33+
if '--sdkbox' in argv:
34+
argv.remove('--sdkbox')
35+
cmd = self._get_sdkbox_path() + ' --runincocos ' + ' '.join(argv)
36+
ret = self._run_cmd(cmd)
37+
else:
38+
cmd = self._get_cocospackage_path() + ' --runincocos ' + ' '.join(argv)
39+
ret = self._run_cmd(cmd)
3540
if 0 != ret:
3641
message = MultiLanguage.get_string('COCOS_ERROR_RUNNING_CMD_RET_FMT', str(ret))
3742
raise cocos.CCPluginError(message, cocos.CCPluginError.ERROR_RUNNING_CMD)
@@ -48,5 +53,13 @@ def _get_sdkbox_path(self):
4853
path = os.path.realpath(os.path.dirname(__file__))
4954
return os.path.join(path, 'sdkbox')
5055

56+
def _get_cocospackage_path(self):
57+
path = ''
58+
if getattr(sys, 'frozen', None):
59+
path = os.path.realpath(os.path.dirname(sys.executable))
60+
else:
61+
path = os.path.realpath(os.path.dirname(__file__))
62+
return os.path.join(path, 'cocospackage')
63+
5164
def print_help(self):
5265
print(MultiLanguage.get_string('PACKAGE_HELP'))

0 commit comments

Comments
 (0)