xref: /openbmc/phosphor-buttons/meson.build (revision 301edb95a5875d134a5d87fb36801e601f399769)
1d6a1bae7SGeorge Liuproject(
2*301edb95SPatrick Williams    'phosphor-buttons',
3*301edb95SPatrick Williams    'cpp',
4d6a1bae7SGeorge Liu    version: '1.0.0',
510bc3aebSPatrick Williams    meson_version: '>=1.1.1',
6*301edb95SPatrick Williams    default_options: ['warning_level=3', 'werror=true', 'cpp_std=c++23'],
7d6a1bae7SGeorge Liu)
8d6a1bae7SGeorge Liu
931ce375eSRush Chenhost_instances = get_option('host-instances')
1031ce375eSRush Chenformatted_instances = host_instances.replace(' ', ', ')
1131ce375eSRush Chen
12d6a1bae7SGeorge Liuconf_data = configuration_data()
1331ce375eSRush Chenconf_data.set('INSTANCES', formatted_instances)
14d6a1bae7SGeorge Liuconf_data.set_quoted('ID_LED_GROUP', get_option('id-led-group'))
151a309f77SMatt Spinlerconf_data.set_quoted('POWER_BUTTON_PROFILE', get_option('power-button-profile'))
16f756f8b0SGeorge Liuconf_data.set('LONG_PRESS_TIME_MS', get_option('long-press-time-ms'))
1788f20387SPatrick Williamsconf_data.set('LOOKUP_GPIO_BASE', get_option('lookup-gpio-base').allowed())
18*301edb95SPatrick Williamsconf_data.set(
19*301edb95SPatrick Williams    'ENABLE_RESET_BUTTON_DO_WARM_REBOOT',
20*301edb95SPatrick Williams    get_option('reset-button-do-warm-reboot').allowed(),
21*301edb95SPatrick Williams)
22d6a1bae7SGeorge Liu
233e30b7a6SDelphine CC Chiuconfigure_file(
243e30b7a6SDelphine CC Chiu    input: 'meson_config.hpp.in',
253e30b7a6SDelphine CC Chiu    output: 'config.hpp',
26*301edb95SPatrick Williams    configuration: conf_data,
27d6a1bae7SGeorge Liu)
28d6a1bae7SGeorge Liu
297824da46SPatrick Williamsgpioplus_dep = dependency('gpioplus')
307824da46SPatrick Williamsnlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
31d6a1bae7SGeorge Liuphosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
32d6a1bae7SGeorge Liuphosphor_logging_dep = dependency('phosphor-logging')
337824da46SPatrick Williamssdbusplus_dep = dependency('sdbusplus')
347824da46SPatrick Williamssdeventplus_dep = dependency('sdeventplus')
35d6a1bae7SGeorge Liu
36d6a1bae7SGeorge Liudeps = [
37d6a1bae7SGeorge Liu    sdbusplus_dep,
38d6a1bae7SGeorge Liu    phosphor_dbus_interfaces_dep,
39d6a1bae7SGeorge Liu    phosphor_logging_dep,
40d6a1bae7SGeorge Liu    nlohmann_json_dep,
41d6a1bae7SGeorge Liu    gpioplus_dep,
429479b06cSMatt Spinler    sdeventplus_dep,
43d6a1bae7SGeorge Liu]
44d6a1bae7SGeorge Liu
45d6a1bae7SGeorge Liusources_buttons = [
46d6a1bae7SGeorge Liu    'src/gpio.cpp',
47ccd7db05SDelphine CC Chiu    'src/cpld.cpp',
48d6a1bae7SGeorge Liu    'src/hostSelector_switch.cpp',
49a6d4e65dSNaveen Moses    'src/debugHostSelector_button.cpp',
50d219fa3cSNaveen Moses    'src/serial_uart_mux.cpp',
51d6a1bae7SGeorge Liu    'src/id_button.cpp',
52d6a1bae7SGeorge Liu    'src/main.cpp',
53d6a1bae7SGeorge Liu    'src/power_button.cpp',
54d6a1bae7SGeorge Liu    'src/reset_button.cpp',
55d6a1bae7SGeorge Liu]
56d6a1bae7SGeorge Liu
57d6a1bae7SGeorge Liusources_handler = [
58d6a1bae7SGeorge Liu    'src/button_handler_main.cpp',
59d6a1bae7SGeorge Liu    'src/button_handler.cpp',
601a309f77SMatt Spinler    'src/host_then_chassis_poweroff.cpp',
61d6a1bae7SGeorge Liu]
62d6a1bae7SGeorge Liu
63d6a1bae7SGeorge Liuexecutable(
64d6a1bae7SGeorge Liu    'buttons',
65d6a1bae7SGeorge Liu    sources_buttons,
66d6a1bae7SGeorge Liu    implicit_include_directories: true,
67d6a1bae7SGeorge Liu    include_directories: ['inc'],
68d6a1bae7SGeorge Liu    dependencies: deps,
69d6a1bae7SGeorge Liu    install: true,
70*301edb95SPatrick Williams    install_dir: get_option('bindir'),
71d6a1bae7SGeorge Liu)
72d6a1bae7SGeorge Liu
73d6a1bae7SGeorge Liuexecutable(
74d6a1bae7SGeorge Liu    'button-handler',
75d6a1bae7SGeorge Liu    sources_handler,
76d6a1bae7SGeorge Liu    implicit_include_directories: true,
77d6a1bae7SGeorge Liu    include_directories: ['inc'],
78d6a1bae7SGeorge Liu    dependencies: deps,
79d6a1bae7SGeorge Liu    install: true,
80*301edb95SPatrick Williams    install_dir: get_option('bindir'),
81d6a1bae7SGeorge Liu)
82d6a1bae7SGeorge Liu
83d6a1bae7SGeorge Liusystemd = dependency('systemd')
84d6a1bae7SGeorge Liusystemd_system_unit_dir = systemd.get_variable(
8506b10603SPatrick Williams    'systemdsystemunitdir',
86*301edb95SPatrick Williams    pkgconfig_define: ['prefix', get_option('prefix')],
87*301edb95SPatrick Williams)
88d6a1bae7SGeorge Liu
8970a0dc8bSGeorge Liufs = import('fs')
9070a0dc8bSGeorge Liufs.copyfile(
9170a0dc8bSGeorge Liu    'service_files/phosphor-button-handler.service',
9270a0dc8bSGeorge Liu    install: true,
93*301edb95SPatrick Williams    install_dir: systemd_system_unit_dir,
9470a0dc8bSGeorge Liu)
9570a0dc8bSGeorge Liufs.copyfile(
9670a0dc8bSGeorge Liu    'service_files/xyz.openbmc_project.Chassis.Buttons.service',
9770a0dc8bSGeorge Liu    install: true,
98*301edb95SPatrick Williams    install_dir: systemd_system_unit_dir,
9970a0dc8bSGeorge Liu)
100