source: mainline/uspace/lib/meson.build@ 7b1ae09

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 7b1ae09 was 63660a3, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 6 years ago

shuffle some variables around

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