xref: /openbmc/entity-manager/meson.build (revision d97c6319)
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    'micron_7450.json',
125    'mori_bmc.json',
126    'mori_motherboard.json',
127    'mtjade.json',
128    'mtmitchell_bmc.json',
129    'mtmitchell_mb.json',
130    'mudflap.json',
131    'nisqually.json',
132    'nvme_p4000.json',
133    'pcie_ssd_retimer.json',
134    'pennybacker.json',
135    'pssf132202a.json',
136    'pssf162205a.json',
137    'pssf212201a.json',
138    'pssf222201a.json',
139    'rainier_2u_chassis.json',
140    'rainier_4u_chassis.json',
141    'rainier_1s4u_chassis.json',
142    'r1000_chassis.json',
143    'r2000_chassis.json',
144    'sas_module.json',
145    'sbp1_baseboard.json',
146    'sbp1_chassis.json',
147    'sbp1_nvme.json',
148    'sbp1_psu.json',
149    'system1_baseboard.json',
150    'solum_pssf162202_psu.json',
151    'storm_king.json',
152    'stp_baseboard.json',
153    'stp_p4000_chassis.json',
154    'twinlake.json',
155    'tyan_s7106_baseboard.json',
156    'tyan_s8036_baseboard.json',
157    'vegman_n110_baseboard.json',
158    'vegman_rx20_baseboard.json',
159    'vegman_sx20_baseboard.json',
160    'wft_baseboard.json',
161    'yosemite4_fanboard.json',
162]
163filepaths = []
164foreach c : configs
165    file = join_paths('configurations', c)
166    install_data(
167        file,
168        install_dir: join_paths(
169            packagedir,
170            'configurations',
171        )
172    )
173    filepaths += [file]
174endforeach
175
176validate_script = files('scripts/validate_configs.py')
177autojson = custom_target(
178  'check_syntax',
179  command: [
180    validate_script,
181    '-v',
182    '-k',
183  ],
184  depend_files: files(filepaths),
185  build_by_default: true,
186  capture: true,
187  output: 'validate_configs.log',
188)
189
190schemas = [
191    'global.json',
192    'legacy.json',
193    'openbmc-dbus.json',
194    'ibm.json',
195    'intel.json',
196    'pid.json',
197    'pid_zone.json',
198    'stepwise.json',
199    'virtual_sensor.json',
200    'satellite_controller.json',
201]
202
203foreach s : schemas
204    install_data(
205        join_paths('schemas', s),
206        install_dir: join_paths(
207            packagedir,
208            'configurations',
209            'schemas',
210        )
211    )
212endforeach
213
214subdir('service_files')
215subdir('src')
216
217if not build_tests.disabled()
218    test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
219    gtest = dependency('gtest', main: true, disabler: true, required: false)
220    gmock = dependency('gmock', disabler: true, required: false)
221    if not (gtest.found() and gmock.found()) and build_tests.enabled()
222        cmake = import('cmake')
223        gtest_subproject = cmake.subproject('gtest')
224        cm_gtest = gtest_subproject.dependency('gtest')
225        cm_gtest_main = gtest_subproject.dependency('gtest_main')
226        gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
227        gmock = gtest_subproject.dependency('gmock')
228
229    endif
230
231    test(
232        'test_entity_manager',
233        executable(
234            'test_entity_manager',
235            'test/test_entity-manager.cpp',
236            'src/expression.cpp',
237            'src/utils.cpp',
238            cpp_args: test_boost_args,
239            dependencies: [
240                boost,
241                gtest,
242                nlohmann_json_dep,
243                sdbusplus,
244                valijson,
245            ],
246            include_directories: 'src',
247        )
248    )
249
250    test(
251        'test_fru_utils',
252        executable(
253            'test_fru_utils',
254            'test/test_fru-utils.cpp',
255            'src/fru_utils.cpp',
256            'src/fru_reader.cpp',
257            cpp_args: test_boost_args,
258            dependencies: [
259                boost,
260                gtest,
261                sdbusplus,
262            ],
263            include_directories: 'src',
264        )
265    )
266
267    test(
268        'test_topology',
269        executable(
270            'test_topology',
271            'test/test_topology.cpp',
272            'src/topology.cpp',
273            cpp_args: test_boost_args,
274            dependencies: [
275                gtest,
276                gmock,
277                nlohmann_json_dep,
278            ],
279            include_directories: 'src',
280        )
281    )
282endif
283