xref: /openbmc/entity-manager/meson.build (revision ee1db76f)
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    '8x25_hsbp.json',
77    'a2ul16riser.json',
78    'a2ux8x4riser.json',
79    'acbell_rica_psu.json',
80    'asrock_e3c246d4i.json',
81    'asrock_romed8hm3.json',
82    'bletchley_baseboard.json',
83    'bletchley_chassis.json',
84    'bletchley_frontpanel.json',
85    'blyth.json',
86    'ahw1um2riser.json',
87    'aspower_u1a-d10550_psu.json',
88    'aspower_u1a-d10800_psu.json',
89    'aspower_u1a-d11200_psu.json',
90    'aspower_u1a-d11600_psu.json',
91    'aspower_u1d-d10800_psu.json',
92    'axx1p100hssi_aic.json',
93    'axx2prthdhd.json',
94    'bnp_baseboard.json',
95    'bellavista.json',
96    'bonnell.json',
97    'delta_awf2dc3200w_psu.json',
98    'delta_dps-750xb_psu.json',
99    'delta_dps-1600ab_psu.json',
100    'delta_dps-2000ab_psu.json',
101    'everest.json',
102    'f1u12x25_hsbp.json',
103    'f1u4x25_hsbp.json',
104    'f2u12x35_hsbp.json',
105    'f2u8x25_hsbp.json',
106    'fbtp.json',
107    'fbyv2.json',
108    'fbyv35.json',
109    'fbyv35_nic_mellanox.json',
110    'flextronics_s-1100adu00-201_psu.json',
111    'greatlakes.json',
112    'greatlakes_nic_mellanox.json',
113    'ibm_1000w_cffps.json',
114    'ibm_1400w_cffps.json',
115    'ibm_1600w_cffps.json',
116    'ibm_2000w_cffps.json',
117    'ibm_2300w_cffps.json',
118    'ibm_tacoma_rack_controller.json',
119    'intel_front_panel.json',
120    'kudo_bmc.json',
121    'kudo_motherboard.json',
122    'mt_jade.json',
123    'nisqually.json',
124    'nvme_p4000.json',
125    'pcie_ssd_retimer.json',
126    'pennybacker.json',
127    'pssf132202a.json',
128    'pssf162205a.json',
129    'pssf212201a.json',
130    'pssf222201a.json',
131    'rainier_2u_chassis.json',
132    'rainier_4u_chassis.json',
133    'rainier_1s4u_chassis.json',
134    'r1000_chassis.json',
135    'r2000_chassis.json',
136    'sas_module.json',
137    'solum_pssf162202_psu.json',
138    'storm_king.json',
139    'stp_baseboard.json',
140    'stp_p4000_chassis.json',
141    'twinlake.json',
142    'tyan_s7106_baseboard.json',
143    'tyan_s8036_baseboard.json',
144    'vegman_n110_baseboard.json',
145    'vegman_rx20_baseboard.json',
146    'vegman_sx20_baseboard.json',
147    'wft_baseboard.json',
148]
149filepaths = []
150foreach c : configs
151    file = join_paths('configurations', c)
152    install_data(
153        file,
154        install_dir: join_paths(
155            packagedir,
156            'configurations',
157        )
158    )
159    filepaths += [file]
160endforeach
161
162validate_script = files('scripts/validate_configs.py')
163autojson = custom_target(
164  'check_syntax',
165  command: [
166    validate_script,
167    '-v',
168    '-k',
169  ],
170  depend_files: files(filepaths),
171  build_by_default: true,
172  capture: true,
173  output: 'validate_configs.log',
174)
175
176schemas = [
177    'global.json',
178    'legacy.json',
179    'openbmc-dbus.json',
180    'ibm.json',
181    'intel.json',
182    'pid.json',
183    'pid_zone.json',
184    'stepwise.json',
185    'virtual_sensor.json',
186    'satellite_controller.json',
187]
188
189foreach s : schemas
190    install_data(
191        join_paths('schemas', s),
192        install_dir: join_paths(
193            packagedir,
194            'configurations',
195            'schemas',
196        )
197    )
198endforeach
199
200subdir('service_files')
201subdir('src')
202
203if not build_tests.disabled()
204    test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
205    gtest = dependency('gtest', main: true, disabler: true, required: false)
206    gmock = dependency('gmock', disabler: true, required: false)
207    if not (gtest.found() and gmock.found()) and build_tests.enabled()
208        cmake = import('cmake')
209        gtest_subproject = cmake.subproject('gtest')
210        cm_gtest = gtest_subproject.dependency('gtest')
211        cm_gtest_main = gtest_subproject.dependency('gtest_main')
212        gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
213        gmock = gtest_subproject.dependency('gmock')
214
215    endif
216
217    test(
218        'test_entity_manager',
219        executable(
220            'test_entity_manager',
221            'test/test_entity-manager.cpp',
222            'src/expression.cpp',
223            'src/utils.cpp',
224            cpp_args: test_boost_args,
225            dependencies: [
226                boost,
227                gtest,
228                nlohmann_json_dep,
229                sdbusplus,
230                valijson,
231            ],
232            include_directories: 'src',
233        )
234    )
235
236    test(
237        'test_fru_utils',
238        executable(
239            'test_fru_utils',
240            'test/test_fru-utils.cpp',
241            'src/fru_utils.cpp',
242            'src/fru_reader.cpp',
243            cpp_args: test_boost_args,
244            dependencies: [
245                boost,
246                gtest,
247                sdbusplus,
248            ],
249            include_directories: 'src',
250        )
251    )
252
253    test(
254        'test_topology',
255        executable(
256            'test_topology',
257            'test/test_topology.cpp',
258            'src/topology.cpp',
259            cpp_args: test_boost_args,
260            dependencies: [
261                gtest,
262                gmock,
263            ],
264            include_directories: 'src',
265        )
266    )
267endif
268