Skip to content

Commit

Permalink
[Add]: Premake5 build support
Browse files Browse the repository at this point in the history
  • Loading branch information
harshfeudal committed Sep 12, 2023
1 parent 7cc5db7 commit 24df3bb
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Auto detect text files and perform LF normalization
*.h linguist-language=C++
*.cpp linguist-language=C++
*.cpp linguist-language=C++
*.lua linguist-language=lua
22 changes: 21 additions & 1 deletion .github/workflows/cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,24 @@ jobs:
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 ..
cmake --build . --config Release
cmake --build . --config Release
premake-windows-build:
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup MSVC
uses: microsoft/[email protected]

- name: Premake setup
uses: abel0b/[email protected]
with:
version: "5.0.0-beta2"

- name: Harshie Build Test
run: |
premake5 vs2022
msbuild /m "Harshie.sln" /p:configuration="release"
19 changes: 18 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# Visual Studio
.vs/
x64/

# Solution file
*.aps
*.sln
*.vcxproj
*.vcxproj.filters
*.vcxproj.user

# Visual Studio Code and CMake build
build/
.env

# Configuration and others
*.exe
*.db
.env
*.rc
54 changes: 54 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
--
-- Copyright (C) 2023 harshfeudal
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.
--

include "resources.lua"
include "setup.lua"

workspace "Harshie"
architecture "x64"
configurations { "Release" }

project "Harshie"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "off"

outputdir = "%{cfg.buildcfg}"

targetdir ("%{wks.location}/x64/%{cfg.buildcfg}")
objdir ("%{wks.location}/x64/%{cfg.buildcfg}")

includedirs{ "include" }
libdirs { "lib" }
links { "dpp.lib" }
files {
"src/**.cpp",
"src/commands/slash/**.h",
"src/commands/slash/cmd_common/**.cpp",
"src/cores/**.h",
"src/cores/**.cpp",
"resources/*.h",
"resources/*.rc",
}

filter { "system:windows", "toolset:msc" }
systemversion "latest"

filter "configurations:Release"
runtime "Release"
optimize "on"
48 changes: 48 additions & 0 deletions resources.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--
-- Copyright (C) 2023 harshfeudal
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.
--

local HARSHIE_VERSION_MAJOR = 1
local HARSHIE_VERSION_MINOR = 0
local HARSHIE_VERSION_PATCH = 0
local HARSHIE_VERSION_BUILD = 0
local HARSHIE_VERSION = HARSHIE_VERSION_MAJOR .. "." .. HARSHIE_VERSION_MINOR .. "." .. HARSHIE_VERSION_PATCH .. "." .. HARSHIE_VERSION_BUILD

local inputFilePath = "resources/harshie.rc.in"
local outputFilePath = "resources/harshie.rc"

local inputFile = io.open(inputFilePath, "r")
if inputFile then
local fileContents = inputFile:read("*a")
inputFile:close()

fileContents = string.gsub(fileContents, "@HARSHIE_VERSION_MAJOR@", tostring(HARSHIE_VERSION_MAJOR))
fileContents = string.gsub(fileContents, "@HARSHIE_VERSION_MINOR@", tostring(HARSHIE_VERSION_MINOR))
fileContents = string.gsub(fileContents, "@HARSHIE_VERSION_PATCH@", tostring(HARSHIE_VERSION_PATCH))
fileContents = string.gsub(fileContents, "@HARSHIE_VERSION_BUILD@", tostring(HARSHIE_VERSION_BUILD))
fileContents = string.gsub(fileContents, "@HARSHIE_VERSION@", HARSHIE_VERSION)

local outputFile = io.open(outputFilePath, "w")
if outputFile then
outputFile:write(fileContents)
outputFile:close()
print("Resource file generated successfully.")
else
print("Error: Failed to open the output file for writing.")
end
else
print("Error: Failed to open the input file.")
end
17 changes: 17 additions & 0 deletions resources/harshie.rc.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2023 harshfeudal
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

#include <Winver.h>
#include "../resources/resource.h"

Expand Down
35 changes: 35 additions & 0 deletions setup.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--
-- Copyright (C) 2023 harshfeudal
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.
--

local sourceDir = "bin"
local destinationDir = "x64/Release"

function copyFiles(source, destination)
for _, filename in ipairs(os.matchfiles(source .. "/*")) do
local destFile = path.join(destination, path.getname(filename))
os.mkdir(path.getdirectory(destFile))
os.copyfile(filename, destFile)
end
end

if not os.isdir(destinationDir) then
os.mkdir(destinationDir)
end

copyFiles(sourceDir, destinationDir)

print("Copying DLLs to x64/Release completed.")
13 changes: 13 additions & 0 deletions start-premake.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off
setlocal

rem Check if premake5.exe exists in the current directory
if not exist premake5.exe (
echo Error: premake5.exe not found in the current directory.
exit /b 1
)

rem Run Premake to generate Visual Studio 2022 project files
premake5 vs2022

endlocal

0 comments on commit 24df3bb

Please sign in to comment.