MCPcopy Create free account
hub / github.com/SolaWing/xcode-build-server / InferFlagsForSwift

Function InferFlagsForSwift

compile_database.py:352–388  ·  view source on GitHub ↗

try infer flags by convention and workspace files

(filename, compileFile, store)

Source from the content-addressed store, hash-verified

350
351# TODO: c family infer flags #
352def 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

Callers 3

register_uriMethod · 0.90
sourceKitOptionsMethod · 0.90
optionsForFileMethod · 0.90

Calls 8

findSwiftModuleRootFunction · 0.85
GetFlagsInCompileFunction · 0.85
findAllHeaderDirectoryFunction · 0.85
findAllSwiftFilesFunction · 0.85
additionalFlagsFunction · 0.85
filterFlagsFunction · 0.85
getXcodeBasePathFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected