Created
March 22, 2021 00:33
-
-
Save codingminecraft/d5f3d01b33498a2c77014e263ed06eb8 to your computer and use it in GitHub Desktop.
Build Files and Code for C++ Episode: 6 (Premake)
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
@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 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
-- 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" |
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
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