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