Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-gpio-monitor', |
| 3 | 'cpp', |
| 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Patrick Williams | ee1663c | 2023-07-12 11:15:43 -0500 | [diff] [blame] | 7 | 'cpp_std=c++23', |
Brandon Wyman | ca2637e | 2021-03-04 12:41:21 -0600 | [diff] [blame] | 8 | 'buildtype=debugoptimized' |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 9 | ], |
| 10 | license: 'Apache-2.0', |
| 11 | version: '1.0', |
Patrick Williams | ee1663c | 2023-07-12 11:15:43 -0500 | [diff] [blame] | 12 | meson_version: '>=1.1.1', |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 13 | ) |
| 14 | |
Patrick Williams | 0172969 | 2023-06-01 09:11:32 -0500 | [diff] [blame] | 15 | cxx = meson.get_compiler('cpp') |
| 16 | |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 17 | libevdev = dependency('libevdev') |
| 18 | libsystemd = dependency('libsystemd') |
Vijay Khemka | 939a643 | 2019-10-09 17:45:45 -0700 | [diff] [blame] | 19 | libgpiod = dependency('libgpiod') |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 20 | phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') |
| 21 | phosphor_logging = dependency('phosphor-logging') |
| 22 | sdbusplus = dependency('sdbusplus') |
Brad Bishop | 26373ab | 2019-09-19 17:18:57 -0400 | [diff] [blame] | 23 | systemd = dependency('systemd') |
| 24 | |
Patrick Williams | ccfea22 | 2023-12-07 14:36:44 -0600 | [diff] [blame] | 25 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
Patrick Williams | 0172969 | 2023-06-01 09:11:32 -0500 | [diff] [blame] | 26 | |
| 27 | if cxx.has_header('CLI/CLI.hpp') |
| 28 | cli11_dep = declare_dependency() |
| 29 | else |
| 30 | cli11_dep = dependency('CLI11') |
| 31 | endif |
| 32 | |
Vijay Khemka | 939a643 | 2019-10-09 17:45:45 -0700 | [diff] [blame] | 33 | boost_args = ['-DBOOST_ASIO_DISABLE_THREADS', |
| 34 | '-DBOOST_ERROR_CODE_HEADER_ONLY', |
| 35 | '-DBOOST_SYSTEM_NO_DEPRECATED'] |
| 36 | |
Konstantin Aladyshev | 9f8459a | 2024-04-22 17:56:53 +0300 | [diff] [blame] | 37 | boost_dep = dependency('boost') |
| 38 | |
Patrick Williams | 0c60faa | 2023-04-12 08:05:56 -0500 | [diff] [blame] | 39 | systemd_system_unit_dir = systemd.get_variable( |
Brad Bishop | 26373ab | 2019-09-19 17:18:57 -0400 | [diff] [blame] | 40 | 'systemdsystemunitdir', |
Patrick Williams | 0c60faa | 2023-04-12 08:05:56 -0500 | [diff] [blame] | 41 | pkgconfig_define: ['prefix', get_option('prefix')]) |
Brad Bishop | 26373ab | 2019-09-19 17:18:57 -0400 | [diff] [blame] | 42 | |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 43 | fs = import('fs') |
| 44 | fs.copyfile( |
| 45 | 'phosphor-gpio-monitor@.service', |
Brad Bishop | 26373ab | 2019-09-19 17:18:57 -0400 | [diff] [blame] | 46 | install: true, |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 47 | install_dir: systemd_system_unit_dir |
Brad Bishop | 26373ab | 2019-09-19 17:18:57 -0400 | [diff] [blame] | 48 | ) |
| 49 | |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 50 | fs.copyfile( |
| 51 | 'phosphor-multi-gpio-monitor.service', |
Vijay Khemka | d34bd96 | 2019-10-29 12:28:07 -0700 | [diff] [blame] | 52 | install: true, |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 53 | install_dir: systemd_system_unit_dir |
Vijay Khemka | d34bd96 | 2019-10-29 12:28:07 -0700 | [diff] [blame] | 54 | ) |
| 55 | |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 56 | fs.copyfile( |
Patrick Rudolph | 46a9a5b | 2023-08-10 18:32:05 +0200 | [diff] [blame] | 57 | 'phosphor-multi-gpio-presence.service', |
| 58 | install: true, |
| 59 | install_dir: systemd_system_unit_dir |
| 60 | ) |
| 61 | |
| 62 | fs.copyfile( |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 63 | 'phosphor-gpio-presence@.service', |
Brad Bishop | 26373ab | 2019-09-19 17:18:57 -0400 | [diff] [blame] | 64 | install: true, |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 65 | install_dir: systemd_system_unit_dir |
Brad Bishop | 26373ab | 2019-09-19 17:18:57 -0400 | [diff] [blame] | 66 | ) |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 67 | |
Alvin Wang | 58dc277 | 2019-11-06 13:35:13 +0800 | [diff] [blame] | 68 | udev = dependency('udev') |
| 69 | udev_rules_dir = join_paths( |
Patrick Williams | 0c60faa | 2023-04-12 08:05:56 -0500 | [diff] [blame] | 70 | udev.get_variable( |
Alvin Wang | 58dc277 | 2019-11-06 13:35:13 +0800 | [diff] [blame] | 71 | 'udevdir', |
Patrick Williams | 0c60faa | 2023-04-12 08:05:56 -0500 | [diff] [blame] | 72 | pkgconfig_define: ['prefix', get_option('prefix')], |
Alvin Wang | 58dc277 | 2019-11-06 13:35:13 +0800 | [diff] [blame] | 73 | ), |
| 74 | 'rules.d', |
| 75 | ) |
| 76 | |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 77 | fs.copyfile( |
| 78 | '99-gpio-keys.rules', |
Alvin Wang | 58dc277 | 2019-11-06 13:35:13 +0800 | [diff] [blame] | 79 | install: true, |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 80 | install_dir: udev_rules_dir |
Alvin Wang | 58dc277 | 2019-11-06 13:35:13 +0800 | [diff] [blame] | 81 | ) |
| 82 | |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 83 | fs.copyfile( |
| 84 | 'phosphor-multi-gpio-monitor.json', |
Vijay Khemka | d34bd96 | 2019-10-29 12:28:07 -0700 | [diff] [blame] | 85 | install: true, |
George Liu | 1c0e4ea | 2023-08-03 11:11:13 +0800 | [diff] [blame] | 86 | install_dir: get_option('datadir') / 'phosphor-gpio-monitor' |
Vijay Khemka | d34bd96 | 2019-10-29 12:28:07 -0700 | [diff] [blame] | 87 | ) |
| 88 | |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 89 | libevdev_o = static_library( |
| 90 | 'libevdev_o', |
| 91 | 'evdev.cpp', |
| 92 | dependencies: [ |
| 93 | libevdev, |
| 94 | phosphor_dbus_interfaces, |
| 95 | phosphor_logging, |
| 96 | sdbusplus, |
| 97 | ] |
| 98 | ) |
| 99 | |
| 100 | libmonitor_o = static_library( |
| 101 | 'libmonitor_o', |
| 102 | 'monitor.cpp', |
| 103 | dependencies: [ |
| 104 | libevdev, |
| 105 | libsystemd, |
| 106 | phosphor_logging, |
| 107 | ], |
| 108 | link_with: [ |
| 109 | libevdev_o, |
| 110 | ], |
| 111 | ) |
| 112 | |
| 113 | phosphor_gpio_monitor = executable( |
| 114 | 'phosphor-gpio-monitor', |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 115 | 'mainapp.cpp', |
| 116 | dependencies: [ |
Patrick Williams | 82b8195 | 2023-08-09 11:10:25 -0500 | [diff] [blame] | 117 | cli11_dep, |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 118 | libevdev, |
| 119 | libsystemd, |
| 120 | phosphor_logging, |
| 121 | ], |
| 122 | install: true, |
| 123 | link_with: [ |
| 124 | libevdev_o, |
| 125 | libmonitor_o, |
| 126 | ], |
| 127 | ) |
| 128 | |
Vijay Khemka | 939a643 | 2019-10-09 17:45:45 -0700 | [diff] [blame] | 129 | executable( |
| 130 | 'phosphor-multi-gpio-monitor', |
| 131 | 'gpioMonMain.cpp', |
| 132 | 'gpioMon.cpp', |
| 133 | dependencies: [ |
Patrick Williams | 0172969 | 2023-06-01 09:11:32 -0500 | [diff] [blame] | 134 | cli11_dep, |
| 135 | libgpiod, |
| 136 | nlohmann_json_dep, |
Patrick Rudolph | 46a9a5b | 2023-08-10 18:32:05 +0200 | [diff] [blame] | 137 | phosphor_dbus_interfaces, |
Vijay Khemka | 939a643 | 2019-10-09 17:45:45 -0700 | [diff] [blame] | 138 | phosphor_logging, |
| 139 | sdbusplus, |
Konstantin Aladyshev | 9f8459a | 2024-04-22 17:56:53 +0300 | [diff] [blame] | 140 | boost_dep |
Vijay Khemka | 939a643 | 2019-10-09 17:45:45 -0700 | [diff] [blame] | 141 | ], |
| 142 | cpp_args: boost_args, |
| 143 | install: true, |
| 144 | ) |
| 145 | |
Brad Bishop | 2d66b51 | 2019-09-19 16:36:47 -0400 | [diff] [blame] | 146 | subdir('presence') |
Patrick Rudolph | 46a9a5b | 2023-08-10 18:32:05 +0200 | [diff] [blame] | 147 | subdir('multi-presence') |
George Liu | bf05528 | 2023-08-03 14:51:31 +0800 | [diff] [blame] | 148 | |
| 149 | build_tests = get_option('tests') |
| 150 | if build_tests.allowed() |
| 151 | subdir('test') |
| 152 | endif |