Skip to content

Commit 166dae5

Browse files
author
zhangbin
committed
Add argument "-e" in cocos new to specify the path of cocos2d-x/cocos2d-js.
1 parent 196bb42 commit 166dae5

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

bin/cocos.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import cocos_project
2323
import shutil
2424

25-
COCOS2D_CONSOLE_VERSION = '0.7'
25+
COCOS2D_CONSOLE_VERSION = '0.8'
2626

2727

2828
class Logging:

plugins/project_new/project_new.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,16 @@ def init(self, args):
4949
self._lang = args.language
5050
self._package = args.package
5151
self._tpname = args.template
52-
self._cocosroot, self._templates_root = self._parse_cfg(self._lang)
52+
53+
if args.engine_path is not None:
54+
if os.path.isabs(args.engine_path):
55+
self._cocosroot = args.engine_path
56+
else:
57+
self._cocosroot = os.path.abspath(args.engine_path)
58+
self._cocosroot = unicode(self._cocosroot, "utf-8")
59+
self._templates_root = os.path.join(self._cocosroot, "templates")
60+
else:
61+
self._cocosroot, self._templates_root = self._parse_cfg(self._lang)
5362
self._other_opts = args
5463
self._mac_bundleid = args.mac_bundleid
5564
self._ios_bundleid = args.ios_bundleid
@@ -79,6 +88,7 @@ def parse_args(self, argv):
7988
parser.add_argument("-t", "--template", metavar="TEMPLATE_NAME",help="Set the template name you want create from")
8089
parser.add_argument("--ios-bundleid", dest="ios_bundleid", help="Set a bundle id for ios project")
8190
parser.add_argument("--mac-bundleid", dest="mac_bundleid", help="Set a bundle id for mac project")
91+
parser.add_argument("-e", "--engine-path", dest="engine_path", help="Set the path of cocos2d-x/cocos2d-js engine")
8292

8393
group = parser.add_argument_group("lua/js project arguments")
8494
group.add_argument("--no-native", action="store_true", dest="no_native", help="No native support.")
@@ -147,14 +157,14 @@ def _create_from_cmd(self):
147157

148158

149159
def _parse_cfg(self, language):
150-
self.script_dir= unicode(os.path.abspath(os.path.dirname(__file__)), "utf-8")
151-
self.create_cfg_file = os.path.join(self.script_dir, "env.json")
160+
script_dir= unicode(os.path.abspath(os.path.dirname(__file__)), "utf-8")
161+
create_cfg_file = os.path.join(script_dir, "env.json")
152162

153-
f = open(self.create_cfg_file)
163+
f = open(create_cfg_file)
154164
create_cfg = json.load(f)
155165
f.close()
156166
langcfg = create_cfg[language]
157-
langcfg['COCOS_ROOT'] = os.path.abspath(os.path.join(self.script_dir,langcfg["COCOS_ROOT"]))
167+
langcfg['COCOS_ROOT'] = os.path.abspath(os.path.join(script_dir,langcfg["COCOS_ROOT"]))
158168
cocos_root = langcfg['COCOS_ROOT']
159169

160170
# replace SDK_ROOT to real path

0 commit comments

Comments
 (0)