Update the vcvarsall situation, build before debugging, update readme
This commit is contained in:
@@ -26,7 +26,8 @@ Launch Sublime (maybe you will need Package Control + and call Package Control:
|
|||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
|
|
||||||
* add remedy_executable to your settings if remedybg is not on your path or has different name.
|
* Add remedy_executable to your settings if remedybg is not on your path or has different name.
|
||||||
|
* Setup vcvarsall, Look at vcvarsall section in readme.
|
||||||
|
|
||||||
### Remedy build system
|
### Remedy build system
|
||||||
|
|
||||||
@@ -57,11 +58,9 @@ you will need to add a field called ```remedy_build_system```, here is an exampl
|
|||||||
```
|
```
|
||||||
### Setting up Microsoft compiler enviroment with vcvarsall.bat
|
### Setting up Microsoft compiler enviroment with vcvarsall.bat
|
||||||
|
|
||||||
If you are developing using remedybg it seems pretty obvious that you would want access to the Microsoft compiler so additionally the package is shipping with the ```setup_vsvars.py```. You can find it in the ```other``` folder. It sets up the vcvarsall paths for you, it was created by one of the sublime developers, I found it on Stack Overflow. You need to:
|
If you are developing using remedybg it seems pretty obvious that you would want access to the Microsoft compiler so additionally the package is shipping with the ```setup_vsvars.py```. You need to update the path to your vcvarsall inside ```Remedy.sublime-settings``` or your global ```Preferences.sublime-settings```. THIS ONLY WORKS FOR REMEDY_BUILD!!! If you want to setup vcvarsall for the builtin ```build``` command, copy setup_vsvars.py to your ```User``` folder. You will have 2 copies one in remedy folder and the other in user folder. You need 2 copies because it seems that sublime heavily sandboxes packages from eachother so this package cannot influence the global enviroment. If anyone has any ideas how to make it global I would be happy to hear them.
|
||||||
|
|
||||||
* Copy it into your User folder ```copy "%appdata%\Sublime Text\Packages\Sublime_RemedyBG\other\setup_vsvars.py" "%appdata%\Sublime Text\Packages\User\setup_vsvars.py"```
|
|
||||||
* Add to your sublime settings the path to vcvarsall, like this:
|
|
||||||
|
|
||||||
|
Update these settings: (you can put them into global settings ```Preferences.sublime-settings``` or ```Remedy.sublime-settings```)
|
||||||
```
|
```
|
||||||
"vc_vars_cmd": "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat",
|
"vc_vars_cmd": "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat",
|
||||||
"vc_vars_arch": "amd64",
|
"vc_vars_arch": "amd64",
|
||||||
|
|||||||
12
Remedy.sublime-settings
Normal file
12
Remedy.sublime-settings
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
// NOTE to build_before_debugging
|
||||||
|
// You need a project and a build system inside that project if you want build_before_debugging,
|
||||||
|
// Sublime API doesnt allow for querying of the selected build system, I need to essentially emulate that process.
|
||||||
|
// Look here to figure out the project format: https://www.sublimetext.com/docs/projects.html
|
||||||
|
// Additionally you need a field called "remedy_build_system" to signal which
|
||||||
|
// build system was chosen if you have more then 1 build system.
|
||||||
|
"build_before_debugging": true,
|
||||||
|
"executable": "remedybg.exe",
|
||||||
|
"vc_vars_cmd": "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Auxiliary/Build/vcvarsall.bat",
|
||||||
|
"vc_vars_arch": "amd64",
|
||||||
|
}
|
||||||
50
remedy.py
50
remedy.py
@@ -8,6 +8,7 @@ import os, io, ctypes
|
|||||||
|
|
||||||
import sublime
|
import sublime
|
||||||
import sublime_plugin
|
import sublime_plugin
|
||||||
|
|
||||||
from Default.exec import ExecCommand
|
from Default.exec import ExecCommand
|
||||||
|
|
||||||
import win32pipe, win32file, pywintypes
|
import win32pipe, win32file, pywintypes
|
||||||
@@ -59,7 +60,6 @@ class RemedyInstance:
|
|||||||
elif cmd == COMMAND_GET_TARGET_STATE:
|
elif cmd == COMMAND_GET_TARGET_STATE:
|
||||||
pass
|
pass
|
||||||
elif cmd == COMMAND_ADD_WATCH:
|
elif cmd == COMMAND_ADD_WATCH:
|
||||||
print(cmd_args)
|
|
||||||
expr = cmd_args['expr']
|
expr = cmd_args['expr']
|
||||||
cmd_buffer.write(ctypes.c_uint8(1)) # watch window 1
|
cmd_buffer.write(ctypes.c_uint8(1)) # watch window 1
|
||||||
cmd_buffer.write(ctypes.c_uint16(len(expr)))
|
cmd_buffer.write(ctypes.c_uint16(len(expr)))
|
||||||
@@ -267,8 +267,8 @@ remedy_instance = RemedyInstance()
|
|||||||
|
|
||||||
def get_remedy_executable():
|
def get_remedy_executable():
|
||||||
window = sublime.active_window()
|
window = sublime.active_window()
|
||||||
settings = window.settings()
|
settings = sublime.load_settings("Remedy.sublime-settings")
|
||||||
result = settings.get("remedy_executable", "remedybg")
|
result = settings.get("executable", "remedybg")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def execute_process(view, cmd, offset = 1):
|
def execute_process(view, cmd, offset = 1):
|
||||||
@@ -280,13 +280,8 @@ def execute_process(view, cmd, offset = 1):
|
|||||||
print(cmd)
|
print(cmd)
|
||||||
subprocess.Popen(cmd)
|
subprocess.Popen(cmd)
|
||||||
|
|
||||||
class RemedyBuildCommand(ExecCommand):
|
def get_build_system(window):
|
||||||
def run(self, **kwargs):
|
project = window.project_data()
|
||||||
self.command = kwargs.get("command")
|
|
||||||
if self.command == None:
|
|
||||||
sublime.message_dialog("RemedyBG: remedy_build expects a command, one of [run_to_cursor, start_debugging, goto_cursor]\n\nexample :: \"args\":{\"command\": \"run_to_cursor\"}")
|
|
||||||
|
|
||||||
project = self.window.project_data()
|
|
||||||
build = None
|
build = None
|
||||||
if project:
|
if project:
|
||||||
bs = project.get("build_systems")
|
bs = project.get("build_systems")
|
||||||
@@ -299,8 +294,25 @@ class RemedyBuildCommand(ExecCommand):
|
|||||||
if rbs == i["name"]:
|
if rbs == i["name"]:
|
||||||
build = i
|
build = i
|
||||||
break
|
break
|
||||||
|
return project, build
|
||||||
|
|
||||||
|
def should_build_before_debugging(window):
|
||||||
|
settings = sublime.load_settings("Remedy.sublime-settings")
|
||||||
|
build_before = settings.get("build_before_debugging", False)
|
||||||
|
if build_before:
|
||||||
|
project, build = get_build_system(window)
|
||||||
|
if project == None or build == None:
|
||||||
|
build_before = False
|
||||||
|
|
||||||
|
return build_before
|
||||||
|
|
||||||
|
class RemedyBuildCommand(ExecCommand):
|
||||||
|
def run(self, **kwargs):
|
||||||
|
self.command = kwargs.get("command")
|
||||||
|
if self.command == None:
|
||||||
|
sublime.message_dialog("RemedyBG: remedy_build expects a command, one of [run_to_cursor, start_debugging, goto_cursor]\n\nexample :: \"args\":{\"command\": \"run_to_cursor\"}")
|
||||||
|
|
||||||
|
project, build = get_build_system(self.window)
|
||||||
if project == None or build == None:
|
if project == None or build == None:
|
||||||
sublime.error_message("""
|
sublime.error_message("""
|
||||||
RemedyBG: You need a project and a build system inside that project to call this function,
|
RemedyBG: You need a project and a build system inside that project to call this function,
|
||||||
@@ -329,6 +341,17 @@ class RemedyBuildCommand(ExecCommand):
|
|||||||
"word_wrap": build.get("word_wrap", True),
|
"word_wrap": build.get("word_wrap", True),
|
||||||
"syntax": build.get("syntax", "Packages/Text/Plain text.tmLanguage"),
|
"syntax": build.get("syntax", "Packages/Text/Plain text.tmLanguage"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variables = self.window.extract_variables()
|
||||||
|
for key in ["cmd", "shell_cmd", "file_regex", "line_regex", "working_dir"]:
|
||||||
|
if kwargs.get(key) != None:
|
||||||
|
kwargs[key] = sublime.expand_variables(kwargs[key], variables)
|
||||||
|
|
||||||
|
print(os.environ)
|
||||||
|
for key in os.environ.keys():
|
||||||
|
if key not in kwargs["env"]:
|
||||||
|
kwargs["env"][key] = os.environ[key]
|
||||||
|
|
||||||
super().run(**kwargs)
|
super().run(**kwargs)
|
||||||
def on_finished(self, proc):
|
def on_finished(self, proc):
|
||||||
super().on_finished(proc)
|
super().on_finished(proc)
|
||||||
@@ -351,6 +374,9 @@ class RemedyStartDebuggingCommand(sublime_plugin.WindowCommand):
|
|||||||
|
|
||||||
state = remedy_instance.send_command(COMMAND_GET_TARGET_STATE)
|
state = remedy_instance.send_command(COMMAND_GET_TARGET_STATE)
|
||||||
if state == TARGETSTATE_NONE:
|
if state == TARGETSTATE_NONE:
|
||||||
|
if should_build_before_debugging(self.window):
|
||||||
|
self.window.run_command("remedy_build", {"command": "start_debugging"})
|
||||||
|
else:
|
||||||
remedy_instance.send_command(COMMAND_START_DEBUGGING)
|
remedy_instance.send_command(COMMAND_START_DEBUGGING)
|
||||||
elif state == TARGETSTATE_SUSPENDED:
|
elif state == TARGETSTATE_SUSPENDED:
|
||||||
remedy_instance.send_command(COMMAND_CONTINUE_EXECUTION)
|
remedy_instance.send_command(COMMAND_CONTINUE_EXECUTION)
|
||||||
@@ -369,6 +395,10 @@ class RemedyRestartDebuggingCommand(sublime_plugin.WindowCommand):
|
|||||||
class RemedyRunToCursorCommand(sublime_plugin.TextCommand):
|
class RemedyRunToCursorCommand(sublime_plugin.TextCommand):
|
||||||
def run(self, edit):
|
def run(self, edit):
|
||||||
if remedy_instance.try_launching(): return
|
if remedy_instance.try_launching(): return
|
||||||
|
window = sublime.active_window()
|
||||||
|
if should_build_before_debugging(sublime.active_window()):
|
||||||
|
window.run_command("remedy_build", {"command": "run_to_cursor"})
|
||||||
|
else:
|
||||||
remedy_instance.run_to_cursor()
|
remedy_instance.run_to_cursor()
|
||||||
|
|
||||||
class RemedyGotoCursorCommand(sublime_plugin.TextCommand):
|
class RemedyGotoCursorCommand(sublime_plugin.TextCommand):
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ def _get_vc_env():
|
|||||||
vars_cmd = settings.get("vc_vars_cmd")
|
vars_cmd = settings.get("vc_vars_cmd")
|
||||||
vars_arch = settings.get("vc_vars_arch", "amd64")
|
vars_arch = settings.get("vc_vars_arch", "amd64")
|
||||||
|
|
||||||
|
if vars_cmd is None:
|
||||||
|
settings = sublime.load_settings("Remedy.sublime-settings")
|
||||||
|
if settings:
|
||||||
|
vars_cmd = settings.get("vc_vars_cmd")
|
||||||
|
vars_arch = settings.get("vc_vars_arch", "amd64")
|
||||||
|
|
||||||
|
|
||||||
if vars_cmd is None:
|
if vars_cmd is None:
|
||||||
print("set_vc_vars: Cannot set Visual Studio Environment")
|
print("set_vc_vars: Cannot set Visual Studio Environment")
|
||||||
print("set_vc_vars: Add 'vc_vars_cmd' setting to settings and restart")
|
print("set_vc_vars: Add 'vc_vars_cmd' setting to settings and restart")
|
||||||
Reference in New Issue
Block a user