George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-buttons', 'cpp', |
| 3 | version: '1.0.0', |
Patrick Williams | 10bc3ae | 2023-07-12 11:15:26 -0500 | [diff] [blame] | 4 | meson_version: '>=1.1.1', |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 5 | default_options: [ |
| 6 | 'warning_level=3', |
| 7 | 'werror=true', |
Patrick Williams | 10bc3ae | 2023-07-12 11:15:26 -0500 | [diff] [blame] | 8 | 'cpp_std=c++23', |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 9 | ] |
| 10 | ) |
| 11 | |
Rush Chen | 31ce375 | 2024-11-08 14:57:27 +0800 | [diff] [blame] | 12 | host_instances = get_option('host-instances') |
| 13 | formatted_instances = host_instances.replace(' ', ', ') |
| 14 | |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 15 | conf_data = configuration_data() |
Rush Chen | 31ce375 | 2024-11-08 14:57:27 +0800 | [diff] [blame] | 16 | conf_data.set('INSTANCES',formatted_instances) |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 17 | conf_data.set_quoted('ID_LED_GROUP', get_option('id-led-group')) |
Matt Spinler | 1a309f7 | 2023-04-04 13:12:19 -0500 | [diff] [blame] | 18 | conf_data.set_quoted('POWER_BUTTON_PROFILE', get_option('power-button-profile')) |
George Liu | f756f8b | 2022-07-06 10:44:28 +0800 | [diff] [blame] | 19 | conf_data.set('LONG_PRESS_TIME_MS', get_option('long-press-time-ms')) |
Patrick Williams | 88f2038 | 2023-11-29 06:44:20 -0600 | [diff] [blame] | 20 | conf_data.set('LOOKUP_GPIO_BASE', get_option('lookup-gpio-base').allowed()) |
| 21 | conf_data.set('ENABLE_RESET_BUTTON_DO_WARM_REBOOT', get_option('reset-button-do-warm-reboot').allowed()) |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 22 | |
Delphine CC Chiu | 3e30b7a | 2024-04-12 13:11:42 -0500 | [diff] [blame] | 23 | configure_file( |
| 24 | input: 'meson_config.hpp.in', |
| 25 | output: 'config.hpp', |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 26 | configuration: conf_data |
| 27 | ) |
| 28 | |
Patrick Williams | 7824da4 | 2023-12-07 17:24:40 -0600 | [diff] [blame] | 29 | gpioplus_dep = dependency('gpioplus') |
| 30 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 31 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 32 | phosphor_logging_dep = dependency('phosphor-logging') |
Patrick Williams | 7824da4 | 2023-12-07 17:24:40 -0600 | [diff] [blame] | 33 | sdbusplus_dep = dependency('sdbusplus') |
| 34 | sdeventplus_dep = dependency('sdeventplus') |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 35 | |
| 36 | deps = [ |
| 37 | sdbusplus_dep, |
| 38 | phosphor_dbus_interfaces_dep, |
| 39 | phosphor_logging_dep, |
| 40 | nlohmann_json_dep, |
| 41 | gpioplus_dep, |
Matt Spinler | 9479b06 | 2023-04-04 11:02:39 -0500 | [diff] [blame] | 42 | sdeventplus_dep, |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 43 | ] |
| 44 | |
| 45 | sources_buttons = [ |
| 46 | 'src/gpio.cpp', |
Delphine CC Chiu | ccd7db0 | 2023-02-09 14:48:53 +0800 | [diff] [blame] | 47 | 'src/cpld.cpp', |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 48 | 'src/hostSelector_switch.cpp', |
Naveen Moses | a6d4e65 | 2022-04-13 19:27:25 +0530 | [diff] [blame] | 49 | 'src/debugHostSelector_button.cpp', |
Naveen Moses | d219fa3 | 2022-07-20 00:01:46 +0530 | [diff] [blame] | 50 | 'src/serial_uart_mux.cpp', |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 51 | 'src/id_button.cpp', |
| 52 | 'src/main.cpp', |
| 53 | 'src/power_button.cpp', |
| 54 | 'src/reset_button.cpp', |
| 55 | ] |
| 56 | |
| 57 | sources_handler = [ |
| 58 | 'src/button_handler_main.cpp', |
| 59 | 'src/button_handler.cpp', |
Matt Spinler | 1a309f7 | 2023-04-04 13:12:19 -0500 | [diff] [blame] | 60 | 'src/host_then_chassis_poweroff.cpp', |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 61 | ] |
| 62 | |
| 63 | executable( |
| 64 | 'buttons', |
| 65 | sources_buttons, |
| 66 | implicit_include_directories: true, |
| 67 | include_directories: ['inc'], |
| 68 | dependencies: deps, |
| 69 | install: true, |
| 70 | install_dir: get_option('bindir') |
| 71 | ) |
| 72 | |
| 73 | executable( |
| 74 | 'button-handler', |
| 75 | sources_handler, |
| 76 | implicit_include_directories: true, |
| 77 | include_directories: ['inc'], |
| 78 | dependencies: deps, |
| 79 | install: true, |
| 80 | install_dir: get_option('bindir') |
| 81 | ) |
| 82 | |
| 83 | systemd = dependency('systemd') |
| 84 | systemd_system_unit_dir = systemd.get_variable( |
Patrick Williams | 06b1060 | 2023-04-12 08:01:05 -0500 | [diff] [blame] | 85 | 'systemdsystemunitdir', |
George Liu | d6a1bae | 2022-06-20 13:47:31 +0800 | [diff] [blame] | 86 | pkgconfig_define: ['prefix', get_option('prefix')]) |
| 87 | |
George Liu | 70a0dc8 | 2023-08-16 15:12:28 +0800 | [diff] [blame] | 88 | fs = import('fs') |
| 89 | fs.copyfile( |
| 90 | 'service_files/phosphor-button-handler.service', |
| 91 | install: true, |
| 92 | install_dir: systemd_system_unit_dir |
| 93 | ) |
| 94 | fs.copyfile( |
| 95 | 'service_files/xyz.openbmc_project.Chassis.Buttons.service', |
| 96 | install: true, |
| 97 | install_dir: systemd_system_unit_dir |
| 98 | ) |