Skip to content

Commit

Permalink
Refactor compdb handling to a separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
rwols committed Aug 26, 2017
1 parent 54a39ba commit d1a66d8
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,32 +290,11 @@ def on_done_input(new_value):
self.targets.add(
Target("BUILD ALL", "BUILD ALL", "ALL",
self.cmake.build_folder, ""))
data = self.window.project_data()
self.targets = list(self.targets)
path = os.path.join(self.cmake.build_folder,
"compile_commands.json")
if os.path.isfile(path):
settings = sublime.load_settings(
"CMakeBuilder.sublime-settings")
s = "auto_update_EasyClangComplete_compile_commands_location"
setting = s
if settings.get(setting, False):
data["settings"]["ecc_flags_sources"] = [{
"file":
"compile_commands.json",
"search_in":
self.cmake.build_folder_pre_expansion
}]
setting = "auto_update_compile_commands_project_setting"
if settings.get(setting, False):
data["settings"]["compile_commands"] = \
self.cmake.build_folder_pre_expansion
setting = "copy_compile_commands_to_project_path"
if settings.get(setting, False):
destination = os.path.join(self.cmake.source_folder,
"compile_commands.json")
shutil.copyfile(path, destination)
self.window.set_project_data(data)
self.handle_compdb()
elif reply == "cache":
cache = thedict.pop("cache")
self.items = []
Expand Down Expand Up @@ -350,6 +329,30 @@ def on_done_input(new_value):
else:
print("received unknown reply type:", reply)

def handle_compdb(self):
data = self.window.project_data()
settings = sublime.load_settings("CMakeBuilder.sublime-settings")
setting = "auto_update_EasyClangComplete_compile_commands_location"
if settings.get(setting, False):
data["settings"]["ecc_flags_sources"] = [{
"file":
"compile_commands.json",
"search_in":
self.cmake.build_folder_pre_expansion
}]
setting = "auto_update_compile_commands_project_setting"
if settings.get(setting, False):
data["settings"]["compile_commands"] = \
self.cmake.build_folder_pre_expansion
setting = "copy_compile_commands_to_project_path"
if settings.get(setting, False):
destination = os.path.join(self.cmake.source_folder,
"compile_commands.json")
path = os.path.join(self.cmake.build_folder,
"compile_commands.json")
shutil.copyfile(path, destination)
self.window.set_project_data(data)

def receive_error(self, thedict):
reply = thedict["inReplyTo"]
msg = thedict["errorMessage"]
Expand Down

0 comments on commit d1a66d8

Please sign in to comment.