xref: /openbmc/entity-manager/meson.build (revision bfda2c43)
1project(
2    'entity-manager',
3    'cpp',
4    default_options: [
5        'warning_level=3',
6        'werror=true',
7        'cpp_std=c++20'
8    ],
9    license: 'Apache-2.0',
10    version: '0.1',
11    meson_version: '>=0.58.0',
12)
13add_project_arguments('-Wno-psabi', language: 'cpp')
14
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',
21    '-DBOOST_ALLOW_DEPRECATED_HEADERS'
22]
23build_tests = get_option('tests')
24cpp = meson.get_compiler('cpp')
25boost = 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     )
31     boost = boost.as_system('system')
32endif
33if get_option('fru-device')
34    i2c = cpp.find_library('i2c')
35endif
36
37nlohmann_json_dep = dependency('nlohmann_json',
38                               fallback: [ 'nlohmann_json', 'nlohmann_json_dep'])
39
40sdbusplus = dependency('sdbusplus', required: false)
41if not sdbusplus.found()
42    sdbusplus_proj = subproject('sdbusplus', required: true)
43    sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
44    sdbusplus = sdbusplus.as_system('system')
45endif
46systemd = dependency('systemd')
47systemd_system_unit_dir = systemd.get_variable(
48    'systemdsystemunitdir',
49    pkgconfig_define: ['prefix', get_option('prefix')])
50packagedir = join_paths(
51    get_option('prefix'),
52    get_option('datadir'),
53    meson.project_name(),
54)
55sysconfdir = join_paths(
56    get_option('prefix'),
57    get_option('sysconfdir'),
58    meson.project_name(),
59)
60threads = dependency('threads')
61if 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')
69endif
70
71install_data('blacklist.json')
72
73configs = [
74    '1ux16_riser.json',
75    '2ux8_riser.json',
76    '3ypower_vast2112_psu.json',
77    '8x25_hsbp.json',
78    'a2ul16riser.json',
79    'a2ux8x4riser.json',
80    'acbell_rica_psu.json',
81    'acbel_r1ca2122a_psu.json',
82    'asrock_e3c246d4i.json',
83    'asrock_romed8hm3.json',
84    'bletchley_baseboard.json',
85    'bletchley_chassis.json',
86    'bletchley_frontpanel.json',
87    'blyth.json',
88    'ahw1um2riser.json',
89    'aspower_u1a-d10550_psu.json',
90    'aspower_u1a-d10800_psu.json',
91    'aspower_u1a-d11200_psu.json',
92    'aspower_u1a-d11600_psu.json',
93    'aspower_u1d-d10800_psu.json',
94    'axx1p100hssi_aic.json',
95    'axx2prthdhd.json',
96    'bnp_baseboard.json',
97    'bellavista.json',
98    'bonnell.json',
99    'delta_awf2dc3200w_psu.json',
100    'delta_dps-750xb_psu.json',
101    'delta_dps-1600ab_psu.json',
102    'delta_dps-2000ab_psu.json',
103    'supermicro-pws-920p-sq_psu.json',
104    'everest.json',
105    'f1u12x25_hsbp.json',
106    'f1u4x25_hsbp.json',
107    'f2u12x35_hsbp.json',
108    'f2u8x25_hsbp.json',
109    'fbtp.json',
110    'fbyv2.json',
111    'fbyv35.json',
112    'fbyv35_nic_mellanox.json',
113    'flextronics_s-1100adu00-201_psu.json',
114    'genesis3_psu.json',
115    'genesis3_baseboard.json',
116    'genesis3_chassis.json',
117    'gospower_g1136-1300wna_psu.json',
118    'greatlakes.json',
119    'greatlakes_nic_mellanox.json',
120    'ibm_tacoma_rack_controller.json',
121    'intel_front_panel.json',
122    'kudo_bmc.json',
123    'kudo_motherboard.json',
124    'mori_bmc.json',
125    'mori_motherboard.json',
126    'mtjade.json',
127    'mtmitchell_bmc.json',
128    'mtmitchell_mb.json',
129    'nisqually.json',
130    'nvme_p4000.json',
131    'pcie_ssd_retimer.json',
132    'pennybacker.json',
133    'pssf132202a.json',
134    'pssf162205a.json',
135    'pssf212201a.json',
136    'pssf222201a.json',
137    'rainier_2u_chassis.json',
138    'rainier_4u_chassis.json',
139    'rainier_1s4u_chassis.json',
140    'r1000_chassis.json',
141    'r2000_chassis.json',
142    'sas_module.json',
143    'sbp1_baseboard.json',
144    'sbp1_chassis.json',
145    'sbp1_psu.json',
146    'system1_baseboard.json',
147    'solum_pssf162202_psu.json',
148    'storm_king.json',
149    'stp_baseboard.json',
150    'stp_p4000_chassis.json',
151    'twinlake.json',
152    'tyan_s7106_baseboard.json',
153    'tyan_s8036_baseboard.json',
154    'vegman_n110_baseboard.json',
155    'vegman_rx20_baseboard.json',
156    'vegman_sx20_baseboard.json',
157    'wft_baseboard.json',
158]
159filepaths = []
160foreach c : configs
161    file = join_paths('configurations', c)
162    install_data(
163        file,
164        install_dir: join_paths(
165            packagedir,
166            'configurations',
167        )
168    )
169    filepaths += [file]
170endforeach
171
172validate_script = files('scripts/validate_configs.py')
173autojson = custom_target(
174  'check_syntax',
175  command: [
176    validate_script,
177    '-v',
178    '-k',
179  ],
180  depend_files: files(filepaths),
181  build_by_default: true,
182  capture: true,
183  output: 'validate_configs.log',
184)
185
186schemas = [
187    'global.json',
188    'legacy.json',
189    'openbmc-dbus.json',
190    'ibm.json',
191    'intel.json',
192    'pid.json',
193    'pid_zone.json',
194    'stepwise.json',
195    'virtual_sensor.json',
196    'satellite_controller.json',
197]
198
199foreach s : schemas
200    install_data(
201        join_paths('schemas', s),
202        install_dir: join_paths(
203            packagedir,
204            'configurations',
205            'schemas',
206        )
207    )
208endforeach
209
210subdir('service_files')
211subdir('src')
212
213if not build_tests.disabled()
214    test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
215    gtest = dependency('gtest', main: true, disabler: true, required: false)
216    gmock = dependency('gmock', disabler: true, required: false)
217    if not (gtest.found() and gmock.found()) and build_tests.enabled()
218        cmake = import('cmake')
219        gtest_subproject = cmake.subproject('gtest')
220        cm_gtest = gtest_subproject.dependency('gtest')
221        cm_gtest_main = gtest_subproject.dependency('gtest_main')
222        gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
223        gmock = gtest_subproject.dependency('gmock')
224
225    endif
226
227    test(
228        'test_entity_manager',
229        executable(
230            'test_entity_manager',
231            'test/test_entity-manager.cpp',
232            'src/expression.cpp',
233            'src/utils.cpp',
234            cpp_args: test_boost_args,
235            dependencies: [
236                boost,
237                gtest,
238                nlohmann_json_dep,
239                sdbusplus,
240                valijson,
241            ],
242            include_directories: 'src',
243        )
244    )
245
246    test(
247        'test_fru_utils',
248        executable(
249            'test_fru_utils',
250            'test/test_fru-utils.cpp',
251            'src/fru_utils.cpp',
252            'src/fru_reader.cpp',
253            cpp_args: test_boost_args,
254            dependencies: [
255                boost,
256                gtest,
257                sdbusplus,
258            ],
259            include_directories: 'src',
260        )
261    )
262
263    test(
264        'test_topology',
265        executable(
266            'test_topology',
267            'test/test_topology.cpp',
268            'src/topology.cpp',
269            cpp_args: test_boost_args,
270            dependencies: [
271                gtest,
272                gmock,
273                nlohmann_json_dep,
274            ],
275            include_directories: 'src',
276        )
277    )
278endif
279