Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added premake5 support #3

Merged
merged 14 commits into from
Jun 24, 2023
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
pull_request:
branches: [ "main", "master" ]

workflow_dispatch:

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"

- name: Clone dev2
run: |
git -C D:\ clone https://github.com/ignite720/dev2.git

- name: Setup premake5
uses: abel0b/[email protected]
with:
version: "5.0.0-beta2"

- name: Add msbuild to PATH
uses: microsoft/[email protected]
with:
vs-version: "latest"

- name: Build app for release
run: |
premake5 vs2022
msbuild build\VEngine-wks.sln -nologo -m -p:Configuration=Release -p:Platform=x64 -p:Projects="build\VEngine\VEngine.vcxproj"

- name: Create artifact
run: |
mkdir -p temp/artifact
cp bin/x64/Release/*.exe temp/artifact/
#cp -r VEngine/Assets temp/artifact/
cp -r VEngine/Shaders temp/artifact/

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: Release-Artifact
path: temp
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ VEngine/Code/FbxSdk/
VEngine/Code/Physx/
VEngine/Shaders/Vertex/
VEngine/Shaders/Pixel/


[Bb]uild/

# User-specific files
*.dll
*.lib
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "premake5-modules/premake-vspropertysheets"]
path = premake5-modules/premake-vspropertysheets
url = https://github.com/ignite720/premake-vspropertysheets.git
[submodule "premake5-modules/premake-wkslight"]
path = premake5-modules/premake-wkslight
url = https://github.com/ignite720/premake-wkslight.git
18 changes: 18 additions & 0 deletions Editor/premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
project("Editor")
location(g_wkslight.workspacedir .. "/%{prj.name}")
targetdir(g_wkslight.targetdir)
debugdir("")
debugargs({ "" })
kind("ConsoleApp")
language("C++")
files({
"src/**.h",
"src/**.cpp",
})
includedirs({
"src",
g_wkslight.workspace.libraries.projects.ExampleStaticLib.includedirs,
})
links({
"ExampleStaticLib",
})
8 changes: 8 additions & 0 deletions Editor/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <ExampleStaticLib.h>

int main(int argc, char *argv[])
{
ExampleStaticLib example;
example.Print();
return 0;
}
14 changes: 7 additions & 7 deletions VEngine/Code/Asset/AssetSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ MeshDataProxy AssetSystem::ReadVMeshAssetFromFile(const std::string filename)
MeshAssetHeader header;
MeshData data;

assert(fread(&header, sizeof(MeshAssetHeader), 1, file));
fread(&header, sizeof(MeshAssetHeader), 1, file);

data.vertices.resize(header.vertexCount);
assert(fread(data.vertices.data(), sizeof(Vertex), header.vertexCount, file));
fread(data.vertices.data(), sizeof(Vertex), header.vertexCount, file);

assert(fread(&data.boundingBox, sizeof(DirectX::BoundingBox), 1, file));
fread(&data.boundingBox, sizeof(DirectX::BoundingBox), 1, file);

data.skeleton.GetJoints().resize(header.boneCount);
//Has to potential to read empty data, don't call assert()
Expand Down Expand Up @@ -217,22 +217,22 @@ Animation AssetSystem::ReadVAnimAssetFromFile(const std::string filename)

AnimationAssetHeader header;

assert(fread(&header, sizeof(AnimationAssetHeader), 1, file));
fread(&header, sizeof(AnimationAssetHeader), 1, file);

Animation anim = Animation(header.name);

for (uint64_t i = 0; i < header.frameCount; i++)
{
int jointIndex = Joint::INVALID_JOINT_INDEX;
assert(fread(&jointIndex, sizeof(int), 1, file));
fread(&jointIndex, sizeof(int), 1, file);
assert(jointIndex != -2);

size_t animFrameCount = 0;
assert(fread(&animFrameCount, sizeof(size_t), 1, file));
fread(&animFrameCount, sizeof(size_t), 1, file);

std::vector<AnimFrame> animFrames;
animFrames.resize(animFrameCount);
assert(fread(animFrames.data(), sizeof(AnimFrame) * animFrameCount, 1, file));
fread(animFrames.data(), sizeof(AnimFrame) * animFrameCount, 1, file);

anim.AddFrame(jointIndex, animFrames);
}
Expand Down
74 changes: 74 additions & 0 deletions VEngine/premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
project("VEngine")
location(g_wkslight.workspacedir .. "/%{prj.name}")
targetdir(g_wkslight.targetdir)
debugdir("")
debugargs({ "" })
kind("ConsoleApp")
language("C++")
pchheader("vpch.h")
pchsource("Code/vpch.cpp")
files({
"Code/**.h",
"Code/**.cpp",
"Code/**.hlsl",
})
removefiles({
"Code/Editor/imgui/backends/**.*",
"Code/Editor/imgui/examples/**.*",
"Code/Editor/imgui/misc/**.*",
"Code/Editor/ImGuizmo/example/**.*",
"Code/Editor/ImGuizmo/vcpkg-example/**.*",
})
files({
"Code/Editor/imgui/backends/imgui_impl_dx11.cpp",
"Code/Editor/imgui/backends/imgui_impl_win32.cpp",
})
includedirs({
"Code",
"Code/Editor/imgui",
"Code/Editor/ImGuizmo",
})
links({
"d3d11.lib",
"dxgi.lib",
"d3dcompiler.lib",
"d2d1.lib",
"dwrite.lib",
})
defines({
--"_USE_MATH_DEFINES",
})
filter("files:Code/Editor/imgui/**.cpp")
flags({ "NoPCH" })
filter("files:Code/Editor/ImGuizmo/**.cpp")
flags({ "NoPCH" })
filter("files:Code/SHMath/**.cpp")
flags({ "NoPCH" })
filter("files:Code/**.hlsl")
flags({ "ExcludeFromBuild" })
shadermodel("5.0")
shaderobjectfileoutput("%{wks.location}/../%{prj.name}/Shaders/%{file.basename}.cso")
filter("files:Code/Render/Shaders/Vertex/*.hlsl")
removeflags({ "ExcludeFromBuild" })
shadertype("Vertex")
shaderobjectfileoutput("%{wks.location}/../%{prj.name}/Shaders/Vertex/%{file.basename}.cso")
filter("files:Code/Render/Shaders/Pixel/*.hlsl")
removeflags({ "ExcludeFromBuild" })
shadertype("Pixel")
shaderobjectfileoutput("%{wks.location}/../%{prj.name}/Shaders/Pixel/%{file.basename}.cso")
filter("files:Code/Render/Shaders/Compute/*CS.hlsl")
removeflags({ "ExcludeFromBuild" })
shadertype("Compute")
shaderentry("CSFunc")
--shaderoptions({ "/E 'CSFunc'" })
filter("action:vs*")
debugenvs({
"$(LocalDebuggerEnvironment)",
"QT_QPA_PLATFORM_PLUGIN_PATH=" .. g_wkslight.extras.qt_qpa_platform_plugin_path,
})
vspropertysheets({
"D:\\dev2\\DirectXTK.props",
"D:\\dev2\\fbxsdk.props",
"D:\\dev2\\PhysX-4.1.props",
"D:\\dev2\\qt5.props",
})
9 changes: 9 additions & 0 deletions libraries/ExampleStaticLib/include/ExampleStaticLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <iostream>

class ExampleStaticLib
{
public:
void Print();
};
12 changes: 12 additions & 0 deletions libraries/ExampleStaticLib/premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
project("ExampleStaticLib")
location(g_wkslight.workspacedir .. "/%{prj.name}")
targetdir(g_wkslight.targetdir)
kind("StaticLib")
language("C++")
files({
"include/**.h",
"src/**.cpp",
})
includedirs({
g_wkslight.workspace.libraries.projects.ExampleStaticLib.includedirs,
})
6 changes: 6 additions & 0 deletions libraries/ExampleStaticLib/src/ExampleStaticLib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "ExampleStaticLib.h"

void ExampleStaticLib::Print()
{
printf("ExampleStaticLib: Hello\n");
}
3 changes: 3 additions & 0 deletions premake5-clean.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
call "premake5.exe" clean
timeout /t 2 > nul
3 changes: 3 additions & 0 deletions premake5-generate-gmake.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
call "premake5.exe" gmake
timeout /t 2 > nul
3 changes: 3 additions & 0 deletions premake5-generate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
call "premake5.exe" vs2022
timeout /t 2 > nul
1 change: 1 addition & 0 deletions premake5-modules/premake-vspropertysheets
1 change: 1 addition & 0 deletions premake5-modules/premake-wkslight
Submodule premake-wkslight added at c7b8e1
25 changes: 25 additions & 0 deletions premake5-wkslight.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
g_wkslight = require("premake5-modules.premake-wkslight.wkslight")
g_wkslight.workspace = {
name = "VEngine-wks",
startproject = "VEngine",
platforms = { "x64" },
cppdialect = "C++20",
libraries = {
name = "libraries",
projects = {
ExampleStaticLib = {
location = "libraries/ExampleStaticLib",
includedirs = {
"%{wks.location}/../libraries/ExampleStaticLib/include",
},
},
},
},
projects = {
"Editor",
"VEngine",
},
}
g_wkslight.extras = {
qt_qpa_platform_plugin_path = "D:\\dev2\\qt-5.15.2\\plugins\\platforms",
}
44 changes: 44 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require("premake5-modules.premake-vspropertysheets.vspropertysheets")
require("premake5-wkslight")
workspace(g_wkslight.workspace.name)
location(path.getbasename(g_wkslight.workspacedir))
platforms(g_wkslight.workspace.platforms)
configurations({ "Debug", "Release" })
characterset("Default")
cppdialect(g_wkslight.workspace.cppdialect)
floatingpoint("Default")
rtti("Default")
exceptionhandling("Default")
filter("system:windows")
systemversion("latest")
filter("system:linux")
pic("On")
filter("action:vs*")
startproject(g_wkslight.workspace.startproject)
staticruntime("Off")
characterset("MBCS")
flags({ "MultiProcessorCompile" })
defines({
"_CRT_SECURE_NO_WARNINGS",
"_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS",
"_HAS_STD_BYTE=0",
})
--buildoptions({ "/utf-8", "/Zc:char8_t-" })
filter({ "action:gmake*", "system:not linux", "kind:*App or StaticLib" })
buildoptions({ "-static" })
filter("configurations:Debug")
defines({ "_DEBUG" })
symbols("On")
optimize("Off")
filter("configurations:Release")
defines({ "NDEBUG" })
symbols("Off")
optimize("Speed")
group(g_wkslight.workspace.libraries.name)
for k, v in pairs(g_wkslight.workspace.libraries.projects) do
include(v.location)
end
group("")
for i, v in ipairs(g_wkslight.workspace.projects) do
include(v)
end