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