Skip to content

Instantly share code, notes, and snippets.

@OdatNurd
Last active March 15, 2021 12:50
Show Gist options
  • Save OdatNurd/b0fc0d95d20786e1c97d58785ed1157e to your computer and use it in GitHub Desktop.
Save OdatNurd/b0fc0d95d20786e1c97d58785ed1157e to your computer and use it in GitHub Desktop.
Sample of a subclass of ExecCommand that allows arbitrary build options
{
"target": "my_exec",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"exe_path": "something.exe",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
]
}
import sublime
import sublime_plugin
from Default.exec import ExecCommand
class MyExecCommand(ExecCommand):
def run(self, **kwargs):
# All arguments that the exec command doesn't handle by default need
# to be popped before continuing, since they're passed to the underlying
# AsyncProcess, which will throw an error if it gets an unrecognized
# argument.
self.exe_path = kwargs.pop("exe_path", "")
super().run(**kwargs)
def finish(self, proc):
super().finish(proc)
print("The build is finished and exe_path is %s" % self.exe_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment