@@ -49,7 +49,16 @@ def init(self, args):
49
49
self ._lang = args .language
50
50
self ._package = args .package
51
51
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 )
53
62
self ._other_opts = args
54
63
self ._mac_bundleid = args .mac_bundleid
55
64
self ._ios_bundleid = args .ios_bundleid
@@ -79,6 +88,7 @@ def parse_args(self, argv):
79
88
parser .add_argument ("-t" , "--template" , metavar = "TEMPLATE_NAME" ,help = "Set the template name you want create from" )
80
89
parser .add_argument ("--ios-bundleid" , dest = "ios_bundleid" , help = "Set a bundle id for ios project" )
81
90
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" )
82
92
83
93
group = parser .add_argument_group ("lua/js project arguments" )
84
94
group .add_argument ("--no-native" , action = "store_true" , dest = "no_native" , help = "No native support." )
@@ -147,14 +157,14 @@ def _create_from_cmd(self):
147
157
148
158
149
159
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" )
152
162
153
- f = open (self . create_cfg_file )
163
+ f = open (create_cfg_file )
154
164
create_cfg = json .load (f )
155
165
f .close ()
156
166
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" ]))
158
168
cocos_root = langcfg ['COCOS_ROOT' ]
159
169
160
170
# replace SDK_ROOT to real path
0 commit comments