blob: ffef7c8bb034f925822742cdfee6bad26d3e8091 [file] [log] [blame]
Brad Bishopb4459912019-11-05 19:39:11 -05001project(
2 'entity-manager',
3 'cpp',
Patrick Williams37304f02025-02-01 08:38:32 -05004 default_options: ['warning_level=3', 'werror=true', 'cpp_std=c++23'],
Brad Bishopb4459912019-11-05 19:39:11 -05005 license: 'Apache-2.0',
6 version: '0.1',
Patrick Williamsa183f4a2023-08-23 06:31:19 -05007 meson_version: '>=1.1.1',
Brad Bishopb4459912019-11-05 19:39:11 -05008)
Brad Bishopec984912020-10-01 10:24:55 -04009add_project_arguments('-Wno-psabi', language: 'cpp')
Brad Bishopb4459912019-11-05 19:39:11 -050010
11boost_args = [
Ed Tanousae2d4352025-02-12 15:51:48 -080012 '-DBOOST_ASIO_NO_DEPRECATED',
Brad Bishopb4459912019-11-05 19:39:11 -050013 '-DBOOST_SYSTEM_NO_DEPRECATED',
14 '-DBOOST_ERROR_CODE_HEADER_ONLY',
15 '-DBOOST_NO_RTTI',
16 '-DBOOST_NO_TYPEID',
17 '-DBOOST_ALL_NO_LIB',
Patrick Williams37304f02025-02-01 08:38:32 -050018 '-DBOOST_ALLOW_DEPRECATED_HEADERS',
Brad Bishopb4459912019-11-05 19:39:11 -050019]
Brad Bishope3a12b62020-01-15 11:56:29 -050020cpp = meson.get_compiler('cpp')
Brad Bishop787e8282020-01-15 12:16:53 -050021boost = dependency('boost', required: false)
22if not boost.found()
Patrick Williams37304f02025-02-01 08:38:32 -050023 subproject('boost', required: false)
24 boost = declare_dependency(include_directories: 'subprojects/boost_1_71_0')
25 boost = boost.as_system('system')
Brad Bishop787e8282020-01-15 12:16:53 -050026endif
Brad Bishop92daaaa2020-01-20 15:45:01 -050027if get_option('fru-device')
28 i2c = cpp.find_library('i2c')
29endif
Andrew Jeffery14a7bc92021-08-02 10:01:22 +093030
Alexander Hansen8c4b1d92024-11-04 14:06:24 +010031if get_option('devicetree-vpd') or get_option('gpio-presence')
Patrick Williams37304f02025-02-01 08:38:32 -050032 phosphor_dbus_interfaces_dep = dependency(
33 'phosphor-dbus-interfaces',
34 include_type: 'system',
35 )
Chris Sides2ab73412024-10-15 16:04:11 -050036endif
37
Patrick Williams7e119822023-12-07 11:38:19 -060038nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Alexander Hansenc3db2c32024-08-20 15:01:38 +020039sdbusplus = dependency('sdbusplus', include_type: 'system')
40phosphor_logging_dep = dependency('phosphor-logging')
Andrew Jeffery14a7bc92021-08-02 10:01:22 +093041
Alexander Hansen8c4b1d92024-11-04 14:06:24 +010042if get_option('gpio-presence') or get_option('tests').allowed()
43 libgpio_dep = dependency('libgpiodcxx', default_options: ['bindings=cxx'])
44endif
45
Brad Bishopb4459912019-11-05 19:39:11 -050046systemd = dependency('systemd')
Patrick Williamsee1db762023-04-12 08:05:58 -050047systemd_system_unit_dir = systemd.get_variable(
Brad Bishopb4459912019-11-05 19:39:11 -050048 'systemdsystemunitdir',
Patrick Williams37304f02025-02-01 08:38:32 -050049 pkgconfig_define: ['prefix', get_option('prefix')],
50)
Brad Bishopb4459912019-11-05 19:39:11 -050051packagedir = join_paths(
52 get_option('prefix'),
53 get_option('datadir'),
54 meson.project_name(),
55)
Andrew Jefferya9c58922021-06-01 09:28:59 +093056sysconfdir = join_paths(
57 get_option('prefix'),
58 get_option('sysconfdir'),
59 meson.project_name(),
60)
Brad Bishopb4459912019-11-05 19:39:11 -050061threads = dependency('threads')
Ed Tanous55ae5a82021-08-02 14:00:02 -070062if cpp.has_header('valijson/validator.hpp')
63 valijson = declare_dependency()
64else
65 subproject('valijson', required: false)
66 valijson = declare_dependency(
Patrick Williams37304f02025-02-01 08:38:32 -050067 include_directories: 'subprojects/valijson/include',
Ed Tanous55ae5a82021-08-02 14:00:02 -070068 )
69 valijson = valijson.as_system('system')
Brad Bishopff1ddb72020-01-15 12:24:56 -050070endif
Brad Bishopb4459912019-11-05 19:39:11 -050071
72install_data('blacklist.json')
73
Alexander Hansenedc46342025-01-06 17:01:54 +010074# this creates the 'configs' variable
75subdir('configurations')
76
Ed Tanous9dc2cc52021-12-20 16:05:49 -080077filepaths = []
Brad Bishopb4459912019-11-05 19:39:11 -050078foreach c : configs
Ed Tanous9dc2cc52021-12-20 16:05:49 -080079 file = join_paths('configurations', c)
Patrick Williams37304f02025-02-01 08:38:32 -050080 install_data(file, install_dir: join_paths(packagedir, 'configurations'))
Ed Tanous9dc2cc52021-12-20 16:05:49 -080081 filepaths += [file]
Brad Bishopb4459912019-11-05 19:39:11 -050082endforeach
83
Matt Spinler7742c872024-05-02 14:13:21 -050084if get_option('validate-json')
85 validate_script = files('scripts/validate_configs.py')
86 autojson = custom_target(
Patrick Williams37304f02025-02-01 08:38:32 -050087 'check_syntax',
88 command: [validate_script, '-v', '-k'],
89 depend_files: files(filepaths),
90 build_by_default: true,
Patrick Williams37304f02025-02-01 08:38:32 -050091 output: 'validate_configs.log',
Matt Spinler7742c872024-05-02 14:13:21 -050092 )
93endif
Ed Tanous9dc2cc52021-12-20 16:05:49 -080094
Brad Bishopb4459912019-11-05 19:39:11 -050095schemas = [
Peter Delevoryas430fbf62025-02-19 00:28:15 +000096 'cpld.json',
Brad Bishopb4459912019-11-05 19:39:11 -050097 'global.json',
Alexander Hansenc1eaad12025-05-30 18:15:59 +020098 'gpio_presence.json',
Brad Bishop66665882020-05-07 17:05:18 -040099 'legacy.json',
Brad Bishopb9809912020-05-07 17:15:31 -0400100 'openbmc-dbus.json',
Brad Bishop7d05ee52022-05-26 16:27:48 -0400101 'ibm.json',
102 'intel.json',
Yikai Tsai7dc140d2025-02-21 13:12:12 +0800103 'mctp.json',
Brad Bishop7d05ee52022-05-26 16:27:48 -0400104 'pid.json',
105 'pid_zone.json',
106 'stepwise.json',
107 'virtual_sensor.json',
Andrew Geissler48edf9a2023-02-21 10:44:14 -0600108 'satellite_controller.json',
Jagpal Singh Gill3671cd22024-11-08 00:07:41 -0800109 'leak_detector.json',
Jagpal Singh Gille6fc3b72024-11-20 18:09:28 -0800110 'firmware.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500111]
112
113foreach s : schemas
114 install_data(
115 join_paths('schemas', s),
Patrick Williams37304f02025-02-01 08:38:32 -0500116 install_dir: join_paths(packagedir, 'configurations', 'schemas'),
Brad Bishopb4459912019-11-05 19:39:11 -0500117 )
118endforeach
119
120subdir('service_files')
121subdir('src')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400122
Ed Tanous955c6eb2025-04-08 12:41:55 -0700123if get_option('tests').allowed()
Patrick Venturea62466c2021-02-08 14:55:18 -0800124 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400125 gtest = dependency('gtest', main: true, disabler: true, required: false)
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000126 gmock = dependency('gmock', disabler: true, required: false)
Ed Tanous955c6eb2025-04-08 12:41:55 -0700127 if not (gtest.found() and gmock.found())
Ed Tanous55ae5a82021-08-02 14:00:02 -0700128 cmake = import('cmake')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400129 gtest_subproject = cmake.subproject('gtest')
130 cm_gtest = gtest_subproject.dependency('gtest')
131 cm_gtest_main = gtest_subproject.dependency('gtest_main')
Patrick Williams37304f02025-02-01 08:38:32 -0500132 gtest = declare_dependency(
133 dependencies: [cm_gtest, cm_gtest_main, threads],
134 )
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000135 gmock = gtest_subproject.dependency('gmock')
136
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400137 endif
138
139 test(
140 'test_entity_manager',
141 executable(
142 'test_entity_manager',
143 'test/test_entity-manager.cpp',
Christopher Meis59ef1e72025-04-16 08:53:25 +0200144 'src/entity_manager/expression.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400145 'src/utils.cpp',
Christopher Meis59ef1e72025-04-16 08:53:25 +0200146 'src/entity_manager/utils.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800147 cpp_args: test_boost_args,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400148 dependencies: [
149 boost,
150 gtest,
Andrew Jeffery14a7bc92021-08-02 10:01:22 +0930151 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200152 phosphor_logging_dep,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400153 sdbusplus,
154 valijson,
155 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030156 include_directories: 'src',
Patrick Williams37304f02025-02-01 08:38:32 -0500157 ),
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400158 )
Patrick Venturea62466c2021-02-08 14:55:18 -0800159
160 test(
161 'test_fru_utils',
162 executable(
163 'test_fru_utils',
164 'test/test_fru-utils.cpp',
Christopher Meis3cbff972025-04-09 14:07:22 +0200165 'src/fru_device/fru_utils.cpp',
166 'src/fru_device/fru_reader.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800167 cpp_args: test_boost_args,
Ed Tanous23e3f452025-04-08 10:37:56 -0700168 dependencies: [boost, gtest, gmock, phosphor_logging_dep, sdbusplus],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030169 include_directories: 'src',
Patrick Williams37304f02025-02-01 08:38:32 -0500170 ),
Patrick Venturea62466c2021-02-08 14:55:18 -0800171 )
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000172
173 test(
174 'test_topology',
175 executable(
176 'test_topology',
177 'test/test_topology.cpp',
Christopher Meisfc9e7fd2025-04-03 13:13:35 +0200178 'src/entity_manager/topology.cpp',
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000179 cpp_args: test_boost_args,
180 dependencies: [
181 gtest,
182 gmock,
Patrick Williamsaf293612023-04-19 10:27:37 -0500183 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200184 phosphor_logging_dep,
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000185 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030186 include_directories: 'src',
Patrick Williams37304f02025-02-01 08:38:32 -0500187 ),
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000188 )
Alexander Hansen8c4b1d92024-11-04 14:06:24 +0100189
190 test(
191 'test_gpio_presence',
192 executable(
193 'test_gpio_presence',
194 'test/test_gpio_presence.cpp',
195 cpp_args: test_boost_args,
196 include_directories: ['src'],
197 dependencies: [
198 boost,
199 gtest,
200 gmock,
201 phosphor_logging_dep,
202 libgpio_dep,
203 ],
204 link_with: gpio_presence_lib,
205 ),
206 )
Jason M. Billsff58eba2020-04-14 16:05:30 -0700207endif