xref: /openbmc/entity-manager/meson.build (revision 8dacf6a8)
1project(
2    'entity-manager',
3    'cpp',
4    default_options: [
5        'warning_level=3',
6        'werror=true',
7        'cpp_std=c++17'
8    ],
9    license: 'Apache-2.0',
10    version: '0.1',
11)
12
13cmake = import('cmake')
14
15add_project_arguments('-Wno-psabi', language: 'cpp')
16
17boost_args = [
18    '-DBOOST_SYSTEM_NO_DEPRECATED',
19    '-DBOOST_ERROR_CODE_HEADER_ONLY',
20    '-DBOOST_NO_RTTI',
21    '-DBOOST_NO_TYPEID',
22    '-DBOOST_ALL_NO_LIB',
23    '-DBOOST_ALLOW_DEPRECATED_HEADERS'
24]
25build_tests = get_option('tests')
26cpp = meson.get_compiler('cpp')
27boost = dependency('boost', required: false)
28if not boost.found()
29     subproject('boost', required: false)
30     boost = declare_dependency(
31         include_directories: 'subprojects/boost_1_71_0',
32     )
33     boost = boost.as_system('system')
34endif
35if get_option('fru-device')
36    i2c = cpp.find_library('i2c')
37endif
38
39nlohmann_json_dep = dependency('nlohmann_json',
40                               fallback: [ 'nlohmann_json', 'nlohmann_json_dep'])
41
42sdbusplus = dependency('sdbusplus', required: false)
43if not sdbusplus.found()
44    sdbusplus_proj = subproject('sdbusplus', required: true)
45    sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
46    sdbusplus = sdbusplus.as_system('system')
47endif
48systemd = dependency('systemd')
49systemd_system_unit_dir = systemd.get_pkgconfig_variable(
50    'systemdsystemunitdir',
51    define_variable: ['prefix', get_option('prefix')])
52packagedir = join_paths(
53    get_option('prefix'),
54    get_option('datadir'),
55    meson.project_name(),
56)
57threads = dependency('threads')
58
59valijson_dep = dependency('valijson', required: false)
60if not valijson_dep.found()
61    valijson_opt = cmake.subproject_options()
62    valijson_opt.add_cmake_defines({'valijson_BUILD_TESTS': false,
63                                    'valijson_BUILD_EXAMPLES': false})
64    valijson_proj = cmake.subproject('valijson', options: valijson_opt)
65    valijson_dep = valijson_proj.dependency('valijson')
66    valijson = valijson_dep.partial_dependency(includes: true).as_system()
67endif
68valijson = valijson.partial_dependency(includes: true).as_system()
69
70install_data('blacklist.json')
71
72configs = [
73    '1Ux16 Riser.json',
74    '2Ux8 Riser.json',
75    '8X25 HSBP.json',
76    'A2UL16RISER.json',
77    'A2UX8X4RISER.json',
78    'ACBELL_RICA_PSU.json',
79    'Blyth.json',
80    'AHW1UM2RISER.json',
81    'ASPOWER_U1A-D10550_PSU.json',
82    'ASPOWER_U1A-D10800_PSU.json',
83    'ASPOWER_U1A-D11200_PSU.json',
84    'ASPOWER_U1A-D11600_PSU.json',
85    'ASPOWER_U1D-D10800_PSU.json',
86    'AXX1P100HSSI_AIC.json',
87    'AXX2PRTHDHD.json',
88    'BNP Baseboard.json',
89    'Bellavista.json',
90    'Delta DPS-750XB PSU.json',
91    'Delta_DPS-1600AB_PSU.json',
92    'Delta_DPS-2000AB_PSU.json',
93    'Everest.json',
94    'F1U12X25 HSBP.json',
95    'F1U4X25 HSBP.json',
96    'F2U12X35 HSBP.json',
97    'F2U8X25 HSBP.json',
98    'FBTP.json',
99    'FBYV2.json',
100    'Flextronics S-1100ADU00-201 PSU.json',
101    'IBM 1000W CFFPS.json',
102    'IBM 1400W CFFPS.json',
103    'IBM 1600W CFFPS.json',
104    'IBM 2000W CFFPS.json',
105    'IBM 2300W CFFPS.json',
106    'Intel Front Panel.json',
107    'Nisqually.json',
108    'NVME P4000.json',
109    'PCIE SSD Retimer.json',
110    'PSSF132202A.json',
111    'PSSF162205A.json',
112    'PSSF212201A.json',
113    'PSSF222201A.json',
114    'Rainier 2U Chassis.json',
115    'Rainier 4U Chassis.json',
116    'Rainier 1S4U Chassis.json',
117    'R1000 Chassis.json',
118    'R2000 Chassis.json',
119    'SAS Module.json',
120    'SOLUM_PSSF162202_PSU.json',
121    'STP Baseboard.json',
122    'STP P4000 Chassis.json',
123    'Tyan_S7106_Baseboard.json',
124    'WFT Baseboard.json',
125]
126
127foreach c : configs
128    install_data(
129        join_paths('configurations', c),
130        install_dir: join_paths(
131            packagedir,
132            'configurations',
133        )
134    )
135endforeach
136
137schemas = [
138    'global.json',
139    'legacy.json',
140    'openbmc-dbus.json',
141    'IBM.json',
142    'Intel.json',
143    'Pid.json',
144    'Pid.Zone.json',
145    'Stepwise.json',
146]
147
148foreach s : schemas
149    install_data(
150        join_paths('schemas', s),
151        install_dir: join_paths(
152            packagedir,
153            'configurations',
154            'schemas',
155        )
156    )
157endforeach
158
159subdir('service_files')
160subdir('src')
161
162if not build_tests.disabled()
163    test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
164    gtest = dependency('gtest', main: true, disabler: true, required: false)
165    if not gtest.found() and build_tests.enabled()
166        gtest_subproject = cmake.subproject('gtest')
167        cm_gtest = gtest_subproject.dependency('gtest')
168        cm_gtest_main = gtest_subproject.dependency('gtest_main')
169        gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
170    endif
171
172    test(
173        'test_entity_manager',
174        executable(
175            'test_entity_manager',
176            'test/test_entity-manager.cpp',
177            'src/Utils.cpp',
178            cpp_args: test_boost_args,
179            dependencies: [
180                boost,
181                gtest,
182                nlohmann_json_dep,
183                sdbusplus,
184                valijson,
185            ],
186            implicit_include_directories: false,
187            include_directories: 'include',
188        )
189    )
190
191    test(
192        'test_fru_utils',
193        executable(
194            'test_fru_utils',
195            'test/test_fru-utils.cpp',
196            'src/FruUtils.cpp',
197            cpp_args: test_boost_args,
198            dependencies: [
199                boost,
200                gtest,
201            ],
202            implicit_include_directories: false,
203            include_directories: 'include',
204        )
205    )
206endif
207