xref: /openbmc/phosphor-buttons/meson.build (revision 9456ffc9)
1project(
2    'phosphor-buttons', 'cpp',
3    version: '1.0.0',
4    meson_version: '>=1.1.1',
5    default_options: [
6        'warning_level=3',
7        'werror=true',
8        'cpp_std=c++23',
9    ]
10)
11
12conf_data = configuration_data()
13conf_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')
23conf_data.set_quoted('SERIAL_CONSOLE_MUX_DBUS_OBJECT_NAME',
24                 '/xyz/openbmc_project/Chassis/Buttons/SerialUartMux')
25conf_data.set_quoted('GPIO_BASE_LABEL_NAME', '1e780000.gpio')
26conf_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')
32conf_data.set_quoted('ID_LED_GROUP', get_option('id-led-group'))
33
34conf_data.set_quoted('POWER_BUTTON_PROFILE', get_option('power-button-profile'))
35
36conf_data.set('LONG_PRESS_TIME_MS', get_option('long-press-time-ms'))
37conf_data.set('LOOKUP_GPIO_BASE', get_option('lookup-gpio-base').enabled())
38conf_data.set('ENABLE_RESET_BUTTON_DO_WARM_REBOOT', get_option('reset-button-do-warm-reboot').enabled())
39
40configure_file(output: 'config.h',
41    configuration: conf_data
42)
43
44sdbusplus_dep = dependency('sdbusplus')
45sdeventplus_dep = dependency('sdeventplus')
46phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
47phosphor_logging_dep = dependency('phosphor-logging')
48gpioplus_dep = dependency('gpioplus')
49
50cpp = meson.get_compiler('cpp')
51if cpp.has_header_symbol(
52        'nlohmann/json.hpp',
53        'nlohmann::json::string_t',
54        required:false)
55    nlohmann_json_dep = declare_dependency()
56else
57    nlohmann_json_dep = dependency('nlohmann-json')
58endif
59
60deps = [
61    sdbusplus_dep,
62    phosphor_dbus_interfaces_dep,
63    phosphor_logging_dep,
64    nlohmann_json_dep,
65    gpioplus_dep,
66    sdeventplus_dep,
67]
68
69sources_buttons = [
70    'src/gpio.cpp',
71    'src/cpld.cpp',
72    'src/hostSelector_switch.cpp',
73    'src/debugHostSelector_button.cpp',
74    'src/serial_uart_mux.cpp',
75    'src/id_button.cpp',
76    'src/main.cpp',
77    'src/power_button.cpp',
78    'src/reset_button.cpp',
79]
80
81sources_handler = [
82    'src/button_handler_main.cpp',
83    'src/button_handler.cpp',
84    'src/host_then_chassis_poweroff.cpp',
85]
86
87executable(
88    'buttons',
89    sources_buttons,
90    implicit_include_directories: true,
91    include_directories: ['inc'],
92    dependencies: deps,
93    install: true,
94    install_dir: get_option('bindir')
95)
96
97executable(
98    'button-handler',
99    sources_handler,
100    implicit_include_directories: true,
101    include_directories: ['inc'],
102    dependencies: deps,
103    install: true,
104    install_dir: get_option('bindir')
105)
106
107systemd = dependency('systemd')
108systemd_system_unit_dir = systemd.get_variable(
109        'systemdsystemunitdir',
110        pkgconfig_define: ['prefix', get_option('prefix')])
111
112configure_file(input: 'service_files/phosphor-button-handler.service',
113                output: 'phosphor-button-handler.service',
114                copy: true,
115                install_dir: systemd_system_unit_dir)
116
117configure_file(input: 'service_files/xyz.openbmc_project.Chassis.Buttons.service',
118                output: 'xyz.openbmc_project.Chassis.Buttons.service',
119                copy: true,
120                install_dir: systemd_system_unit_dir)
121