source: mainline/uspace/lib/meson.build@ 5d380b6

ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 5d380b6 was 5b19d80, checked in by Jiri Svoboda <jiri@…>, 3 years ago

Display configuration library

Initial version of protocol library for managing seats and device
assignments.

  • Property mode set to 100644
File size: 10.2 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 'display',
36 'pixconv',
37 'posix',
38 'clui',
39 'pcm',
40 'hound',
41 'gfx',
42 'gfximage',
43 'ipcgfx',
44 'congfx',
45 'display',
46 'ui',
47]
48
49# IMPORTANT: Dependencies must be listed before libs that depend on them.
50libs = [
51 'c',
52
53 'inet',
54
55 'device',
56
57 'block',
58 'clui',
59 'codepage',
60 'compress',
61 'cpp',
62 'crypto',
63 'dltest',
64 'fbfont',
65 'fdisk',
66 'fmtutil',
67 'fs',
68 'gfx',
69 'http',
70 'label',
71 'math',
72 'minix',
73 'nettl',
74 'pcm',
75 'pcut',
76 'pixconv',
77 'posix',
78 'riff',
79 'scsi',
80 'sif',
81 'trackmod',
82 'untar',
83 'uri',
84
85 'bithenge',
86 'congfx',
87 'drv',
88 'ext4',
89 'gfxfont',
90 'gfximage',
91 'hound',
92 'ipcgfx',
93 'memgfx',
94 'nic',
95 'usb',
96 'usbdev',
97 'usbhid',
98 'usbhost',
99 'usbvirt',
100 'virtio',
101
102 'ieee80211',
103 'ddev',
104 'dispcfg',
105 'display',
106 'wndmgt',
107
108 'ui',
109]
110
111# Generated list of include directory paths
112include_paths = []
113
114# Generated list of test sources
115testfiles = []
116
117# Text of the install script.
118uspace_lib_devel_install_script_text = []
119
120foreach l : libs
121 # Variables that might be defined in library meson files:
122
123 # List of source files.
124 # To set it correctly, use files('list.c', 'of.c', 'files.c')
125 # Often this is the only variable that needs to be set.
126 src = files()
127
128 # Public include directories. These are used by everyone who depends
129 # on this library.
130 # Use include_directories('include_dir1', 'include_dir2') to set this.
131 # If the variable is omitted, it defaults to 'include' subdirectory
132 # if it exists, or the source directory otherwise.
133 # If the library has no headers, you can use
134 # includes += include_directories()
135 includes = []
136
137 # Private include directories.
138 # Unnecessary if you always include private headers using relative
139 # paths, but may be useful if you need to override system headers.
140 private_includes = []
141
142 # List of dependency names.
143 # E.g. to use libnic and libuntar use
144 # `deps = [ 'nic', 'untar' ]`
145 deps = []
146
147 # Extra arguments for the C compiler.
148 # Don't use for arguments involving file paths.
149 c_args = []
150
151 # Shared object version of the library.
152 version = '0.0'
153
154 # Sources of unit tests.
155 # Automatically get compiled into a test binary,
156 # but not into the library itself.
157 test_src = []
158
159 # Language of the library.
160 # Currently supported options are 'c' and 'cpp', with 'c' being default.
161 language = 'c'
162
163 # Whether the library can be dynamically linked.
164 # Eventually, all libraries will be shared by default and this will go away.
165 allow_shared = false
166
167 subdir(l)
168
169 # Add `include` or `.` subdirectory to include dirs if needed.
170 if includes.length() == 0
171 incdir = join_paths(l, 'include')
172 if run_command('[', '-d', incdir, ']').returncode() == 0
173 includes += include_directories(incdir)
174
175 if installed_libs.contains(l)
176 _sdir = meson.current_source_dir() / l / 'include'
177 uspace_lib_devel_install_script_text += 'cp -R -L -T "@0@" "${DESTDIR}include/lib@1@"'.format(_sdir, l)
178 endif
179 else
180 includes += include_directories(l)
181
182 if installed_libs.contains(l)
183 _sdir = meson.current_source_dir() / l
184 uspace_lib_devel_install_script_text += 'mkdir -p "${DESTDIR}include/lib@0@"'.format(l)
185 uspace_lib_devel_install_script_text += 'cp -L -t "${DESTDIR}include/lib@0@" "@1@"/*.h || true'.format(l, _sdir)
186 endif
187 endif
188 endif
189
190 # Pretty much everything depends on libc.
191 if l != 'c'
192 deps += 'c'
193 endif
194
195 if language == 'cpp' and l != 'cpp'
196 deps += 'cpp'
197 endif
198
199 mapfile = meson.current_build_dir() / 'lib' + l + '.map'
200
201 link_args = [ '-Wl,--no-undefined,--no-allow-shlib-undefined' ]
202 # We want linker to generate link map for debugging.
203 link_args += [ '-Wl,-Map,' + mapfile ]
204
205 # Convert strings to dependency objects
206 # TODO: this dependency business is way too convoluted due to issues in current Meson
207 _any_deps = []
208 _static_deps = []
209 _shared_deps = []
210 _include_deps = []
211 foreach s : deps
212 _any_deps += get_variable('lib' + s).get('any')
213 _static_deps += get_variable('lib' + s).get('static')
214 if not always_static
215 _shared_deps += get_variable('lib' + s).get('shared')
216 endif
217 _include_deps += get_variable('lib' + s).get('include')
218 endforeach
219
220 install_static_lib = CONFIG_DEVEL_FILES and installed_libs.contains(l)
221 install_shared_lib = allow_shared
222
223 _shared_dep = disabler()
224
225 if src.length() > 0
226 if not always_static
227 _libname = 'lib' + l + '.so.' + version.split('.')[0]
228
229 _shared_lib = shared_library(l, src,
230 # TODO: Include private headers using #include "quoted",
231 # and get rid of private_includes.
232 include_directories: [ private_includes, includes ],
233 dependencies: _shared_deps,
234 c_args: arch_uspace_c_args + c_args,
235 cpp_args: arch_uspace_c_args + c_args,
236 link_args: arch_uspace_c_args + arch_uspace_link_args + link_args,
237 version: version,
238 build_by_default: true,
239 )
240
241 if install_shared_lib
242 install_files += [[ 'lib', _shared_lib.full_path(), _libname ]]
243 install_deps += [ _shared_lib ]
244 endif
245
246 if install_shared_lib and install_debug_files
247 install_files += [[ 'debug/lib', mapfile, _libname + '.map' ]]
248 endif
249
250 if disassemble
251 _disasm = custom_target('lib' + l + '.disasm',
252 command: [ objdump, '-S', '@INPUT@' ],
253 input: _shared_lib,
254 output: 'lib' + l + '.disasm',
255 capture: true,
256 build_by_default: true,
257 )
258
259 if install_shared_lib and install_debug_files
260 install_files += [[ 'debug/lib', _disasm.full_path(), _libname + '.disasm' ]]
261 install_deps += [ _disasm ]
262 endif
263 endif
264
265 _shared_dep = declare_dependency(
266 link_with: _shared_lib,
267 # TODO: Always use `include` subdirectory for public headers,
268 # and ditch the variable.
269 include_directories: includes,
270 dependencies: _shared_deps,
271 )
272 endif
273
274 _static_lib = static_library(l, src,
275 # TODO: Include private headers using #include "quoted",
276 # and get rid of private_includes.
277 include_directories: [ private_includes, includes ],
278 dependencies: _include_deps,
279 c_args: arch_uspace_c_args + c_args,
280 cpp_args: arch_uspace_c_args + c_args,
281 )
282
283 if install_static_lib
284 install_files += [[ 'lib', _static_lib.full_path(), 'lib' + l + '.a' ]]
285 install_deps += [ _static_lib ]
286 endif
287
288 _static_dep = declare_dependency(
289 link_with: _static_lib,
290 # TODO: Always use `include` subdirectory for public headers,
291 # and ditch the variable.
292 include_directories: includes,
293 dependencies: _static_deps,
294 )
295
296 if always_static or not allow_shared
297 _any_dep = declare_dependency(
298 link_with: _static_lib,
299 # TODO: Always use `include` subdirectory for public headers,
300 # and ditch the variable.
301 include_directories: includes,
302 dependencies: _any_deps,
303 )
304 else
305 _any_dep = declare_dependency(
306 link_with: _shared_lib,
307 # TODO: Always use `include` subdirectory for public headers,
308 # and ditch the variable.
309 include_directories: includes,
310 dependencies: _any_deps,
311 )
312 endif
313
314 _include_dep = declare_dependency(
315 # TODO: Always use `include` subdirectory for public headers,
316 # and ditch the variable.
317 include_directories: includes,
318 dependencies: _include_deps,
319 )
320 else
321 # Header-only library.
322 _any_dep = declare_dependency(
323 include_directories: includes,
324 dependencies: _any_deps,
325 )
326 _static_dep = declare_dependency(
327 include_directories: includes,
328 dependencies: _static_deps,
329 )
330 endif
331
332 if test_src.length() > 0
333 testfiles += [ {
334 'name': l,
335 'src': test_src,
336 'includes': [ private_includes, includes ],
337 } ]
338 endif
339
340 set_variable('lib' + l, {
341 'any': _any_dep,
342 'static': _static_dep,
343 'shared': _shared_dep,
344 'include': _include_dep,
345 })
346endforeach
347
348if not CONFIG_PCUT_TESTS
349 subdir_done()
350endif
351
352# Test binaries
353foreach test : testfiles
354 _testname = test['name']
355 _libname = _testname.split('-')[0]
356 _ldargs = []
357 _test_binname = 'test-lib' + _testname
358
359 if link_map
360 # We want linker to generate link map for debugging.
361 _ldargs += [ '-Wl,-Map,' + meson.current_build_dir() / _test_binname + '.map' ]
362 endif
363
364 _bin = executable(_test_binname, test.get('src'),
365 include_directories: test.get('includes'),
366 dependencies: [ get_variable('lib' + _libname).get('any'), libpcut.get('any') ],
367 link_whole: libstartfiles,
368 c_args: arch_uspace_c_args,
369 cpp_args: arch_uspace_c_args,
370 link_args: arch_uspace_c_args + arch_uspace_link_args + _ldargs,
371 build_by_default: true,
372 )
373
374 install_files += [[ 'test', _bin.full_path(), _test_binname ]]
375 install_deps += [ _bin ]
376
377 if disassemble
378 _disasm = custom_target(_test_binname + '.disasm',
379 command: [ objdump, '-S', '@INPUT@' ],
380 input: _bin,
381 output: _test_binname + '.disasm',
382 capture: true,
383 build_by_default: true,
384 )
385
386 if install_debug_files
387 install_files += [[ 'debug/test', _disasm.full_path(), _test_binname + '.disasm' ]]
388 install_deps += [ _disasm ]
389 endif
390 endif
391endforeach
Note: See TracBrowser for help on using the repository browser.