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

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

Add IPC transport library for GFX

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