xref: /openbmc/phosphor-buttons/meson.build (revision d6a1bae7b7d07e05d658d686ff688d4c5a448e82)
1project(
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()
13conf_data.set_quoted('POWER_DBUS_OBJECT_NAME', 'xyz/openbmc_project/Chassis/Buttons/Power')
14conf_data.set_quoted('RESET_DBUS_OBJECT_NAME', 'xyz/openbmc_project/Chassis/Buttons/Reset')
15conf_data.set_quoted('ID_DBUS_OBJECT_NAME', 'xyz/openbmc_project/Chassis/Buttons/ID')
16conf_data.set_quoted('HS_DBUS_OBJECT_NAME', 'xyz/openbmc_project/Chassis/Buttons/HostSelector')
17conf_data.set_quoted('GPIO_BASE_LABEL_NAME', '/com/inspur/cpld/motherboard/acfail')
18conf_data.set_quoted('BUTTON_PATH', '1e780000.gpio')
19conf_data.set_quoted('CHASSIS_STATE_OBJECT_NAME', 'xyz/openbmc_project/state/chassis')
20conf_data.set_quoted('CHASSISSYSTEM_STATE_OBJECT_NAME', 'xyz/openbmc_project/state/chassis_system')
21conf_data.set_quoted('HOST_STATE_OBJECT_NAME', 'xyz/openbmc_project/state/host')
22conf_data.set_quoted('ID_LED_GROUP', get_option('id-led-group'))
23
24conf_data.set('LONG_PRESS_TIME_MS', 3000)
25
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)
101