forked from psychowasp/kivy-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Untitled.patch
203 lines (192 loc) · 8.72 KB
/
Untitled.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
diff --git a/kivy_ios/toolchain.py b/kivy_ios/toolchain.py
old mode 100755
new mode 100644
index ff4a8a6..acef23c
--- a/kivy_ios/toolchain.py
+++ b/kivy_ios/toolchain.py
@@ -9,7 +9,7 @@ This tool intend to replace all the previous tools/ in shell script.
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
@@ -1187,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 = []
@@ -1196,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
@@ -1239,19 +1250,39 @@ def update_pbxproj(filename, pbx_frameworks=None):
logger.info("Ensure {} is in the project (pbx_frameworks, system)".format(framework))
f_path = join(sysroot, "System", "Library", "Frameworks",
"{}.framework".format(framework))
- project.add_file(f_path, parent=group, tree="DEVELOPER_DIR",
- force=False, file_options=file_options)
+ # Quick Fix
+ items = project.get_files_by_name(basename(f_path),None)
+ if len(items) == 0:
+ # # Quick Fix end
+ project.add_file(f_path, parent=group, tree="DEVELOPER_DIR",
+ force=True, file_options=file_options)
+
for library in pbx_libraries:
logger.info("Ensure {} is in the project (pbx_libraries, dylib+tbd)".format(library))
f_path = join(sysroot, "usr", "lib",
"{}.dylib".format(library))
- project.add_file(f_path, parent=group, tree="DEVELOPER_DIR", force=False)
+ # Quick Fix
+ items = project.get_files_by_name(basename(f_path),group)
+ if len(items) == 0:
+ # Quick Fix end
+ project.add_file(f_path, parent=group, tree="DEVELOPER_DIR", force=True)
+
f_path = join(sysroot, "usr", "lib",
"{}.tbd".format(library))
- project.add_file(f_path, parent=group, tree="DEVELOPER_DIR", force=False)
+ # Quick Fix
+ items = project.get_files_by_name(basename(f_path),group)
+ if len(items) == 0:
+ # Quick Fix end
+ project.add_file(f_path, parent=group, tree="DEVELOPER_DIR", force=True)
+
for library in libraries:
logger.info("Ensure {} is in the project (libraries)".format(library))
- project.add_file(library, parent=group, force=False)
+ # Quick Fix
+ items = project.get_files_by_name(basename(library),group)
+ if len(items) == 0:
+ # Quick Fix end
+ project.add_file(library, parent=group, force=True)
+
for name in sources:
logger.info("Ensure {} sources are used".format(name))
fn = join(ctx.dist_dir, "sources", name)
@@ -1303,16 +1334,6 @@ pip Install a pip dependency into the distribution
filename = xcodeproj[0]
return filename
- @staticmethod
- def validate_custom_recipe_paths(ctx, paths):
- for custom_recipe_path in paths:
- if exists(custom_recipe_path):
- logger.info(f"Adding {custom_recipe_path} to custom recipes paths")
- ctx.custom_recipes_paths.append(custom_recipe_path)
- else:
- logger.error(f"{custom_recipe_path} isn't a valid path")
- raise FileNotFoundError
-
def build(self):
ctx = Context()
parser = argparse.ArgumentParser(
@@ -1348,16 +1369,18 @@ pip Install a pip dependency into the distribution
ctx.use_pigz = False
if args.no_pbzip2:
ctx.use_pbzip2 = False
-
- self.validate_custom_recipe_paths(ctx, args.add_custom_recipe)
-
ctx.use_pigz = ctx.use_pbzip2
logger.info("Building with {} processes, where supported".format(ctx.num_cores))
if ctx.use_pigz:
logger.info("Using pigz to decompress gzip data")
if ctx.use_pbzip2:
logger.info("Using pbzip2 to decompress bzip2 data")
-
+ for custom_recipe_path in args.add_custom_recipe:
+ if exists(custom_recipe_path):
+ logger.info(f"Adding {custom_recipe_path} to custom recipes paths")
+ ctx.custom_recipes_paths.append(custom_recipe_path)
+ else:
+ logger.error(f"{custom_recipe_path} isn't a valid path")
build_recipes(args.recipe, ctx)
def recipes(self):
@@ -1385,16 +1408,11 @@ pip Install a pip dependency into the distribution
if exists(recipe_inst.archive_fn):
unlink(recipe_inst.archive_fn)
- ctx = Context()
parser = argparse.ArgumentParser(
description="Clean the build")
parser.add_argument("recipe", nargs="*", help="Recipe to clean")
- parser.add_argument("--add-custom-recipe", action="append", default=[],
- help="Path to custom recipe")
args = parser.parse_args(sys.argv[2:])
-
- self.validate_custom_recipe_paths(ctx, args.add_custom_recipe)
-
+ ctx = Context()
if args.recipe:
for recipe in args.recipe:
logger.info("Cleaning {} build".format(recipe))
@@ -1425,12 +1443,22 @@ pip Install a pip dependency into the distribution
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
@@ -1458,7 +1486,11 @@ pip Install a pip dependency into the distribution
"{}-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_recipe)
+
+ 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()))
@@ -1470,6 +1502,8 @@ pip Install a pip dependency into the distribution
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)
@@ -1478,7 +1512,10 @@ pip Install a pip dependency into the distribution
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_recipe)
+
+ update_pbxproj(filename, pbx_frameworks=args.add_framework,
+ custom_recipes=recipes, custom_recipes_paths=args.add_custom_recipe)
print("--")
print("Project {} updated".format(filename))