Skip to content

Commit 4108401

Browse files
committed
Swap over to separate builds for each example
1 parent e237ea9 commit 4108401

File tree

21 files changed

+223
-226
lines changed

21 files changed

+223
-226
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,6 @@ Release
147147
*.vcxproj
148148
*.filters
149149
*.user
150+
box2d-main
151+
raylib-master
152+
*.sln

.gitmodules

-6
This file was deleted.

box2d

-1
This file was deleted.

box2d_raylib/premake5.lua

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1+
baseName = path.getbasename(os.getcwd())
12

2-
baseName = path.getbasename(os.getcwd());
3+
defineWorkspace(baseName)
34

45
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h", "../box2d/include/**h", "../box2d/src/**.cpp", "../box2d/src/**.h"}
15-
16-
includedirs { "./","../box2d/include/"}
17-
setup_raylib();
6+
files {"../box2d-main/include/**h", "../box2d-main/src/**.cpp", "../box2d-main/src/**.h"}
7+
includedirs {"../box2d-main/include/"}
8+
files {"../box2d/include/**h", "../box2dn/src/**.cpp", "../box2d/src/**.h"}
9+
includedirs {"../box2d/include/"}

box2d_raylib_objects/premake5.lua

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1+
baseName = path.getbasename(os.getcwd())
12

2-
baseName = path.getbasename(os.getcwd());
3+
defineWorkspace(baseName)
34

45
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h", "../box2d/include/**h", "../box2d/src/**.cpp", "../box2d/src/**.h"}
15-
16-
includedirs { "./","../box2d/include/"}
17-
setup_raylib();
6+
files {"../box2d-main/include/**h", "../box2d-main/src/**.cpp", "../box2d-main/src/**.h"}
7+
includedirs {"../box2d-main/include/"}
8+
files {"../box2d/include/**h", "../box2dn/src/**.cpp", "../box2d/src/**.h"}
9+
includedirs {"../box2d/include/"}

cards/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)

light_caster/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)

pew/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)

platform_example/premake5.lua

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11

2-
baseName = path.getbasename(os.getcwd());
2+
baseName = path.getbasename(os.getcwd())
33

4-
project (baseName)
5-
kind "ConsoleApp"
6-
location "../build"
7-
targetdir "../bin/%{cfg.buildcfg}"
8-
9-
vpaths
10-
{
11-
["Header Files/*"] = { "**.h"},
12-
["Source Files/*"] = {"**.c", "**.cpp"},
13-
}
14-
files {"**.c", "**.cpp", "**.h"}
15-
16-
includedirs { "./"}
17-
setup_raylib();
4+
defineWorkspace(baseName)
File renamed without changes.

premake5.lua

+108-39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11

2+
newoption
3+
{
4+
trigger = "graphics",
5+
value = "OPENGL_VERSION",
6+
description = "version of OpenGL to build raylib against",
7+
allowed = {
8+
{ "opengl11", "OpenGL 1.1"},
9+
{ "opengl21", "OpenGL 2.1"},
10+
{ "opengl33", "OpenGL 3.3"},
11+
{ "opengl43", "OpenGL 4.3"}
12+
},
13+
default = "opengl33"
14+
}
15+
216
function define_C()
317
language "C"
418
end
@@ -8,55 +22,110 @@ function define_Cpp()
822
end
923

1024
function string.starts(String,Start)
11-
return string.sub(String,1,string.len(Start))==Start
25+
return string.sub(String,1,string.len(Start))==Start
1226
end
1327

1428
function link_to(lib)
15-
links (lib)
16-
includedirs ("../"..lib)
29+
links (lib)
30+
includedirs ("../"..lib,"../"..lib.."/include" )
1731
end
1832

19-
baseName = path.getbasename(os.getcwd())
33+
function download_progress(total, current)
34+
local ratio = current / total;
35+
ratio = math.min(math.max(ratio, 0), 1);
36+
local percent = math.floor(ratio * 100);
37+
print("Download progress (" .. percent .. "%/100%)")
38+
end
2039

21-
workspace (baseName)
22-
configurations { "Debug","Debug.DLL", "Release", "Release.DLL" }
23-
platforms { "x64", "x86"}
40+
function check_raylib()
41+
if(os.isdir("raylib") == false and os.isdir("raylib-master") == false) then
42+
if(not os.isfile("raylib-master.zip")) then
43+
print("Raylib not found, downloading from github")
44+
local result_str, response_code = http.download("https://github.com/raysan5/raylib/archive/refs/heads/master.zip", "raylib-master.zip", {
45+
progress = download_progress,
46+
headers = { "From: Premake", "Referer: Premake" }
47+
})
48+
end
49+
print("Unzipping to " .. os.getcwd())
50+
zip.extract("raylib-master.zip", os.getcwd())
51+
os.remove("raylib-master.zip")
52+
end
53+
end
2454

25-
filter "configurations:Debug"
26-
defines { "DEBUG" }
27-
symbols "On"
28-
29-
filter "configurations:Debug.DLL"
30-
defines { "DEBUG" }
31-
symbols "On"
55+
function check_box2d()
56+
if(os.isdir(".box2d") == false and os.isdir("box2d-main") == false) then
57+
if(not os.isfile("box2d-main.zip")) then
58+
print("box2d not found, downloading from github")
59+
local result_str, response_code = http.download("https://github.com/erincatto/box2d/archive/refs/heads/main.zip", "box2d-main.zip", {
60+
progress = download_progress,
61+
headers = { "From: Premake", "Referer: Premake" }
62+
})
63+
end
64+
print("Unzipping to " .. os.getcwd())
65+
zip.extract("box2d-main.zip", os.getcwd())
66+
os.remove("box2d-main.zip")
67+
end
68+
end
3269

33-
filter "configurations:Release"
34-
defines { "NDEBUG" }
35-
optimize "On"
36-
37-
filter "configurations:Release.DLL"
38-
defines { "NDEBUG" }
39-
optimize "On"
40-
41-
filter { "platforms:x64" }
42-
architecture "x86_64"
70+
function defineWorkspace(baseName)
71+
workspace (baseName)
72+
configurations { "Debug", "Release"}
73+
platforms { "x64", "x86"}
74+
75+
filter "configurations:Debug"
76+
defines { "DEBUG" }
77+
symbols "On"
78+
79+
filter "configurations:Release"
80+
defines { "NDEBUG" }
81+
optimize "On"
82+
83+
filter { "platforms:x64" }
84+
architecture "x86_64"
85+
86+
filter {}
4387

44-
targetdir "bin/%{cfg.buildcfg}/"
45-
88+
targetdir "_bin/%{cfg.buildcfg}/"
89+
90+
startproject(baseName)
91+
92+
defineRaylibProject()
93+
94+
project (baseName)
95+
kind "ConsoleApp"
96+
location "_build"
97+
targetdir "_bin/%{cfg.buildcfg}"
98+
99+
filter "action:vs*"
100+
debugdir "$(SolutionDir)"
101+
102+
filter {"action:vs*", "configurations:Release"}
103+
kind "WindowedApp"
104+
entrypoint "mainCRTStartup"
105+
106+
filter{}
107+
108+
vpaths
109+
{
110+
["Header Files/*"] = { "include/**.h", "include/**.hpp", "src/**.h", "src/**.hpp", "**.h", "**.hpp"},
111+
["Source Files/*"] = {"src/**.c", "src/**.cpp","**.c", "**.cpp"},
112+
}
113+
files {"**.c", "**.cpp", "**.h", "**.hpp"}
114+
115+
includedirs { "./"}
116+
link_raylib();
117+
end
118+
46119
include ("raylib_premake5.lua")
120+
check_raylib()
121+
check_box2d()
47122

48123
folders = os.matchdirs("*")
49-
50124
for _, folderName in ipairs(folders) do
51-
if (folderName ~= "raylib"
52-
and folderName ~= "resources"
53-
and folderName ~= "build"
54-
and folderName ~= "bin"
55-
and folderName ~= "box2d"
56-
and string.starts(folderName, "_") == false
57-
and string.starts(folderName, ".") == false)
58-
then
59-
print(folderName)
60-
include (folderName)
61-
end
62-
end
125+
if (string.starts(folderName, "raylib") == false and string.starts(folderName, "_") == false and string.starts(folderName, ".") == false) then
126+
if (os.isfile(folderName .. "/premake5.lua")) then
127+
print(folderName)
128+
include (folderName)
129+
end
130+
end
131+
end

premake5.osx

1.27 MB
Binary file not shown.

raylib

-1
This file was deleted.

0 commit comments

Comments
 (0)