George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-buttons', 'cpp', |
| 3 | version: '1.0.0', |
| 4 | meson_version: '>=0.58.0', |
| 5 | default_options: [ |
| 6 | 'warning_level=3', |
| 7 | 'werror=true', |
| 8 | 'cpp_std=c++20', |
| 9 | ] |
| 10 | ) |
| 11 | |
| 12 | conf_data = configuration_data() |
Naveen Moses | a6d4e65 | 2022-04-13 19:27:25 +0530 | [diff] [blame] | 13 | conf_data.set_quoted('POWER_DBUS_OBJECT_NAME', |
| 14 | '/xyz/openbmc_project/Chassis/Buttons/Power0') |
| 15 | conf_data.set_quoted('RESET_DBUS_OBJECT_NAME', |
| 16 | '/xyz/openbmc_project/Chassis/Buttons/Reset0') |
| 17 | conf_data.set_quoted('ID_DBUS_OBJECT_NAME', |
| 18 | '/xyz/openbmc_project/Chassis/Buttons/ID0') |
| 19 | conf_data.set_quoted('HS_DBUS_OBJECT_NAME', |
| 20 | '/xyz/openbmc_project/Chassis/Buttons/HostSelector') |
| 21 | conf_data.set_quoted('DBG_HS_DBUS_OBJECT_NAME', |
| 22 | '/xyz/openbmc_project/Chassis/Buttons/DebugHostSelector') |
Naveen Moses | d219fa3 | 2022-07-20 00:01:46 +0530 | [diff] [blame] | 23 | conf_data.set_quoted('SERIAL_CONSOLE_MUX_DBUS_OBJECT_NAME', |
| 24 | '/xyz/openbmc_project/Chassis/Buttons/SerialUartMux') |
George Liu | ba33275 | 2022-07-07 13:31:40 +0800 | [diff] [blame] | 25 | conf_data.set_quoted('GPIO_BASE_LABEL_NAME', '1e780000.gpio') |
Naveen Moses | a6d4e65 | 2022-04-13 19:27:25 +0530 | [diff] [blame] | 26 | conf_data.set_quoted('CHASSIS_STATE_OBJECT_NAME', |
| 27 | '/xyz/openbmc_project/state/chassis') |
| 28 | conf_data.set_quoted('CHASSISSYSTEM_STATE_OBJECT_NAME', |
| 29 | '/xyz/openbmc_project/state/chassis_system') |
| 30 | conf_data.set_quoted('HOST_STATE_OBJECT_NAME', |
| 31 | '/xyz/openbmc_project/state/host') |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 32 | conf_data.set_quoted('ID_LED_GROUP', get_option('id-led-group')) |
| 33 | |
George Liu | f756f8b | 2022-07-06 10:44:28 +0800 | [diff] [blame] | 34 | conf_data.set('LONG_PRESS_TIME_MS', get_option('long-press-time-ms')) |
George Liu | ba33275 | 2022-07-07 13:31:40 +0800 | [diff] [blame] | 35 | conf_data.set('LOOKUP_GPIO_BASE', get_option('lookup-gpio-base').enabled()) |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 36 | |
| 37 | configure_file(output: 'config.h', |
| 38 | configuration: conf_data |
| 39 | ) |
| 40 | |
| 41 | sdbusplus_dep = dependency('sdbusplus') |
| 42 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 43 | phosphor_logging_dep = dependency('phosphor-logging') |
| 44 | gpioplus_dep = dependency('gpioplus') |
| 45 | |
| 46 | cpp = meson.get_compiler('cpp') |
| 47 | if cpp.has_header_symbol( |
| 48 | 'nlohmann/json.hpp', |
| 49 | 'nlohmann::json::string_t', |
| 50 | required:false) |
| 51 | nlohmann_json_dep = declare_dependency() |
| 52 | else |
| 53 | nlohmann_json_dep = dependency('nlohmann-json') |
| 54 | endif |
| 55 | |
| 56 | deps = [ |
| 57 | sdbusplus_dep, |
| 58 | phosphor_dbus_interfaces_dep, |
| 59 | phosphor_logging_dep, |
| 60 | nlohmann_json_dep, |
| 61 | gpioplus_dep, |
| 62 | ] |
| 63 | |
| 64 | sources_buttons = [ |
| 65 | 'src/gpio.cpp', |
| 66 | 'src/hostSelector_switch.cpp', |
Naveen Moses | a6d4e65 | 2022-04-13 19:27:25 +0530 | [diff] [blame] | 67 | 'src/debugHostSelector_button.cpp', |
Naveen Moses | d219fa3 | 2022-07-20 00:01:46 +0530 | [diff] [blame] | 68 | 'src/serial_uart_mux.cpp', |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 69 | 'src/id_button.cpp', |
| 70 | 'src/main.cpp', |
| 71 | 'src/power_button.cpp', |
| 72 | 'src/reset_button.cpp', |
| 73 | ] |
| 74 | |
| 75 | sources_handler = [ |
| 76 | 'src/button_handler_main.cpp', |
| 77 | 'src/button_handler.cpp', |
| 78 | ] |
| 79 | |
| 80 | executable( |
| 81 | 'buttons', |
| 82 | sources_buttons, |
| 83 | implicit_include_directories: true, |
| 84 | include_directories: ['inc'], |
| 85 | dependencies: deps, |
| 86 | install: true, |
| 87 | install_dir: get_option('bindir') |
| 88 | ) |
| 89 | |
| 90 | executable( |
| 91 | 'button-handler', |
| 92 | sources_handler, |
| 93 | implicit_include_directories: true, |
| 94 | include_directories: ['inc'], |
| 95 | dependencies: deps, |
| 96 | install: true, |
| 97 | install_dir: get_option('bindir') |
| 98 | ) |
| 99 | |
| 100 | systemd = dependency('systemd') |
| 101 | systemd_system_unit_dir = systemd.get_variable( |
| 102 | pkgconfig: 'systemdsystemunitdir', |
| 103 | pkgconfig_define: ['prefix', get_option('prefix')]) |
| 104 | |
| 105 | configure_file(input: 'service_files/phosphor-button-handler.service', |
| 106 | output: 'phosphor-button-handler.service', |
| 107 | copy: true, |
| 108 | install_dir: systemd_system_unit_dir) |
| 109 | |
| 110 | configure_file(input: 'service_files/xyz.openbmc_project.Chassis.Buttons.service', |
| 111 | output: 'xyz.openbmc_project.Chassis.Buttons.service', |
| 112 | copy: true, |
| 113 | install_dir: systemd_system_unit_dir) |