Skip to content

Instantly share code, notes, and snippets.

@codingminecraft
Created March 22, 2021 00:33
Show Gist options
  • Save codingminecraft/d5f3d01b33498a2c77014e263ed06eb8 to your computer and use it in GitHub Desktop.
Save codingminecraft/d5f3d01b33498a2c77014e263ed06eb8 to your computer and use it in GitHub Desktop.
Build Files and Code for C++ Episode: 6 (Premake)
@echo off
IF "%~1" == "" GOTO PrintHelp
IF "%~1" == "compile" GOTO Compile
vendor\premake5.exe %1
GOTO Done
:PrintHelp
echo.
echo Enter 'build.bat action' where action is one of the following:
echo.
echo compile Will generate make file then compile using the make file.
echo clean Remove all binaries and intermediate binaries and project files.
echo codelite Generate CodeLite project files
echo gmake Generate GNU makefiles for Linux
echo vs2005 Generate Visual Studio 2005 project files
echo vs2008 Generate Visual Studio 2008 project files
echo vs2010 Generate Visual Studio 2010 project files
echo vs2012 Generate Visual Studio 2012 project files
echo vs2013 Generate Visual Studio 2013 project files
echo vs2015 Generate Visual Studio 2015 project files
echo vs2017 Generate Visual Studio 2017 project files
echo vs2019 Generate Visual Studio 2019 project files
echo xcode4 Generate Apple Xcode 4 project files
GOTO Done
:Compile
vendor\premake5.exe vs2019
if not defined DevEnvDir (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
)
set solutionFile="Workspace.sln"
msbuild /t:Build /p:Configuration=Debug /p:Platform=x64 %solutionFile%
:Done
-- This is in PracticeProject/premake5.lua, I just can't create a subdirectory in a Github gist
project "PracticeProject"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "on"
targetdir("../bin/" .. outputdir .. "/%{prj.name}")
objdir("../bin-int/" .. outputdir .. "/%{prj.name}")
files {
"cpp/**.cpp",
"include/**.h"
}
includedirs {
"include"
}
defines {
"WINDOWS"
}
filter { "configurations:Debug" }
buildoptions "/MTd"
runtime "Debug"
symbols "on"
filter { "configurations:Release" }
buildoptions "/MT"
runtime "Release"
optimize "on"
workspace "Workspace"
architecture "x64"
configurations {
"Debug",
"Release"
}
startproject "PracticeProject"
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
include "PracticeProject"
newaction {
trigger = "clean",
description = "Remove all binaries and intermediate binaries, and vs files.",
execute = function()
print("Removing binaries")
os.rmdir("./bin")
print("Removing intermediate binaries")
os.rmdir("./bin-int")
print("Removing project files")
os.rmdir("./.vs")
os.remove("**.sln")
os.remove("**.vcxproj")
os.remove("**.vcxproj.filters")
os.remove("**.vcxproj.user")
print("Done")
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment