blob: 614351f178a385910af676120070967438e7289c [file] [log] [blame]
Brad Bishop2d66b512019-09-19 16:36:47 -04001project(
2 'phosphor-gpio-monitor',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Patrick Williamsee1663c2023-07-12 11:15:43 -05007 'cpp_std=c++23',
Brandon Wymanca2637e2021-03-04 12:41:21 -06008 'buildtype=debugoptimized'
Brad Bishop2d66b512019-09-19 16:36:47 -04009 ],
10 license: 'Apache-2.0',
11 version: '1.0',
Patrick Williamsee1663c2023-07-12 11:15:43 -050012 meson_version: '>=1.1.1',
Brad Bishop2d66b512019-09-19 16:36:47 -040013)
14
Patrick Williams01729692023-06-01 09:11:32 -050015cxx = meson.get_compiler('cpp')
16
Brad Bishop2d66b512019-09-19 16:36:47 -040017libevdev = dependency('libevdev')
18libsystemd = dependency('libsystemd')
Vijay Khemka939a6432019-10-09 17:45:45 -070019libgpiod = dependency('libgpiod')
Brad Bishop2d66b512019-09-19 16:36:47 -040020phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
21phosphor_logging = dependency('phosphor-logging')
22sdbusplus = dependency('sdbusplus')
Brad Bishop26373ab2019-09-19 17:18:57 -040023systemd = dependency('systemd')
24
Patrick Williamsccfea222023-12-07 14:36:44 -060025nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williams01729692023-06-01 09:11:32 -050026
27if cxx.has_header('CLI/CLI.hpp')
28 cli11_dep = declare_dependency()
29else
30 cli11_dep = dependency('CLI11')
31endif
32
Vijay Khemka939a6432019-10-09 17:45:45 -070033boost_args = ['-DBOOST_ASIO_DISABLE_THREADS',
34 '-DBOOST_ERROR_CODE_HEADER_ONLY',
35 '-DBOOST_SYSTEM_NO_DEPRECATED']
36
Patrick Williams0c60faa2023-04-12 08:05:56 -050037systemd_system_unit_dir = systemd.get_variable(
Brad Bishop26373ab2019-09-19 17:18:57 -040038 'systemdsystemunitdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050039 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishop26373ab2019-09-19 17:18:57 -040040
George Liu1c0e4ea2023-08-03 11:11:13 +080041fs = import('fs')
42fs.copyfile(
43 'phosphor-gpio-monitor@.service',
Brad Bishop26373ab2019-09-19 17:18:57 -040044 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080045 install_dir: systemd_system_unit_dir
Brad Bishop26373ab2019-09-19 17:18:57 -040046)
47
George Liu1c0e4ea2023-08-03 11:11:13 +080048fs.copyfile(
49 'phosphor-multi-gpio-monitor.service',
Vijay Khemkad34bd962019-10-29 12:28:07 -070050 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080051 install_dir: systemd_system_unit_dir
Vijay Khemkad34bd962019-10-29 12:28:07 -070052)
53
George Liu1c0e4ea2023-08-03 11:11:13 +080054fs.copyfile(
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +020055 'phosphor-multi-gpio-presence.service',
56 install: true,
57 install_dir: systemd_system_unit_dir
58)
59
60fs.copyfile(
George Liu1c0e4ea2023-08-03 11:11:13 +080061 'phosphor-gpio-presence@.service',
Brad Bishop26373ab2019-09-19 17:18:57 -040062 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080063 install_dir: systemd_system_unit_dir
Brad Bishop26373ab2019-09-19 17:18:57 -040064)
Brad Bishop2d66b512019-09-19 16:36:47 -040065
Alvin Wang58dc2772019-11-06 13:35:13 +080066udev = dependency('udev')
67udev_rules_dir = join_paths(
Patrick Williams0c60faa2023-04-12 08:05:56 -050068 udev.get_variable(
Alvin Wang58dc2772019-11-06 13:35:13 +080069 'udevdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050070 pkgconfig_define: ['prefix', get_option('prefix')],
Alvin Wang58dc2772019-11-06 13:35:13 +080071 ),
72 'rules.d',
73)
74
George Liu1c0e4ea2023-08-03 11:11:13 +080075fs.copyfile(
76 '99-gpio-keys.rules',
Alvin Wang58dc2772019-11-06 13:35:13 +080077 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080078 install_dir: udev_rules_dir
Alvin Wang58dc2772019-11-06 13:35:13 +080079)
80
George Liu1c0e4ea2023-08-03 11:11:13 +080081fs.copyfile(
82 'phosphor-multi-gpio-monitor.json',
Vijay Khemkad34bd962019-10-29 12:28:07 -070083 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080084 install_dir: get_option('datadir') / 'phosphor-gpio-monitor'
Vijay Khemkad34bd962019-10-29 12:28:07 -070085)
86
Brad Bishop2d66b512019-09-19 16:36:47 -040087libevdev_o = static_library(
88 'libevdev_o',
89 'evdev.cpp',
90 dependencies: [
91 libevdev,
92 phosphor_dbus_interfaces,
93 phosphor_logging,
94 sdbusplus,
95 ]
96)
97
98libmonitor_o = static_library(
99 'libmonitor_o',
100 'monitor.cpp',
101 dependencies: [
102 libevdev,
103 libsystemd,
104 phosphor_logging,
105 ],
106 link_with: [
107 libevdev_o,
108 ],
109)
110
111phosphor_gpio_monitor = executable(
112 'phosphor-gpio-monitor',
Brad Bishop2d66b512019-09-19 16:36:47 -0400113 'mainapp.cpp',
114 dependencies: [
Patrick Williams82b81952023-08-09 11:10:25 -0500115 cli11_dep,
Brad Bishop2d66b512019-09-19 16:36:47 -0400116 libevdev,
117 libsystemd,
118 phosphor_logging,
119 ],
120 install: true,
121 link_with: [
122 libevdev_o,
123 libmonitor_o,
124 ],
125)
126
Vijay Khemka939a6432019-10-09 17:45:45 -0700127executable(
128 'phosphor-multi-gpio-monitor',
129 'gpioMonMain.cpp',
130 'gpioMon.cpp',
131 dependencies: [
Patrick Williams01729692023-06-01 09:11:32 -0500132 cli11_dep,
133 libgpiod,
134 nlohmann_json_dep,
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +0200135 phosphor_dbus_interfaces,
Vijay Khemka939a6432019-10-09 17:45:45 -0700136 phosphor_logging,
137 sdbusplus,
Vijay Khemka939a6432019-10-09 17:45:45 -0700138 ],
139 cpp_args: boost_args,
140 install: true,
141)
142
Brad Bishop2d66b512019-09-19 16:36:47 -0400143subdir('presence')
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +0200144subdir('multi-presence')
George Liubf055282023-08-03 14:51:31 +0800145
146build_tests = get_option('tests')
147if build_tests.allowed()
148 subdir('test')
149endif