xref: /openbmc/entity-manager/meson.build (revision f8ae2ba5)
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.57.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
36if cpp.has_header('nlohmann/json.hpp')
37    nlohmann_json = declare_dependency()
38else
39    subproject('nlohmann', required: false)
40    nlohmann_json = declare_dependency(
41        include_directories: [
42            'subprojects/nlohmann/single_include',
43            'subprojects/nlohmann/single_include/nlohmann',
44        ]
45    )
46    nlohmann_json = nlohmann_json.as_system('system')
47endif
48sdbusplus = dependency('sdbusplus', required: false)
49if not sdbusplus.found()
50    sdbusplus_proj = subproject('sdbusplus', required: true)
51    sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
52    sdbusplus = sdbusplus.as_system('system')
53endif
54systemd = dependency('systemd')
55systemd_system_unit_dir = systemd.get_pkgconfig_variable(
56    'systemdsystemunitdir',
57    define_variable: ['prefix', get_option('prefix')])
58packagedir = join_paths(
59    get_option('prefix'),
60    get_option('datadir'),
61    meson.project_name(),
62)
63sysconfdir = join_paths(
64    get_option('prefix'),
65    get_option('sysconfdir'),
66    meson.project_name(),
67)
68threads = dependency('threads')
69if cpp.has_header('valijson/validator.hpp')
70    valijson = declare_dependency()
71else
72    subproject('valijson', required: false)
73    valijson = declare_dependency(
74        include_directories: 'subprojects/valijson/include'
75    )
76    valijson = valijson.as_system('system')
77endif
78
79install_data('blacklist.json')
80
81configs = [
82    '1Ux16 Riser.json',
83    '2Ux8 Riser.json',
84    '8X25 HSBP.json',
85    'A2UL16RISER.json',
86    'A2UX8X4RISER.json',
87    'ACBELL_RICA_PSU.json',
88    'ASRock_E3C246D4I.json',
89    'Bletchley_Baseboard.json',
90    'Bletchley_Chassis.json',
91    'Blyth.json',
92    'AHW1UM2RISER.json',
93    'ASPOWER_U1A-D10550_PSU.json',
94    'ASPOWER_U1A-D10800_PSU.json',
95    'ASPOWER_U1A-D11200_PSU.json',
96    'ASPOWER_U1A-D11600_PSU.json',
97    'ASPOWER_U1D-D10800_PSU.json',
98    'AXX1P100HSSI_AIC.json',
99    'AXX2PRTHDHD.json',
100    'BNP Baseboard.json',
101    'Bellavista.json',
102    'Delta_AWF2DC3200W_PSU.json',
103    'Delta DPS-750XB PSU.json',
104    'Delta_DPS-1600AB_PSU.json',
105    'Delta_DPS-2000AB_PSU.json',
106    'Everest.json',
107    'F1U12X25 HSBP.json',
108    'F1U4X25 HSBP.json',
109    'F2U12X35 HSBP.json',
110    'F2U8X25 HSBP.json',
111    'FBTP.json',
112    'FBYV2.json',
113    'Flextronics S-1100ADU00-201 PSU.json',
114    'IBM 1000W CFFPS.json',
115    'IBM 1400W CFFPS.json',
116    'IBM 1600W CFFPS.json',
117    'IBM 2000W CFFPS.json',
118    'IBM 2300W CFFPS.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    'PSSF132202A.json',
127    'PSSF162205A.json',
128    'PSSF212201A.json',
129    'PSSF222201A.json',
130    'Rainier 2U Chassis.json',
131    'Rainier 4U Chassis.json',
132    'Rainier 1S4U Chassis.json',
133    'R1000 Chassis.json',
134    'R2000 Chassis.json',
135    'SAS Module.json',
136    'SOLUM_PSSF162202_PSU.json',
137    'Storm King.json',
138    'STP Baseboard.json',
139    'STP P4000 Chassis.json',
140    'Tyan_S7106_Baseboard.json',
141    'Tyan_S8036_Baseboard.json',
142    'WFT Baseboard.json',
143]
144filepaths = []
145foreach c : configs
146    file = join_paths('configurations', c)
147    install_data(
148        file,
149        install_dir: join_paths(
150            packagedir,
151            'configurations',
152        )
153    )
154    filepaths += [file]
155endforeach
156
157validate_script = files('scripts/validate-configs.py')
158autojson = custom_target(
159  'check_syntax',
160  command: [
161    validate_script,
162    '-v',
163    '-k',
164  ],
165  depend_files: files(filepaths),
166  build_by_default: true,
167  capture: true,
168  output: 'validate_configs.log',
169)
170
171schemas = [
172    'global.json',
173    'legacy.json',
174    'openbmc-dbus.json',
175    'IBM.json',
176    'Intel.json',
177    'Pid.json',
178    'Pid.Zone.json',
179    'Stepwise.json',
180    'VirtualSensor.json',
181]
182
183foreach s : schemas
184    install_data(
185        join_paths('schemas', s),
186        install_dir: join_paths(
187            packagedir,
188            'configurations',
189            'schemas',
190        )
191    )
192endforeach
193
194subdir('service_files')
195subdir('src')
196
197if not build_tests.disabled()
198    test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
199    gtest = dependency('gtest', main: true, disabler: true, required: false)
200    if not gtest.found() and build_tests.enabled()
201        cmake = import('cmake')
202        gtest_subproject = cmake.subproject('gtest')
203        cm_gtest = gtest_subproject.dependency('gtest')
204        cm_gtest_main = gtest_subproject.dependency('gtest_main')
205        gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
206    endif
207
208    test(
209        'test_entity_manager',
210        executable(
211            'test_entity_manager',
212            'test/test_entity-manager.cpp',
213            'src/Utils.cpp',
214            cpp_args: test_boost_args,
215            dependencies: [
216                boost,
217                gtest,
218                nlohmann_json,
219                sdbusplus,
220                valijson,
221            ],
222            implicit_include_directories: false,
223            include_directories: 'include',
224        )
225    )
226
227    test(
228        'test_fru_utils',
229        executable(
230            'test_fru_utils',
231            'test/test_fru-utils.cpp',
232            'src/FruUtils.cpp',
233            cpp_args: test_boost_args,
234            dependencies: [
235                boost,
236                gtest,
237            ],
238            implicit_include_directories: false,
239            include_directories: 'include',
240        )
241    )
242endif
243