2eba85c8b3c5b987772cd76272e4e3cd795fd22f
[apps/camera-gstreamer.git] / app / meson.build
1 cpp = meson.get_compiler('cpp')
2 dep_wayland_client = dependency('wayland-client', version: '>= 1.20.0')
3
4 dep_wp = dependency('wayland-protocols', version: '>= 1.24')
5 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
6
7 grpcpp_reflection_dep = cpp.find_library('grpc++_reflection')
8 protoc = find_program('protoc')
9 grpc_cpp = find_program('grpc_cpp_plugin')
10
11 dep_scanner = dependency('wayland-scanner')
12 prog_scanner = find_program('wayland-scanner')
13
14 protoc_gen = generator(protoc, \
15                        output : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
16                        arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/protocol',
17                          '--cpp_out=@BUILD_DIR@',
18                          '@INPUT@'])
19
20 generated_protoc_sources = protoc_gen.process('protocol/agl_shell.proto')
21
22 grpc_gen = generator(protoc, \
23                      output : ['@BASENAME@.grpc.pb.cc', '@BASENAME@.grpc.pb.h'],
24                      arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/protocol',
25                        '--grpc_out=@BUILD_DIR@',
26                        '--plugin=protoc-gen-grpc=' + grpc_cpp.path(),
27                        '@INPUT@'])
28
29 generated_grpc_sources = grpc_gen.process('protocol/agl_shell.proto')
30
31 grpc_deps = [
32     dependency('protobuf'),
33     dependency('grpc'),
34     dependency('grpc++'),
35     grpcpp_reflection_dep,
36 ]
37
38
39 protocols = [
40         [ 'xdg-shell', 'stable' ],
41 ]
42
43 foreach proto: protocols
44         proto_name = proto[0]
45         if proto[1] == 'internal'
46                 base_file = proto_name
47                 xml_path = '@0@.xml'.format(proto_name)
48         elif proto[1] == 'stable'
49                 base_file = proto_name
50                 xml_path = '@0@/stable/@1@/@1@.xml'.format(dir_wp_base, base_file)
51         else
52                 base_file = '@0@-unstable-@1@'.format(proto_name, proto[1])
53                 xml_path = '@0@/unstable/@1@/@2@.xml'.format(dir_wp_base, proto_name, base_file)
54         endif
55
56         foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
57                 if output_type == 'client-header'
58                         output_file = '@0@-client-protocol.h'.format(base_file)
59                 elif output_type == 'server-header'
60                         output_file = '@0@-server-protocol.h'.format(base_file)
61                 else
62                         output_file = '@0@-protocol.c'.format(base_file)
63                         if dep_scanner.version().version_compare('< 1.14.91')
64                                 output_type = 'code'
65                         endif
66                 endif
67
68                 var_name = output_file.underscorify()
69                 target = custom_target(
70                         '@0@ @1@'.format(base_file, output_type),
71                         command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
72                         input: xml_path,
73                         output: output_file,
74                 )
75
76                 set_variable(var_name, target)
77         endforeach
78 endforeach
79
80 depnames_gstreamer = [
81         'gstreamer-1.0', 'gstreamer-plugins-bad-1.0', 'gstreamer-wayland-1.0',
82         'gstreamer-video-1.0', 'gstreamer-plugins-base-1.0',
83 ]
84
85 deps_gstreamer = []
86 foreach depname : depnames_gstreamer
87         dep = dependency(depname, required: false)
88         if not dep.found()
89                 error('Required @0@ which was not found. '.format(depname) + user_hint)
90         endif
91         deps_gstreamer += dep
92 endforeach
93
94
95 camera_gstreamer_dep = [
96     dep_wayland_client,
97     deps_gstreamer,
98     grpc_deps
99 ]
100
101 camera_gstreamer_src_headers = [
102   xdg_shell_client_protocol_h,
103   'utils.h',
104   'AglShellGrpcClient.h',
105 ]
106
107 camera_gstreamer_src = [
108   xdg_shell_protocol_c,
109   'utils.cpp',
110   'AglShellGrpcClient.cpp',
111   'main.cpp',
112   generated_protoc_sources,
113   generated_grpc_sources
114 ]
115
116 install_data('still-image.jpg', install_dir: get_option('datadir') / 'applications/data')
117
118 executable('camera-gstreamer', camera_gstreamer_src, camera_gstreamer_src_headers,
119             dependencies : camera_gstreamer_dep,
120             install: true)