68
68
FEATURE_ARGS_ARRAY = []
69
69
# The Firebase features supported by this script.
70
70
FIREBASE_FEATURES_ARRAY = ["AdMob" , "Analytics" , "Invites" , "Messaging" ]
71
+ # The path to the Firebase SDK to use. This is optional, if left blank the most
72
+ # recent release will be downloaded and used.
73
+ FIREBASE_SDK_PATH = None
71
74
72
75
73
76
def add_cocos2dx_library ():
@@ -118,7 +121,26 @@ def add_cocos2dx_library():
118
121
logging .info ("Finished adding the cocos2d-x library to the sample project." )
119
122
120
123
121
- def add_firebase_sdk ():
124
+ def copy_firebase_sdk ():
125
+ """Copies the given version of the Firebase SDK to the sample project.
126
+
127
+ Raises:
128
+ IOError: An error occurred copying the sdk to the target directory.
129
+ """
130
+ logging .info ("Copying the Firebase SDK..." )
131
+ try :
132
+ shutil .copytree (FIREBASE_SDK_PATH , os .path .join (LIBS_DIR ,
133
+ "firebase_cpp_sdk" ))
134
+ except IOError as e :
135
+ logging .exception ("IOError: [Errno %d] %s: in %s" , e .errno , e .strerror ,
136
+ sys ._getframe ().f_code .co_name )
137
+ exit ()
138
+ logging .info (
139
+ "Finished copying the Firebase SDK to the sample project's Libs "
140
+ "directory" )
141
+
142
+
143
+ def retrieve_latest_firebase_sdk ():
122
144
"""Adds the latest version of the Firebase SDK to the sample project.
123
145
124
146
Raises:
@@ -341,12 +363,23 @@ def check_valid_arguments():
341
363
nargs = 1 ,
342
364
help = "The Firebase feature must be one of the following: "
343
365
"AdMob, Analytics, Auth, Invites, Messaging, or Remote_Config" )
366
+ parser .add_argument (
367
+ "--firebase_sdk" ,
368
+ action = 'store' ,
369
+ const = None ,
370
+ metavar = "FIREBASE_SDK" ,
371
+ help = "The path to the directory containing the unzipped Firebase SDK. "
372
+ "If left blank, the most recent release will be downloaded and used." )
344
373
args = parser .parse_args ()
345
374
for feature in args .feature :
346
375
feature_str = str (feature )
347
376
if not feature_str in FIREBASE_FEATURES_ARRAY :
348
377
return False
349
378
FEATURE_ARGS_ARRAY .append (feature_str )
379
+
380
+ global FIREBASE_SDK_PATH
381
+ FIREBASE_SDK_PATH = args .firebase_sdk
382
+
350
383
return True
351
384
352
385
@@ -372,7 +405,10 @@ def main():
372
405
exit ()
373
406
374
407
add_cocos2dx_library ()
375
- add_firebase_sdk ()
408
+ if FIREBASE_SDK_PATH :
409
+ copy_firebase_sdk ()
410
+ else :
411
+ retrieve_latest_firebase_sdk ()
376
412
add_cpp_default_template ()
377
413
add_project_template_files ()
378
414
update_ios_project_file ()
0 commit comments