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

Last change on this file since a19d7fc4 was 04e520e, checked in by Jiri Svoboda <jiri@…>, 12 months ago

Config file persistence

Copy /cfg to /w/cfg when installing and when starting live image
Move futil to separate library
Wait for /w to be mounted while booting from disk
Change taskbar and taskbar-cfg to work with /w/cfg/taskbar.sif

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