try infer flags by convention and workspace files
(filename, compileFile, store)
| 350 | |
| 351 | # TODO: c family infer flags # |
| 352 | def InferFlagsForSwift(filename, compileFile, store): |
| 353 | """try infer flags by convention and workspace files""" |
| 354 | project_root, flagFile, compileFile = findSwiftModuleRoot(filename) |
| 355 | logging.debug(f"infer root: {project_root}, {compileFile}") |
| 356 | final_flags = GetFlagsInCompile(filename, compileFile, store) |
| 357 | |
| 358 | if not final_flags and flagFile: |
| 359 | final_flags = [] |
| 360 | headers, frameworks = findAllHeaderDirectory(project_root, store) |
| 361 | for h in headers: |
| 362 | final_flags += ["-Xcc", "-I" + h] |
| 363 | for f in frameworks: |
| 364 | final_flags.append("-F" + f) |
| 365 | swiftfiles = findAllSwiftFiles(project_root) |
| 366 | final_flags += swiftfiles |
| 367 | a = additionalFlags(flagFile) |
| 368 | if a: |
| 369 | # sourcekit not allow same swift name. so if same name, use the find one to support move file |
| 370 | swift_names = set(os.path.basename(p) for p in swiftfiles) |
| 371 | final_flags += ( |
| 372 | arg |
| 373 | for arg in filterFlags(a, store.setdefault("filelist", {})) |
| 374 | if os.path.basename(arg) not in swift_names |
| 375 | ) |
| 376 | else: |
| 377 | final_flags += [ |
| 378 | "-sdk", |
| 379 | os.path.join(getXcodeBasePath(), "Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/"), |
| 380 | ] |
| 381 | if not final_flags: |
| 382 | final_flags = [ |
| 383 | filename, |
| 384 | "-sdk", |
| 385 | os.path.join(getXcodeBasePath(), "Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/"), |
| 386 | ] |
| 387 | |
| 388 | return final_flags |
no test coverage detected