Handmade Hero » Forums » Code » Sublime Text Build System
LegenKiller666
Matt Gilene
1 posts
#259 Sublime Text Build System
4 years ago

For anyone using Sublime Text as their editor here is a build system that should automatically build the entire project just like you would from the command window.

**NOTE - If you run Sublime text from the command line this will not work. You need to run it from the Shortcut.

How to use

-Go to Tools->Build Systems->New Build System
-Copy the following into the file and save it accordingly
1
2
3
4
5
6
{
"cmd": ["${file_path}/build.bat", "${file}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "w:/build",
"selector": "source.c, source.cpp, source.c++"
}

-Select the new build system
-To build simply press F7
winnythefoo
Linus
2 posts
#14596 Sublime Text Build System
8 months, 3 weeks ago

Thanks for the tip. It didn't quite work for me, maybe because I'm still just on day 004 and something changed later.

I got something else to work, which I will post in case it's useful to anyone.

I saved the build config as part of a sublime project config, so the equivalent portion to the OP is just the "build_system" part.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
	"folders":
	[
		{
			"path": "."
		}
	],
	"build_systems": [
		{
			"name": "Build Handmade Hero",
			"shell_cmd": "\"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/Tools/VsDevCmd.bat\" -no_logo & cd \"C:/FULL/PATH/TO/handmade-hero/handmade/code/\" & \"build.bat\"",
			"selector": "source.c, source.cpp, source.c++"
		}
	]
}


Sorry for the really long line. :)

Note the part where you have to replace "FULL/PATH/TO" ... also, I'm not currently using the "W:" drive with "subst", but you might have to add something to get the shell to switch to the "W:" drive in that case.
Todd
113 posts

Code hacker/developer

#14602 Sublime Text Build System
8 months, 3 weeks ago

Nice. Sublime is my fav editor now. Anyone else got any other tips for Sublime?

I'm the smartest man in Athens because I know that I know nothing. ~ Socrates
mrmixer
Simon Anciaux
488 posts
#14620 Sublime Text Build System
8 months, 3 weeks ago

I don't use sublime so I may be wrong but it looks like this line is calling vsdevcmd.bat each time you compile, which will take some unnecessary time.
1
"shell_cmd": "\"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/Tools/VsDevCmd.bat\" -no_logo & cd \"C:/FULL/PATH/TO/handmade-hero/handmade/code/\" & \"build.bat\"",

A solution would be to launch sublime from a command line window which as already called vsdevcmd.bat so you don't need to call it when you compile.