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

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

Save typeface to (RIFF) TPF file using newly introduced libriff

Originally I planned introducing libriff for better RIFF WAVE support.
It could be used for this purpose in the future (as well as for WebP
and other RIFF-based formats).

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