xref: /openbmc/entity-manager/meson.build (revision e153a9d3)
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_bp.json',
163    'mtjefferson_mb.json',
164    'mtmitchell_bmc.json',
165    'mtmitchell_bp.json',
166    'mtmitchell_mb.json',
167    'mtmitchell_riser.json',
168    'mudflap.json',
169    'nf5280m7_baseboard.json',
170    'nisqually.json',
171    'nuvoton_npcm8xx_evb.json',
172    'nvidia_gb200_io_board.json',
173    'nvidia_gb200.json',
174    'nvidia_hmc.json',
175    'nvme_intel_p_series.json',
176    'nvme_p4500_p5500.json',
177    'pcie_ssd_retimer.json',
178    'pennybacker.json',
179    'pssf132202a.json',
180    'pssf162205a.json',
181    'pssf212201a.json',
182    'pssf222201a.json',
183    'r1000_chassis.json',
184    'r2000_chassis.json',
185    'rainier_1s4u_chassis.json',
186    'rainier_2u_chassis.json',
187    'rainier_4u_chassis.json',
188    'sas_module.json',
189    'sbp1_baseboard.json',
190    'sbp1_chassis.json',
191    'sbp1_hbm.json',
192    'sbp1_nvme.json',
193    'sbp1_psu.json',
194    'sbp1_rssd.json',
195    'solum_pssf162202_psu.json',
196    'storm_king.json',
197    'stp_baseboard.json',
198    'stp_p4000_chassis.json',
199    'supermicro-pws-920p-sq_psu.json',
200    'system1_baseboard.json',
201    'system1_chassis.json',
202    'terminus_2x100g_nic_tsff.json',
203    'tola.json',
204    'twinlake.json',
205    'tyan_s7106_baseboard.json',
206    'tyan_s8036_baseboard.json',
207    'vegman_n110_baseboard.json',
208    'vegman_rx20_baseboard.json',
209    'vegman_sx20_baseboard.json',
210    'ventura_fanboard.json',
211    'ventura_ioboard.json',
212    'ventura_ledboard.json',
213    'ventura_rmc.json',
214    'ventura_scm.json',
215    'wft_baseboard.json',
216    'yosemite4.json',
217    'yosemite4_chassis.json',
218    'yosemite4_fanboard_fsc_max_adc_ti_led_nxp_efuse_max.json',
219    'yosemite4_fanboard_fsc_max_adc_ti_led_nxp_efuse_mps.json',
220    'yosemite4_fanboard_fsc_nct_adc_max_led_ons_efuse_max.json',
221    'yosemite4_fanboard_fsc_nct_adc_max_led_ons_efuse_mps.json',
222    'yosemite4_floatingfalls.json',
223    'yosemite4_medusaboard_adc_rns_12vhsc_adi_48vhsc_inf.json',
224    'yosemite4_medusaboard_adc_rns_12vhsc_mps_48vhsc_adi.json',
225    'yosemite4_medusaboard_adc_rns_12vhsc_mps_48vhsc_inf.json',
226    'yosemite4_medusaboard_adc_rns_hsc_adi.json',
227    'yosemite4_medusaboard_adc_rns_isl_12vhsc_adi_48vhsc_inf.json',
228    'yosemite4_medusaboard_adc_ti_12vhsc_adi_48vhsc_inf.json',
229    'yosemite4_medusaboard_adc_ti_12vhsc_mps_48vhsc_adi.json',
230    'yosemite4_medusaboard_adc_ti_12vhsc_mps_48vhsc_inf.json',
231    'yosemite4_medusaboard_adc_ti_hsc_adi.json',
232    'yosemite4_sentineldome_chassis.json',
233    'yosemite4_sentineldome_t1.json',
234    'yosemite4_sentineldome_t1_retimer.json',
235    'yosemite4_sentineldome_t2.json',
236    'yosemite4_sentineldome_t2_retimer.json',
237    'yosemite4_spiderboard_adc_max_pwr_ti.json',
238    'yosemite4_spiderboard_adc_ti_pwr_ti.json',
239    'yosemite4_cpu.json',
240    'yosemite4_wailuafalls.json',
241    'yosemite4n.json',
242]
243filepaths = []
244foreach c : configs
245    file = join_paths('configurations', c)
246    install_data(
247        file,
248        install_dir: join_paths(
249            packagedir,
250            'configurations',
251        )
252    )
253    filepaths += [file]
254endforeach
255
256if get_option('validate-json')
257    validate_script = files('scripts/validate_configs.py')
258    autojson = custom_target(
259      'check_syntax',
260      command: [
261        validate_script,
262        '-v',
263        '-k',
264      ],
265      depend_files: files(filepaths),
266      build_by_default: true,
267      capture: true,
268      output: 'validate_configs.log',
269    )
270endif
271
272schemas = [
273    'global.json',
274    'legacy.json',
275    'openbmc-dbus.json',
276    'ibm.json',
277    'intel.json',
278    'pid.json',
279    'pid_zone.json',
280    'stepwise.json',
281    'virtual_sensor.json',
282    'satellite_controller.json',
283]
284
285foreach s : schemas
286    install_data(
287        join_paths('schemas', s),
288        install_dir: join_paths(
289            packagedir,
290            'configurations',
291            'schemas',
292        )
293    )
294endforeach
295
296subdir('service_files')
297subdir('src')
298
299if not build_tests.disabled()
300    test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
301    gtest = dependency('gtest', main: true, disabler: true, required: false)
302    gmock = dependency('gmock', disabler: true, required: false)
303    if not (gtest.found() and gmock.found()) and build_tests.enabled()
304        cmake = import('cmake')
305        gtest_subproject = cmake.subproject('gtest')
306        cm_gtest = gtest_subproject.dependency('gtest')
307        cm_gtest_main = gtest_subproject.dependency('gtest_main')
308        gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
309        gmock = gtest_subproject.dependency('gmock')
310
311    endif
312
313    test(
314        'test_entity_manager',
315        executable(
316            'test_entity_manager',
317            'test/test_entity-manager.cpp',
318            'src/expression.cpp',
319            'src/utils.cpp',
320            cpp_args: test_boost_args,
321            dependencies: [
322                boost,
323                gtest,
324                nlohmann_json_dep,
325                phosphor_logging_dep,
326                sdbusplus,
327                valijson,
328            ],
329            include_directories: 'src',
330        )
331    )
332
333    test(
334        'test_fru_utils',
335        executable(
336            'test_fru_utils',
337            'test/test_fru-utils.cpp',
338            'src/fru_utils.cpp',
339            'src/fru_reader.cpp',
340            cpp_args: test_boost_args,
341            dependencies: [
342                boost,
343                gtest,
344                phosphor_logging_dep,
345                sdbusplus,
346            ],
347            include_directories: 'src',
348        )
349    )
350
351    test(
352        'test_topology',
353        executable(
354            'test_topology',
355            'test/test_topology.cpp',
356            'src/topology.cpp',
357            cpp_args: test_boost_args,
358            dependencies: [
359                gtest,
360                gmock,
361                nlohmann_json_dep,
362                phosphor_logging_dep,
363            ],
364            include_directories: 'src',
365        )
366    )
367endif
368