From 912bbe766b8eedd838f1fd2c86d81bd1d5fb62eb Mon Sep 17 00:00:00 2001 From: meow464 Date: Fri, 24 Sep 2021 18:41:03 -0300 Subject: [PATCH 1/2] # 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: https://github.com/kivy/kivy-ios/issues/642 # This is the commit message #2: adds custom recipe support to the create command --- kivy_ios/toolchain.py | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/kivy_ios/toolchain.py b/kivy_ios/toolchain.py index f1130153..04e1a476 100755 --- a/kivy_ios/toolchain.py +++ b/kivy_ios/toolchain.py @@ -9,7 +9,7 @@ import argparse import sys from sys import stdout -from os.path import join, dirname, realpath, exists, isdir, basename +from os.path import join, dirname, realpath, exists, isdir, basename, split from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk import sh import zipfile @@ -1188,7 +1188,7 @@ def _hostpython_pip(args): shprint(pip_cmd, *args) -def update_pbxproj(filename, pbx_frameworks=None): +def update_pbxproj(filename, pbx_frameworks=None, custom_recipes=None, custom_recipes_paths=None): # list all the compiled recipes ctx = Context() pbx_libraries = [] @@ -1197,7 +1197,17 @@ def update_pbxproj(filename, pbx_frameworks=None): frameworks = [] libraries = [] sources = [] + + if custom_recipes and custom_recipes_paths: + recipes = custom_recipes + ctx.custom_recipes_paths = custom_recipes_paths + else: + recipes = [] + for recipe in Recipe.list_recipes(): + recipes.append(recipe) + + for recipe in recipes: key = "{}.build_all".format(recipe) if key not in ctx.state: continue @@ -1413,12 +1423,22 @@ def status(self): print("{:<12} - {}".format( recipe, status)) + def recipes_names_from_paths(self, paths): + recipes = [] + for p in paths: + _, name = split(p) + recipes.append(name) + + return recipes + def create(self): parser = argparse.ArgumentParser( description="Create a new xcode project") parser.add_argument("name", help="Name of your project") parser.add_argument("directory", help="Directory where your project lives") parser.add_argument("--add-framework", action="append", help="Additional Frameworks to include with this project") + parser.add_argument("--add-custom-recipe", action="append", default=[], + help="Path to custom recipe") args = parser.parse_args(sys.argv[2:]) from cookiecutter.main import cookiecutter @@ -1446,7 +1466,11 @@ def create(self): "{}-ios".format(args.name.lower()), "{}.xcodeproj".format(args.name.lower()), "project.pbxproj") - update_pbxproj(filename, pbx_frameworks=args.add_framework) + + recipes = self.recipes_names_from_paths(args.add_custom_recipes) + + update_pbxproj(filename, pbx_frameworks=args.add_framework, + custom_recipes=recipes, custom_recipes_paths=args.add_custom_recipe) print("--") print("Project directory : {}-ios".format( args.name.lower())) @@ -1458,6 +1482,9 @@ def update(self): description="Update an existing xcode project") parser.add_argument("filename", help="Path to your project or xcodeproj") parser.add_argument("--add-framework", action="append", help="Additional Frameworks to include with this project") + parser.add_argument("--add-custom-recipe", action="append", default=[], + help="Path to custom recipe (the recipe must already have been built with the 'build' command)") + args = parser.parse_args(sys.argv[2:]) filename = self.find_xcodeproj(args.filename) @@ -1466,7 +1493,10 @@ def update(self): logger.error("{} not found".format(filename)) sys.exit(1) - update_pbxproj(filename, pbx_frameworks=args.add_framework) + recipes = self.recipes_names_from_paths(args.add_custom_recipes) + + update_pbxproj(filename, pbx_frameworks=args.add_framework, + custom_recipes=recipes, custom_recipes_paths=args.add_custom_recipe) print("--") print("Project {} updated".format(filename)) From 0573477b1ae024f805f6eba7cca666c537fba08b Mon Sep 17 00:00:00 2001 From: meow464 Date: Sun, 26 Sep 2021 11:34:25 -0300 Subject: [PATCH 2/2] Adds `--add-custom-recipe` to `update` and `create` commands Custom recipes were built but not added to the XCode project. See: https://github.com/kivy/kivy-ios/issues/642 --- kivy_ios/toolchain.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kivy_ios/toolchain.py b/kivy_ios/toolchain.py index 04e1a476..cb27b74f 100755 --- a/kivy_ios/toolchain.py +++ b/kivy_ios/toolchain.py @@ -1467,7 +1467,7 @@ def create(self): "{}.xcodeproj".format(args.name.lower()), "project.pbxproj") - recipes = self.recipes_names_from_paths(args.add_custom_recipes) + recipes = self.recipes_names_from_paths(args.add_custom_recipe) update_pbxproj(filename, pbx_frameworks=args.add_framework, custom_recipes=recipes, custom_recipes_paths=args.add_custom_recipe) @@ -1484,7 +1484,6 @@ def update(self): parser.add_argument("--add-framework", action="append", help="Additional Frameworks to include with this project") parser.add_argument("--add-custom-recipe", action="append", default=[], help="Path to custom recipe (the recipe must already have been built with the 'build' command)") - args = parser.parse_args(sys.argv[2:]) filename = self.find_xcodeproj(args.filename) @@ -1493,7 +1492,7 @@ def update(self): logger.error("{} not found".format(filename)) sys.exit(1) - recipes = self.recipes_names_from_paths(args.add_custom_recipes) + recipes = self.recipes_names_from_paths(args.add_custom_recipe) update_pbxproj(filename, pbx_frameworks=args.add_framework, custom_recipes=recipes, custom_recipes_paths=args.add_custom_recipe)