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