blob: 2d1d1b8dbd70c453c7a70854b8460c96a00b2f09 [file] [log] [blame]
George Liud6a1bae2022-06-20 13:47:31 +08001project(
2 'phosphor-buttons', 'cpp',
3 version: '1.0.0',
Patrick Williams10bc3ae2023-07-12 11:15:26 -05004 meson_version: '>=1.1.1',
George Liud6a1bae2022-06-20 13:47:31 +08005 default_options: [
6 'warning_level=3',
7 'werror=true',
Patrick Williams10bc3ae2023-07-12 11:15:26 -05008 'cpp_std=c++23',
George Liud6a1bae2022-06-20 13:47:31 +08009 ]
10)
11
12conf_data = configuration_data()
Naveen Mosesa6d4e652022-04-13 19:27:25 +053013conf_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')
Naveen Mosesd219fa32022-07-20 00:01:46 +053023conf_data.set_quoted('SERIAL_CONSOLE_MUX_DBUS_OBJECT_NAME',
24 '/xyz/openbmc_project/Chassis/Buttons/SerialUartMux')
George Liuba332752022-07-07 13:31:40 +080025conf_data.set_quoted('GPIO_BASE_LABEL_NAME', '1e780000.gpio')
Naveen Mosesa6d4e652022-04-13 19:27:25 +053026conf_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')
George Liud6a1bae2022-06-20 13:47:31 +080032conf_data.set_quoted('ID_LED_GROUP', get_option('id-led-group'))
33
Matt Spinler1a309f72023-04-04 13:12:19 -050034conf_data.set_quoted('POWER_BUTTON_PROFILE', get_option('power-button-profile'))
35
George Liuf756f8b2022-07-06 10:44:28 +080036conf_data.set('LONG_PRESS_TIME_MS', get_option('long-press-time-ms'))
George Liuba332752022-07-07 13:31:40 +080037conf_data.set('LOOKUP_GPIO_BASE', get_option('lookup-gpio-base').enabled())
George Liud6a1bae2022-06-20 13:47:31 +080038
39configure_file(output: 'config.h',
40 configuration: conf_data
41)
42
43sdbusplus_dep = dependency('sdbusplus')
Matt Spinler9479b062023-04-04 11:02:39 -050044sdeventplus_dep = dependency('sdeventplus')
George Liud6a1bae2022-06-20 13:47:31 +080045phosphor_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,
Matt Spinler9479b062023-04-04 11:02:39 -050065 sdeventplus_dep,
George Liud6a1bae2022-06-20 13:47:31 +080066]
67
68sources_buttons = [
69 'src/gpio.cpp',
Delphine CC Chiuccd7db02023-02-09 14:48:53 +080070 'src/cpld.cpp',
George Liud6a1bae2022-06-20 13:47:31 +080071 'src/hostSelector_switch.cpp',
Naveen Mosesa6d4e652022-04-13 19:27:25 +053072 'src/debugHostSelector_button.cpp',
Naveen Mosesd219fa32022-07-20 00:01:46 +053073 'src/serial_uart_mux.cpp',
George Liud6a1bae2022-06-20 13:47:31 +080074 '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',
Matt Spinler1a309f72023-04-04 13:12:19 -050083 'src/host_then_chassis_poweroff.cpp',
George Liud6a1bae2022-06-20 13:47:31 +080084]
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(
Patrick Williams06b10602023-04-12 08:01:05 -0500108 'systemdsystemunitdir',
George Liud6a1bae2022-06-20 13:47:31 +0800109 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)