xref: /openbmc/entity-manager/meson.build (revision 9f9f25b4)
1project(
2    'entity-manager',
3    'cpp',
4    default_options: [
5        'warning_level=3',
6        'werror=true',
7        'cpp_std=c++23'
8    ],
9    license: 'Apache-2.0',
10    version: '0.1',
11    meson_version: '>=1.1.1',
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', include_type: 'system')
38sdbusplus = dependency('sdbusplus', include_type: 'system')
39phosphor_logging_dep = dependency('phosphor-logging')
40
41systemd = dependency('systemd')
42systemd_system_unit_dir = systemd.get_variable(
43    'systemdsystemunitdir',
44    pkgconfig_define: ['prefix', get_option('prefix')])
45packagedir = join_paths(
46    get_option('prefix'),
47    get_option('datadir'),
48    meson.project_name(),
49)
50sysconfdir = join_paths(
51    get_option('prefix'),
52    get_option('sysconfdir'),
53    meson.project_name(),
54)
55threads = dependency('threads')
56if cpp.has_header('valijson/validator.hpp')
57    valijson = declare_dependency()
58else
59    subproject('valijson', required: false)
60    valijson = declare_dependency(
61        include_directories: 'subprojects/valijson/include'
62    )
63    valijson = valijson.as_system('system')
64endif
65
66install_data('blacklist.json')
67
68configs = [
69    '1ux16_riser.json',
70    '2ux8_riser.json',
71    '3ypower_vast2112_psu.json',
72    '8x25_hsbp.json',
73    'a2ul16riser.json',
74    'a2ux8x4riser.json',
75    'acbel_r1ca2122a_psu.json',
76    'acbell_rica_psu.json',
77    'ahw1um2riser.json',
78    'aspower_u1a-d10550_psu.json',
79    'aspower_u1a-d10800_psu.json',
80    'aspower_u1a-d11200_psu.json',
81    'aspower_u1a-d11600_psu.json',
82    'aspower_u1d-d10800_psu.json',
83    'asrock_c3_medium_x86.json',
84    'asrock_e3c246d4i.json',
85    'asrock_e3c256d4i.json',
86    'asrock_m3_small_x86.json',
87    'asrock_n3_xlarge_x86.json',
88    'asrock_romed8hm3.json',
89    'asrock_spc621d8hm3.json',
90    'axx1p100hssi_aic.json',
91    'axx2prthdhd.json',
92    'bellavista.json',
93    'bletchley_baseboard.json',
94    'bletchley_chassis.json',
95    'bletchley_frontpanel.json',
96    'blueridge_1s4u_chassis.json',
97    'blueridge_2u_chassis.json',
98    'blueridge_4u_chassis.json',
99    'blyth.json',
100    'bmc_storage_module.json',
101    'bnp_baseboard.json',
102    'bonnell.json',
103    'brcm_100g_1p_ocp_mezz.json',
104    'brcm_200g_1p_ocp_mezz.json',
105    'catalina_fio.json',
106    'catalina_hdd.json',
107    'catalina_osfp.json',
108    'catalina_pdb.json',
109    'catalina_scm.json',
110    'cx7_ocp.json',
111    'delta_awf2dc3200w_psu.json',
112    'delta_dps-1600ab_psu.json',
113    'delta_dps-2000ab_psu.json',
114    'delta_dps-750xb_psu.json',
115    'everest.json',
116    'f1u12x25_hsbp.json',
117    'f1u4x25_hsbp.json',
118    'f2u12x35_hsbp.json',
119    'f2u8x25_hsbp.json',
120    'fbtp.json',
121    'fbyv2.json',
122    'fbyv35.json',
123    'fbyv35_nic_mellanox.json',
124    'flextronics_s-1100adu00-201_psu.json',
125    'fp5280g3_chassis.json',
126    'fp5280g3_fanboard.json',
127    'fuji.json',
128    'genesis3_baseboard.json',
129    'genesis3_chassis.json',
130    'genesis3_psu.json',
131    'gospower_g1136-1300wna_psu.json',
132    'greatlakes.json',
133    'greatlakes_nic_mellanox.json',
134    'harma_bsm.json',
135    'harma_fanboard.json',
136    'harma_mb.json',
137    'harma_mb_vr_infineon.json',
138    'harma_scm.json',
139    'ibm_tacoma_rack_controller.json',
140    'ingraham.json',
141    'intel_front_panel.json',
142    'kudo_bmc.json',
143    'kudo_motherboard.json',
144    'micron_7450.json',
145    'minerva_cmm.json',
146    'minerva_cmm_bsm.json',
147    'minerva_cmm_hsc_infineon.json',
148    'minerva_cmm_scm.json',
149    'minerva_fanboard.json',
150    'minerva_pdb.json',
151    'minerva_pdb_hsc_xdp.json',
152    'minerva_pttv.json',
153    'minerva_sitv.json',
154    'mori_bmc.json',
155    'mori_motherboard.json',
156    'mtjade.json',
157    'mtjefferson_bmc.json',
158    'mtjefferson_mb.json',
159    'mtmitchell_bmc.json',
160    'mtmitchell_bp.json',
161    'mtmitchell_mb.json',
162    'mtmitchell_riser.json',
163    'mudflap.json',
164    'nf5280m7_baseboard.json',
165    'nisqually.json',
166    'nuvoton_npcm8xx_evb.json',
167    'nvidia_gb200_io_board.json',
168    'nvidia_gb200.json',
169    'nvidia_hmc.json',
170    'nvme_intel_p_series.json',
171    'nvme_p4500_p5500.json',
172    'pcie_ssd_retimer.json',
173    'pennybacker.json',
174    'pssf132202a.json',
175    'pssf162205a.json',
176    'pssf212201a.json',
177    'pssf222201a.json',
178    'r1000_chassis.json',
179    'r2000_chassis.json',
180    'rainier_1s4u_chassis.json',
181    'rainier_2u_chassis.json',
182    'rainier_4u_chassis.json',
183    'sas_module.json',
184    'sbp1_baseboard.json',
185    'sbp1_chassis.json',
186    'sbp1_hbm.json',
187    'sbp1_nvme.json',
188    'sbp1_psu.json',
189    'sbp1_rssd.json',
190    'solum_pssf162202_psu.json',
191    'storm_king.json',
192    'stp_baseboard.json',
193    'stp_p4000_chassis.json',
194    'supermicro-pws-920p-sq_psu.json',
195    'system1_baseboard.json',
196    'system1_chassis.json',
197    'terminus_2x100g_nic_tsff.json',
198    'tola.json',
199    'twinlake.json',
200    'tyan_s7106_baseboard.json',
201    'tyan_s8036_baseboard.json',
202    'vegman_n110_baseboard.json',
203    'vegman_rx20_baseboard.json',
204    'vegman_sx20_baseboard.json',
205    'ventura_fanboard.json',
206    'ventura_ioboard.json',
207    'ventura_ledboard.json',
208    'ventura_rmc.json',
209    'ventura_scm.json',
210    'wft_baseboard.json',
211    'yosemite4.json',
212    'yosemite4_chassis.json',
213    'yosemite4_fanboard_fsc_max_adc_ti_led_nxp_efuse_max.json',
214    'yosemite4_fanboard_fsc_max_adc_ti_led_nxp_efuse_mps.json',
215    'yosemite4_fanboard_fsc_nct_adc_max_led_ons_efuse_max.json',
216    'yosemite4_fanboard_fsc_nct_adc_max_led_ons_efuse_mps.json',
217    'yosemite4_floatingfalls.json',
218    'yosemite4_medusaboard_adc_rns_12vhsc_adi_48vhsc_inf.json',
219    'yosemite4_medusaboard_adc_rns_12vhsc_mps_48vhsc_adi.json',
220    'yosemite4_medusaboard_adc_rns_12vhsc_mps_48vhsc_inf.json',
221    'yosemite4_medusaboard_adc_rns_hsc_adi.json',
222    'yosemite4_medusaboard_adc_rns_isl_12vhsc_adi_48vhsc_inf.json',
223    'yosemite4_medusaboard_adc_ti_12vhsc_adi_48vhsc_inf.json',
224    'yosemite4_medusaboard_adc_ti_12vhsc_mps_48vhsc_adi.json',
225    'yosemite4_medusaboard_adc_ti_12vhsc_mps_48vhsc_inf.json',
226    'yosemite4_medusaboard_adc_ti_hsc_adi.json',
227    'yosemite4_sentineldome_chassis.json',
228    'yosemite4_sentineldome_t1.json',
229    'yosemite4_sentineldome_t1_retimer.json',
230    'yosemite4_sentineldome_t2.json',
231    'yosemite4_sentineldome_t2_retimer.json',
232    'yosemite4_spiderboard_adc_max_pwr_ti.json',
233    'yosemite4_spiderboard_adc_ti_pwr_ti.json',
234    'yosemite4_wailuafalls.json',
235    'yosemite4n.json',
236]
237filepaths = []
238foreach c : configs
239    file = join_paths('configurations', c)
240    install_data(
241        file,
242        install_dir: join_paths(
243            packagedir,
244            'configurations',
245        )
246    )
247    filepaths += [file]
248endforeach
249
250if get_option('validate-json')
251    validate_script = files('scripts/validate_configs.py')
252    autojson = custom_target(
253      'check_syntax',
254      command: [
255        validate_script,
256        '-v',
257        '-k',
258      ],
259      depend_files: files(filepaths),
260      build_by_default: true,
261      capture: true,
262      output: 'validate_configs.log',
263    )
264endif
265
266schemas = [
267    'global.json',
268    'legacy.json',
269    'openbmc-dbus.json',
270    'ibm.json',
271    'intel.json',
272    'pid.json',
273    'pid_zone.json',
274    'stepwise.json',
275    'virtual_sensor.json',
276    'satellite_controller.json',
277]
278
279foreach s : schemas
280    install_data(
281        join_paths('schemas', s),
282        install_dir: join_paths(
283            packagedir,
284            'configurations',
285            'schemas',
286        )
287    )
288endforeach
289
290subdir('service_files')
291subdir('src')
292
293if not build_tests.disabled()
294    test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
295    gtest = dependency('gtest', main: true, disabler: true, required: false)
296    gmock = dependency('gmock', disabler: true, required: false)
297    if not (gtest.found() and gmock.found()) and build_tests.enabled()
298        cmake = import('cmake')
299        gtest_subproject = cmake.subproject('gtest')
300        cm_gtest = gtest_subproject.dependency('gtest')
301        cm_gtest_main = gtest_subproject.dependency('gtest_main')
302        gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
303        gmock = gtest_subproject.dependency('gmock')
304
305    endif
306
307    test(
308        'test_entity_manager',
309        executable(
310            'test_entity_manager',
311            'test/test_entity-manager.cpp',
312            'src/expression.cpp',
313            'src/utils.cpp',
314            cpp_args: test_boost_args,
315            dependencies: [
316                boost,
317                gtest,
318                nlohmann_json_dep,
319                phosphor_logging_dep,
320                sdbusplus,
321                valijson,
322            ],
323            include_directories: 'src',
324        )
325    )
326
327    test(
328        'test_fru_utils',
329        executable(
330            'test_fru_utils',
331            'test/test_fru-utils.cpp',
332            'src/fru_utils.cpp',
333            'src/fru_reader.cpp',
334            cpp_args: test_boost_args,
335            dependencies: [
336                boost,
337                gtest,
338                phosphor_logging_dep,
339                sdbusplus,
340            ],
341            include_directories: 'src',
342        )
343    )
344
345    test(
346        'test_topology',
347        executable(
348            'test_topology',
349            'test/test_topology.cpp',
350            'src/topology.cpp',
351            cpp_args: test_boost_args,
352            dependencies: [
353                gtest,
354                gmock,
355                nlohmann_json_dep,
356                phosphor_logging_dep,
357            ],
358            include_directories: 'src',
359        )
360    )
361endif
362