-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cmake_binary setting, and make preps for version 3.11
- Protocol version 1.1 is used in 3.11 - Allow cmake_binary setting to point to another cmake executable, if desired.
- Loading branch information
Showing
6 changed files
with
60 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,10 @@ | ||
import sublime | ||
import sublime_plugin | ||
import os | ||
from .command import CmakeCommand | ||
from ..support import capabilities | ||
|
||
|
||
if capabilities("serverMode"): | ||
class CmakeEditCacheCommand(CmakeCommand): | ||
|
||
def description(self): | ||
return "Edit Cache..." | ||
|
||
class CmakeEditCacheCommand(CmakeCommand): | ||
|
||
def description(self): | ||
return "Edit Cache..." | ||
|
||
def run(self): | ||
self.server.cache() | ||
|
||
else: | ||
|
||
|
||
class CmakeEditCacheCommand(sublime_plugin.WindowCommand): | ||
|
||
"""Edit an entry from the CMake cache.""" | ||
def is_enabled(self): | ||
try: | ||
build_folder = self.window.project_data()["settings"]["cmake"]["build_folder"] | ||
build_folder = sublime.expand_variables(build_folder, self.window.extract_variables()) | ||
return os.path.exists(os.path.join(build_folder, "CMakeCache.txt")) | ||
except Exception as e: | ||
return False | ||
|
||
def description(self): | ||
return "Edit Cache..." | ||
|
||
def run(self): | ||
build_folder = self.window.project_data()["settings"]["cmake"]["build_folder"] | ||
build_folder = sublime.expand_variables(build_folder, self.window.extract_variables()) | ||
self.window.open_file(os.path.join(build_folder, "CMakeCache.txt")) | ||
self.window.run_command("show_overlay", args={"overlay": "goto", "text": "@"}) | ||
def run(self): | ||
self.server.cache() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,15 @@ | ||
import sublime | ||
import sublime_plugin | ||
import os | ||
from .command import CmakeCommand | ||
from ..support import capabilities | ||
|
||
|
||
if capabilities("serverMode"): | ||
class CmakeOpenBuildFolderCommand(CmakeCommand): | ||
"""Opens the build folder.""" | ||
|
||
@classmethod | ||
def description(cls): | ||
return "Browse Build Folder..." | ||
|
||
class CmakeOpenBuildFolderCommand(CmakeCommand): | ||
"""Opens the build folder.""" | ||
|
||
@classmethod | ||
def description(cls): | ||
return "Browse Build Folder..." | ||
|
||
def run(self): | ||
build_folder = self.server.cmake.build_folder | ||
self.window.run_command("open_dir", args={"dir": os.path.realpath(build_folder)}) | ||
|
||
else: | ||
|
||
|
||
class CmakeOpenBuildFolderCommand(sublime_plugin.WindowCommand): | ||
"""Opens the build folder.""" | ||
|
||
@classmethod | ||
def description(cls): | ||
return "Browse Build Folder..." | ||
|
||
def is_enabled(self): | ||
try: | ||
build_folder = self.window.project_data()["settings"]["cmake"]["build_folder"] | ||
build_folder = sublime.expand_variables(build_folder, self.window.extract_variables()) | ||
return os.path.exists(build_folder) | ||
except Exception as e: | ||
return False | ||
|
||
def run(self): | ||
build_folder = self.window.project_data()["settings"]["cmake"]["build_folder"] | ||
build_folder = sublime.expand_variables(build_folder, self.window.extract_variables()) | ||
self.window.run_command('open_dir', args={'dir': os.path.realpath(build_folder)}) | ||
def run(self): | ||
build_folder = self.server.cmake.build_folder | ||
args = {"dir": os.path.realpath(build_folder)} | ||
self.window.run_command("open_dir", args=args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,42 @@ | ||
from .check_output import check_output | ||
import json | ||
import sublime | ||
|
||
_capabilities = None | ||
|
||
|
||
def plugin_loaded(): | ||
settings = sublime.load_settings("CMakeBuilder.sublime-settings") | ||
settings.add_on_change("CMakeBuilder", _reload_capabilities) | ||
_reload_capabilities() | ||
|
||
|
||
def _reload_capabilities(): | ||
global _capabilities | ||
try: | ||
print("loading settings") | ||
settings = sublime.load_settings("CMakeBuilder.sublime-settings") | ||
print("fetching cmake binary") | ||
cmake = settings.get("cmake_binary", "cmake") | ||
command = "{} -E capabilities".format(cmake) | ||
print("running", command) | ||
output = check_output(command) | ||
_capabilities = json.loads(output) | ||
except Exception as e: | ||
sublime.error_message("There was an error loading cmake's " | ||
"capabilities. Your \"cmake_binary\" setting is " | ||
"set to \"{}\". Please make sure that this " | ||
"points to a valid cmake executable." | ||
.format(cmake)) | ||
print(str(e)) | ||
_capabilities = {"error": None} | ||
|
||
|
||
def capabilities(key): | ||
global _capabilities | ||
if _capabilities is None: | ||
try: | ||
_capabilities = json.loads(check_output("cmake -E capabilities")) | ||
except Exception as e: | ||
print("CMakeBuilder: Error: Could not load cmake's capabilities") | ||
_capabilities = {"error": None} | ||
return _capabilities.get(key, None) | ||
raise KeyError("Capabilities called too early!") | ||
elif "error" in _capabilities: | ||
raise ValueError("Error loading capabilities") | ||
else: | ||
return _capabilities.get(key, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters