Last active
October 14, 2021 09:18
-
-
Save Taara-Sinh-Aatrey/9249e85197ec4f7485a0e0f82c6ed6fb to your computer and use it in GitHub Desktop.
A custom target to run fast olympic coding after the build finishes successfully. Allows user to have a complex build system (for example: having multiple variants) along with the functionality of running fast olympic coding. The run_settings of FastOlympicCoding.sublime-settings file have fewer options compared to what a build system offers. So…
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
Show hidden characters
// put this file in your User package | |
// Preferences -> Browse Packages -> User | |
// Feel free to modify this as per your usage | |
{ | |
"target": "fast_olympic_coding_on_finish", | |
"cancel": {"kill": true}, | |
// Start: Slow Compile And Run | |
"osx": { | |
"shell_cmd": "g++-11 -std=c++17 -Wshadow -Wall \"${file_name}\" -o \"${file_base_name}\".out -DLOCAL -g -D_GLIBCXX_DEBUG", | |
}, | |
"linux": { | |
"shell_cmd": "g++ -std=c++17 -Wshadow -Wall \"${file_name}\" -o \"${file_base_name}\".out -DLOCAL -g -D_GLIBCXX_DEBUG", | |
}, | |
"windows": { | |
"shell_cmd": "g++ -std=c++17 -Wshadow -Wall \"${file_name}\" -o \"${file_base_name}\" \"-Wl,--stack=268435456\" -DLOCAL -g -D_GLIBCXX_DEBUG", | |
}, | |
// End: Slow Compile And Run | |
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", | |
"selector": "source.c++, source.cc, source.cpp, source.c", | |
"working_dir": "$file_path", | |
"variants": | |
[ | |
{ | |
// Start: Fast Compile And Run | |
"name":"Fast Compile And Run", | |
"osx": { | |
"shell_cmd": "g++-11 -std=c++17 \"${file_name}\" -o \"${file_base_name}\".out -DLOCAL -O2", | |
}, | |
"linux": { | |
"shell_cmd": "g++ -std=c++17 \"${file_name}\" -o \"${file_base_name}\".out -DLOCAL -O2", | |
}, | |
"windows": { | |
"shell_cmd": "g++ -std=c++17 \"${file_name}\" -o \"${file_base_name}\" \"-Wl,--stack=268435456\" -DLOCAL -O2", | |
}, | |
// End: Fast Compile And Run | |
} | |
] | |
} |
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
// Go to Preferences -> Key Bindings and add these two key bindings | |
// value of `your_operating_system` will be one of ['OSX', 'Linux', 'Windows'] as per the Operating System. | |
// change keys as per your preference | |
{ "keys": ["f7"], "command": "build", "args": {"variant": ""} }, | |
{ "keys": ["f8"], "command": "build", "args": {"variant": "Fast Compile And Run"} }, |
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
# put this file in your User package | |
# Preferences -> Browse Packages -> User | |
# This plugin runs fastolympiccoding after running the original build. | |
import sublime | |
import sublime_plugin | |
from Default.exec import ExecCommand | |
class FastOlympicCodingOnFinishCommand(ExecCommand): | |
def run(self, **kwargs): | |
super().run(**kwargs) | |
def on_finished(self, proc): | |
super().on_finished(proc) | |
if proc != self.proc: | |
return | |
if proc.killed: | |
self.window.status_message("Build Cancelled") | |
else: | |
exit_code = proc.exit_code() | |
if exit_code == 0 or exit_code is None: | |
# Run fast olympic coding | |
self.window.active_view().run_command("view_tester", {"action": "make_opd", "use_debugger": False}) | |
else: | |
self.window.status_message("Build Failed") |
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
// Go to Preferences -> Browse Packages -> CppFastOlympicCoding -> FastOlympicCoding (Linux).sublime-settings | |
// Comment out the existing run_settings of C++ and paste this instead | |
// the important thing here is to have an empty string for compile_cmd | |
// Warning: Don't comment the "compile_cmd" line | |
{ | |
"name": "C++", | |
"extensions": ["cpp"], | |
"compile_cmd": "", | |
"run_cmd": "./\"{file_name}\".out {args} -debug", | |
"lint_compile_cmd": "g++ -std=c++17 '{source_file}' -I '{source_file_dir}'" | |
}, |
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
// Go to Preferences -> Browse Packages -> CppFastOlympicCoding -> FastOlympicCoding (OSX).sublime-settings | |
// Comment out the existing run_settings of C++ and paste this instead | |
// the important thing here is to have an empty string for compile_cmd | |
// Warning: Don't comment the "compile_cmd" line | |
{ | |
"name": "C++", | |
"extensions": ["cpp"], | |
"compile_cmd": "", | |
"run_cmd": "./\"{file_name}\".out {args} -debug", | |
"lint_compile_cmd": "g++-11 -std=c++17 '{source_file}' -I '{source_file_dir}'" | |
}, |
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
// Go to Preferences -> Browse Packages -> CppFastOlympicCoding -> FastOlympicCoding (Windows).sublime-settings | |
// Comment out the existing run_settings of C++ and paste this instead | |
// the important thing here is to have an empty string for compile_cmd | |
// Warning: Don't comment the "compile_cmd" line | |
{ | |
"name": "C++", | |
"extensions": ["cpp"], | |
"compile_cmd": "", | |
"run_cmd": "\"{source_file_dir}\\{file_name}.exe\" {args} -debug", | |
"lint_compile_cmd": "g++ -std=c++17 \"{source_file}\" -I \"{source_file_dir}\"" | |
}, |
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
// Go to Preferences -> Settings | |
// This is optional but recommended | |
// Add this if you don't want to see the build output panel which shows at the bottom | |
// You can still see the build message (such as "Build Cancelled", "Build Failed" or "Build Finished") in the status bar | |
// However, if you wish to see the detailed message anytime, you can right click the bottom left icon and open up the build result panel | |
"show_panel_on_build": false, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment