Skip to content

Commit 5de32a6

Browse files
committed
- add "usage" module for premake and simplify project configuration
1 parent 34467bb commit 5de32a6

9 files changed

Lines changed: 689 additions & 49 deletions

File tree

Driver2CutsceneTool/premake5.lua

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,9 @@
33
project "Driver2CutsceneTool"
44
kind "ConsoleApp"
55
language "C++"
6-
compileas "C++"
76
targetdir "bin/%{cfg.buildcfg}"
87

9-
-- framework link
10-
dependson { "frameworkLib", "libnstd" }
11-
links { "frameworkLib", "libnstd" }
12-
includedirs {
13-
"../dependencies/libnstd/include",
14-
}
15-
--
8+
uses { "frameworkLib", "libnstd" }
169

1710
files {
1811
"**.cpp",

Driver2MissionTool/premake5.lua

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ project "Driver2MissionTool"
55
language "C++"
66
targetdir "bin/%{cfg.buildcfg}"
77

8-
-- framework link
9-
dependson { "frameworkLib", "libnstd" }
10-
links { "frameworkLib", "libnstd" }
11-
includedirs {
12-
"../dependencies/libnstd/include",
13-
}
14-
--
8+
uses { "frameworkLib", "libnstd" }
159

1610
files {
1711
"**.cpp",

DriverImageTool/premake5.lua

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,9 @@
33
project "DriverImageTool"
44
kind "ConsoleApp"
55
language "C++"
6-
compileas "C++"
76
targetdir "bin/%{cfg.buildcfg}"
87

9-
-- framework link
10-
dependson { "frameworkLib", "libnstd" }
11-
links { "frameworkLib", "libnstd" }
12-
includedirs {
13-
"../dependencies/libnstd/include",
14-
}
15-
--
8+
uses { "frameworkLib", "libnstd" }
169

1710
files {
1811
"**.cpp",

DriverLevelTool/premake5.lua

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,9 @@ SDL2_DIR = os.getenv("SDL2_DIR") or "../dependencies/SDL2"
66
project "DriverLevelTool"
77
kind "ConsoleApp"
88
language "C++"
9-
compileas "C++"
109
targetdir "bin/%{cfg.buildcfg}"
1110

12-
dependson { "ImGui", "frameworkLib", "libnstd", "glad" }
13-
14-
-- framework link
15-
links { "libnstd", "glad", "ImGui", "frameworkLib" }
16-
includedirs {
17-
"../dependencies/libnstd/include",
18-
}
19-
--
11+
uses { "libnstd", "glad", "ImGui", "frameworkLib" }
2012

2113
includedirs {
2214
"./",

DriverSoundTool/premake5.lua

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,9 @@
33
project "DriverSoundTool"
44
kind "ConsoleApp"
55
language "C++"
6-
compileas "C++"
76
targetdir "bin/%{cfg.buildcfg}"
87

9-
-- framework link
10-
dependson { "frameworkLib", "libnstd" }
11-
links { "frameworkLib", "libnstd" }
12-
includedirs {
13-
"../dependencies/libnstd/include",
14-
}
15-
--
8+
uses { "frameworkLib", "libnstd" }
169

1710
files {
1811
"**.cpp",

premake5.lua

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
-- premake5.lua
22

3+
require "premake_modules/usage"
4+
35
-- you can redefine dependencies
46
SDL2_DIR = os.getenv("SDL2_DIR") or "dependencies/SDL2"
57

68
workspace "OpenDriver2Tools"
79
language "C++"
810
configurations { "Debug", "Release" }
911
linkgroups 'On'
12+
characterset "ASCII"
1013

1114
includedirs {
1215
"./"
@@ -50,17 +53,21 @@ project "libnstd"
5053
"dependencies/libnstd/src/**.h",
5154
}
5255

56+
usage "libnstd"
57+
includedirs {
58+
"dependencies/libnstd/include"
59+
}
60+
links "libnstd"
61+
5362
-- little framework
5463
project "frameworkLib"
5564
kind "StaticLib"
5665
targetdir "bin/%{cfg.buildcfg}"
66+
67+
uses "libnstd"
5768

5869
filter "system:Windows"
5970
defines { "_CRT_SECURE_NO_WARNINGS" }
60-
61-
includedirs {
62-
"dependencies/libnstd/include",
63-
}
6471

6572
files {
6673
"math/**.cpp",
@@ -84,6 +91,11 @@ project "glad"
8491
"dependencies/glad/*.h",
8592
}
8693

94+
usage "glad"
95+
includedirs {
96+
"dependencies/glad/*.h",
97+
}
98+
8799
-- ImGui
88100
project "ImGui"
89101
kind "StaticLib"
@@ -106,9 +118,15 @@ project "ImGui"
106118
"dependencies/imgui/backends/imgui_impl_sdl.cpp",
107119
"dependencies/imgui/backends/imgui_impl_sdl.h",
108120
}
121+
122+
usage "ImGui"
123+
includedirs {
124+
"dependencies/imgui",
125+
}
126+
links { "ImGui" }
109127

110-
dofile("DriverLevelTool/premake5.lua")
111-
dofile("DriverSoundTool/premake5.lua")
112-
dofile("DriverImageTool/premake5.lua")
113-
dofile("Driver2CutsceneTool/premake5.lua")
114-
dofile("Driver2MissionTool/premake5.lua")
128+
include "DriverLevelTool/premake5.lua"
129+
include "DriverSoundTool/premake5.lua"
130+
include "DriverImageTool/premake5.lua"
131+
include "Driver2CutsceneTool/premake5.lua"
132+
include "Driver2MissionTool/premake5.lua"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
return {
2+
"usage.lua",
3+
}

premake_modules/usage/stack.lua

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
-- Stack Table
2+
-- Uses a table as stack, use <table>:push(value) and <table>:pop()
3+
-- Lua 5.1 compatible
4+
5+
unpack = table.unpack or unpack
6+
7+
-- GLOBAL
8+
Stack = {}
9+
10+
-- Create a Table with stack functions
11+
function Stack:Create()
12+
13+
-- stack table
14+
local t = {}
15+
-- entry table
16+
t._et = {}
17+
18+
-- push a value on to the stack
19+
function t:push(...)
20+
if ... then
21+
local targs = {...}
22+
-- add values
23+
for _,v in ipairs(targs) do
24+
table.insert(self._et, v)
25+
end
26+
end
27+
end
28+
29+
-- pop a value from the stack
30+
function t:pop(num)
31+
32+
-- get num values from stack
33+
local num = num or 1
34+
35+
-- return table
36+
local entries = {}
37+
38+
-- get values into entries
39+
for i = 1, num do
40+
-- get last entry
41+
if #self._et ~= 0 then
42+
table.insert(entries, self._et[#self._et])
43+
-- remove last value
44+
table.remove(self._et)
45+
else
46+
break
47+
end
48+
end
49+
-- return unpacked entries
50+
return unpack(entries)
51+
end
52+
53+
-- get entries
54+
function t:getn()
55+
return #self._et
56+
end
57+
58+
-- get entry form index
59+
function t:get(index)
60+
return self._et[index]
61+
end
62+
63+
-- list values
64+
function t:list()
65+
for i,v in pairs(self._et) do
66+
print(i, v)
67+
end
68+
end
69+
-- list values
70+
function t:find_value(value)
71+
for i,v in pairs(self._et) do
72+
if v == value then
73+
return i
74+
end
75+
end
76+
return nil
77+
end
78+
return t
79+
end

0 commit comments

Comments
 (0)