meson.build: Use 0.0.24 as the agl compositor version
[apps/homescreen.git] / homescreen / meson.build
1 cpp = meson.get_compiler('cpp')
2 qt5_dep = dependency('qt5', modules: ['Qml', 'Quick', 'Gui'])
3 dep_wayland_client = dependency('wayland-client', version: '>= 1.20.0')
4 dep_qtappfw = [
5     dependency('qtappfw-weather'),
6     dependency('qtappfw-network'),
7     dependency('qtappfw-bt'),
8     dependency('qtappfw-vehicle-signals'),
9     dependency('qtappfw-applauncher')
10 ]
11
12 grpcpp_reflection_dep = cpp.find_library('grpc++_reflection')
13 protoc = find_program('protoc')
14 grpc_cpp = find_program('grpc_cpp_plugin')
15
16 qt_defines = []
17 qpa_header_path = join_paths(qt5_dep.version(), 'QtGui')
18 qpa_header = join_paths(qpa_header_path, 'qpa/qplatformnativeinterface.h')
19 # we pass this QT_QPA_HEADER straight in the code as there's no easy
20 # way to pass the correct header
21 if cpp.has_header(qpa_header, dependencies : qt5_dep)
22   qt_defines += [ '-DQT_QPA_HEADER=<@0@>'.format(qpa_header) ]
23   message('Found QtGui QPA header in ' + qpa_header_path)
24 endif
25
26 dep_scanner = dependency('wayland-scanner')
27 prog_scanner = find_program('wayland-scanner')
28 agl_compositor_version = '0.0.24'
29 agl_compositor_dep = dependency('agl-compositor-' + agl_compositor_version + '-protocols')
30 dir_agl_compositor_base = agl_compositor_dep.get_variable(pkgconfig: 'pkgdatadir')
31
32 protoc_gen = generator(protoc, \
33                        output : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
34                        arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/proto',
35                          '--cpp_out=@BUILD_DIR@',
36                          '@INPUT@'])
37
38 generated_protoc_sources = protoc_gen.process('proto/agl_shell.proto')
39
40 grpc_gen = generator(protoc, \
41                      output : ['@BASENAME@.grpc.pb.cc', '@BASENAME@.grpc.pb.h'],
42                      arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/proto',
43                        '--grpc_out=@BUILD_DIR@',
44                        '--plugin=protoc-gen-grpc=' + grpc_cpp.path(),
45                        '@INPUT@'])
46 generated_grpc_sources = grpc_gen.process('proto/agl_shell.proto')
47
48 grpc_deps = [
49     dependency('protobuf'),
50     dependency('grpc'),
51     dependency('grpc++'),
52     grpcpp_reflection_dep,
53 ]
54
55
56 homescreen_dep = [
57     qt5_dep,
58     dep_wayland_client,
59     dep_qtappfw,
60     grpc_deps
61 ]
62
63 homescreen_resources = [
64   'qml/images/MediaPlayer/mediaplayer.qrc',
65   'qml/images/MediaMusic/mediamusic.qrc',
66   'qml/images/Weather/weather.qrc',
67   'qml/images/Shortcut/shortcut.qrc',
68   'qml/images/Status/status.qrc',
69   'qml/images/images.qrc',
70   'qml/qml.qrc'
71 ]
72
73 resource_files = qt5.compile_resources(sources: homescreen_resources)
74
75 protocols = [
76         [ 'agl-shell', 'agl-compositor' ],
77 ]
78
79 foreach proto: protocols
80         proto_name = proto[0]
81         if proto[1] == 'agl-compositor'
82                 base_file = proto_name
83                 xml_path = join_paths(dir_agl_compositor_base, '@0@.xml'.format(base_file))
84         endif
85
86         foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
87                 if output_type == 'client-header'
88                         output_file = '@0@-client-protocol.h'.format(base_file)
89                 elif output_type == 'server-header'
90                         output_file = '@0@-server-protocol.h'.format(base_file)
91                 else
92                         output_file = '@0@-protocol.c'.format(base_file)
93                         if dep_scanner.version().version_compare('< 1.14.91')
94                                 output_type = 'code'
95                         endif
96                 endif
97
98                 var_name = output_file.underscorify()
99                 target = custom_target(
100                         '@0@ @1@'.format(base_file, output_type),
101                         command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
102                         input: xml_path,
103                         output: output_file,
104                 )
105                 message('protocol name is ' + var_name)
106                 set_variable(var_name, target)
107         endforeach
108 endforeach
109
110 homescreen_src_headers = [
111   'src/applicationlauncher.h',
112   'src/mastervolume.h',
113   'src/statusbarmodel.h',
114   'src/statusbarserver.h',
115   'src/homescreenhandler.h',
116   'src/AglShellGrpcClient.h',
117 ]
118
119 moc_files = qt5.compile_moc(headers: homescreen_src_headers,
120                             dependencies: qt5_dep)
121
122 homescreen_src = [
123   'src/statusbarserver.cpp',
124   'src/statusbarmodel.cpp',
125   'src/applicationlauncher.cpp',
126   'src/mastervolume.cpp',
127   'src/homescreenhandler.cpp',
128   'src/AglShellGrpcClient.cpp',
129   'src/main.cpp',
130   agl_shell_client_protocol_h,
131   agl_shell_protocol_c,
132   generated_protoc_sources,
133   generated_grpc_sources
134 ]
135
136 executable('homescreen', homescreen_src, resource_files, moc_files,
137             cpp_args: qt_defines,
138             dependencies : homescreen_dep,
139             install: true)