blob: dc55722d6d79562ac2e86ea611839c30d8946aea [file] [log] [blame]
George Liud6a1bae2022-06-20 13:47:31 +08001project(
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
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
George Liuf756f8b2022-07-06 10:44:28 +080034conf_data.set('LONG_PRESS_TIME_MS', get_option('long-press-time-ms'))
George Liuba332752022-07-07 13:31:40 +080035conf_data.set('LOOKUP_GPIO_BASE', get_option('lookup-gpio-base').enabled())
George Liud6a1bae2022-06-20 13:47:31 +080036
37configure_file(output: 'config.h',
38 configuration: conf_data
39)
40
41sdbusplus_dep = dependency('sdbusplus')
Matt Spinler9479b062023-04-04 11:02:39 -050042sdeventplus_dep = dependency('sdeventplus')
George Liud6a1bae2022-06-20 13:47:31 +080043phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
44phosphor_logging_dep = dependency('phosphor-logging')
45gpioplus_dep = dependency('gpioplus')
46
47cpp = meson.get_compiler('cpp')
48if cpp.has_header_symbol(
49 'nlohmann/json.hpp',
50 'nlohmann::json::string_t',
51 required:false)
52 nlohmann_json_dep = declare_dependency()
53else
54 nlohmann_json_dep = dependency('nlohmann-json')
55endif
56
57deps = [
58 sdbusplus_dep,
59 phosphor_dbus_interfaces_dep,
60 phosphor_logging_dep,
61 nlohmann_json_dep,
62 gpioplus_dep,
Matt Spinler9479b062023-04-04 11:02:39 -050063 sdeventplus_dep,
George Liud6a1bae2022-06-20 13:47:31 +080064]
65
66sources_buttons = [
67 'src/gpio.cpp',
Delphine CC Chiuccd7db02023-02-09 14:48:53 +080068 'src/cpld.cpp',
George Liud6a1bae2022-06-20 13:47:31 +080069 'src/hostSelector_switch.cpp',
Naveen Mosesa6d4e652022-04-13 19:27:25 +053070 'src/debugHostSelector_button.cpp',
Naveen Mosesd219fa32022-07-20 00:01:46 +053071 'src/serial_uart_mux.cpp',
George Liud6a1bae2022-06-20 13:47:31 +080072 'src/id_button.cpp',
73 'src/main.cpp',
74 'src/power_button.cpp',
75 'src/reset_button.cpp',
76]
77
78sources_handler = [
79 'src/button_handler_main.cpp',
80 'src/button_handler.cpp',
81]
82
83executable(
84 'buttons',
85 sources_buttons,
86 implicit_include_directories: true,
87 include_directories: ['inc'],
88 dependencies: deps,
89 install: true,
90 install_dir: get_option('bindir')
91)
92
93executable(
94 'button-handler',
95 sources_handler,
96 implicit_include_directories: true,
97 include_directories: ['inc'],
98 dependencies: deps,
99 install: true,
100 install_dir: get_option('bindir')
101)
102
103systemd = dependency('systemd')
104systemd_system_unit_dir = systemd.get_variable(
Patrick Williams06b10602023-04-12 08:01:05 -0500105 'systemdsystemunitdir',
George Liud6a1bae2022-06-20 13:47:31 +0800106 pkgconfig_define: ['prefix', get_option('prefix')])
107
108configure_file(input: 'service_files/phosphor-button-handler.service',
109 output: 'phosphor-button-handler.service',
110 copy: true,
111 install_dir: systemd_system_unit_dir)
112
113configure_file(input: 'service_files/xyz.openbmc_project.Chassis.Buttons.service',
114 output: 'xyz.openbmc_project.Chassis.Buttons.service',
115 copy: true,
116 install_dir: systemd_system_unit_dir)