blob: 46b90af1acb5d8972d266fc223f04217d15248ab [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 Liu4b062012020-10-13 15:26:58 +08009 '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())
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')
67 nlohmann_json = declare_dependency()
68else
69 subproject('nlohmann', required: false)
70 nlohmann_json = declare_dependency(
71 include_directories: [
72 'subprojects/nlohmann/single_include',
73 'subprojects/nlohmann/single_include/nlohmann',
74 ]
75 )
76endif
77
78selected_subdirs = []
79selected_subdirs += 'xyz/openbmc_project'
80
81generated_root = meson.current_build_dir() / 'gen'
82generated_others = []
83generated_sources = []
84
85# Source the generated meson files.
86subdir('gen')
87foreach d : selected_subdirs
88 subdir('gen' / d)
89endforeach
90
91# Parse through the list from sdbus++-gendir and put into sets.
92generated_headers = []
93generated_cpp = []
94generated_others_files = []
95
96foreach g : generated_sources generated_others
97 foreach f : g.to_list()
98 rel_path = run_command(
99 realpath_prog,
100 '--relative-to', generated_root,
101 f.full_path(),
102 ).stdout().strip().split('\n')[-1]
103
104 if rel_path.endswith('.hpp')
105 generated_headers += rel_path
106 elif rel_path.endswith('.cpp')
107 generated_cpp += rel_path
108 else
109 generated_others_files += rel_path
110 endif
111 endforeach
112endforeach
113
114deps = [
115 sdbusplus_dep,
George Liu687fe072021-05-04 16:16:43 +0800116 sdeventplus_dep,
117 phosphor_logging_dep,
118 phosphor_dbus_interfaces_dep,
George Liu4b062012020-10-13 15:26:58 +0800119 nlohmann_json
120]
121
122sources = [
123 'group.cpp',
124 'led-main.cpp',
125 'manager.cpp',
126 'serialize.cpp',
127 'utils.cpp',
128]
129
130if get_option('use-json').disabled()
131 led_gen_hpp = custom_target(
132 'led-gen.hpp',
133 command : [
134 prog_python,
George Liue367cea2021-05-04 10:25:43 +0800135 meson.project_source_root() + '/parse_led.py',
Seires Liad738852021-06-24 07:00:37 +0800136 '-i', meson.project_source_root(),
George Liu4b062012020-10-13 15:26:58 +0800137 '-o', meson.current_build_dir(),
138 ],
139 output : 'led-gen.hpp')
140 sources += [led_gen_hpp]
141endif
142
143if get_option('use-lamp-test').enabled()
144 conf_data.set_quoted('LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/lamp_test')
145 conf_data.set_quoted('HOST_LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/host_lamp_test')
146 conf_data.set_quoted('LAMP_TEST_LED_OVERRIDES_JSON', '/usr/share/phosphor-led-manager/lamp-test-led-overrides.json')
147 conf_data.set('LAMP_TEST_TIMEOUT_IN_SECS', 240)
148
149 sources += ['lamptest.cpp']
150endif
151
152configure_file(output: 'config.h',
153 configuration: conf_data
154)
155
156install_data(
157 'scripts/led-set-all-groups-asserted.sh',
158 install_dir: get_option('bindir')
159)
160
161executable(
162 'phosphor-ledmanager',
163 sources,
164 generated_sources,
165 include_directories: include_directories('gen'),
George Liu4b062012020-10-13 15:26:58 +0800166 implicit_include_directories: true,
167 dependencies: deps,
168 install: true,
169 install_dir: get_option('bindir')
170)
171subdir('fault-monitor')
172
173build_tests = get_option('tests')
174if not build_tests.disabled()
175 subdir('test')
176endif
George Liu629f4a32021-04-14 17:42:08 +0800177
178install_subdir('configs',
179 install_dir: get_option('datadir') / 'phosphor-led-manager',
180 strip_directory: true)