9
9
import argparse
10
10
import sys
11
11
from sys import stdout
12
- from os .path import join , dirname , realpath , exists , isdir , basename
12
+ from os .path import join , dirname , realpath , exists , isdir , basename , split
13
13
from os import listdir , unlink , makedirs , environ , chdir , getcwd , walk
14
14
import sh
15
15
import zipfile
@@ -1188,7 +1188,7 @@ def _hostpython_pip(args):
1188
1188
shprint (pip_cmd , * args )
1189
1189
1190
1190
1191
- def update_pbxproj (filename , pbx_frameworks = None ):
1191
+ def update_pbxproj (filename , pbx_frameworks = None , custom_recipes = None , custom_recipes_paths = None ):
1192
1192
# list all the compiled recipes
1193
1193
ctx = Context ()
1194
1194
pbx_libraries = []
@@ -1197,7 +1197,17 @@ def update_pbxproj(filename, pbx_frameworks=None):
1197
1197
frameworks = []
1198
1198
libraries = []
1199
1199
sources = []
1200
+
1201
+ if custom_recipes and custom_recipes_paths :
1202
+ recipes = custom_recipes
1203
+ ctx .custom_recipes_paths = custom_recipes_paths
1204
+ else :
1205
+ recipes = []
1206
+
1200
1207
for recipe in Recipe .list_recipes ():
1208
+ recipes .append (recipe )
1209
+
1210
+ for recipe in recipes :
1201
1211
key = "{}.build_all" .format (recipe )
1202
1212
if key not in ctx .state :
1203
1213
continue
@@ -1413,12 +1423,22 @@ def status(self):
1413
1423
print ("{:<12} - {}" .format (
1414
1424
recipe , status ))
1415
1425
1426
+ def recipes_names_from_paths (self , paths ):
1427
+ recipes = []
1428
+ for p in paths :
1429
+ _ , name = split (p )
1430
+ recipes .append (name )
1431
+
1432
+ return recipes
1433
+
1416
1434
def create (self ):
1417
1435
parser = argparse .ArgumentParser (
1418
1436
description = "Create a new xcode project" )
1419
1437
parser .add_argument ("name" , help = "Name of your project" )
1420
1438
parser .add_argument ("directory" , help = "Directory where your project lives" )
1421
1439
parser .add_argument ("--add-framework" , action = "append" , help = "Additional Frameworks to include with this project" )
1440
+ parser .add_argument ("--add-custom-recipe" , action = "append" , default = [],
1441
+ help = "Path to custom recipe" )
1422
1442
args = parser .parse_args (sys .argv [2 :])
1423
1443
1424
1444
from cookiecutter .main import cookiecutter
@@ -1446,7 +1466,11 @@ def create(self):
1446
1466
"{}-ios" .format (args .name .lower ()),
1447
1467
"{}.xcodeproj" .format (args .name .lower ()),
1448
1468
"project.pbxproj" )
1449
- update_pbxproj (filename , pbx_frameworks = args .add_framework )
1469
+
1470
+ recipes = self .recipes_names_from_paths (args .add_custom_recipes )
1471
+
1472
+ update_pbxproj (filename , pbx_frameworks = args .add_framework ,
1473
+ custom_recipes = recipes , custom_recipes_paths = args .add_custom_recipe )
1450
1474
print ("--" )
1451
1475
print ("Project directory : {}-ios" .format (
1452
1476
args .name .lower ()))
@@ -1458,6 +1482,9 @@ def update(self):
1458
1482
description = "Update an existing xcode project" )
1459
1483
parser .add_argument ("filename" , help = "Path to your project or xcodeproj" )
1460
1484
parser .add_argument ("--add-framework" , action = "append" , help = "Additional Frameworks to include with this project" )
1485
+ parser .add_argument ("--add-custom-recipe" , action = "append" , default = [],
1486
+ help = "Path to custom recipe (the recipe must already have been built with the 'build' command)" )
1487
+
1461
1488
args = parser .parse_args (sys .argv [2 :])
1462
1489
1463
1490
filename = self .find_xcodeproj (args .filename )
@@ -1466,7 +1493,10 @@ def update(self):
1466
1493
logger .error ("{} not found" .format (filename ))
1467
1494
sys .exit (1 )
1468
1495
1469
- update_pbxproj (filename , pbx_frameworks = args .add_framework )
1496
+ recipes = self .recipes_names_from_paths (args .add_custom_recipes )
1497
+
1498
+ update_pbxproj (filename , pbx_frameworks = args .add_framework ,
1499
+ custom_recipes = recipes , custom_recipes_paths = args .add_custom_recipe )
1470
1500
print ("--" )
1471
1501
print ("Project {} updated" .format (filename ))
1472
1502
0 commit comments