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
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',
[3dd99dde]35 'console',
[265989d]36 'display',
[3dd99dde]37 'input',
38 'output',
[0d3bc7b1]39 'pixconv',
[5fd05862]40 'posix',
[fc65b87]41 'clui',
42 'pcm',
[ecb7828]43 'hound',
44 'gfx',
[63b35c7]45 'gfximage',
[ecb7828]46 'ipcgfx',
[dbf1be5]47 'congfx',
[ecb7828]48 'display',
[38f5598]49 'ui',
[5fd05862]50]
51
52# IMPORTANT: Dependencies must be listed before libs that depend on them.
53libs = [
54 'c',
55
[ec7902d]56 'inet',
57
[6cef8d6a]58 'input',
[10fc93c]59 'output',
[a635535]60 'console',
[5fc8244]61 'device',
62
[5fd05862]63 'block',
[cad7b7e]64 'clipboard',
[5fd05862]65 'clui',
[9b2e20c]66 'codepage',
[5fd05862]67 'compress',
[8f04992]68 'corecfg',
[5fd05862]69 'cpp',
70 'crypto',
71 'dltest',
[26653c9]72 'fbfont',
[5fd05862]73 'fdisk',
74 'fmtutil',
75 'fs',
[04e520e]76 'futil',
[a3f63ac]77 'gfx',
[5fd05862]78 'http',
[0e2eee1]79 'ipctest',
[5fd05862]80 'label',
81 'math',
82 'minix',
83 'nettl',
[4d58bac]84 'ofw',
[5fd05862]85 'pcm',
86 'pcut',
[0d3bc7b1]87 'pixconv',
[5fd05862]88 'posix',
[d53af3c8]89 'riff',
[5fd05862]90 'scsi',
91 'sif',
[b279899]92 'tbarcfg',
[5fd05862]93 'trackmod',
94 'untar',
95 'uri',
96
97 'bithenge',
[4645b2c]98 'congfx',
[5fd05862]99 'drv',
100 'ext4',
[ee2f0beb]101 'gfxfont',
[0576df9]102 'gfximage',
[5fd05862]103 'hound',
[4645b2c]104 'ipcgfx',
[d8e2485]105 'memgfx',
[5fd05862]106 'nic',
107 'usb',
108 'usbdev',
109 'usbhid',
110 'usbhost',
111 'usbvirt',
112 'virtio',
113
[2791fbb7]114 'ata',
[5fd05862]115 'ieee80211',
[973efd36]116 'ddev',
[5b19d80]117 'dispcfg',
[973efd36]118 'display',
[0761448]119 'wndmgt',
[4645b2c]120
[f80690a]121 'ui',
[5fd05862]122]
123
124# Generated list of include directory paths
125include_paths = []
126
127# Generated list of test sources
128testfiles = []
129
[5852a5a]130# Text of the install script.
[7749646]131uspace_lib_devel_install_script_text = []
[5852a5a]132
[5fd05862]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)
[00e6288]187 _sdir = meson.current_source_dir() / l / 'include'
[5fd05862]188
[7749646]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)
[5fd05862]191 endif
[00e6288]192
193 exported_devel_files += ['include', _sdir, 'lib' + l]
[5fd05862]194 else
195 includes += include_directories(l)
[d63c842]196
[7749646]197 if installed_libs.contains(l)
[d63c842]198 _sdir = meson.current_source_dir() / l
[7749646]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)
[d63c842]201 endif
[5fd05862]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
[68b892a]242 _libname = 'lib' + l + '.so.' + version.split('.')[0]
243
[5fd05862]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,
[63660a3]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,
[5fd05862]252 version: version,
253 build_by_default: true,
254 )
255
[68b892a]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
[5fd05862]265 if disassemble
[68b892a]266 _disasm = custom_target('lib' + l + '.disasm',
[5fd05862]267 command: [ objdump, '-S', '@INPUT@' ],
268 input: _shared_lib,
269 output: 'lib' + l + '.disasm',
270 capture: true,
271 build_by_default: true,
272 )
[68b892a]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
[5fd05862]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,
[63660a3]294 c_args: arch_uspace_c_args + c_args,
295 cpp_args: arch_uspace_c_args + c_args,
[5fd05862]296 )
297
[68b892a]298 if install_static_lib
299 install_files += [[ 'lib', _static_lib.full_path(), 'lib' + l + '.a' ]]
300 install_deps += [ _static_lib ]
301 endif
302
[00e6288]303 exported_devel_files += ['staticlib', _static_lib, 'lib' + l + '.a']
304
[5fd05862]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') ],
[71069a9]384 link_whole: libstartfiles,
[63660a3]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,
[740e952]388 build_by_default: true,
[5fd05862]389 )
390
[68b892a]391 install_files += [[ 'test', _bin.full_path(), _test_binname ]]
392 install_deps += [ _bin ]
393
[5fd05862]394 if disassemble
[68b892a]395 _disasm = custom_target(_test_binname + '.disasm',
[5fd05862]396 command: [ objdump, '-S', '@INPUT@' ],
397 input: _bin,
398 output: _test_binname + '.disasm',
399 capture: true,
[740e952]400 build_by_default: true,
[5fd05862]401 )
[68b892a]402
[740e952]403 if install_debug_files
404 install_files += [[ 'debug/test', _disasm.full_path(), _test_binname + '.disasm' ]]
405 install_deps += [ _disasm ]
406 endif
[5fd05862]407 endif
408endforeach
Note: See TracBrowser for help on using the repository browser.