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

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

Move fixed width font to its own library, libfbfont

We've actually three copies, one in kernel/, one in output server
(not used anymorei, removed), one in libdraw (now moved to separate library
libfbfont). So we are left with two copies, that could be coalesced
somehow in the future.

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