forked from rive-app/rive-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake5_pls_renderer.lua
222 lines (192 loc) · 5.89 KB
/
premake5_pls_renderer.lua
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
dofile('rive_build_config.lua')
-- Are we in the "rive-renderer" or "rive" repository?
local handle = io.popen('git remote -v')
local git_remote = handle:read('*a')
handle:close()
if string.find(git_remote, 'rive%-renderer') or string.find(git_remote, 'rive%-pls') then
-- In rive-renderer. Rive runtime is a submodule.
RIVE_RUNTIME_DIR = path.getabsolute('submodules/rive-cpp')
else
-- In rive. Rive runtime is further up the tree.
RIVE_RUNTIME_DIR = path.getabsolute('../runtime')
end
filter('system:windows or macosx or linux')
do
-- Define RIVE_DESKTOP_GL outside of a project so that it also gets defined for consumers. It is
-- the responsibility of consumers to call gladLoadCustomLoader() when RIVE_DESKTOP_GL is
-- defined.
defines({ 'RIVE_DESKTOP_GL' })
end
filter('system:macosx')
do
defines({ 'RIVE_MACOSX' })
end
filter('system:android')
do
defines({ 'RIVE_ANDROID' })
end
filter({ 'system:ios', 'options:variant=system' })
do
defines({ 'RIVE_IOS' })
end
newoption({
trigger = 'with-dawn',
description = 'compile in support for webgpu via dawn',
})
filter({ 'options:with-dawn' })
do
defines({ 'RIVE_DAWN' })
end
newoption({
trigger = 'with-webgpu',
description = 'compile in native support for webgpu',
})
filter({ 'options:with-webgpu' })
do
defines({ 'RIVE_WEBGPU' })
end
filter({ 'system:ios', 'options:variant=emulator' })
do
defines({ 'RIVE_IOS_SIMULATOR' })
end
filter('system:emscripten')
do
defines({ 'RIVE_WEBGL' })
end
filter({})
-- Minify PLS shaders, and precompile them into metal libraries if targeting ios or macosx.
newoption({
trigger = 'human-readable-shaders',
description = 'don\'t minimize shaders',
})
project('rive_pls_shaders')
do
kind('Makefile')
local makecommand = '@make -C ' .. path.getabsolute('renderer/shaders')
if _OPTIONS['human-readable-shaders'] then
makecommand = makecommand .. ' FLAGS=--human-readable'
end
cleancommands({ makecommand .. ' clean' })
buildcommands({ makecommand .. ' minify' })
rebuildcommands({ makecommand .. ' minify' })
filter('system:macosx')
do
buildcommands({ makecommand .. ' rive_pls_macosx_metallib' })
rebuildcommands({ makecommand .. ' rive_pls_macosx_metallib' })
end
filter({ 'system:ios', 'options:variant=system' })
do
buildcommands({ makecommand .. ' rive_pls_ios_metallib' })
rebuildcommands({ makecommand .. ' rive_pls_ios_metallib' })
end
filter({ 'system:ios', 'options:variant=emulator' })
do
buildcommands({ makecommand .. ' rive_pls_ios_simulator_metallib' })
rebuildcommands({ makecommand .. ' rive_pls_ios_simulator_metallib' })
end
filter({ 'options:with-dawn or with-webgpu' })
do
buildcommands({ makecommand .. ' spirv' })
rebuildcommands({ makecommand .. ' spirv' })
end
filter('system:windows')
do
architecture('x64')
end
end
newoption({
trigger = 'nop-obj-c',
description = 'include Metal classes, but as no-ops (for compilers that don\'t support Obj-C)',
})
newoption({
trigger = 'no-rive-decoders',
description = 'don\'t use the rive_decoders library (built-in image decoding will fail)',
})
newoption({
trigger = 'universal-release',
description = '(Apple only): build a universal binary to release to the store',
})
project('rive_pls_renderer')
do
dependson('rive_pls_shaders')
kind('StaticLib')
includedirs({ 'include', 'glad', 'renderer', RIVE_RUNTIME_DIR .. '/include' })
flags({ 'FatalWarnings' })
files({ 'renderer/*.cpp', 'renderer/decoding/*.cpp' })
-- The Visual Studio clang toolset doesn't recognize -ffp-contract.
filter('system:not windows')
do
buildoptions({
'-ffp-contract=on',
'-fassociative-math',
-- Don't warn about simd vectors larger than 128 bits when AVX is not enabled.
'-Wno-psabi',
})
end
filter('system:not ios')
do
files({
'renderer/gl/gl_state.cpp',
'renderer/gl/gl_utils.cpp',
'renderer/gl/load_store_actions_ext.cpp',
'renderer/gl/pls_render_buffer_gl_impl.cpp',
'renderer/gl/pls_render_context_gl_impl.cpp',
'renderer/gl/pls_render_target_gl.cpp',
})
end
filter('system:windows or macosx or linux')
do
files({
'renderer/gl/pls_impl_webgl.cpp', -- Emulate WebGL with ANGLE.
'renderer/gl/pls_impl_rw_texture.cpp',
'glad/glad.c',
'glad/glad_custom.c',
}) -- GL loader library for ANGLE.
end
filter('system:android')
do
files({
'renderer/gl/load_gles_extensions.cpp',
'renderer/gl/pls_impl_ext_native.cpp',
'renderer/gl/pls_impl_framebuffer_fetch.cpp',
})
end
filter({ 'system:macosx or ios', 'options:not nop-obj-c' })
do
files({ 'renderer/metal/*.mm' })
buildoptions({ '-fobjc-arc' })
end
filter({ 'options:with-dawn' })
do
includedirs({
'dependencies/dawn/include',
'dependencies/dawn/out/release/gen/include',
})
files({ 'dependencies/dawn/out/release/gen/src/dawn/webgpu_cpp.cpp' })
end
filter({ 'options:with-webgpu or with-dawn' })
do
files({
'renderer/webgpu/**.cpp',
'renderer/gl/load_store_actions_ext.cpp',
})
end
filter({ 'options:nop-obj-c' })
do
files({ 'renderer/metal/pls_metal_nop.cpp' })
end
filter({ 'options:not no-rive-decoders' })
do
includedirs({ RIVE_RUNTIME_DIR .. '/decoders/include' })
defines({ 'RIVE_DECODERS' })
end
filter('system:windows')
do
architecture('x64')
files({ 'renderer/d3d/*.cpp' })
end
filter('system:emscripten')
do
files({ 'renderer/gl/pls_impl_webgl.cpp' })
end
end