source: mainline/uspace/lib/meson.build@ 4453a12a

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

Fix missing libraries for gzx, msim, sycek

It seems the export includes are taken from the dist/include which contains
headers that will end up on the ram disk.

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