-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild.lua
More file actions
130 lines (100 loc) · 2.9 KB
/
Build.lua
File metadata and controls
130 lines (100 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
function GetParentFolderName()
return string.match(os.getcwd(), "[/\\]([^/\\]+)$")
end
function CopyOnBuild(source, destination)
destination = destination or ""
postbuildcommands {
"{COPY} \""..path.getabsolute(source).."\" \"%{cfg.targetdir}/"..destination..source.."\""
}
end
function DefinePath(name, relativePath)
_G[name] = relativePath..'/'
_G[name.."Abs"] = path.getabsolute(relativePath)..'/'
end
function DefineProject()
DefinePath(project().name.."IncPath", "Source")
end
function LinkDependency(name)
includedirs { _G[name.."Include"] }
libdirs { _G[name.."Lib"] }
links { _G[name.."Links"] }
end
function LinkProject(name)
includedirs { _G[name.."IncPathAbs"] }
links { name }
end
function UsePCH()
pchheader "_%{prj.name}.h"
pchsource "Source/_%{prj.name}.cpp"
end
if (string.match(_ACTION, "vs")) then
Environment = "MSVC"
elseif string.match(_ACTION, "gmake") and os.target() == "emscripten" then
Environment = "Web"
elseif string.match(_ACTION, "gmake") then
Environment = "GCC"
end
solution (GetParentFolderName())
configurations { "Debug", "Release" }
startproject "Project"
if Environment == "Web" then
platforms { "HTML5" }
else
platforms { "x64", "x86" }
end
language "C++"
cppdialect "C++20"
fatalwarnings "All"
filter "configurations:Debug"
defines { "DEBUG" }
symbols "On"
filter "configurations:Release"
defines { "NDEBUG" }
optimize "On"
filter "platforms:x64"
architecture "x86_64"
filter "platforms:x86"
architecture "x86"
filter "platforms:HTML5"
architecture "wasm64"
defines { "PLATFORM_WEB" }
DefinePath("BuildPath", "Binaries/"..Environment)
OutputStructure = "%{cfg.platform}/%{cfg.buildcfg}/"
filter { }
debugdir ("")
targetdir (BuildPath..OutputStructure)
objdir (BuildPath..OutputStructure.."Intermediate")
DefinePath("VendorPath", "Vendor")
DefinePath("RaylibPath", VendorPath.."raylib/"..Environment.."/%{cfg.platform}")
RaylibInclude = RaylibPathAbs.."include"
RaylibLib = RaylibPathAbs.."lib"
RaylibLinks = { "raylib" }
filter "system:windows"
defines { "PLATFORM_WINDOWS" }
if Environment ~= "Web" then
table.insert(RaylibLinks, "winmm")
table.insert(RaylibLinks, "gdi32")
table.insert(RaylibLinks, "opengl32")
end
if Environment == "Web" then
local htmlOutput = "\""..BuildPathAbs..OutputStructure.."%{prj.name}.html".."\""
EM_FLAGS = {
"-s USE_GLFW=3",
"-s TOTAL_MEMORY=128MB",
"-s STACK_SIZE=1MB",
"-s MINIFY_HTML=0",
"-s ASYNCIFY",
"-s ASYNCIFY_STACK_SIZE=1048576",
-- "-s FORCE_FILESYSTEM=1",
-- "--preload-file ../"..ResourcesPath,
"-Wall -std=c++20",
"--shell-file "..RaylibPathAbs.."minshell.html",
"-o "..htmlOutput,
-- "-s 'EXPORTED_FUNCTIONS=[\"_main\", \"_malloc\", \"_free\"]' -s EXPORTED_RUNTIME_METHODS=ccall"
}
filter "configurations:Debug"
table.insert(EM_FLAGS, "-s ASSERTIONS=1")
filter { }
linkoptions (EM_FLAGS)
end
include "Project/Build.lua"