blob: cd237674cb589f84d87f63c212255911c00cda52 [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()
George Liuba332752022-07-07 13:31:40 +080013conf_data.set_quoted('POWER_DBUS_OBJECT_NAME', '/xyz/openbmc_project/Chassis/Buttons/Power0')
14conf_data.set_quoted('RESET_DBUS_OBJECT_NAME', '/xyz/openbmc_project/Chassis/Buttons/Reset0')
15conf_data.set_quoted('ID_DBUS_OBJECT_NAME', '/xyz/openbmc_project/Chassis/Buttons/ID0')
16conf_data.set_quoted('HS_DBUS_OBJECT_NAME', '/xyz/openbmc_project/Chassis/Buttons/HostSelector')
17conf_data.set_quoted('GPIO_BASE_LABEL_NAME', '1e780000.gpio')
18conf_data.set_quoted('CHASSIS_STATE_OBJECT_NAME', '/xyz/openbmc_project/state/chassis')
19conf_data.set_quoted('CHASSISSYSTEM_STATE_OBJECT_NAME', '/xyz/openbmc_project/state/chassis_system')
20conf_data.set_quoted('HOST_STATE_OBJECT_NAME', '/xyz/openbmc_project/state/host')
George Liud6a1bae2022-06-20 13:47:31 +080021conf_data.set_quoted('ID_LED_GROUP', get_option('id-led-group'))
22
George Liuf756f8b2022-07-06 10:44:28 +080023conf_data.set('LONG_PRESS_TIME_MS', get_option('long-press-time-ms'))
George Liuba332752022-07-07 13:31:40 +080024conf_data.set('LOOKUP_GPIO_BASE', get_option('lookup-gpio-base').enabled())
George Liud6a1bae2022-06-20 13:47:31 +080025
26configure_file(output: 'config.h',
27 configuration: conf_data
28)
29
30sdbusplus_dep = dependency('sdbusplus')
31phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
32phosphor_logging_dep = dependency('phosphor-logging')
33gpioplus_dep = dependency('gpioplus')
34
35cpp = meson.get_compiler('cpp')
36if cpp.has_header_symbol(
37 'nlohmann/json.hpp',
38 'nlohmann::json::string_t',
39 required:false)
40 nlohmann_json_dep = declare_dependency()
41else
42 nlohmann_json_dep = dependency('nlohmann-json')
43endif
44
45deps = [
46 sdbusplus_dep,
47 phosphor_dbus_interfaces_dep,
48 phosphor_logging_dep,
49 nlohmann_json_dep,
50 gpioplus_dep,
51]
52
53sources_buttons = [
54 'src/gpio.cpp',
55 'src/hostSelector_switch.cpp',
56 'src/id_button.cpp',
57 'src/main.cpp',
58 'src/power_button.cpp',
59 'src/reset_button.cpp',
60]
61
62sources_handler = [
63 'src/button_handler_main.cpp',
64 'src/button_handler.cpp',
65]
66
67executable(
68 'buttons',
69 sources_buttons,
70 implicit_include_directories: true,
71 include_directories: ['inc'],
72 dependencies: deps,
73 install: true,
74 install_dir: get_option('bindir')
75)
76
77executable(
78 'button-handler',
79 sources_handler,
80 implicit_include_directories: true,
81 include_directories: ['inc'],
82 dependencies: deps,
83 install: true,
84 install_dir: get_option('bindir')
85)
86
87systemd = dependency('systemd')
88systemd_system_unit_dir = systemd.get_variable(
89 pkgconfig: 'systemdsystemunitdir',
90 pkgconfig_define: ['prefix', get_option('prefix')])
91
92configure_file(input: 'service_files/phosphor-button-handler.service',
93 output: 'phosphor-button-handler.service',
94 copy: true,
95 install_dir: systemd_system_unit_dir)
96
97configure_file(input: 'service_files/xyz.openbmc_project.Chassis.Buttons.service',
98 output: 'xyz.openbmc_project.Chassis.Buttons.service',
99 copy: true,
100 install_dir: systemd_system_unit_dir)