Skip to content

Commit 912bbe7

Browse files
committed
# This is a combination of 2 commits.
# This is the 1st commit message: Adds `--add-custom-recipe` to `update` and `create` commands Custom recipes were built but not added to the XCode project. See: #642 # This is the commit message #2: adds custom recipe support to the create command
1 parent 651461b commit 912bbe7

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

kivy_ios/toolchain.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import argparse
1010
import sys
1111
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
1313
from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk
1414
import sh
1515
import zipfile
@@ -1188,7 +1188,7 @@ def _hostpython_pip(args):
11881188
shprint(pip_cmd, *args)
11891189

11901190

1191-
def update_pbxproj(filename, pbx_frameworks=None):
1191+
def update_pbxproj(filename, pbx_frameworks=None, custom_recipes=None, custom_recipes_paths=None):
11921192
# list all the compiled recipes
11931193
ctx = Context()
11941194
pbx_libraries = []
@@ -1197,7 +1197,17 @@ def update_pbxproj(filename, pbx_frameworks=None):
11971197
frameworks = []
11981198
libraries = []
11991199
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+
12001207
for recipe in Recipe.list_recipes():
1208+
recipes.append(recipe)
1209+
1210+
for recipe in recipes:
12011211
key = "{}.build_all".format(recipe)
12021212
if key not in ctx.state:
12031213
continue
@@ -1413,12 +1423,22 @@ def status(self):
14131423
print("{:<12} - {}".format(
14141424
recipe, status))
14151425

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+
14161434
def create(self):
14171435
parser = argparse.ArgumentParser(
14181436
description="Create a new xcode project")
14191437
parser.add_argument("name", help="Name of your project")
14201438
parser.add_argument("directory", help="Directory where your project lives")
14211439
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")
14221442
args = parser.parse_args(sys.argv[2:])
14231443

14241444
from cookiecutter.main import cookiecutter
@@ -1446,7 +1466,11 @@ def create(self):
14461466
"{}-ios".format(args.name.lower()),
14471467
"{}.xcodeproj".format(args.name.lower()),
14481468
"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)
14501474
print("--")
14511475
print("Project directory : {}-ios".format(
14521476
args.name.lower()))
@@ -1458,6 +1482,9 @@ def update(self):
14581482
description="Update an existing xcode project")
14591483
parser.add_argument("filename", help="Path to your project or xcodeproj")
14601484
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+
14611488
args = parser.parse_args(sys.argv[2:])
14621489

14631490
filename = self.find_xcodeproj(args.filename)
@@ -1466,7 +1493,10 @@ def update(self):
14661493
logger.error("{} not found".format(filename))
14671494
sys.exit(1)
14681495

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)
14701500
print("--")
14711501
print("Project {} updated".format(filename))
14721502

0 commit comments

Comments
 (0)