Perhaps a roundabout way of doing things but I start a shell with this shortcut
# The shortcut target
# This is a shortcut I leave on the desktop for easy access
%comspec% /k C:\<code path>\shell.bat
This is what it targets (note that your pathing will differ. I also subst
my source dir so it’s always the same. Note that this is for a 64 bit target. If you have a different target select appropriate vcsvars script to run. This what Microsoft wants you to do in order to turn your shell into a dev shell.
# file: misc/shell.bat
@echo off
set VSDEVCMD="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
if EXIST %VSDEVCMD% call %VSDEVCMD%
set path="<PATH TO MISC FOLDER>";C:\Program Files\Sublime Text;%path%
Now the trick is to start sublime from this shell so it can get all the env vars that vcvars sets up
so from the shell I have a subl
script under that misc/
folder I added to path above
# File: misc/subl.bat
# another shortcut file to start sublime with my project preloaded
@echo off
call "C:\Program Files\Sublime Text 3\subl.exe" "--project <your project file>.sublime-project"
Now to get the project building it looks like this:
# file: misc/<your project file>.sublime-project
{
"folders":
[
{
"path": "..",
"folder_exclude_patterns": ["build", ".vs"],
"follow_symlinks": true
}
],
"build_systems":
[
{
"selector": "source.c",
"name": "Project Build",
"working_dir": "$folder/code",
"osx":
{
"cmd": ["./build.sh"],
"file_regex": "(^.*)[:](\\d+)[:](\\d+)[:].+$",
},
"windows":
{
"cmd": ["build.bat"],
"file_regex": "^(.*)\\((\\d+),?(\\d+)?\\)\\s?:\\s([^\n]+)",
}
}
]
}
# File: code/build.bat
# Here just do your build. I keep this file with the source code unde code/
cl <params>
Now I can build with cl from sublime just fine.
Of course you can also skip all the boilerplate stuff and just call vcvars64.bat in a shell of your choosing and open sublime from that shell using the build in shortcut subl
if you have all path’s set up correctly from the start.