Intro to Premake and Build Systems | C++ For Java Devs Ep. 6

  Рет қаралды 7,758

GamesWithGabe

GamesWithGabe

Күн бұрын

Join the Discord: / discord
In this episode I go over a quick introduction to what a build system is and why we need it, then I describe how to create a premake file and generate a Visual Studio solution using the premake file.
Premake: premake.github.io/
Source Code/Build Files for this Episode: gist.github.com/codingminecra...
0:00 In This Episode
2:56 Premake Installation & Docs
3:23 Setting up the File Structure
5:33 Creating the First Premake File
14:11 Generating Build Files using Premake
15:41 Exploring Generated VS Project
16:55 Updating Build.bat
22:04 Adding a "Clean" Action
24:35 Fixing a Bug
25:20 Challenge
---------------------------------------------------------------------
Website: ambrosiogabe.github.io/
Github: github.com/ambrosiogabe
Here are some books I recommend if you want to learn about game engine development more thoroughly. I do not profit off any of these sales, these are just some books that have helped me out :)
My Recommended Game Engine Books:
Game Engine Architecture: www.gameenginebook.com/
Game Physics Cookbook (Read this before the next physics book): www.amazon.com/Game-Physics-C...
Game Physics (Ian Millington): www.amazon.com/Game-Physics-E...
Game Programming Patterns (Free): gameprogrammingpatterns.com/
My Recommended Beginning Game Programming Books:
JavaScript Game Design: www.apress.com/gp/book/978143...
My Recommended Java Books:
Data Structures/Algorithms: www.amazon.com/Data-Structure...
LWJGL (Free, but I haven't read this thoroughly): lwjglgamedev.gitbooks.io/3d-g...

Пікірлер: 27
@postedactive
@postedactive 3 жыл бұрын
Honest, this is amazing stuff. Can't wait for the next one to go up.
@GamesWithGabe
@GamesWithGabe 3 жыл бұрын
Hey @PostedActive, I really appreciate the comment! The C++ series hasn't been doing as well as the game engine series so I was wondering if people were finding it useful haha. The next episode should be going up tomorrow morning though :)
@postedactive
@postedactive 3 жыл бұрын
@@GamesWithGabe Take it from this dude. They're an immense help if that's worth anything. Probably series just needs more Clickbait is all 😂 cause the material itself is going very well. I'll have my IDE ready, cheers mate 👍.
@FunGameDeveloper
@FunGameDeveloper 3 жыл бұрын
very good, congratulations for your work!
@GamesWithGabe
@GamesWithGabe 3 жыл бұрын
Thanks @FunGameDeveloper!
@abhay29
@abhay29 2 жыл бұрын
Great Tutorial !
@wolfdesroyer8711
@wolfdesroyer8711 3 жыл бұрын
FOR LINUX AND MAC USERS I made a the bash script that works on mac and linux you just have to put both of the binaries and the vendor folder and call the mac one premake5mac and the linux one premake5lin and I've removed the compile option because I'm lazy and people can just compile it with whatever IDE there using. It should auto detect the OS but if it doesn't then just add linux or mac after the action to select your OS. Also let me know if there are any problems because I'm not that good at writing in bash. :) Examples: ./build.sh gmake2 linux ./build.sh xcode4 #!/bin/sh PrintHelp() { echo Enter 'build.sh action' where action is one of the following: echo echo clean Remove all binaries and generated files echo codelite Generate CodeLite project files echo gmake Generate GNU makefiles for POSIX, MinGW, and Cygwin echo gmake2 Generate GNU makefiles for POSIX, MinGW, and Cygwin 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 } if [ "$1" = "" ] ;then PrintHelp else if [ "$2" = "mac" ] ;then echo using mac ./vendor/premake5mac $1 exit fi if [ "$2" = "linux" ] ;then echo using linux ./vendor/premake5lin $1 exit fi if [ "$(uname)" = "Darwin" ]; then echo using mac ./vendor/premake5mac $1 elif [ "$(expr substr "$(uname -s)" 1 5)" = "Linux" ]; then echo using linux ./vendor/premake5lin $1 fi fi
@eXtremeElectronics
@eXtremeElectronics 3 ай бұрын
Very helpful
@RenatoSousaRS
@RenatoSousaRS 3 жыл бұрын
Very nice!
@GamesWithGabe
@GamesWithGabe 3 жыл бұрын
Thanks Renato!
@erik9817
@erik9817 6 ай бұрын
Interesting video. Do you consider the generated solutions as part of the code that should be checked into source control? It appears, using premake5, one can generate solutions at any time and consider them "generated". Then the question is, since the solution file is sure to change over time, are these changes important to track in source control?
@GamesWithGabe
@GamesWithGabe 6 ай бұрын
I don’t put generated solutions in source control. I make sure to re-generate the solutions before committing though so that anyone that clones the repository will end up with the same files (and you could add a pre-commit hook if you wanted that does this). But I believe the general consensus is that any generated files should stay out of source control :)
@erik9817
@erik9817 6 ай бұрын
Thanks! @@GamesWithGabe
@DieserDeutscheTyp
@DieserDeutscheTyp 3 жыл бұрын
Good day, nice tutorial but i still have a problem when i type in my pathf(vendor/bin/premake/premake5.exe) a error cold (Der Befehl "vendor" ist entweder falsch geschrieben oder konnte nicht gefunden werden.) appear what i can do?
@GamesWithGabe
@GamesWithGabe 3 жыл бұрын
Hey @FyMa2618! Which operating system are you running? I'm guessing windows since you downloaded the .exe version. If you're on windows try doing .\vendor\bin\premake5.exe with the . In front and using \ instead of /. Also, make sure you're premake5.exe is in the folder vendor/bin/premake. All I'm doing when I type in that command is running the premake exe, so as long as you have the correct path it should work out :)
@DieserDeutscheTyp
@DieserDeutscheTyp 3 жыл бұрын
@@GamesWithGabe Good day, he finds but it say: "invalid value 'C++19' for cppdialect". My Code is:" workspace "GotGames" architecture "x64" configurations { "Debug", "Release", "Dist" } outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}" project "GotGames" location "GotGames" kind "SharedLib" language "C++" targetdir ("bin/" .. outputdir .. "/%{prj.name}") objdir ("bin-int/" .. outputdir .. "/%{prj.name}") files { "%{prj.name}/src/**.h", "%{prj.name}/src/**.cpp" } includedirs { "%{prj.name}/vendor/spdlog/include" } filter "system:windows" cppdialect "C++19" staticruntime "On" systemversion "latest" defines { "GG_PLATFORM_WINDOWS", "GG_BUILD_DLL" } postbuildcommands { ("{COPY} %{cfg.buildtarget.relpath} ../bin/" .. outputdir .. "/SandBoxGame") } filter "configurations:Debug" defines "GG_DEBUG" symbols "On" filter "configurations:Release" defines "GG_RELEASE" optimize "On" filter "configurations:Dist" defines "GG_DIST" optimize "On" project "SandBoxGame" location "SandBoxGame" kind "ConsoleApp" language "C++" targetdir ("bin/" .. outputdir .. "/%{prj.name}") objdir ("bin-int/" .. outputdir .. "/%{prj.name}") files { "%{prj.name}/src/**.h", "%{prj.name}/src/**.cpp" } includedirs { "GotGames/vendor/spdlog/include", "GotGames/src" } links { "GotGames" } filter "system:windows" cppdialect "C++19" staticruntime "On" systemversion "latest" defines { "GG_PLATFORM_WINDOWS" } filter "configurations:Debug" defines "GG_DEBUG" symbols "On" filter "configurations:Release" defines "GG_RELEASE" optimize "On" filter "configurations:Dist" defines "GG_DIST" optimize "On" " I am dont no why can did you can help me?
@GamesWithGabe
@GamesWithGabe 3 жыл бұрын
@@DieserDeutscheTyp that would be because C++19 isn't a valid C++ version. If you're having trouble with your premake scripts I would highly suggest you take a look at the premake documentation: github.com/premake/premake-core/wiki/cppdialect
@brendonlantz5972
@brendonlantz5972 3 жыл бұрын
I like premake much better than cmake, but I haven't seen much on vcpkg integration for the libraries.
@GamesWithGabe
@GamesWithGabe 3 жыл бұрын
Hey Brendon, I've never used vcpkg and I was reading up on it and couldn't tell what makes it any better then just distributing the binaries for a project. I was wondering if you could let me know what vcpkg is primarily used for, or point me to some resources so I can learn a bit about it :)
@brendonlantz5972
@brendonlantz5972 3 жыл бұрын
@@GamesWithGabe For vcpkg it essentially manages libraries on your machine and cmake can integrate with it to know where the libraries are. So you can make a cmake lists with find(glfw) and it will be able to find them on whatever platform you're on (assuming vcpkg is installed). Conan is also similar but I found it less intuitive. If you are managing libraries directly you will have to somehow account for the different platforms and where the libraries are. It integrates with visual studio, and this is where I learned about it -
@brendonlantz5972
@brendonlantz5972 3 жыл бұрын
@@GamesWithGabe kzbin.info/www/bejne/n5vQi36Ifsuihas
@brendonlantz5972
@brendonlantz5972 3 жыл бұрын
of course git submodules and keeping the library source in the project are ways around this problem as well. There are lots of different approaches.
@GamesWithGabe
@GamesWithGabe 3 жыл бұрын
@@brendonlantz5972 Gotcha, that makes more sense. I wish C++ had one central package manager like npm or pip. But maybe one day it will :)
@davidmarinho2848
@davidmarinho2848 3 жыл бұрын
Linux bash script. First, of all, I want to thank you Gabe, your tutorials have been amazing! I am learning a lot of new things. Step by step, I am closer to building a 3d game engine. One more time, thank you for your help, your tutorials have been very helpful. Just keep going and keep lunching that great content :). I also will let the bash script code for you all ;). Code for linux: -------- # If there are no arguments or if the argument is equivalent to "help" if [ "$1" == "" ] || [ "$1" == "help" ] then # echo -e allow us to use arguments, like that breaks the line echo -e " " echo "Enter 'build.bat action' where action is one of the following:" echo -e " " echo "create_project Will create the resources needed to a new project into the current directory" echo "compile Will generate make file then compile using the make file." echo "run Will generate make file then compile using the make file then run the project" echo "clean Remove all binaries and intermediate binaries and project files." echo "codelite Generate CodeLite project files" echo "gmake2 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" elif [ "$1" == "compile" ] then # Create makefile gmake ./vendor/premake5 gmake make elif [ "$1" == "run" ] then # Create makefile gmake ./vendor/premake5 gmake make # Run cd bin # Create a variable that will get the folder that has the word "...linux..." in its name var=$(find -name *linux*) ./$var/ProjectFolder/ProjectFolder cd .. fi exit -------- P.S.: I don't know why, but in the lua's file inside of Project folder, you have to delete the lines: buildoptions "/MTd" buildoptions "/MT" If someone knows why I would love to receive an explanation :D Edit: I just kept working on the file and it is becoming pretty cool (I guess ahaha) so I will let a link bellow if you want take a look github.com/davidalmarinho/beaver
Structures and Namespaces  | C++ For Java Devs Ep. 7
14:12
GamesWithGabe
Рет қаралды 1,3 М.
The Tyrannical Mods of Stack Overflow
12:15
GamesWithGabe
Рет қаралды 373 М.
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 24 МЛН
아이스크림으로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 55 МЛН
Did you believe it was real? #tiktok
00:25
Анастасия Тарасова
Рет қаралды 55 МЛН
Survival skills: A great idea with duct tape #survival #lifehacks #camping
00:27
How to Properly Setup C++ Projects
32:46
The Cherno
Рет қаралды 98 М.
So you want to make a Game Engine!? (WATCH THIS before you start)
14:39
Giant Sloth Games
Рет қаралды 276 М.
All about MEMORY // Code Review
33:42
The Cherno
Рет қаралды 159 М.
Makefiles: 95% of what you need to know
1:01:53
Gabriel Parmer
Рет қаралды 115 М.
Simulating the Evolution of Rock, Paper, Scissors
15:00
Primer
Рет қаралды 459 М.
I Coded a Video Editor (and it kind of sucks)
18:35
GamesWithGabe
Рет қаралды 233 М.
Introduction to CMake Crash Course
14:08
PunchedTape
Рет қаралды 10 М.
BEST WAY to understand graphics and rendering code
34:46
The Cherno
Рет қаралды 35 М.
C++ Easy Mode -- Getting Started with C++ (Using VCPKG)
31:37
Gamefromscratch
Рет қаралды 31 М.
Learning C++ by making a Game... in 1 Week?!
10:14
Floky
Рет қаралды 389 М.
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 24 МЛН