source: mainline/uspace/meson.build@ 2fff3c4

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

Convert uspace to meson

  • Property mode set to 100644
File size: 4.7 KB
Line 
1# FIXME: somehow disabling link map makes tools/mkext4.py crash
2link_map = true
3disassemble = CONFIG_LINE_DEBUG
4install_nonessential_data = not CONFIG_BAREBONE
5# TODO: Allow installing debug files.
6# This is currently disabled due to boot image size restrictions.
7install_debug_files = false
8
9rd_essential = []
10
11subdir('lib')
12subdir('app')
13subdir('srv')
14subdir('drv')
15
16init = [
17 'app/init',
18 'srv/bd/rd',
19 'srv/fs/' + RDFMT,
20 'srv/loader',
21 'srv/locsrv',
22 'srv/logger',
23 'srv/ns',
24 'srv/vfs',
25]
26
27rd_essential += init
28
29rd_essential += [
30 'app/bdsh',
31 'app/getterm',
32 'app/kio',
33
34 'srv/devman',
35 'srv/fs/locfs',
36 'srv/hid/input',
37 'srv/hid/output',
38 'srv/hid/compositor',
39 'srv/hid/console',
40 'srv/klog',
41
42 'drv/root/root',
43 'drv/root/virt',
44 'drv/fb/kfb',
45]
46
47if CONFIG_FB
48 rd_essential += [
49 'app/vlaunch',
50 'app/vterm',
51 ]
52endif
53
54dirs = []
55
56foreach app : apps
57 dirs += {
58 'subdir': join_paths('app', app),
59 'installdir': 'app',
60 }
61endforeach
62
63foreach srv : srvs
64 _dirname = run_command(dirname, srv, check: true).stdout().strip()
65
66 dirs += {
67 'subdir': join_paths('srv', srv),
68 'installdir': _dirname == '.' ? 'srv' : ('srv' / _dirname),
69 }
70endforeach
71
72foreach drv : drvs
73 _basename = run_command(basename, drv, check: true).stdout().strip()
74 _dirname = run_command(dirname, drv, check: true).stdout().strip()
75
76 dirs += {
77 'subdir': 'drv' / drv,
78 'installdir': 'drv' / _basename,
79 }
80
81 # Install driver metadata.
82 if not CONFIG_BAREBONE or rd_essential.contains('drv' / drv)
83 install_data('drv' / drv / _basename + '.ma', install_dir: 'drv' / _basename)
84 endif
85endforeach
86
87bin_targets = []
88
89foreach appdirs : dirs
90 src = []
91 test_src = []
92 includes = []
93 deps = []
94 c_args = []
95 link_args = []
96 language = 'c'
97
98 subdir(appdirs.get('subdir'))
99
100 dir = appdirs.get('subdir')
101 installdir = appdirs.get('installdir')
102
103 install = not CONFIG_BAREBONE or rd_essential.contains(dir)
104
105 # basename/dirname will be is useful later.
106 _basename = run_command(basename, dir, check: true).stdout().strip()
107 _dirname = run_command(dirname, dir, check: true).stdout().strip()
108
109 # Extra linker flags
110
111 # TODO: let meson do this on install instead, so that disassembly works
112 if CONFIG_STRIP_BINARIES
113 link_args += [ '-s' ]
114 endif
115
116 # Init binaries need to always be linked statically.
117 static_build = (not CONFIG_USE_SHARED_LIBS) or init.contains(dir)
118
119 # Add the corresponding standard libraries to dependencies.
120
121 deps += [ 'c' ]
122
123 if language == 'cpp'
124 deps += 'cpp'
125 endif
126
127 # Binaries in the 'drv' subdirectory link libdrv by default.
128
129 is_drv = (dir.split('/')[0] == 'drv')
130
131 if is_drv
132 deps += [ 'drv' ]
133 endif
134
135 # Convert strings to dependency objects
136
137 _deps = []
138 foreach s : deps
139 _deps += get_variable('lib' + s).get(static_build ? 'static' : 'any')
140 endforeach
141
142 # Build executable
143
144 if src.length() > 0
145 bin_targets += {
146 'src': src,
147 'dirname': _dirname,
148 'basename': _basename,
149 'install': install,
150 'install_dir': installdir,
151 'includes': includes,
152 'dependencies': _deps,
153 'c_args': c_args,
154 'link_args': link_args + (static_build ? [ '-static' ] : []),
155 }
156 endif
157
158 # Build test executable, if any
159
160 if test_src.length() > 0
161 bin_targets += {
162 'src': test_src,
163 'dirname': _dirname,
164 'basename': 'test-' + installdir.underscorify() + (is_drv ? '' : ('_' + _basename)),
165 'install': install and CONFIG_PCUT_TESTS,
166 'install_dir': 'test',
167 'includes': includes,
168 'dependencies': [ _deps, libpcut.get('any') ],
169 'c_args': c_args,
170 'link_args': link_args,
171 }
172 endif
173endforeach
174
175foreach tst : bin_targets
176 _ldargs = tst.get('link_args')
177 _src = tst.get('src')
178
179 _install_dir = tst.get('install_dir').split('/')
180 _install_dir += tst.get('basename')
181 _install = tst.get('install')
182
183 if _install
184 _install_name = 'install@' + '$'.join(_install_dir)
185 else
186 _install_name = '_'.join(_install_dir)
187 endif
188
189 if _install and install_debug_files
190 _debug_name = 'install@' + '$'.join([ 'debug' ] + _install_dir)
191 else
192 _debug_name = '_'.join(_install_dir)
193 endif
194
195 if link_map
196 # We want linker to generate link map for debugging.
197 _ldargs += [ '-Wl,-Map,' + meson.current_build_dir() / _debug_name + '.map' ]
198 endif
199
200 _bin = executable(_install_name, _src,
201 include_directories: tst.get('includes'),
202 dependencies: tst.get('dependencies'),
203 objects: startfiles,
204 c_args: tst.get('c_args'),
205 link_args: _ldargs,
206 implicit_include_directories: false,
207 install: false,
208 #install_dir: tst.get('install_dir'),
209 build_by_default: true,
210 )
211
212 if disassemble
213 custom_target(_debug_name + '.disasm',
214 command: [ objdump, '-S', '@INPUT@' ],
215 input: _bin,
216 output: _debug_name + '.disasm',
217 capture: true,
218 install: false,
219 #install_dir: 'debug' / tst.get('install_dir'),
220 build_by_default: true,
221 )
222 endif
223endforeach
Note: See TracBrowser for help on using the repository browser.