Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions compile_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ def filterFlags(items, fileCache):
pass


def findSwiftModuleRoot(filename):
def findSwiftModuleRoot(filename, directory=None):
"""return project root or None. if not found"""
filename = os.path.abspath(filename)
directory = os.path.dirname(filename)
if not directory:
directory = os.path.dirname(filename)
flagFile = None
compileFile = None
while directory and directory != "/":
Expand Down Expand Up @@ -352,6 +353,10 @@ def GetFlags(filename: str, compileFile=None, store=None):
def InferFlagsForSwift(filename, compileFile, store):
"""try infer flags by convention and workspace files"""
project_root, flagFile, compileFile = findSwiftModuleRoot(filename)
if not compileFile:
# search for workspace from current directory if no compile file found
project_root, flagFile, compileFile = findSwiftModuleRoot(filename, directory=os.getcwd())

logging.debug(f"infer root: {project_root}, {compileFile}")
final_flags = GetFlagsInCompile(filename, compileFile, store)

Expand Down