-
Notifications
You must be signed in to change notification settings - Fork 28
Building
Building is done with a simple build.bat
file and requires the environment (PATH and other environment variables to be set). This is best done by first running Visual Studio's vcvarsall.bat
in the command-line that sets it all up. I have a vc.bat
file setup that I always use to call current vcvarsall.bat
(so I don't have to care when I upgrade Visual Studio in the future). My vc.bat
looks like this (it's for Visual Studio 2015):
@echo off
if exist "%PROGRAMFILES(X86)%" (
call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
) else (
call "c:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
)
The vc.bat
sits in a directory that is included in PATH
environment variable, so anytime I want to use Visual Studio's command-line I simply type vc
and hit Enter.
Similarily I have a mingw.bat
file that does the same for MinGW:
SET PATH=%PATH%;D:\Programs\MinGW\bin;D:\Programs\MinGW\msys\1.0\bin
Other good way is to run Visual Studio Command Prompt from Start menu that is installed with Visual Studio that launches command prompt with environment set.
Build creates a ./bin
directory where it outputs the exe file. Build is sensitive to following arguments (in arbitrary order):
-
cl
- Builds with Microsoft Visual Studio Compiler (default). -
gcc
- Builds with MinGW GCC. -
debug
- Builds debug version (default). -
release
- Builds release version. -
sdl
- Builds with SDL2 runtime. (experimental) -
lunity
- Builds Lunity executable. (experimental) -
luajit
- Builds Lunity with LuaJIT. (experimental)
Every other word specifies the base name of a target (the default target is set to main
). For example build example-platformer
builds example-platformer.c
with example-platformer.rc
resources, and outputs bin/example-platformer.exe
.
Some examples:
-
build release example-platformer
- Buildsexample-platformer.c
in release mode. -
build debug example-platformer gcc
- Buildexample-platformer.c
in debug mode with GCC. -
build
- Buildsmain.c
in debug mode with MSVC.
I have following Punity.sublime-project
file that I copy and paste to my Punity projects to easily build within Sublime (with Ctrl+B):
{
"folders":
[
{
"path": "."
}
],
"build_systems":
[
{
"name": "Build",
"shell_cmd": "\"c:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat\" & build",
"file_regex": "^ *([A-z]:.*)[(]([0-9]+)[)]",
"working_dir": "${project_path}"
}
]
}
Please replace \"c:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat\"
with a path to your vcvarsall.bat
if you have a different version of Visual Studio.
Setup your Visual Studio Environment (see above) and then simply run: devenv bin/main.exe
(where main.exe
is your executable). Make sure you built your exe with debug
and cl
build argument. When in Visual Studio, you can open your source with Ctrl+O
, setup breakpoints and step through the source code.