MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / main

Function main

scripts/ios/create-shared-scheme.py:213–266  ·  view source on GitHub ↗
(argv: List[str])

Source from the content-addressed store, hash-verified

211
212
213def main(argv: List[str]) -> int:
214 parser = argparse.ArgumentParser(description=__doc__)
215 parser.add_argument("project_dir", type=Path)
216 parser.add_argument("scheme_name", nargs="?", help="Override the generated scheme name")
217 args = parser.parse_args(argv[1:])
218
219 project_dir: Path = args.project_dir.resolve()
220 if not project_dir.is_dir():
221 print(f"error: project directory not found: {project_dir}", file=sys.stderr)
222 return 1
223
224 try:
225 xcodeproj = next(project_dir.glob("*.xcodeproj"))
226 except StopIteration:
227 print(f"error: unable to locate an .xcodeproj under {project_dir}", file=sys.stderr)
228 return 1
229
230 project_container = xcodeproj.name
231 project_file = xcodeproj / "project.pbxproj"
232 if not project_file.is_file():
233 print(f"error: missing project file: {project_file}", file=sys.stderr)
234 return 1
235
236 targets = parse_targets(project_file)
237 if not targets:
238 print(f"error: no build targets discovered in {project_file}", file=sys.stderr)
239 return 1
240
241 app, unit, ui = choose_targets(targets)
242 if not app:
243 print("error: unable to find application target", file=sys.stderr)
244 return 1
245
246 scheme_name = args.scheme_name or app.name
247
248 # Prefer UI tests only. Include unit tests only if there is no UI test target.
249 testables: List[str] = []
250 if ui is not None:
251 testables.append(render_testable(ui, project_container))
252 elif unit is not None:
253 testables.append(render_testable(unit, project_container))
254
255 if not testables:
256 print("warning: no unit or UI test targets discovered; emitting app-only scheme", file=sys.stderr)
257
258 xml = render_scheme(scheme_name, project_container, app, testables)
259
260 destinations = [xcodeproj / "xcshareddata" / "xcschemes"]
261 destinations.extend(ws / "xcshareddata" / "xcschemes" for ws in project_dir.glob("*.xcworkspace"))
262
263 for dest in destinations:
264 ensure_scheme(dest, scheme_name, xml)
265
266 return 0
267
268
269if __name__ == "__main__":

Callers 1

Calls 8

parse_targetsFunction · 0.85
choose_targetsFunction · 0.85
render_testableFunction · 0.85
render_schemeFunction · 0.85
ensure_schemeFunction · 0.85
appendMethod · 0.65
resolveMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected