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