(argv=sys.argv)
| 35 | |
| 36 | |
| 37 | def main(argv=sys.argv): |
| 38 | it = iter(argv) |
| 39 | name = next(it, None) |
| 40 | _usage = partial(usage, name) |
| 41 | # generate a config bind xcodeproj |
| 42 | if len(argv) < 3 or "-h" == argv[1] or "--help" == argv[1] or "-help" == argv[1]: |
| 43 | _usage() |
| 44 | |
| 45 | workspace = None |
| 46 | scheme = None |
| 47 | project = None |
| 48 | skip_validate_bin = None |
| 49 | build_root = None |
| 50 | while (arg := next(it, None)) is not None: |
| 51 | if arg == "-workspace" or arg == "--workspace": |
| 52 | workspace = next(it, None) |
| 53 | elif arg == "-scheme" or arg == "--scheme": |
| 54 | scheme = next(it, None) |
| 55 | elif arg == "-project" or arg == "--project": |
| 56 | project = next(it, None) |
| 57 | elif arg == "--build_root": |
| 58 | build_root = next(it, None) |
| 59 | elif arg == "--skip-validate-bin": |
| 60 | skip_validate_bin = True |
| 61 | elif "-h" == arg or "--help" == arg or "-help" == arg: |
| 62 | _usage() |
| 63 | else: |
| 64 | _usage(f"unknown arg {arg}") |
| 65 | |
| 66 | def update(scheme): |
| 67 | print("find root:", build_root) |
| 68 | |
| 69 | config = ServerConfig.shared() |
| 70 | config.workspace = workspace |
| 71 | config.build_root = build_root |
| 72 | config.scheme = scheme |
| 73 | config.kind = "xcode" |
| 74 | config.skip_validate_bin = skip_validate_bin |
| 75 | config.save() |
| 76 | print("updated buildServer.json") |
| 77 | |
| 78 | if build_root: |
| 79 | build_root = os.path.abspath(os.path.expanduser(build_root)) |
| 80 | return update(scheme) |
| 81 | |
| 82 | if workspace is None: |
| 83 | |
| 84 | def get_workspace(): |
| 85 | nonlocal project |
| 86 | if project is None: |
| 87 | workspaces = glob.glob("*.xcworkspace") |
| 88 | if len(workspaces) > 1: |
| 89 | _usage("there are multiple xcworkspace in pwd, please specify one") |
| 90 | if len(workspaces) == 1: |
| 91 | return workspaces[0] |
| 92 | |
| 93 | projects = glob.glob("*.xcodeproj") |
| 94 | if len(projects) > 1: |
nothing calls this directly
no test coverage detected