blob: 492ab2689f11f00043053474ea96ca820dbd6df8 [file] [log] [blame]
George Liu4b062012020-10-13 15:26:58 +08001project(
2 'phosphor-ledmanager', 'cpp',
3 version : '1.0.0',
George Liue367cea2021-05-04 10:25:43 +08004 meson_version: '>=0.57.0',
George Liu4b062012020-10-13 15:26:58 +08005 default_options: [
6 'warning_level=3',
7 'werror=true',
George Liue367cea2021-05-04 10:25:43 +08008 'cpp_std=c++20',
George Liudb6d7632021-12-27 14:11:01 +08009 'buildtype=debugoptimized',
George Liu4b062012020-10-13 15:26:58 +080010 ]
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())
George Liud76c0742021-04-15 17:56:03 +080026conf_data.set('MONITOR_OPERATIONAL_STATUS', get_option('monitor-operational-status').enabled())
George Liu4b062012020-10-13 15:26:58 +080027
28sdbusplus_dep = dependency('sdbusplus', required: false)
29if sdbusplus_dep.found()
30 sdbusplusplus_prog = find_program('sdbus++')
31 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
32else
33 sdbusplus_proj = subproject('sdbusplus', required: true)
34 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
35 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
36 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
37 'sdbuspp_gen_meson_prog'
38 )
39endif
40
George Liu687fe072021-05-04 16:16:43 +080041sdeventplus_dep = dependency(
42 'sdeventplus',
43 fallback: [
44 'sdeventplus',
45 'sdeventplus_dep'
46 ],
47)
48phosphor_logging_dep = dependency(
49 'phosphor-logging',
50 fallback: [
51 'phosphor-logging',
52 'phosphor_logging_dep'
53 ],
54)
55phosphor_dbus_interfaces_dep = dependency(
56 'phosphor-dbus-interfaces',
57 fallback: [
58 'phosphor-dbus-interfaces',
59 'phosphor_dbus_interfaces_dep'
60 ],
61)
George Liu4b062012020-10-13 15:26:58 +080062prog_python = find_program('python3', required: true)
63realpath_prog = find_program('realpath')
64
65cpp = meson.get_compiler('cpp')
66if cpp.has_header('nlohmann/json.hpp')
Patrick Williamsd1c1f0e2022-03-16 10:46:47 -050067 nlohmann_json_dep = declare_dependency()
George Liu4b062012020-10-13 15:26:58 +080068else
69 subproject('nlohmann', required: false)
Patrick Williamsd1c1f0e2022-03-16 10:46:47 -050070 nlohmann_json_dep = declare_dependency(
George Liu4b062012020-10-13 15:26:58 +080071 include_directories: [
72 'subprojects/nlohmann/single_include',
73 'subprojects/nlohmann/single_include/nlohmann',
74 ]
75 )
76endif
77
Patrick Williamsd1c1f0e2022-03-16 10:46:47 -050078# Get Cereal dependency.
79cereal_dep = dependency('cereal', required: false)
80has_cereal = cpp.has_header_symbol(
81 'cereal/cereal.hpp',
82 'cereal::specialize',
83 dependencies: cereal_dep,
84 required: false)
85if not has_cereal
86 cereal_opts = import('cmake').subproject_options()
87 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
88 cereal_proj = import('cmake').subproject(
89 'cereal',
90 options: cereal_opts,
91 required: false)
92 assert(cereal_proj.found(), 'cereal is required')
93 cereal_dep = cereal_proj.dependency('cereal')
94endif
95
George Liu4b062012020-10-13 15:26:58 +080096selected_subdirs = []
97selected_subdirs += 'xyz/openbmc_project'
98
99generated_root = meson.current_build_dir() / 'gen'
100generated_others = []
101generated_sources = []
102
103# Source the generated meson files.
104subdir('gen')
105foreach d : selected_subdirs
106 subdir('gen' / d)
107endforeach
108
109# Parse through the list from sdbus++-gendir and put into sets.
110generated_headers = []
111generated_cpp = []
112generated_others_files = []
113
114foreach g : generated_sources generated_others
115 foreach f : g.to_list()
116 rel_path = run_command(
117 realpath_prog,
118 '--relative-to', generated_root,
119 f.full_path(),
120 ).stdout().strip().split('\n')[-1]
121
122 if rel_path.endswith('.hpp')
123 generated_headers += rel_path
124 elif rel_path.endswith('.cpp')
125 generated_cpp += rel_path
126 else
127 generated_others_files += rel_path
128 endif
129 endforeach
130endforeach
131
132deps = [
133 sdbusplus_dep,
George Liu687fe072021-05-04 16:16:43 +0800134 sdeventplus_dep,
135 phosphor_logging_dep,
136 phosphor_dbus_interfaces_dep,
Patrick Williamsd1c1f0e2022-03-16 10:46:47 -0500137 nlohmann_json_dep,
138 cereal_dep,
George Liu4b062012020-10-13 15:26:58 +0800139]
140
141sources = [
142 'group.cpp',
143 'led-main.cpp',
144 'manager.cpp',
145 'serialize.cpp',
146 'utils.cpp',
147]
148
149if get_option('use-json').disabled()
150 led_gen_hpp = custom_target(
151 'led-gen.hpp',
152 command : [
153 prog_python,
George Liue367cea2021-05-04 10:25:43 +0800154 meson.project_source_root() + '/parse_led.py',
Seires Liad738852021-06-24 07:00:37 +0800155 '-i', meson.project_source_root(),
George Liu4b062012020-10-13 15:26:58 +0800156 '-o', meson.current_build_dir(),
157 ],
158 output : 'led-gen.hpp')
159 sources += [led_gen_hpp]
160endif
161
162if get_option('use-lamp-test').enabled()
163 conf_data.set_quoted('LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/lamp_test')
164 conf_data.set_quoted('HOST_LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/host_lamp_test')
165 conf_data.set_quoted('LAMP_TEST_LED_OVERRIDES_JSON', '/usr/share/phosphor-led-manager/lamp-test-led-overrides.json')
166 conf_data.set('LAMP_TEST_TIMEOUT_IN_SECS', 240)
167
168 sources += ['lamptest.cpp']
169endif
170
171configure_file(output: 'config.h',
172 configuration: conf_data
173)
174
175install_data(
176 'scripts/led-set-all-groups-asserted.sh',
177 install_dir: get_option('bindir')
178)
179
180executable(
181 'phosphor-ledmanager',
182 sources,
183 generated_sources,
184 include_directories: include_directories('gen'),
George Liu4b062012020-10-13 15:26:58 +0800185 implicit_include_directories: true,
186 dependencies: deps,
187 install: true,
188 install_dir: get_option('bindir')
189)
190subdir('fault-monitor')
191
192build_tests = get_option('tests')
193if not build_tests.disabled()
194 subdir('test')
195endif
George Liu629f4a32021-04-14 17:42:08 +0800196
197install_subdir('configs',
198 install_dir: get_option('datadir') / 'phosphor-led-manager',
199 strip_directory: true)