blob: b70468783a05070d403ece514e8a8176529eb6a3 [file] [log] [blame]
Brad Bishopb4459912019-11-05 19:39:11 -05001project(
2 'entity-manager',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Patrick Williamsa183f4a2023-08-23 06:31:19 -05007 'cpp_std=c++23'
Brad Bishopb4459912019-11-05 19:39:11 -05008 ],
9 license: 'Apache-2.0',
10 version: '0.1',
Patrick Williamsa183f4a2023-08-23 06:31:19 -050011 meson_version: '>=1.1.1',
Brad Bishopb4459912019-11-05 19:39:11 -050012)
Brad Bishopec984912020-10-01 10:24:55 -040013add_project_arguments('-Wno-psabi', language: 'cpp')
Brad Bishopb4459912019-11-05 19:39:11 -050014
15boost_args = [
Ed Tanousae2d4352025-02-12 15:51:48 -080016 '-DBOOST_ASIO_NO_DEPRECATED',
Brad Bishopb4459912019-11-05 19:39:11 -050017 '-DBOOST_SYSTEM_NO_DEPRECATED',
18 '-DBOOST_ERROR_CODE_HEADER_ONLY',
19 '-DBOOST_NO_RTTI',
20 '-DBOOST_NO_TYPEID',
21 '-DBOOST_ALL_NO_LIB',
Ed Tanous07d467b2021-02-23 14:48:37 -080022 '-DBOOST_ALLOW_DEPRECATED_HEADERS'
Brad Bishopb4459912019-11-05 19:39:11 -050023]
24build_tests = get_option('tests')
Brad Bishope3a12b62020-01-15 11:56:29 -050025cpp = meson.get_compiler('cpp')
Brad Bishop787e8282020-01-15 12:16:53 -050026boost = dependency('boost', required: false)
27if not boost.found()
28 subproject('boost', required: false)
29 boost = declare_dependency(
30 include_directories: 'subprojects/boost_1_71_0',
31 )
Ed Tanous07d467b2021-02-23 14:48:37 -080032 boost = boost.as_system('system')
Brad Bishop787e8282020-01-15 12:16:53 -050033endif
Brad Bishop92daaaa2020-01-20 15:45:01 -050034if get_option('fru-device')
35 i2c = cpp.find_library('i2c')
36endif
Andrew Jeffery14a7bc92021-08-02 10:01:22 +093037
Chris Sides2ab73412024-10-15 16:04:11 -050038if get_option('devicetree-vpd')
39 phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces', include_type: 'system')
40endif
41
Patrick Williams7e119822023-12-07 11:38:19 -060042nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Alexander Hansenc3db2c32024-08-20 15:01:38 +020043sdbusplus = dependency('sdbusplus', include_type: 'system')
44phosphor_logging_dep = dependency('phosphor-logging')
Andrew Jeffery14a7bc92021-08-02 10:01:22 +093045
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 Williamsee1db762023-04-12 08:05:58 -050049 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishopb4459912019-11-05 19:39:11 -050050packagedir = join_paths(
51 get_option('prefix'),
52 get_option('datadir'),
53 meson.project_name(),
54)
Andrew Jefferya9c58922021-06-01 09:28:59 +093055sysconfdir = join_paths(
56 get_option('prefix'),
57 get_option('sysconfdir'),
58 meson.project_name(),
59)
Brad Bishopb4459912019-11-05 19:39:11 -050060threads = dependency('threads')
Ed Tanous55ae5a82021-08-02 14:00:02 -070061if 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')
Brad Bishopff1ddb72020-01-15 12:24:56 -050069endif
Brad Bishopb4459912019-11-05 19:39:11 -050070
71install_data('blacklist.json')
72
Alexander Hansenedc46342025-01-06 17:01:54 +010073# this creates the 'configs' variable
74subdir('configurations')
75
Ed Tanous9dc2cc52021-12-20 16:05:49 -080076filepaths = []
Brad Bishopb4459912019-11-05 19:39:11 -050077foreach c : configs
Ed Tanous9dc2cc52021-12-20 16:05:49 -080078 file = join_paths('configurations', c)
Brad Bishopb4459912019-11-05 19:39:11 -050079 install_data(
Ed Tanous9dc2cc52021-12-20 16:05:49 -080080 file,
Brad Bishopb4459912019-11-05 19:39:11 -050081 install_dir: join_paths(
82 packagedir,
83 'configurations',
84 )
85 )
Ed Tanous9dc2cc52021-12-20 16:05:49 -080086 filepaths += [file]
Brad Bishopb4459912019-11-05 19:39:11 -050087endforeach
88
Matt Spinler7742c872024-05-02 14:13:21 -050089if get_option('validate-json')
90 validate_script = files('scripts/validate_configs.py')
91 autojson = custom_target(
92 'check_syntax',
93 command: [
94 validate_script,
95 '-v',
96 '-k',
97 ],
98 depend_files: files(filepaths),
99 build_by_default: true,
100 capture: true,
101 output: 'validate_configs.log',
102 )
103endif
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800104
Brad Bishopb4459912019-11-05 19:39:11 -0500105schemas = [
106 'global.json',
Brad Bishop66665882020-05-07 17:05:18 -0400107 'legacy.json',
Brad Bishopb9809912020-05-07 17:15:31 -0400108 'openbmc-dbus.json',
Brad Bishop7d05ee52022-05-26 16:27:48 -0400109 'ibm.json',
110 'intel.json',
Yikai Tsai7dc140d2025-02-21 13:12:12 +0800111 'mctp.json',
Brad Bishop7d05ee52022-05-26 16:27:48 -0400112 'pid.json',
113 'pid_zone.json',
114 'stepwise.json',
115 'virtual_sensor.json',
Andrew Geissler48edf9a2023-02-21 10:44:14 -0600116 'satellite_controller.json',
Jagpal Singh Gill3671cd22024-11-08 00:07:41 -0800117 'leak_detector.json',
Jagpal Singh Gille6fc3b72024-11-20 18:09:28 -0800118 'firmware.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500119]
120
121foreach s : schemas
122 install_data(
123 join_paths('schemas', s),
124 install_dir: join_paths(
125 packagedir,
126 'configurations',
127 'schemas',
128 )
129 )
130endforeach
131
132subdir('service_files')
133subdir('src')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400134
Jason M. Billsff58eba2020-04-14 16:05:30 -0700135if not build_tests.disabled()
Patrick Venturea62466c2021-02-08 14:55:18 -0800136 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400137 gtest = dependency('gtest', main: true, disabler: true, required: false)
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000138 gmock = dependency('gmock', disabler: true, required: false)
139 if not (gtest.found() and gmock.found()) and build_tests.enabled()
Ed Tanous55ae5a82021-08-02 14:00:02 -0700140 cmake = import('cmake')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400141 gtest_subproject = cmake.subproject('gtest')
142 cm_gtest = gtest_subproject.dependency('gtest')
143 cm_gtest_main = gtest_subproject.dependency('gtest_main')
144 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000145 gmock = gtest_subproject.dependency('gmock')
146
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400147 endif
148
149 test(
150 'test_entity_manager',
151 executable(
152 'test_entity_manager',
153 'test/test_entity-manager.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400154 'src/expression.cpp',
155 'src/utils.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800156 cpp_args: test_boost_args,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400157 dependencies: [
158 boost,
159 gtest,
Andrew Jeffery14a7bc92021-08-02 10:01:22 +0930160 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200161 phosphor_logging_dep,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400162 sdbusplus,
163 valijson,
164 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030165 include_directories: 'src',
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400166 )
167 )
Patrick Venturea62466c2021-02-08 14:55:18 -0800168
169 test(
170 'test_fru_utils',
171 executable(
172 'test_fru_utils',
173 'test/test_fru-utils.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400174 'src/fru_utils.cpp',
Zev Weiss309c0b12022-02-25 01:44:12 +0000175 'src/fru_reader.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800176 cpp_args: test_boost_args,
177 dependencies: [
178 boost,
179 gtest,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200180 phosphor_logging_dep,
Andrew Jeffery5bda1822023-01-27 13:40:21 +1030181 sdbusplus,
Patrick Venturea62466c2021-02-08 14:55:18 -0800182 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030183 include_directories: 'src',
Patrick Venturea62466c2021-02-08 14:55:18 -0800184 )
185 )
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000186
187 test(
188 'test_topology',
189 executable(
190 'test_topology',
191 'test/test_topology.cpp',
192 'src/topology.cpp',
193 cpp_args: test_boost_args,
194 dependencies: [
195 gtest,
196 gmock,
Patrick Williamsaf293612023-04-19 10:27:37 -0500197 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200198 phosphor_logging_dep,
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000199 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030200 include_directories: 'src',
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000201 )
202 )
Jason M. Billsff58eba2020-04-14 16:05:30 -0700203endif