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

Function findSwiftModuleRoot

compile_database.py:153–180  ·  view source on GitHub ↗

return project root or None. if not found

(filename)

Source from the content-addressed store, hash-verified

151
152
153def findSwiftModuleRoot(filename):
154 """return project root or None. if not found"""
155 filename = os.path.abspath(filename)
156 directory = os.path.dirname(filename)
157 flagFile = None
158 compileFile = None
159 while directory and directory != "/":
160 p = os.path.join(directory, ".swiftflags")
161 if os.path.isfile(p):
162 return (
163 directory,
164 p,
165 compileFile,
166 ) # prefer use swiftflags file as module root directory
167
168 if compileFile is None:
169 p = os.path.join(directory, ".compile")
170 if os.path.isfile(p):
171 compileFile = p
172
173 if isProjectRoot(directory):
174 break
175 else:
176 directory = os.path.dirname(directory)
177 else:
178 return (None, flagFile, compileFile)
179
180 return (directory, flagFile, compileFile)
181
182
183def filekey(filename):

Callers 1

InferFlagsForSwiftFunction · 0.85

Calls 1

isProjectRootFunction · 0.85

Tested by

no test coverage detected