blob: 5f733afd7388d0c4c95a24833e656b3bb60e8ee1 [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 Williams22ed4282021-10-06 15:33:01 -050011 meson_version: '>=0.57.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
Ed Tanous55ae5a82021-08-02 14:00:02 -070036if cpp.has_header('nlohmann/json.hpp')
37 nlohmann_json = declare_dependency()
38else
39 subproject('nlohmann', required: false)
40 nlohmann_json = declare_dependency(
41 include_directories: [
42 'subprojects/nlohmann/single_include',
43 'subprojects/nlohmann/single_include/nlohmann',
44 ]
45 )
46 nlohmann_json = nlohmann_json.as_system('system')
47endif
Brad Bishop6765d902020-01-15 12:31:41 -050048sdbusplus = dependency('sdbusplus', required: false)
49if not sdbusplus.found()
Patrick Williams7f5a3362020-06-01 09:30:47 -050050 sdbusplus_proj = subproject('sdbusplus', required: true)
51 sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
Ed Tanous07d467b2021-02-23 14:48:37 -080052 sdbusplus = sdbusplus.as_system('system')
Brad Bishop6765d902020-01-15 12:31:41 -050053endif
Brad Bishopb4459912019-11-05 19:39:11 -050054systemd = dependency('systemd')
55systemd_system_unit_dir = systemd.get_pkgconfig_variable(
56 'systemdsystemunitdir',
57 define_variable: ['prefix', get_option('prefix')])
58packagedir = join_paths(
59 get_option('prefix'),
60 get_option('datadir'),
61 meson.project_name(),
62)
Andrew Jefferya9c58922021-06-01 09:28:59 +093063sysconfdir = join_paths(
64 get_option('prefix'),
65 get_option('sysconfdir'),
66 meson.project_name(),
67)
Brad Bishopb4459912019-11-05 19:39:11 -050068threads = dependency('threads')
Ed Tanous55ae5a82021-08-02 14:00:02 -070069if cpp.has_header('valijson/validator.hpp')
70 valijson = declare_dependency()
71else
72 subproject('valijson', required: false)
73 valijson = declare_dependency(
74 include_directories: 'subprojects/valijson/include'
75 )
76 valijson = valijson.as_system('system')
Brad Bishopff1ddb72020-01-15 12:24:56 -050077endif
Brad Bishopb4459912019-11-05 19:39:11 -050078
79install_data('blacklist.json')
80
81configs = [
82 '1Ux16 Riser.json',
83 '2Ux8 Riser.json',
84 '8X25 HSBP.json',
85 'A2UL16RISER.json',
86 'A2UX8X4RISER.json',
Vijay Khemkaab4535d2021-03-05 20:46:12 +000087 'ACBELL_RICA_PSU.json',
Zev Weiss43e1d7a2021-09-08 16:30:39 -050088 'ASRock_E3C246D4I.json',
Potin Lai52f56092021-12-15 10:35:42 +080089 'Bletchley_Baseboard.json',
90 'Bletchley_Chassis.json',
Matt Spinlerc451e8b2021-01-20 14:29:15 -060091 'Blyth.json',
Brad Bishopb4459912019-11-05 19:39:11 -050092 'AHW1UM2RISER.json',
Andrei Kartashevb32e00d2020-09-11 22:40:38 +030093 'ASPOWER_U1A-D10550_PSU.json',
94 'ASPOWER_U1A-D10800_PSU.json',
95 'ASPOWER_U1A-D11200_PSU.json',
96 'ASPOWER_U1A-D11600_PSU.json',
97 'ASPOWER_U1D-D10800_PSU.json',
Brad Bishopb4459912019-11-05 19:39:11 -050098 'AXX1P100HSSI_AIC.json',
99 'AXX2PRTHDHD.json',
100 'BNP Baseboard.json',
Brandon Wymaneb8a4472021-01-08 16:05:02 -0600101 'Bellavista.json',
Zev Weissee4b6362022-02-14 16:01:27 -0800102 'Delta_AWF2DC3200W_PSU.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500103 'Delta DPS-750XB PSU.json',
Andrei Kartashevb32e00d2020-09-11 22:40:38 +0300104 'Delta_DPS-1600AB_PSU.json',
105 'Delta_DPS-2000AB_PSU.json',
Andrew Geisslerc7c5de72020-12-16 09:47:21 -0600106 'Everest.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500107 'F1U12X25 HSBP.json',
108 'F1U4X25 HSBP.json',
109 'F2U12X35 HSBP.json',
110 'F2U8X25 HSBP.json',
111 'FBTP.json',
112 'FBYV2.json',
113 'Flextronics S-1100ADU00-201 PSU.json',
Adriana Kobylak886c1ba2021-02-01 14:05:11 -0600114 'IBM 1000W CFFPS.json',
115 'IBM 1400W CFFPS.json',
116 'IBM 1600W CFFPS.json',
117 'IBM 2000W CFFPS.json',
118 'IBM 2300W CFFPS.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500119 'Intel Front Panel.json',
Mustafa Shehabi09929ac2021-07-28 17:32:05 -0500120 'Kudo_BMC.json',
121 'Kudo_Motherboard.json',
Thang Q. Nguyenf466cce2021-11-26 06:08:03 +0000122 'Mt_Jade.json',
Brad Bishop55237c42020-10-01 10:08:42 -0400123 'Nisqually.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500124 'NVME P4000.json',
125 'PCIE SSD Retimer.json',
126 'PSSF132202A.json',
127 'PSSF162205A.json',
128 'PSSF212201A.json',
129 'PSSF222201A.json',
Brad Bishop5f4a0262020-10-09 08:30:19 -0400130 'Rainier 2U Chassis.json',
131 'Rainier 4U Chassis.json',
Andrew Geissler3e55ec42021-03-11 14:04:27 -0600132 'Rainier 1S4U Chassis.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500133 'R1000 Chassis.json',
134 'R2000 Chassis.json',
135 'SAS Module.json',
136 'SOLUM_PSSF162202_PSU.json',
Bruce Mitchell849c07d2021-07-01 13:12:37 -0500137 'Storm King.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500138 'STP Baseboard.json',
139 'STP P4000 Chassis.json',
Vijay Khemka93a93262021-02-04 19:10:29 +0000140 'Tyan_S7106_Baseboard.json',
Ali El-Haj-Mahmoud32fc0a52022-02-16 17:02:52 -0500141 'Tyan_S8036_Baseboard.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500142 'WFT Baseboard.json',
143]
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800144filepaths = []
Brad Bishopb4459912019-11-05 19:39:11 -0500145foreach c : configs
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800146 file = join_paths('configurations', c)
Brad Bishopb4459912019-11-05 19:39:11 -0500147 install_data(
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800148 file,
Brad Bishopb4459912019-11-05 19:39:11 -0500149 install_dir: join_paths(
150 packagedir,
151 'configurations',
152 )
153 )
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800154 filepaths += [file]
Brad Bishopb4459912019-11-05 19:39:11 -0500155endforeach
156
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800157validate_script = files('scripts/validate-configs.py')
158autojson = custom_target(
159 'check_syntax',
160 command: [
161 validate_script,
162 '-v',
163 '-k',
164 ],
165 depend_files: files(filepaths),
166 build_by_default: true,
167 capture: true,
168 output: 'validate_configs.log',
169)
170
Brad Bishopb4459912019-11-05 19:39:11 -0500171schemas = [
172 'global.json',
Brad Bishop66665882020-05-07 17:05:18 -0400173 'legacy.json',
Brad Bishopb9809912020-05-07 17:15:31 -0400174 'openbmc-dbus.json',
Brad Bishop4afe7082020-10-01 09:59:26 -0400175 'IBM.json',
Brad Bishop6fe729d2020-10-01 09:54:20 -0400176 'Intel.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500177 'Pid.json',
178 'Pid.Zone.json',
179 'Stepwise.json',
Rashmica Guptae23af562021-07-29 15:12:16 +1000180 'VirtualSensor.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500181]
182
183foreach s : schemas
184 install_data(
185 join_paths('schemas', s),
186 install_dir: join_paths(
187 packagedir,
188 'configurations',
189 'schemas',
190 )
191 )
192endforeach
193
194subdir('service_files')
195subdir('src')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400196
Jason M. Billsff58eba2020-04-14 16:05:30 -0700197if not build_tests.disabled()
Patrick Venturea62466c2021-02-08 14:55:18 -0800198 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400199 gtest = dependency('gtest', main: true, disabler: true, required: false)
200 if not gtest.found() and build_tests.enabled()
Ed Tanous55ae5a82021-08-02 14:00:02 -0700201 cmake = import('cmake')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400202 gtest_subproject = cmake.subproject('gtest')
203 cm_gtest = gtest_subproject.dependency('gtest')
204 cm_gtest_main = gtest_subproject.dependency('gtest_main')
205 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
206 endif
207
208 test(
209 'test_entity_manager',
210 executable(
211 'test_entity_manager',
212 'test/test_entity-manager.cpp',
Andrew Jefferya05437e2022-04-07 16:17:21 +0930213 'src/Expression.cpp',
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400214 'src/Utils.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800215 cpp_args: test_boost_args,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400216 dependencies: [
217 boost,
218 gtest,
Ed Tanous55ae5a82021-08-02 14:00:02 -0700219 nlohmann_json,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400220 sdbusplus,
221 valijson,
222 ],
223 implicit_include_directories: false,
224 include_directories: 'include',
225 )
226 )
Patrick Venturea62466c2021-02-08 14:55:18 -0800227
228 test(
229 'test_fru_utils',
230 executable(
231 'test_fru_utils',
232 'test/test_fru-utils.cpp',
233 'src/FruUtils.cpp',
234 cpp_args: test_boost_args,
235 dependencies: [
236 boost,
237 gtest,
238 ],
239 implicit_include_directories: false,
240 include_directories: 'include',
241 )
242 )
Jason M. Billsff58eba2020-04-14 16:05:30 -0700243endif