this class control all user config. options: kind: xcode|manual # where to find flags. default: manual when kind=xcode: workspace: the bind workspace path scheme: the bind scheme build_root: the build_root find from xcworkspace and scheme when kind=manual(or no
| 24 | return property(fget, fset, fdel, doc) |
| 25 | |
| 26 | class ServerConfig(object): |
| 27 | """this class control all user config. options: |
| 28 | |
| 29 | kind: xcode|manual # where to find flags. default: manual |
| 30 | when kind=xcode: |
| 31 | workspace: the bind workspace path |
| 32 | scheme: the bind scheme |
| 33 | build_root: the build_root find from xcworkspace and scheme |
| 34 | when kind=manual(or no kind): |
| 35 | indexStorePath?: the manual parsed index path. may not exists |
| 36 | |
| 37 | user can change scheme by call `xcode-build-server config`, |
| 38 | or change to manual by call `xcode-build-server parse` directly. |
| 39 | |
| 40 | after config change. server should change to new flags too.. |
| 41 | |
| 42 | other config: |
| 43 | skip_validate_bin: if true, will skip validate bin for background parser |
| 44 | """ |
| 45 | |
| 46 | # TODO: distinguish configuration and destination # |
| 47 | |
| 48 | default_path = "buildServer.json" |
| 49 | |
| 50 | kind = _config_property("kind", default="manual") |
| 51 | workspace = _config_property("workspace") |
| 52 | scheme = _config_property("scheme") |
| 53 | build_root = _config_property("build_root") |
| 54 | indexStorePath = _config_property("indexStorePath") |
| 55 | |
| 56 | skip_validate_bin = _config_property("skip_validate_bin") |
| 57 | |
| 58 | @cache |
| 59 | def shared(): |
| 60 | return ServerConfig(ServerConfig.default_path) |
| 61 | |
| 62 | def __init__(self, path): |
| 63 | self.path = os.path.abspath(path) |
| 64 | if os.path.exists(path): |
| 65 | with open(path, "r") as f: |
| 66 | self.data = json.load(f) |
| 67 | else: |
| 68 | self.data = {} |
| 69 | |
| 70 | self.data.update({ |
| 71 | "name": "xcode build server", |
| 72 | "version": VERSION, |
| 73 | "bspVersion": "2.2.0", |
| 74 | "languages": ["c", "cpp", "objective-c", "objective-cpp", "swift"], |
| 75 | "argv": [sys.argv[0]] |
| 76 | }) |
| 77 | |
| 78 | def save(self): |
| 79 | with open(self.path, "w") as f: |
| 80 | json.dump(self.data, f, indent="\t") |
no test coverage detected