Skip to content

Instantly share code, notes, and snippets.

@axefrog
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axefrog/6a035b69e710f8315c24 to your computer and use it in GitHub Desktop.
Save axefrog/6a035b69e710f8315c24 to your computer and use it in GitHub Desktop.
A simple MSVC++ build script for my game development. Supports an arbitrary source folder structure and command arguments for running the built file and optionally starting the debugger.
$postbuild = ""
foreach ($arg in $args) {
switch ($arg) {
"run" { $postbuild = "run" }
"debug" { $postbuild = "debug" }
}
}
if (!(test-path build)) { mkdir build }
if (!(test-path build/obj)) { mkdir build/obj }
if (!(test-path build/bin)) { mkdir build/bin }
pushd build
$opts = "/Zi","/Gm","/EHsc","/Foobj/","/I..\libs\include","/Fe./obj/MyGame.exe","../src/*.cpp"
$srcdirs = get-childitem -recurse -Attribute Directory ../src
foreach ($dir in $srcdirs) {
foreach($file in $dir.GetFiles()) {
if($file.Extension -eq ".cpp") {
$opts += "`"$($dir.FullName)\*.cpp`""
break
}
}
}
$opts += "user32.lib","gdi32.lib","opengl32.lib","glu32.lib","../libs/lib/*.lib"
&cl $opts
if (!$LASTEXITCODE) {
xcopy ..\libs\dll\*.dll bin /Y
xcopy .\obj\MyGame.exe bin /Y
xcopy .\obj\MyGame.pdb bin /Y
robocopy /XC /NJS /NJH ../src/graphics/shaders bin/shaders
switch ($postbuild) {
"run" {
pushd bin
Start-Process MyGame.exe
popd
}
"debug" {
pushd bin
Start-Process devenv -ArgumentList "MyGame.exe"
popd
}
}
}
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment