blob: c6cf29fdc63f9cb47a94471fb44e5e8b13549037 [file] [log] [blame]
Brad Bishopb4459912019-11-05 19:39:11 -05001project(
2 'entity-manager',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Patrick Williams22ed4282021-10-06 15:33:01 -05007 'cpp_std=c++20'
Brad Bishopb4459912019-11-05 19:39:11 -05008 ],
9 license: 'Apache-2.0',
10 version: '0.1',
Patrick Williamsee1db762023-04-12 08:05:58 -050011 meson_version: '>=0.58.0',
Brad Bishopb4459912019-11-05 19:39:11 -050012)
Brad Bishopec984912020-10-01 10:24:55 -040013add_project_arguments('-Wno-psabi', language: 'cpp')
Brad Bishopb4459912019-11-05 19:39:11 -050014
15boost_args = [
16 '-DBOOST_SYSTEM_NO_DEPRECATED',
17 '-DBOOST_ERROR_CODE_HEADER_ONLY',
18 '-DBOOST_NO_RTTI',
19 '-DBOOST_NO_TYPEID',
20 '-DBOOST_ALL_NO_LIB',
Ed Tanous07d467b2021-02-23 14:48:37 -080021 '-DBOOST_ALLOW_DEPRECATED_HEADERS'
Brad Bishopb4459912019-11-05 19:39:11 -050022]
23build_tests = get_option('tests')
Brad Bishope3a12b62020-01-15 11:56:29 -050024cpp = meson.get_compiler('cpp')
Brad Bishop787e8282020-01-15 12:16:53 -050025boost = dependency('boost', required: false)
26if not boost.found()
27 subproject('boost', required: false)
28 boost = declare_dependency(
29 include_directories: 'subprojects/boost_1_71_0',
30 )
Ed Tanous07d467b2021-02-23 14:48:37 -080031 boost = boost.as_system('system')
Brad Bishop787e8282020-01-15 12:16:53 -050032endif
Brad Bishop92daaaa2020-01-20 15:45:01 -050033if get_option('fru-device')
34 i2c = cpp.find_library('i2c')
35endif
Andrew Jeffery14a7bc92021-08-02 10:01:22 +093036
37nlohmann_json_dep = dependency('nlohmann_json',
38 fallback: [ 'nlohmann_json', 'nlohmann_json_dep'])
39
Brad Bishop6765d902020-01-15 12:31:41 -050040sdbusplus = dependency('sdbusplus', required: false)
41if not sdbusplus.found()
Patrick Williams7f5a3362020-06-01 09:30:47 -050042 sdbusplus_proj = subproject('sdbusplus', required: true)
43 sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
Ed Tanous07d467b2021-02-23 14:48:37 -080044 sdbusplus = sdbusplus.as_system('system')
Brad Bishop6765d902020-01-15 12:31:41 -050045endif
Brad Bishopb4459912019-11-05 19:39:11 -050046systemd = dependency('systemd')
Patrick Williamsee1db762023-04-12 08:05:58 -050047systemd_system_unit_dir = systemd.get_variable(
Brad Bishopb4459912019-11-05 19:39:11 -050048 'systemdsystemunitdir',
Patrick Williamsee1db762023-04-12 08:05:58 -050049 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishopb4459912019-11-05 19:39:11 -050050packagedir = join_paths(
51 get_option('prefix'),
52 get_option('datadir'),
53 meson.project_name(),
54)
Andrew Jefferya9c58922021-06-01 09:28:59 +093055sysconfdir = join_paths(
56 get_option('prefix'),
57 get_option('sysconfdir'),
58 meson.project_name(),
59)
Brad Bishopb4459912019-11-05 19:39:11 -050060threads = dependency('threads')
Ed Tanous55ae5a82021-08-02 14:00:02 -070061if cpp.has_header('valijson/validator.hpp')
62 valijson = declare_dependency()
63else
64 subproject('valijson', required: false)
65 valijson = declare_dependency(
66 include_directories: 'subprojects/valijson/include'
67 )
68 valijson = valijson.as_system('system')
Brad Bishopff1ddb72020-01-15 12:24:56 -050069endif
Brad Bishopb4459912019-11-05 19:39:11 -050070
71install_data('blacklist.json')
72
73configs = [
Brad Bishopf4b2e5a2022-05-26 16:17:12 -040074 '1ux16_riser.json',
75 '2ux8_riser.json',
Ali El-Haj-Mahmoudffe7df42023-05-08 14:27:22 -040076 '3ypower_vast2112_psu.json',
Brad Bishopf4b2e5a2022-05-26 16:17:12 -040077 '8x25_hsbp.json',
78 'a2ul16riser.json',
79 'a2ux8x4riser.json',
80 'acbell_rica_psu.json',
81 'asrock_e3c246d4i.json',
82 'asrock_romed8hm3.json',
83 'bletchley_baseboard.json',
84 'bletchley_chassis.json',
Potin Lai546d3752022-11-10 08:57:47 +080085 'bletchley_frontpanel.json',
Brad Bishopf4b2e5a2022-05-26 16:17:12 -040086 'blyth.json',
87 'ahw1um2riser.json',
88 'aspower_u1a-d10550_psu.json',
89 'aspower_u1a-d10800_psu.json',
90 'aspower_u1a-d11200_psu.json',
91 'aspower_u1a-d11600_psu.json',
92 'aspower_u1d-d10800_psu.json',
93 'axx1p100hssi_aic.json',
94 'axx2prthdhd.json',
95 'bnp_baseboard.json',
96 'bellavista.json',
Adriana Kobylak0b5b1222023-01-31 14:15:27 -060097 'bonnell.json',
Brad Bishopf4b2e5a2022-05-26 16:17:12 -040098 'delta_awf2dc3200w_psu.json',
99 'delta_dps-750xb_psu.json',
100 'delta_dps-1600ab_psu.json',
101 'delta_dps-2000ab_psu.json',
102 'everest.json',
103 'f1u12x25_hsbp.json',
104 'f1u4x25_hsbp.json',
105 'f2u12x35_hsbp.json',
106 'f2u8x25_hsbp.json',
107 'fbtp.json',
108 'fbyv2.json',
Jayashree Dhanapal90249e22022-06-13 15:00:57 +0530109 'fbyv35.json',
Jayashree Dhanapal8232a6a2022-06-21 15:50:50 +0530110 'fbyv35_nic_mellanox.json',
Brad Bishopf4b2e5a2022-05-26 16:17:12 -0400111 'flextronics_s-1100adu00-201_psu.json',
BonnieLo-wiwynncbaec702022-11-17 15:42:46 +0800112 'greatlakes.json',
113 'greatlakes_nic_mellanox.json',
Brad Bishopf4b2e5a2022-05-26 16:17:12 -0400114 'ibm_1000w_cffps.json',
115 'ibm_1400w_cffps.json',
116 'ibm_1600w_cffps.json',
117 'ibm_2000w_cffps.json',
118 'ibm_2300w_cffps.json',
Andrew Geissler3a1cbe22023-02-17 13:57:15 -0600119 'ibm_tacoma_rack_controller.json',
Brad Bishopf4b2e5a2022-05-26 16:17:12 -0400120 'intel_front_panel.json',
121 'kudo_bmc.json',
122 'kudo_motherboard.json',
123 'mt_jade.json',
124 'nisqually.json',
125 'nvme_p4000.json',
126 'pcie_ssd_retimer.json',
Adriana Kobylak0b5b1222023-01-31 14:15:27 -0600127 'pennybacker.json',
Brad Bishopf4b2e5a2022-05-26 16:17:12 -0400128 'pssf132202a.json',
129 'pssf162205a.json',
130 'pssf212201a.json',
131 'pssf222201a.json',
132 'rainier_2u_chassis.json',
133 'rainier_4u_chassis.json',
134 'rainier_1s4u_chassis.json',
135 'r1000_chassis.json',
136 'r2000_chassis.json',
137 'sas_module.json',
138 'solum_pssf162202_psu.json',
139 'storm_king.json',
140 'stp_baseboard.json',
141 'stp_p4000_chassis.json',
Jayashree Dhanapal10612f32022-11-02 16:12:41 +0530142 'twinlake.json',
Brad Bishopf4b2e5a2022-05-26 16:17:12 -0400143 'tyan_s7106_baseboard.json',
144 'tyan_s8036_baseboard.json',
Andrei Kartashev9d455522022-01-11 13:27:29 +0300145 'vegman_n110_baseboard.json',
146 'vegman_rx20_baseboard.json',
147 'vegman_sx20_baseboard.json',
Brad Bishopf4b2e5a2022-05-26 16:17:12 -0400148 'wft_baseboard.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500149]
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800150filepaths = []
Brad Bishopb4459912019-11-05 19:39:11 -0500151foreach c : configs
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800152 file = join_paths('configurations', c)
Brad Bishopb4459912019-11-05 19:39:11 -0500153 install_data(
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800154 file,
Brad Bishopb4459912019-11-05 19:39:11 -0500155 install_dir: join_paths(
156 packagedir,
157 'configurations',
158 )
159 )
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800160 filepaths += [file]
Brad Bishopb4459912019-11-05 19:39:11 -0500161endforeach
162
Brad Bishopbfc72962022-05-26 16:33:00 -0400163validate_script = files('scripts/validate_configs.py')
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800164autojson = custom_target(
165 'check_syntax',
166 command: [
167 validate_script,
168 '-v',
169 '-k',
170 ],
171 depend_files: files(filepaths),
172 build_by_default: true,
173 capture: true,
174 output: 'validate_configs.log',
175)
176
Brad Bishopb4459912019-11-05 19:39:11 -0500177schemas = [
178 'global.json',
Brad Bishop66665882020-05-07 17:05:18 -0400179 'legacy.json',
Brad Bishopb9809912020-05-07 17:15:31 -0400180 'openbmc-dbus.json',
Brad Bishop7d05ee52022-05-26 16:27:48 -0400181 'ibm.json',
182 'intel.json',
183 'pid.json',
184 'pid_zone.json',
185 'stepwise.json',
186 'virtual_sensor.json',
Andrew Geissler48edf9a2023-02-21 10:44:14 -0600187 'satellite_controller.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500188]
189
190foreach s : schemas
191 install_data(
192 join_paths('schemas', s),
193 install_dir: join_paths(
194 packagedir,
195 'configurations',
196 'schemas',
197 )
198 )
199endforeach
200
201subdir('service_files')
202subdir('src')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400203
Jason M. Billsff58eba2020-04-14 16:05:30 -0700204if not build_tests.disabled()
Patrick Venturea62466c2021-02-08 14:55:18 -0800205 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400206 gtest = dependency('gtest', main: true, disabler: true, required: false)
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000207 gmock = dependency('gmock', disabler: true, required: false)
208 if not (gtest.found() and gmock.found()) and build_tests.enabled()
Ed Tanous55ae5a82021-08-02 14:00:02 -0700209 cmake = import('cmake')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400210 gtest_subproject = cmake.subproject('gtest')
211 cm_gtest = gtest_subproject.dependency('gtest')
212 cm_gtest_main = gtest_subproject.dependency('gtest_main')
213 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000214 gmock = gtest_subproject.dependency('gmock')
215
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400216 endif
217
218 test(
219 'test_entity_manager',
220 executable(
221 'test_entity_manager',
222 'test/test_entity-manager.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400223 'src/expression.cpp',
224 'src/utils.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800225 cpp_args: test_boost_args,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400226 dependencies: [
227 boost,
228 gtest,
Andrew Jeffery14a7bc92021-08-02 10:01:22 +0930229 nlohmann_json_dep,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400230 sdbusplus,
231 valijson,
232 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030233 include_directories: 'src',
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400234 )
235 )
Patrick Venturea62466c2021-02-08 14:55:18 -0800236
237 test(
238 'test_fru_utils',
239 executable(
240 'test_fru_utils',
241 'test/test_fru-utils.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400242 'src/fru_utils.cpp',
Zev Weiss309c0b12022-02-25 01:44:12 +0000243 'src/fru_reader.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800244 cpp_args: test_boost_args,
245 dependencies: [
246 boost,
247 gtest,
Andrew Jeffery5bda1822023-01-27 13:40:21 +1030248 sdbusplus,
Patrick Venturea62466c2021-02-08 14:55:18 -0800249 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030250 include_directories: 'src',
Patrick Venturea62466c2021-02-08 14:55:18 -0800251 )
252 )
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000253
254 test(
255 'test_topology',
256 executable(
257 'test_topology',
258 'test/test_topology.cpp',
259 'src/topology.cpp',
260 cpp_args: test_boost_args,
261 dependencies: [
262 gtest,
263 gmock,
Patrick Williamsaf293612023-04-19 10:27:37 -0500264 nlohmann_json_dep,
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000265 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030266 include_directories: 'src',
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000267 )
268 )
Jason M. Billsff58eba2020-04-14 16:05:30 -0700269endif