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