source: mainline/uspace/lib/meson.build@ c7ecd290

Last change on this file since c7ecd290 was d3109ff, checked in by Jiri Svoboda <jiri@…>, 10 months ago

Cursor and color control in remote console + RGB

Move vt100 module from output server into separate vt library
Add cursor and color control to remcons using libvt
Add RGB color control to serial console and remote console

  • Property mode set to 100644
File size: 10.5 KB
Line 
1#
2# Copyright (c) 2019 Jiří Zárevúcky
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29always_static = not CONFIG_BUILD_SHARED_LIBS
30
31# Which libraries are installed when CONFIG_DEVEL_FILES is enabled
32installed_libs = [
33 'c',
34 'math',
35 'console',
36 'display',
37 'input',
38 'output',
39 'pixconv',
40 'posix',
41 'clui',
42 'pcm',
43 'hound',
44 'gfx',
45 'gfximage',
46 'ipcgfx',
47 'congfx',
48 'display',
49 'ui',
50]
51
52# IMPORTANT: Dependencies must be listed before libs that depend on them.
53libs = [
54 'c',
55
56 'inet',
57
58 'input',
59 'output',
60 'console',
61 'device',
62
63 'block',
64 'clipboard',
65 'clui',
66 'codepage',
67 'compress',
68 'corecfg',
69 'cpp',
70 'crypto',
71 'dltest',
72 'fbfont',
73 'fdisk',
74 'fmtutil',
75 'fs',
76 'futil',
77 'gfx',
78 'http',
79 'ipctest',
80 'label',
81 'math',
82 'minix',
83 'nettl',
84 'ofw',
85 'pcm',
86 'pcut',
87 'pixconv',
88 'posix',
89 'riff',
90 'scsi',
91 'sif',
92 'tbarcfg',
93 'termui',
94 'trackmod',
95 'untar',
96 'uri',
97
98 'bithenge',
99 'congfx',
100 'drv',
101 'ext4',
102 'gfxfont',
103 'gfximage',
104 'hound',
105 'ipcgfx',
106 'memgfx',
107 'nic',
108 'usb',
109 'usbdev',
110 'usbhid',
111 'usbhost',
112 'usbvirt',
113 'virtio',
114
115 'ata',
116 'ieee80211',
117 'ddev',
118 'dispcfg',
119 'display',
120 'wndmgt',
121
122 'ui',
123 'vt',
124]
125
126# Generated list of include directory paths
127include_paths = []
128
129# Generated list of test sources
130testfiles = []
131
132# Text of the install script.
133uspace_lib_devel_install_script_text = []
134
135foreach l : libs
136 # Variables that might be defined in library meson files:
137
138 # List of source files.
139 # To set it correctly, use files('list.c', 'of.c', 'files.c')
140 # Often this is the only variable that needs to be set.
141 src = files()
142
143 # Public include directories. These are used by everyone who depends
144 # on this library.
145 # Use include_directories('include_dir1', 'include_dir2') to set this.
146 # If the variable is omitted, it defaults to 'include' subdirectory
147 # if it exists, or the source directory otherwise.
148 # If the library has no headers, you can use
149 # includes += include_directories()
150 includes = []
151
152 # Private include directories.
153 # Unnecessary if you always include private headers using relative
154 # paths, but may be useful if you need to override system headers.
155 private_includes = []
156
157 # List of dependency names.
158 # E.g. to use libnic and libuntar use
159 # `deps = [ 'nic', 'untar' ]`
160 deps = []
161
162 # Extra arguments for the C compiler.
163 # Don't use for arguments involving file paths.
164 c_args = []
165
166 # Shared object version of the library.
167 version = '0.0'
168
169 # Sources of unit tests.
170 # Automatically get compiled into a test binary,
171 # but not into the library itself.
172 test_src = []
173
174 # Language of the library.
175 # Currently supported options are 'c' and 'cpp', with 'c' being default.
176 language = 'c'
177
178 # Whether the library can be dynamically linked.
179 # Eventually, all libraries will be shared by default and this will go away.
180 allow_shared = false
181
182 subdir(l)
183
184 # Add `include` or `.` subdirectory to include dirs if needed.
185 if includes.length() == 0
186 incdir = join_paths(l, 'include')
187 if run_command('[', '-d', incdir, ']').returncode() == 0
188 includes += include_directories(incdir)
189 _sdir = meson.current_source_dir() / l / 'include'
190
191 if installed_libs.contains(l)
192 uspace_lib_devel_install_script_text += 'cp -R -L -T "@0@" "${DESTDIR}include/lib@1@"'.format(_sdir, l)
193 endif
194
195 exported_devel_files += ['include', _sdir, 'lib' + l]
196 else
197 includes += include_directories(l)
198
199 if installed_libs.contains(l)
200 _sdir = meson.current_source_dir() / l
201 uspace_lib_devel_install_script_text += 'mkdir -p "${DESTDIR}include/lib@0@"'.format(l)
202 uspace_lib_devel_install_script_text += 'cp -L -t "${DESTDIR}include/lib@0@" "@1@"/*.h || true'.format(l, _sdir)
203 endif
204 endif
205 endif
206
207 # Pretty much everything depends on libc.
208 if l != 'c'
209 deps += 'c'
210 endif
211
212 if language == 'cpp' and l != 'cpp'
213 deps += 'cpp'
214 endif
215
216 mapfile = meson.current_build_dir() / 'lib' + l + '.map'
217
218 link_args = [ '-Wl,--no-undefined,--no-allow-shlib-undefined' ]
219 # We want linker to generate link map for debugging.
220 link_args += [ '-Wl,-Map,' + mapfile ]
221
222 # Convert strings to dependency objects
223 # TODO: this dependency business is way too convoluted due to issues in current Meson
224 _any_deps = []
225 _static_deps = []
226 _shared_deps = []
227 _include_deps = []
228 foreach s : deps
229 _any_deps += get_variable('lib' + s).get('any')
230 _static_deps += get_variable('lib' + s).get('static')
231 if not always_static
232 _shared_deps += get_variable('lib' + s).get('shared')
233 endif
234 _include_deps += get_variable('lib' + s).get('include')
235 endforeach
236
237 install_static_lib = CONFIG_DEVEL_FILES and installed_libs.contains(l)
238 install_shared_lib = allow_shared
239
240 _shared_dep = disabler()
241
242 if src.length() > 0
243 if not always_static
244 _libname = 'lib' + l + '.so.' + version.split('.')[0]
245
246 _shared_lib = shared_library(l, src,
247 # TODO: Include private headers using #include "quoted",
248 # and get rid of private_includes.
249 include_directories: [ private_includes, includes ],
250 dependencies: _shared_deps,
251 c_args: arch_uspace_c_args + c_args,
252 cpp_args: arch_uspace_c_args + c_args,
253 link_args: arch_uspace_c_args + arch_uspace_link_args + link_args,
254 version: version,
255 build_by_default: true,
256 )
257
258 if install_shared_lib
259 install_files += [[ 'lib', _shared_lib.full_path(), _libname ]]
260 install_deps += [ _shared_lib ]
261 endif
262
263 if install_shared_lib and install_debug_files
264 install_files += [[ 'debug/lib', mapfile, _libname + '.map' ]]
265 endif
266
267 if disassemble
268 _disasm = custom_target('lib' + l + '.disasm',
269 command: [ objdump, '-S', '@INPUT@' ],
270 input: _shared_lib,
271 output: 'lib' + l + '.disasm',
272 capture: true,
273 build_by_default: true,
274 )
275
276 if install_shared_lib and install_debug_files
277 install_files += [[ 'debug/lib', _disasm.full_path(), _libname + '.disasm' ]]
278 install_deps += [ _disasm ]
279 endif
280 endif
281
282 _shared_dep = declare_dependency(
283 link_with: _shared_lib,
284 # TODO: Always use `include` subdirectory for public headers,
285 # and ditch the variable.
286 include_directories: includes,
287 dependencies: _shared_deps,
288 )
289 endif
290
291 _static_lib = static_library(l, src,
292 # TODO: Include private headers using #include "quoted",
293 # and get rid of private_includes.
294 include_directories: [ private_includes, includes ],
295 dependencies: _include_deps,
296 c_args: arch_uspace_c_args + c_args,
297 cpp_args: arch_uspace_c_args + c_args,
298 )
299
300 if install_static_lib
301 install_files += [[ 'lib', _static_lib.full_path(), 'lib' + l + '.a' ]]
302 install_deps += [ _static_lib ]
303 endif
304
305 exported_devel_files += ['staticlib', _static_lib, 'lib' + l + '.a']
306
307 _static_dep = declare_dependency(
308 link_with: _static_lib,
309 # TODO: Always use `include` subdirectory for public headers,
310 # and ditch the variable.
311 include_directories: includes,
312 dependencies: _static_deps,
313 )
314
315 if always_static or not allow_shared
316 _any_dep = declare_dependency(
317 link_with: _static_lib,
318 # TODO: Always use `include` subdirectory for public headers,
319 # and ditch the variable.
320 include_directories: includes,
321 dependencies: _any_deps,
322 )
323 else
324 _any_dep = declare_dependency(
325 link_with: _shared_lib,
326 # TODO: Always use `include` subdirectory for public headers,
327 # and ditch the variable.
328 include_directories: includes,
329 dependencies: _any_deps,
330 )
331 endif
332
333 _include_dep = declare_dependency(
334 # TODO: Always use `include` subdirectory for public headers,
335 # and ditch the variable.
336 include_directories: includes,
337 dependencies: _include_deps,
338 )
339 else
340 # Header-only library.
341 _any_dep = declare_dependency(
342 include_directories: includes,
343 dependencies: _any_deps,
344 )
345 _static_dep = declare_dependency(
346 include_directories: includes,
347 dependencies: _static_deps,
348 )
349 endif
350
351 if test_src.length() > 0
352 testfiles += [ {
353 'name': l,
354 'src': test_src,
355 'includes': [ private_includes, includes ],
356 } ]
357 endif
358
359 set_variable('lib' + l, {
360 'any': _any_dep,
361 'static': _static_dep,
362 'shared': _shared_dep,
363 'include': _include_dep,
364 })
365endforeach
366
367if not CONFIG_PCUT_TESTS
368 subdir_done()
369endif
370
371# Test binaries
372foreach test : testfiles
373 _testname = test['name']
374 _libname = _testname.split('-')[0]
375 _ldargs = []
376 _test_binname = 'test-lib' + _testname
377
378 if link_map
379 # We want linker to generate link map for debugging.
380 _ldargs += [ '-Wl,-Map,' + meson.current_build_dir() / _test_binname + '.map' ]
381 endif
382
383 _bin = executable(_test_binname, test.get('src'),
384 include_directories: test.get('includes'),
385 dependencies: [ get_variable('lib' + _libname).get('any'), libpcut.get('any') ],
386 link_whole: libstartfiles,
387 c_args: arch_uspace_c_args,
388 cpp_args: arch_uspace_c_args,
389 link_args: arch_uspace_c_args + arch_uspace_link_args + _ldargs,
390 build_by_default: true,
391 )
392
393 install_files += [[ 'test', _bin.full_path(), _test_binname ]]
394 install_deps += [ _bin ]
395
396 if disassemble
397 _disasm = custom_target(_test_binname + '.disasm',
398 command: [ objdump, '-S', '@INPUT@' ],
399 input: _bin,
400 output: _test_binname + '.disasm',
401 capture: true,
402 build_by_default: true,
403 )
404
405 if install_debug_files
406 install_files += [[ 'debug/test', _disasm.full_path(), _test_binname + '.disasm' ]]
407 install_deps += [ _disasm ]
408 endif
409 endif
410endforeach
Note: See TracBrowser for help on using the repository browser.