-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxmake.lua
286 lines (257 loc) · 8.83 KB
/
xmake.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
set_project('webrtc-rdp')
add_rules('mode.debug', 'mode.release')
set_toolchains('clang')
set_defaultmode("debug")
local webrtc_dir = '../webrtc'
local webrtc_branch = 'm113 refs/remotes/branch-heads/5672'
local webrtc_src_dir = path.join(webrtc_dir, 'src')
local webrtc_out_dir = path.join('out', '$(os)' .. '-' .. '$(mode)')
local webrtc_obj_dir = path.join(webrtc_src_dir, webrtc_out_dir, 'obj')
local slint_dir = './third_party/Slint-cpp-1.0.2-Linux-x86_64'
local slint_compiler = is_os('linux') and 'slint_compiler' or 'slint_compiler.exe'
add_requireconfs("*", { configs = { shared = false, system = true, debug = true }, shared = false })
local function require_vcpkg(pkg, opts)
local o = { alias = pkg }
for k, v in pairs(opts) do
o[k] = v
end
add_requires('vcpkg::' .. pkg, o)
end
require_vcpkg('boost-asio')
require_vcpkg('boost-beast')
require_vcpkg('boost-url')
require_vcpkg('fmt')
require_vcpkg('spdlog')
require_vcpkg('abseil')
require_vcpkg('nlohmann-json')
require_vcpkg('libyuv')
-- glew
require_vcpkg('glew')
-- end glew
require_vcpkg('sdl2')
-- sdl2-ttf
require_vcpkg('sdl2-ttf')
require_vcpkg('freetype')
require_vcpkg('bzip2')
require_vcpkg('brotli')
require_vcpkg('zlib')
require_vcpkg('libpng')
-- end sdl2-ttf
-- ffmpeg
require_vcpkg('ffmpeg[avcodec]', { alias = 'avcodec' })
require_vcpkg('ffmpeg[avutil]', { alias = 'avutil' })
require_vcpkg('ffmpeg[avformat]', { alias = 'avformat' })
require_vcpkg('liblzma')
-- end ffmpeg
if is_os('linux') then
add_requires('system::xdo', { alias = 'xdo' })
end
if is_os('windows') then
require_vcpkg('opengl')
require_vcpkg('x264')
end
local function windows_options()
-- clang windows workarounds
add_cxxflags('-fms-runtime-lib=static_dbg', '-fms-extensions')
add_defines('WEBRTC_WIN', 'NOMINMAX', '_WIN32_WINNT=0x0601', '_CRT_SECURE_NO_WARNINGS')
add_defines(
'SDL_MAIN_HANDLED',
'BOOST_ASIO_HAS_STD_COROUTINE',
'BOOST_ASIO_HAS_CO_AWAIT',
'BOOST_URL_NO_LIB',
'FMT_HEADER_ONLY')
add_syslinks('kernel32', 'user32', 'gdi32', 'winspool', 'comdlg32', 'advapi32', 'shell32',
'ole32', 'oleaut32', 'uuid', 'secur32', 'strmiids', 'mfuuid', 'd3d11', 'wmcodecdspuuid', 'dmoguids',
'odbc32', 'odbccp32', 'version', 'winmm', 'setupapi', 'imm32', 'iphlpapi', 'msdmo', 'shcore', 'dwmapi', 'dxgi')
end
local function linux_options()
add_defines('WEBRTC_POSIX', 'WEBRTC_LINUX', 'WEBRTC_USE_X11')
add_links('glib-2.0', 'gobject-2.0', 'gio-2.0', 'gbm')
add_links('X11', 'Xext', 'Xfixes', 'Xdamage', 'Xrandr', 'Xcomposite', 'Xtst')
add_links('rt', 'drm')
end
local function add_vcpkg(...)
local args = { ... }
for _, v in ipairs(args) do
add_packages(v)
end
end
target('dezk', function()
set_default(true)
set_kind('binary')
set_languages('c17', 'cxx20')
add_cxxflags('-Wno-deprecated-declarations')
add_defines('SLINT_FEATURE_EXPERIMENTAL')
add_includedirs('src', webrtc_src_dir, slint_dir .. '/include')
add_files('src/**.cc')
remove_files('src/server/**.cc')
remove_files('src/**_test.cc')
add_linkdirs(webrtc_obj_dir, slint_dir .. '/lib')
add_links('webrtc', 'slint_cpp')
if is_os('linux') then
linux_options()
add_packages('xdo')
end
if is_os('windows') then
windows_options()
add_vcpkg('x264', 'opengl')
end
add_vcpkg('boost-url', 'boost-asio', 'boost-beast', 'spdlog', 'abseil', 'nlohmann-json')
add_vcpkg('sdl2', 'sdl2-ttf', 'glew')
add_vcpkg('avcodec', 'avutil', 'avformat', 'libyuv')
add_vcpkg('freetype', 'zlib', 'liblzma', 'brotli', 'libpng', 'bzip2')
before_build(function ()
os.exec('%s src/ui/app.slint > src/ui/app.slint.h', slint_compiler)
end)
if is_os('linux') then
after_build(function(target)
os.exec('rsync %s notebook:dezk', target:targetfile())
end)
end
end)
target('signal_server', function()
set_kind('binary')
set_languages('c17', 'cxx20')
add_files('src/server/*.cc')
add_includedirs('src')
add_packages('spdlog', 'fmt')
if is_os('windows') then
windows_options()
end
if is_os('linux') then
add_cxxflags('-static-libstdc++', '-static-libgcc')
-- add_ldflags('-Wl,--rpath=./lib')
-- add_ldflags('-Wl,--dynamic-linker=./lib/ld-linux.so.2')
end
add_packages('boost-asio', 'boost-url', 'boost-beast', 'nlohmann-json')
if is_os('linux') then
after_build(function(target)
os.exec('rsync %s notebook:signal_server', target:targetfile())
end)
end
end)
if get_config('buildtest') == 1 then
target('video_player_test', function()
set_kind('binary')
set_languages('c17', 'cxx20')
add_files('src/sink/*.cc')
add_includedirs('src', webrtc_src_dir)
add_packages('spdlog', 'fmt', 'sdl2', 'sdl2-ttf', 'glew')
add_linkdirs(webrtc_obj_dir)
add_links('webrtc')
if is_os('linux') then
linux_options()
end
if is_os('windows') then
windows_options()
add_packages('opengl')
end
end)
if is_os('windows') then
target('executor_test', function()
set_kind('binary')
set_languages('c17', 'cxx20')
add_includedirs('src')
add_files('src/executor/*.cc')
add_vcpkg('sdl2', 'spdlog')
if is_os('linux') then
add_packages('xdo')
end
if is_os('windows') then
windows_options()
end
end)
end
end
-- TODO: use package() instead
local gn_args = {
'is_debug=true',
'enable_libaom=true', -- av1 support
'rtc_use_h264=false', -- use custom h264 impl
'rtc_include_tests=false',
'rtc_enable_protobuf=false',
-- 'ffmpeg_branding=\"Chrome\"',
'use_rtti=true', -- typeinfo
'use_custom_libcxx=false', -- stdlib
'use_debug_fission=true', -- -gsplit-dwarf
-- 'rtc_enable_symbol_export=true',
}
if is_os('windows') then
gn_args = {
'is_debug=true',
'enable_libaom=true', -- av1 support
'rtc_use_h264=false', -- use custom h264 impl
-- 'ffmpeg_branding=\"Chrome\"',
'rtc_include_tests=false',
'rtc_enable_protobuf=false',
-- for windows
'use_lld=false', -- linker
'use_rtti=true', -- typeinfo
'use_custom_libcxx=false', -- stdlib
'fatal_linker_warnings=false',
'treat_warnings_as_errors=false',
'enable_iterator_debugging=true',
-- no rtc_enable_symbol_export, which leads build errors
}
end
local check_cmd = string.format([[git checkout -b %s]], webrtc_branch)
local gn_cmd = string.format([[gn gen %s --args="%s"]], webrtc_out_dir, table.concat(gn_args, ' '))
local ninja_cmd = string.format([[ninja -C %s]], webrtc_out_dir)
local mt_cmd = [[mt.exe -manifest .\dezk.manifest -outputresource:'.\build\windows\x64\debug\dezk.exe;#1']]
task('fetch-webrtc', function()
on_run(function()
os.cd(webrtc_dir)
os.exec('fetch webrtc') -- TODO: need install depot_tools
os.cd(webrtc_src_dir)
os.exec(check_cmd)
end)
set_menu {
usage = 'xmake fetch-webrtc',
description = 'fetch webrtc source from google',
}
end)
task('build-webrtc', function()
on_run(function()
os.cd(webrtc_src_dir)
os.exec(gn_cmd)
os.exec(ninja_cmd)
end)
set_menu {
usage = 'xmake build-webrtc',
description = 'build webrtc source',
}
end)
task('fetch-slint', function()
on_run(function()
os.cd('third_party')
os.exec(
'wget -c https://github.com/slint-ui/slint/releases/download/v1.0.2/Slint-cpp-1.0.2-Linux-x86_64.tar.gz -O - | tar -zx')
end)
set_menu {
usage = 'xmake fetch-slint',
description = 'fetch slint binary release',
}
end)
task('echo-cmd', function()
on_run(function()
cprint('${yellow}webrtc dir${clear}: %s', path.absolute(webrtc_src_dir))
cprint('${yellow}webrtc branch${clear}: %s', check_cmd)
cprint('${yellow}webrtc config cmd${clear}: %s', gn_cmd)
cprint('${yellow}webrtc build cmd${clear}: %s', ninja_cmd)
cprint('${yellow}mt cmd${clear}: %s', mt_cmd)
end)
set_menu {
usage = 'xmake echo-cmd',
description = 'show webrtc build commands',
}
end)
-- package("slint", function()
-- add_deps("cmake")
-- set_sourcedir(path.join(os.scriptdir(), "third_party", 'Slint-cpp-1.0.2-Linux-x86_64'))
-- on_install(function(package)
-- local configs = {}
-- table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
-- table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
-- import("package.tools.cmake").install(package, configs)
-- end)
-- end)