1project(
2    'phosphor-ledmanager', 'cpp',
3    version : '1.0.0',
4    meson_version: '>=0.57.0',
5    default_options: [
6        'warning_level=3',
7        'werror=true',
8        'cpp_std=c++20',
9        'buildtype=debugoptimized',
10    ]
11)
12
13conf_data = configuration_data()
14conf_data.set_quoted('BUSNAME', 'xyz.openbmc_project.LED.GroupManager')
15conf_data.set_quoted('OBJPATH', '/xyz/openbmc_project/led/groups')
16conf_data.set_quoted('LED_JSON_FILE', '/usr/share/phosphor-led-manager/led-group-config.json')
17conf_data.set_quoted('SAVED_GROUPS_FILE', '/var/lib/phosphor-led-manager/savedGroups')
18conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout')
19conf_data.set_quoted('CALLOUT_REV_ASSOCIATION', 'fault')
20conf_data.set_quoted('ELOG_ENTRY', 'entry')
21conf_data.set_quoted('LED_FAULT', 'fault')
22
23conf_data.set('CLASS_VERSION', 1)
24conf_data.set('LED_USE_JSON', get_option('use-json').enabled())
25conf_data.set('USE_LAMP_TEST', get_option('use-lamp-test').enabled())
26conf_data.set('MONITOR_OPERATIONAL_STATUS', get_option('monitor-operational-status').enabled())
27
28sdbusplus_dep = dependency('sdbusplus')
29sdeventplus_dep = dependency('sdeventplus')
30phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
31phosphor_logging_dep = dependency('phosphor-logging')
32
33prog_python = find_program('python3', required: true)
34realpath_prog = find_program('realpath')
35
36cpp = meson.get_compiler('cpp')
37if cpp.has_header('nlohmann/json.hpp')
38    nlohmann_json_dep = declare_dependency()
39else
40    subproject('nlohmann', required: false)
41    nlohmann_json_dep = declare_dependency(
42        include_directories: [
43            'subprojects/nlohmann/single_include',
44            'subprojects/nlohmann/single_include/nlohmann',
45        ]
46    )
47endif
48
49if cpp.has_header('CLI/CLI.hpp')
50    CLI11_dep = declare_dependency()
51else
52    CLI11_dep = dependency('CLI11')
53endif
54
55# Get Cereal dependency.
56cereal_dep = dependency('cereal', required: false)
57has_cereal = cpp.has_header_symbol(
58    'cereal/cereal.hpp',
59    'cereal::specialize',
60    dependencies: cereal_dep,
61    required: false)
62if not has_cereal
63    cereal_opts = import('cmake').subproject_options()
64    cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
65    cereal_proj = import('cmake').subproject(
66        'cereal',
67        options: cereal_opts,
68        required: false)
69    assert(cereal_proj.found(), 'cereal is required')
70    cereal_dep = cereal_proj.dependency('cereal')
71endif
72
73deps = [
74    CLI11_dep,
75    cereal_dep,
76    nlohmann_json_dep,
77    phosphor_dbus_interfaces_dep,
78    phosphor_logging_dep,
79    sdbusplus_dep,
80    sdeventplus_dep,
81]
82
83subdir('manager')
84subdir('fault-monitor')
85
86configure_file(output: 'config.h',
87    configuration: conf_data
88)
89
90install_data(
91    'scripts/led-set-all-groups-asserted.sh',
92    install_dir: get_option('bindir')
93)
94
95build_tests = get_option('tests')
96if not build_tests.disabled()
97  subdir('test')
98endif
99
100install_subdir('configs',
101    install_dir: get_option('datadir') / 'phosphor-led-manager',
102    strip_directory: true)
103