blob: 5f7ca535ca4959ea84ec432a20c24c2e8ac8e87d [file] [log] [blame]
George Liud6a1bae2022-06-20 13:47:31 +08001project(
Patrick Williams301edb92025-03-03 11:08:14 -05002 'phosphor-buttons',
3 'cpp',
George Liud6a1bae2022-06-20 13:47:31 +08004 version: '1.0.0',
Patrick Williams10bc3ae2023-07-12 11:15:26 -05005 meson_version: '>=1.1.1',
Patrick Williams301edb92025-03-03 11:08:14 -05006 default_options: ['warning_level=3', 'werror=true', 'cpp_std=c++23'],
George Liud6a1bae2022-06-20 13:47:31 +08007)
8
Rush Chen31ce3752024-11-08 14:57:27 +08009host_instances = get_option('host-instances')
10formatted_instances = host_instances.replace(' ', ', ')
11
George Liud6a1bae2022-06-20 13:47:31 +080012conf_data = configuration_data()
Patrick Williams301edb92025-03-03 11:08:14 -050013conf_data.set('INSTANCES', formatted_instances)
George Liud6a1bae2022-06-20 13:47:31 +080014conf_data.set_quoted('ID_LED_GROUP', get_option('id-led-group'))
Matt Spinler1a309f72023-04-04 13:12:19 -050015conf_data.set_quoted('POWER_BUTTON_PROFILE', get_option('power-button-profile'))
George Liuf756f8b2022-07-06 10:44:28 +080016conf_data.set('LONG_PRESS_TIME_MS', get_option('long-press-time-ms'))
Patrick Williams88f20382023-11-29 06:44:20 -060017conf_data.set('LOOKUP_GPIO_BASE', get_option('lookup-gpio-base').allowed())
Patrick Williams301edb92025-03-03 11:08:14 -050018conf_data.set(
19 'ENABLE_RESET_BUTTON_DO_WARM_REBOOT',
20 get_option('reset-button-do-warm-reboot').allowed(),
21)
George Liud6a1bae2022-06-20 13:47:31 +080022
Delphine CC Chiu3e30b7a2024-04-12 13:11:42 -050023configure_file(
24 input: 'meson_config.hpp.in',
25 output: 'config.hpp',
Patrick Williams301edb92025-03-03 11:08:14 -050026 configuration: conf_data,
George Liud6a1bae2022-06-20 13:47:31 +080027)
28
Patrick Williams7824da42023-12-07 17:24:40 -060029gpioplus_dep = dependency('gpioplus')
30nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
George Liud6a1bae2022-06-20 13:47:31 +080031phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
32phosphor_logging_dep = dependency('phosphor-logging')
Patrick Williams7824da42023-12-07 17:24:40 -060033sdbusplus_dep = dependency('sdbusplus')
34sdeventplus_dep = dependency('sdeventplus')
George Liud6a1bae2022-06-20 13:47:31 +080035
36deps = [
37 sdbusplus_dep,
38 phosphor_dbus_interfaces_dep,
39 phosphor_logging_dep,
40 nlohmann_json_dep,
41 gpioplus_dep,
Matt Spinler9479b062023-04-04 11:02:39 -050042 sdeventplus_dep,
George Liud6a1bae2022-06-20 13:47:31 +080043]
44
45sources_buttons = [
46 'src/gpio.cpp',
Delphine CC Chiuccd7db02023-02-09 14:48:53 +080047 'src/cpld.cpp',
George Liud6a1bae2022-06-20 13:47:31 +080048 'src/hostSelector_switch.cpp',
Naveen Mosesa6d4e652022-04-13 19:27:25 +053049 'src/debugHostSelector_button.cpp',
Naveen Mosesd219fa32022-07-20 00:01:46 +053050 'src/serial_uart_mux.cpp',
George Liud6a1bae2022-06-20 13:47:31 +080051 'src/id_button.cpp',
52 'src/main.cpp',
53 'src/power_button.cpp',
54 'src/reset_button.cpp',
55]
56
57sources_handler = [
58 'src/button_handler_main.cpp',
59 'src/button_handler.cpp',
Matt Spinler1a309f72023-04-04 13:12:19 -050060 'src/host_then_chassis_poweroff.cpp',
George Liud6a1bae2022-06-20 13:47:31 +080061]
62
63executable(
64 'buttons',
65 sources_buttons,
66 implicit_include_directories: true,
67 include_directories: ['inc'],
68 dependencies: deps,
69 install: true,
Patrick Williams301edb92025-03-03 11:08:14 -050070 install_dir: get_option('bindir'),
George Liud6a1bae2022-06-20 13:47:31 +080071)
72
73executable(
74 'button-handler',
75 sources_handler,
76 implicit_include_directories: true,
77 include_directories: ['inc'],
78 dependencies: deps,
79 install: true,
Patrick Williams301edb92025-03-03 11:08:14 -050080 install_dir: get_option('bindir'),
George Liud6a1bae2022-06-20 13:47:31 +080081)
82
83systemd = dependency('systemd')
84systemd_system_unit_dir = systemd.get_variable(
Patrick Williams301edb92025-03-03 11:08:14 -050085 'systemdsystemunitdir',
86 pkgconfig_define: ['prefix', get_option('prefix')],
87)
George Liud6a1bae2022-06-20 13:47:31 +080088
George Liu70a0dc82023-08-16 15:12:28 +080089fs = import('fs')
90fs.copyfile(
91 'service_files/phosphor-button-handler.service',
92 install: true,
Patrick Williams301edb92025-03-03 11:08:14 -050093 install_dir: systemd_system_unit_dir,
George Liu70a0dc82023-08-16 15:12:28 +080094)
95fs.copyfile(
96 'service_files/xyz.openbmc_project.Chassis.Buttons.service',
97 install: true,
Patrick Williams301edb92025-03-03 11:08:14 -050098 install_dir: systemd_system_unit_dir,
George Liu70a0dc82023-08-16 15:12:28 +080099)