agl-shell-test: Improve test
[src/agl-compositor.git] / meson.build
1 project('agl-compositor',
2   'c', 'cpp',
3   version: '0.0.19',
4   default_options: [
5     'warning_level=3',
6     'c_std=gnu99',
7   ],
8   meson_version: '>= 0.47',
9   license: 'MIT/Expat',
10 )
11
12 config_h = configuration_data()
13 agl_compositor_version = '0.0.19'
14 libweston_version = 'libweston-9'
15 pkgconfig = import('pkgconfig')
16 env_modmap = ''
17
18 cc = meson.get_compiler('c')
19 cxx = meson.get_compiler('cpp')
20
21 add_project_arguments(
22   cc.get_supported_arguments([
23     '-Wno-missing-field-initializers',
24     '-Wno-unused-parameter',
25     '-Wno-pedantic',
26     '-Wextra',
27     '-Werror'
28   ]),
29   language: 'c'
30 )
31
32 add_project_arguments([
33     '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
34     '-D_GNU_SOURCE',
35     '-D_ALL_SOURCE',
36   ],
37   language: 'c'
38 )
39
40 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
41 foreach func: optional_libc_funcs
42     if cc.has_function(func)
43         add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
44     endif
45 endforeach
46
47 dep_libsystemd = dependency('libsystemd', required: false)
48 dep_libsmack = dependency('libsmack', required: false)
49 dep_scanner = dependency('wayland-scanner', native: true)
50 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
51 dep_wp = dependency('wayland-protocols', version: '>= 1.18')
52 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
53
54 depnames = [
55   'gstreamer-1.0', 'gstreamer-allocators-1.0',
56   'gstreamer-app-1.0', 'gstreamer-video-1.0',
57   'gobject-2.0', 'glib-2.0'
58 ]
59
60 deps_remoting = []
61 foreach depname : depnames
62   dep = dependency(depname, required: false)
63   if not dep.found()
64     message('Remoting requires @0@ which was not found. '.format(depname))
65   endif
66   deps_remoting += dep
67 endforeach
68
69
70 # the transmitter plug-in requires waltham but we don't have a cflags or libs
71 # for it so we add waltham depends here. Further more, the output is being
72 # handled by remoting plug-in
73 depnames_waltham = [
74   'waltham'
75 ]
76
77 deps_waltham = []
78 foreach depname : depnames_waltham
79   dep = dependency(depname, required: false)
80   if dep.found()
81     deps_waltham += dep
82   else
83     message('Waltham requires @0@ which was not found. '.format(depname))
84   endif
85 endforeach
86
87 deps_waltham += deps_remoting
88
89 agl_shell_xml = files('protocol/agl-shell.xml')
90 agl_shell_desktop_xml = files('protocol/agl-shell-desktop.xml')
91 agl_screenshooter = files('protocol/agl-screenshooter.xml')
92 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
93
94 protocols = [
95   { 'name': 'agl-shell', 'source': 'internal' },
96   { 'name': 'agl-shell-desktop', 'source': 'internal' },
97   { 'name': 'agl-screenshooter', 'source': 'internal' },
98   { 'name': 'weston-test', 'source': 'internal' },
99   { 'name': 'xdg-shell', 'source': 'wp-stable' },
100   { 'name': 'viewporter', 'source': 'wp-stable' },
101   { 'name': 'xdg-output', 'source': 'unstable', 'version': 'v1' },
102 ]
103
104 foreach proto: protocols
105     proto_name = proto['name']
106     if proto['source'] == 'internal'
107         base_file = proto_name
108         xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
109     elif proto['source'] == 'wp-stable'
110         base_file = proto_name
111         xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
112     else
113         base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
114         xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
115     endif
116
117     foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
118         if output_type == 'client-header'
119             output_file = '@0@-client-protocol.h'.format(base_file)
120         elif output_type == 'server-header'
121             output_file = '@0@-server-protocol.h'.format(base_file)
122         else
123             output_file = '@0@-protocol.c'.format(base_file)
124             if dep_scanner.version().version_compare('< 1.14.91')
125                 output_type = 'code'
126             endif
127         endif
128
129         var_name = output_file.underscorify()
130         target = custom_target(
131             '@0@ @1@'.format(base_file, output_type),
132             command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
133             input: xml_path,
134             output: output_file,
135         )
136
137         set_variable(var_name, target)
138     endforeach
139 endforeach
140
141 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
142 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
143 # path as to allow building and installing the compositor locally
144 prefix_path = get_option('prefix')
145 message('prefix_path ' + prefix_path)
146 if not prefix_path.contains('/usr')
147   additional_include_dir = include_directories(prefix_path + '/' + 'include')
148   local_dep = declare_dependency(include_directories: additional_include_dir)
149 else
150   local_dep = []
151 endif
152
153 dir_data = join_paths(prefix_path, get_option('datadir'))
154 dir_data_agl_compositor = join_paths('agl-compositor', 'protocols')
155 dir_data_pc = join_paths(dir_data, 'pkgconfig')
156 libweston_dep = dependency(libweston_version)
157
158 deps_libweston = [
159   dependency('wayland-server'),
160   libweston_dep,
161   dependency('libweston-desktop-9'),
162   local_dep,
163 ]
164
165 srcs_agl_compositor = [
166         'src/compositor.c',
167         'src/desktop.c',
168         'src/layout.c',
169         'src/policy.c',
170         'src/shell.c',
171         'src/screenshooter.c',
172         'src/input.c',
173         'shared/option-parser.c',
174         'shared/os-compatibility.c',
175         agl_shell_server_protocol_h,
176         agl_shell_desktop_server_protocol_h,
177         agl_screenshooter_server_protocol_h,
178         agl_shell_protocol_c,
179         agl_shell_desktop_protocol_c,
180         agl_screenshooter_protocol_c,
181         xdg_shell_protocol_c,
182 ]
183
184
185 policy_to_install = get_option('policy-default')
186 if policy_to_install == 'auto' or policy_to_install == 'allow-all'
187   srcs_agl_compositor += 'src/policy-default.c'
188   message('Installing allow all policy')
189 elif policy_to_install == 'deny-all'
190   srcs_agl_compositor += 'src/policy-deny.c'
191   message('Installing deny all policy')
192 elif policy_to_install == 'rba'
193   srcs_agl_compositor += ['src/policy-rba.c', 'src/rba_adapter.cpp']
194   deps_libweston += dependency('librba')
195   message('Installing rba policy')
196 endif
197
198
199 # From meson documentation:
200 # In order to look for headers in a specific directory you can use args :
201 # '-I/extra/include/dir, but this should only be used in exceptional cases for
202 # includes that can't be detected via pkg-config and passed via dependencies.
203 if libweston_dep.found()
204   if not meson.is_cross_build()
205     if not prefix_path.contains('/usr')
206       dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
207     else
208       dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
209     endif
210   else
211     message('Building with cross environment')
212     dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
213   endif
214
215   # do the test
216   if cc.has_header(dir_path_x11_backend)
217     config_h.set('HAVE_BACKEND_X11', 1)
218   endif
219 endif
220
221 if dep_libsystemd.found()
222   config_h.set('HAVE_SYSTEMD', 1)
223   srcs_agl_compositor += 'src/systemd-notify.c'
224   deps_libweston += dep_libsystemd
225
226   message('Found systemd, enabling notify support')
227 endif
228
229 if deps_remoting.length() == depnames.length()
230   config_h.set('HAVE_REMOTING', 1)
231   message('Found remoting depends, enabling remoting')
232 endif
233
234 if deps_waltham.length() == depnames_waltham.length() + depnames.length()
235   config_h.set('HAVE_WALTHAM', 1)
236   message('Found waltham depends, enabling waltham')
237 endif
238
239 if dep_libsmack.found()
240   config_h.set('HAVE_SMACK', 1)
241   deps_libweston += dep_libsmack
242 endif
243
244 configure_file(output: 'config.h', configuration: config_h)
245
246 libexec_compositor = shared_library(
247         'exec_compositor',
248         sources: srcs_agl_compositor,
249         dependencies: deps_libweston,
250 #install_dir: dir_module_weston,
251         install: true,
252         version: '0.0.0',
253         soversion: 0
254 )
255
256 dep_libexec_compositor = declare_dependency(
257         link_with: libexec_compositor,
258         include_directories: [ include_directories('.') ],
259         dependencies: deps_libweston,
260 )
261
262 exe_agl_compositor = executable(
263         'agl-compositor',
264         'src/main.c',
265         dependencies: dep_libexec_compositor,
266         install: true
267 )
268
269 pkgconfig.generate(
270         filebase: 'agl-compositor-@0@-protocols'.format(agl_compositor_version),
271         name: 'agl-compositor private protocols',
272         version: agl_compositor_version,
273         description: 'agl-compositor protocol files',
274         variables: [
275                 'datarootdir=' + join_paths('${prefix}', get_option('datadir')),
276                 'pkgdatadir=' + join_paths('${pc_sysrootdir}${datarootdir}', dir_data_agl_compositor)
277         ],
278         install_dir: dir_data_pc
279 )
280
281 install_data(
282         [ agl_shell_xml, agl_shell_desktop_xml ],
283         install_dir: join_paths(dir_data, dir_data_agl_compositor)
284 )
285
286 common_inc = [ include_directories('src'), include_directories('.') ]
287 subdir('clients')
288 subdir('tests')