source: mainline/uspace/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: 4.3 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
9subdir('lib')
10subdir('app')
11subdir('srv')
12subdir('drv')
13
14dirs = []
15
16foreach app : apps
17 dirs += {
18 'subdir': join_paths('app', app),
19 'installdir': 'app',
20 }
21endforeach
22
23foreach srv : srvs
24 _dirname = run_command(dirname, srv, check: true).stdout().strip()
25
26 dirs += {
27 'subdir': join_paths('srv', srv),
28 'installdir': _dirname == '.' ? 'srv' : ('srv' / _dirname),
29 }
30endforeach
31
32foreach drv : drvs
33 _basename = run_command(basename, drv, check: true).stdout().strip()
34 _dirname = run_command(dirname, drv, check: true).stdout().strip()
35
36 dirs += {
37 'subdir': 'drv' / drv,
38 'installdir': 'drv' / _basename,
39 }
40
41 # Install driver metadata.
42 if not CONFIG_BAREBONE or rd_essential.contains('drv' / drv)
43 install_data('drv' / drv / _basename + '.ma', install_dir: 'drv' / _basename)
44 endif
45endforeach
46
47bin_targets = []
48
49foreach appdirs : dirs
50 src = []
51 test_src = []
52 includes = []
53 deps = []
54 c_args = []
55 link_args = []
56 language = 'c'
57
58 subdir(appdirs.get('subdir'))
59
60 dir = appdirs.get('subdir')
61 installdir = appdirs.get('installdir')
62
63 install = not CONFIG_BAREBONE or rd_essential.contains(dir)
64
65 # basename/dirname will be is useful later.
66 _basename = run_command(basename, dir, check: true).stdout().strip()
67 _dirname = run_command(dirname, dir, check: true).stdout().strip()
68
69 # Extra linker flags
70
71 # TODO: let meson do this on install instead, so that disassembly works
72 if CONFIG_STRIP_BINARIES
73 link_args += [ '-s' ]
74 endif
75
76 # Init binaries need to always be linked statically.
77 static_build = (not CONFIG_USE_SHARED_LIBS) or rd_init.contains(dir)
78
79 # Add the corresponding standard libraries to dependencies.
80
81 deps += [ 'c' ]
82
83 if language == 'cpp'
84 deps += 'cpp'
85 endif
86
87 # Binaries in the 'drv' subdirectory link libdrv by default.
88
89 is_drv = (dir.split('/')[0] == 'drv')
90
91 if is_drv
92 deps += [ 'drv' ]
93 endif
94
95 # Convert strings to dependency objects
96
97 _deps = []
98 foreach s : deps
99 _deps += get_variable('lib' + s).get(static_build ? 'static' : 'any')
100 endforeach
101
102 # Build executable
103
104 if src.length() > 0
105 bin_targets += {
106 'src': src,
107 'dirname': _dirname,
108 'basename': _basename,
109 'install': install,
110 'install_dir': installdir,
111 'includes': includes,
112 'dependencies': _deps,
113 'c_args': c_args,
114 'link_args': link_args + (static_build ? [ '-static' ] : []),
115 }
116 endif
117
118 # Build test executable, if any
119
120 if test_src.length() > 0
121 bin_targets += {
122 'src': test_src,
123 'dirname': _dirname,
124 'basename': 'test-' + installdir.underscorify() + (is_drv ? '' : ('_' + _basename)),
125 'install': install and CONFIG_PCUT_TESTS,
126 'install_dir': 'test',
127 'includes': includes,
128 'dependencies': [ _deps, libpcut.get('any') ],
129 'c_args': c_args,
130 'link_args': link_args,
131 }
132 endif
133endforeach
134
135foreach tst : bin_targets
136 _ldargs = tst.get('link_args')
137 _src = tst.get('src')
138
139 _install_dir = tst.get('install_dir').split('/')
140 _install_dir += tst.get('basename')
141 _install = tst.get('install')
142
143 if _install
144 _install_name = 'install@' + '$'.join(_install_dir)
145 else
146 _install_name = '_'.join(_install_dir)
147 endif
148
149 if _install and install_debug_files
150 _debug_name = 'install@' + '$'.join([ 'debug' ] + _install_dir)
151 else
152 _debug_name = '_'.join(_install_dir)
153 endif
154
155 if link_map
156 # We want linker to generate link map for debugging.
157 _ldargs += [ '-Wl,-Map,' + meson.current_build_dir() / _debug_name + '.map' ]
158 endif
159
160 _bin = executable(_install_name, _src,
161 include_directories: tst.get('includes'),
162 dependencies: tst.get('dependencies'),
163 objects: startfiles,
164 c_args: arch_uspace_c_args + tst.get('c_args'),
165 cpp_args: arch_uspace_c_args + tst.get('c_args'),
166 link_args: arch_uspace_c_args + arch_uspace_link_args + _ldargs,
167 implicit_include_directories: false,
168 install: false,
169 #install_dir: tst.get('install_dir'),
170 build_by_default: true,
171 )
172
173 if disassemble
174 custom_target(_debug_name + '.disasm',
175 command: [ objdump, '-S', '@INPUT@' ],
176 input: _bin,
177 output: _debug_name + '.disasm',
178 capture: true,
179 install: false,
180 #install_dir: 'debug' / tst.get('install_dir'),
181 build_by_default: true,
182 )
183 endif
184endforeach
Note: See TracBrowser for help on using the repository browser.