From 3fba769bb8a5eeab2754b5cbc03107ac995f82ab Mon Sep 17 00:00:00 2001 From: Barbato Federico <45495935+Developer310301@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:45:34 +0100 Subject: [PATCH 1/2] feat: update build configuration --- .gitignore | 7 ++----- Build.lua | 15 ++++++++++----- Scripts/Setup-Linux.sh | 5 ----- {App => apps/App}/Build-App.lua | 7 +++---- {App => apps/App}/Source/App.cpp | 0 {Core => cores/Core}/Build-Core.lua | 5 ++--- {Core => cores/Core}/Source/Core/Core.cpp | 0 {Core => cores/Core}/Source/Core/Core.h | 0 dependencies/add_deps.txt | 0 scripts/Setup-Linux.sh | 5 +++++ {Scripts => scripts}/Setup-Windows.bat | 0 .../Premake => vendor/bin/premake}/LICENSE.txt | 0 .../bin/premake}/Linux/premake5 | Bin .../bin/premake}/Windows/premake5.exe | Bin .../bin/premake}/macOS/premake5 | Bin 15 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 Scripts/Setup-Linux.sh rename {App => apps/App}/Build-App.lua (78%) rename {App => apps/App}/Source/App.cpp (100%) rename {Core => cores/Core}/Build-Core.lua (78%) rename {Core => cores/Core}/Source/Core/Core.cpp (100%) rename {Core => cores/Core}/Source/Core/Core.h (100%) create mode 100644 dependencies/add_deps.txt create mode 100755 scripts/Setup-Linux.sh rename {Scripts => scripts}/Setup-Windows.bat (100%) rename {Vendor/Binaries/Premake => vendor/bin/premake}/LICENSE.txt (100%) rename {Vendor/Binaries/Premake => vendor/bin/premake}/Linux/premake5 (100%) mode change 100644 => 100755 rename {Vendor/Binaries/Premake => vendor/bin/premake}/Windows/premake5.exe (100%) rename {Vendor/Binaries/Premake => vendor/bin/premake}/macOS/premake5 (100%) diff --git a/.gitignore b/.gitignore index 4468bd6..79f3008 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Directories .vs/ -Binaries/ +output/ # Files *.vcxproj @@ -8,7 +8,4 @@ Binaries/ *.vcxproj.filters *.sln *.log -Makefile - -# Exclude -!Vendor/Binaries \ No newline at end of file +Makefile \ No newline at end of file diff --git a/Build.lua b/Build.lua index 059b37b..c4d5060 100644 --- a/Build.lua +++ b/Build.lua @@ -8,10 +8,15 @@ workspace "New Project" filter "system:windows" buildoptions { "/EHsc", "/Zc:preprocessor", "/Zc:__cplusplus" } -OutputDir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}" +OutputDir = "../../output/bin/%{cfg.architecture}/%{cfg.system}/%{cfg.buildcfg}" +ObjDir = "../../output/obj/%{cfg.architecture}/%{cfg.system}/%{cfg.buildcfg}" +CoresDir = "../../cores/" +AppsDir = "../../apps/" -group "Core" - include "Core/Build-Core.lua" -group "" +group "Cores" + include "cores/Core/Build-Core.lua" -include "App/Build-App.lua" \ No newline at end of file +group "Apps" + include "apps/App/Build-App.lua" + +group "Dependencies" \ No newline at end of file diff --git a/Scripts/Setup-Linux.sh b/Scripts/Setup-Linux.sh deleted file mode 100644 index f66ada0..0000000 --- a/Scripts/Setup-Linux.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -pushd .. -Vendor/Binaries/Premake/Linux/premake5 --cc=clang --file=Build.lua gmake2 -popd diff --git a/App/Build-App.lua b/apps/App/Build-App.lua similarity index 78% rename from App/Build-App.lua rename to apps/App/Build-App.lua index 4dc8d51..eee3fea 100644 --- a/App/Build-App.lua +++ b/apps/App/Build-App.lua @@ -2,7 +2,6 @@ project "App" kind "ConsoleApp" language "C++" cppdialect "C++20" - targetdir "Binaries/%{cfg.buildcfg}" staticruntime "off" files { "Source/**.h", "Source/**.cpp" } @@ -12,7 +11,7 @@ project "App" "Source", -- Include Core - "../Core/Source" + CoresDir.."Core/Source" } links @@ -20,8 +19,8 @@ project "App" "Core" } - targetdir ("../Binaries/" .. OutputDir .. "/%{prj.name}") - objdir ("../Binaries/Intermediates/" .. OutputDir .. "/%{prj.name}") + targetdir ( OutputDir .. "/") + objdir (ObjDir .. "/%{prj.name}") filter "system:windows" systemversion "latest" diff --git a/App/Source/App.cpp b/apps/App/Source/App.cpp similarity index 100% rename from App/Source/App.cpp rename to apps/App/Source/App.cpp diff --git a/Core/Build-Core.lua b/cores/Core/Build-Core.lua similarity index 78% rename from Core/Build-Core.lua rename to cores/Core/Build-Core.lua index 03a4b94..a9fe6c6 100644 --- a/Core/Build-Core.lua +++ b/cores/Core/Build-Core.lua @@ -2,7 +2,6 @@ project "Core" kind "StaticLib" language "C++" cppdialect "C++20" - targetdir "Binaries/%{cfg.buildcfg}" staticruntime "off" files { "Source/**.h", "Source/**.cpp" } @@ -12,8 +11,8 @@ project "Core" "Source" } - targetdir ("../Binaries/" .. OutputDir .. "/%{prj.name}") - objdir ("../Binaries/Intermediates/" .. OutputDir .. "/%{prj.name}") + targetdir ( OutputDir .. "/lib") + objdir (ObjDir .. "/%{prj.name}") filter "system:windows" systemversion "latest" diff --git a/Core/Source/Core/Core.cpp b/cores/Core/Source/Core/Core.cpp similarity index 100% rename from Core/Source/Core/Core.cpp rename to cores/Core/Source/Core/Core.cpp diff --git a/Core/Source/Core/Core.h b/cores/Core/Source/Core/Core.h similarity index 100% rename from Core/Source/Core/Core.h rename to cores/Core/Source/Core/Core.h diff --git a/dependencies/add_deps.txt b/dependencies/add_deps.txt new file mode 100644 index 0000000..e69de29 diff --git a/scripts/Setup-Linux.sh b/scripts/Setup-Linux.sh new file mode 100755 index 0000000..c69a05a --- /dev/null +++ b/scripts/Setup-Linux.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +pushd .. +vendor/bin/premake/Linux/premake5 --cc=clang --file=Build.lua gmake2 +popd diff --git a/Scripts/Setup-Windows.bat b/scripts/Setup-Windows.bat similarity index 100% rename from Scripts/Setup-Windows.bat rename to scripts/Setup-Windows.bat diff --git a/Vendor/Binaries/Premake/LICENSE.txt b/vendor/bin/premake/LICENSE.txt similarity index 100% rename from Vendor/Binaries/Premake/LICENSE.txt rename to vendor/bin/premake/LICENSE.txt diff --git a/Vendor/Binaries/Premake/Linux/premake5 b/vendor/bin/premake/Linux/premake5 old mode 100644 new mode 100755 similarity index 100% rename from Vendor/Binaries/Premake/Linux/premake5 rename to vendor/bin/premake/Linux/premake5 diff --git a/Vendor/Binaries/Premake/Windows/premake5.exe b/vendor/bin/premake/Windows/premake5.exe similarity index 100% rename from Vendor/Binaries/Premake/Windows/premake5.exe rename to vendor/bin/premake/Windows/premake5.exe diff --git a/Vendor/Binaries/Premake/macOS/premake5 b/vendor/bin/premake/macOS/premake5 similarity index 100% rename from Vendor/Binaries/Premake/macOS/premake5 rename to vendor/bin/premake/macOS/premake5 From 1e355bd0cf83ea78170dc77123e0829312ee5bf8 Mon Sep 17 00:00:00 2001 From: Barbato Federico <45495935+Developer310301@users.noreply.github.com> Date: Fri, 31 May 2024 14:28:36 +0200 Subject: [PATCH 2/2] feat: refactoring project template --- Build.lua | 22 -------- README.md | 24 --------- UNLICENSE.txt | 24 --------- apps/App/Build-App.lua | 44 --------------- apps/App/Source/App.cpp | 6 --- cores/Core/Build-Core.lua | 36 ------------- cores/Core/Source/Core/Core.cpp | 13 ----- cores/Core/Source/Core/Core.h | 7 --- .../include/palceholder.h | 0 external/lib/palceholder.so | 0 premake5.lua | 53 +++++++++++++++++++ scripts/Setup-Linux.sh | 5 -- scripts/Setup-Windows.bat | 6 --- src/app/include/palceholder.h | 0 src/app/src/palceholder.cpp | 0 src/library/include/palceholder.h | 0 src/library/src/palceholder.cpp | 0 17 files changed, 53 insertions(+), 187 deletions(-) delete mode 100644 Build.lua delete mode 100644 README.md delete mode 100644 UNLICENSE.txt delete mode 100644 apps/App/Build-App.lua delete mode 100644 apps/App/Source/App.cpp delete mode 100644 cores/Core/Build-Core.lua delete mode 100644 cores/Core/Source/Core/Core.cpp delete mode 100644 cores/Core/Source/Core/Core.h rename dependencies/add_deps.txt => external/include/palceholder.h (100%) create mode 100644 external/lib/palceholder.so create mode 100644 premake5.lua delete mode 100755 scripts/Setup-Linux.sh delete mode 100644 scripts/Setup-Windows.bat create mode 100644 src/app/include/palceholder.h create mode 100644 src/app/src/palceholder.cpp create mode 100644 src/library/include/palceholder.h create mode 100644 src/library/src/palceholder.cpp diff --git a/Build.lua b/Build.lua deleted file mode 100644 index c4d5060..0000000 --- a/Build.lua +++ /dev/null @@ -1,22 +0,0 @@ --- premake5.lua -workspace "New Project" - architecture "x64" - configurations { "Debug", "Release", "Dist" } - startproject "App" - - -- Workspace-wide build options for MSVC - filter "system:windows" - buildoptions { "/EHsc", "/Zc:preprocessor", "/Zc:__cplusplus" } - -OutputDir = "../../output/bin/%{cfg.architecture}/%{cfg.system}/%{cfg.buildcfg}" -ObjDir = "../../output/obj/%{cfg.architecture}/%{cfg.system}/%{cfg.buildcfg}" -CoresDir = "../../cores/" -AppsDir = "../../apps/" - -group "Cores" - include "cores/Core/Build-Core.lua" - -group "Apps" - include "apps/App/Build-App.lua" - -group "Dependencies" \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index b9f4968..0000000 --- a/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# C++ Project Starter Template - -This is a little quick-start project template for C++ projects which utilise a Core/App project architecture. There are two included projects - one called _Core_, and one called _App_. [Premake](https://github.com/premake/premake-core) is used to generate project files. - -Core builds into a static library and is meant to contain common code intended for use in multiple applications. App builds into an executable and links the Core static library, as well as provides an include path to Core's code. - -The `Scripts/` directory contains build scripts for Windows and Linux, and the `Vendor/` directory contains Premake binaries (currently version `5.0-beta2`). - -## Getting Started -1. Clone this repository or use the "Use this template" button on GitHub to quickly set up your own repository based on this template -2. `App/` and `Core/` are the two projects - you can edit the names of these folders and their contents to suit -3. The three included Premake build files are `Build.lua`, `Core/Build-Core.lua` and `App/Build-App.lua` - you can edit these to customise your build configurations, edit the names of your projects and workspace/solution, etc. -4. Open the `Scripts/` directory and run the appropriate `Setup` script to generate projects files. You can edit the setup scripts to change the type of project that is generated - out of the box they are set to Visual Studio 2022 for Windows and gmake2 for Linux. - -Note that no macOS setup script is currently provided; you can duplicate the Linux script and adjust accordingly. - -## Included -- Some example code (in `App/Source` and `Core/Source`) to provide a starting point and test -- Simple `.gitignore` to ignore project files and binaries -- Premake binaries for Win/Mac/Linux (`v5.0-beta2`) - -## License -- UNLICENSE for this repository (see `UNLICENSE.txt` for more details) -- Premake is licensed under BSD 3-Clause (see included LICENSE.txt file for more details) \ No newline at end of file diff --git a/UNLICENSE.txt b/UNLICENSE.txt deleted file mode 100644 index 3c577b0..0000000 --- a/UNLICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to \ No newline at end of file diff --git a/apps/App/Build-App.lua b/apps/App/Build-App.lua deleted file mode 100644 index eee3fea..0000000 --- a/apps/App/Build-App.lua +++ /dev/null @@ -1,44 +0,0 @@ -project "App" - kind "ConsoleApp" - language "C++" - cppdialect "C++20" - staticruntime "off" - - files { "Source/**.h", "Source/**.cpp" } - - includedirs - { - "Source", - - -- Include Core - CoresDir.."Core/Source" - } - - links - { - "Core" - } - - targetdir ( OutputDir .. "/") - objdir (ObjDir .. "/%{prj.name}") - - filter "system:windows" - systemversion "latest" - defines { "WINDOWS" } - - filter "configurations:Debug" - defines { "DEBUG" } - runtime "Debug" - symbols "On" - - filter "configurations:Release" - defines { "RELEASE" } - runtime "Release" - optimize "On" - symbols "On" - - filter "configurations:Dist" - defines { "DIST" } - runtime "Release" - optimize "On" - symbols "Off" \ No newline at end of file diff --git a/apps/App/Source/App.cpp b/apps/App/Source/App.cpp deleted file mode 100644 index 47d7845..0000000 --- a/apps/App/Source/App.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "Core/Core.h" - -int main() -{ - Core::PrintHelloWorld(); -} \ No newline at end of file diff --git a/cores/Core/Build-Core.lua b/cores/Core/Build-Core.lua deleted file mode 100644 index a9fe6c6..0000000 --- a/cores/Core/Build-Core.lua +++ /dev/null @@ -1,36 +0,0 @@ -project "Core" - kind "StaticLib" - language "C++" - cppdialect "C++20" - staticruntime "off" - - files { "Source/**.h", "Source/**.cpp" } - - includedirs - { - "Source" - } - - targetdir ( OutputDir .. "/lib") - objdir (ObjDir .. "/%{prj.name}") - - filter "system:windows" - systemversion "latest" - defines { } - - filter "configurations:Debug" - defines { "DEBUG" } - runtime "Debug" - symbols "On" - - filter "configurations:Release" - defines { "RELEASE" } - runtime "Release" - optimize "On" - symbols "On" - - filter "configurations:Dist" - defines { "DIST" } - runtime "Release" - optimize "On" - symbols "Off" \ No newline at end of file diff --git a/cores/Core/Source/Core/Core.cpp b/cores/Core/Source/Core/Core.cpp deleted file mode 100644 index be2a5e2..0000000 --- a/cores/Core/Source/Core/Core.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Core.h" - -#include - -namespace Core { - - void PrintHelloWorld() - { - std::cout << "Hello World!\n"; - std::cin.get(); - } - -} \ No newline at end of file diff --git a/cores/Core/Source/Core/Core.h b/cores/Core/Source/Core/Core.h deleted file mode 100644 index 99e110a..0000000 --- a/cores/Core/Source/Core/Core.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -namespace Core { - - void PrintHelloWorld(); - -} \ No newline at end of file diff --git a/dependencies/add_deps.txt b/external/include/palceholder.h similarity index 100% rename from dependencies/add_deps.txt rename to external/include/palceholder.h diff --git a/external/lib/palceholder.so b/external/lib/palceholder.so new file mode 100644 index 0000000..e69de29 diff --git a/premake5.lua b/premake5.lua new file mode 100644 index 0000000..d54ef0b --- /dev/null +++ b/premake5.lua @@ -0,0 +1,53 @@ +workspace "Workspace" + architecture "x64" + configurations { "Debug", "Release" } + libdirs {"external/lib"} + includedirs {"external/include"} + + OutputDir = "output/bin/%{cfg.architecture}/%{cfg.system}/%{cfg.buildcfg}" + ObjDir = "output/obj/%{cfg.architecture}/%{cfg.system}/%{cfg.buildcfg}" + + +project "library" + kind "SharedLib" + language "C++" + cppdialect "c++20" + buildoptions {"-fPIC"} + targetdir ( OutputDir .. "/") + objdir (ObjDir .. "/%{prj.name}") + + files { "src/library/include/**.h", "src/library/src/**.cpp" } + + includedirs { "src/library/include" } + + --links { "spdlog" } + + filter "configurations:Debug" + defines { "DEBUG" } + symbols "On" + debugger "GDB" + + filter "configurations:Release" + defines { "NDEBUG" } + optimize "On" + +project "app" + kind "ConsoleApp" + language "C++" + targetdir ( OutputDir .. "/") + objdir (ObjDir .. "/%{prj.name}") + + files { "src/app/include/**.h", "src/app/src/**.cpp" } + + includedirs { "src/library/include", "src/app/include" } + + --links { "qfengine", "spdlog", "raylib", "rlImGui" } + + filter "configurations:Debug" + defines { "DEBUG" } + symbols "On" + debugger "GDB" + + filter "configurations:Release" + defines { "NDEBUG" } + optimize "On" \ No newline at end of file diff --git a/scripts/Setup-Linux.sh b/scripts/Setup-Linux.sh deleted file mode 100755 index c69a05a..0000000 --- a/scripts/Setup-Linux.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -pushd .. -vendor/bin/premake/Linux/premake5 --cc=clang --file=Build.lua gmake2 -popd diff --git a/scripts/Setup-Windows.bat b/scripts/Setup-Windows.bat deleted file mode 100644 index 9dbc5b4..0000000 --- a/scripts/Setup-Windows.bat +++ /dev/null @@ -1,6 +0,0 @@ -@echo off - -pushd .. -Vendor\Binaries\Premake\Windows\premake5.exe --file=Build.lua vs2022 -popd -pause \ No newline at end of file diff --git a/src/app/include/palceholder.h b/src/app/include/palceholder.h new file mode 100644 index 0000000..e69de29 diff --git a/src/app/src/palceholder.cpp b/src/app/src/palceholder.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/library/include/palceholder.h b/src/library/include/palceholder.h new file mode 100644 index 0000000..e69de29 diff --git a/src/library/src/palceholder.cpp b/src/library/src/palceholder.cpp new file mode 100644 index 0000000..e69de29