Last active
August 29, 2015 14:14
-
-
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.
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
$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