blob: b8ef89d6bcc3f7e13c4a4910b535246338872f41 [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 = [
16 '-DBOOST_SYSTEM_NO_DEPRECATED',
17 '-DBOOST_ERROR_CODE_HEADER_ONLY',
18 '-DBOOST_NO_RTTI',
19 '-DBOOST_NO_TYPEID',
20 '-DBOOST_ALL_NO_LIB',
Ed Tanous07d467b2021-02-23 14:48:37 -080021 '-DBOOST_ALLOW_DEPRECATED_HEADERS'
Brad Bishopb4459912019-11-05 19:39:11 -050022]
23build_tests = get_option('tests')
Brad Bishope3a12b62020-01-15 11:56:29 -050024cpp = meson.get_compiler('cpp')
Brad Bishop787e8282020-01-15 12:16:53 -050025boost = 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 )
Ed Tanous07d467b2021-02-23 14:48:37 -080031 boost = boost.as_system('system')
Brad Bishop787e8282020-01-15 12:16:53 -050032endif
Brad Bishop92daaaa2020-01-20 15:45:01 -050033if get_option('fru-device')
34 i2c = cpp.find_library('i2c')
35endif
Andrew Jeffery14a7bc92021-08-02 10:01:22 +093036
Chris Sides2ab73412024-10-15 16:04:11 -050037if get_option('devicetree-vpd')
38 phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces', include_type: 'system')
39endif
40
Patrick Williams7e119822023-12-07 11:38:19 -060041nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Alexander Hansenc3db2c32024-08-20 15:01:38 +020042sdbusplus = dependency('sdbusplus', include_type: 'system')
43phosphor_logging_dep = dependency('phosphor-logging')
Andrew Jeffery14a7bc92021-08-02 10:01:22 +093044
Brad Bishopb4459912019-11-05 19:39:11 -050045systemd = dependency('systemd')
Patrick Williamsee1db762023-04-12 08:05:58 -050046systemd_system_unit_dir = systemd.get_variable(
Brad Bishopb4459912019-11-05 19:39:11 -050047 'systemdsystemunitdir',
Patrick Williamsee1db762023-04-12 08:05:58 -050048 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishopb4459912019-11-05 19:39:11 -050049packagedir = join_paths(
50 get_option('prefix'),
51 get_option('datadir'),
52 meson.project_name(),
53)
Andrew Jefferya9c58922021-06-01 09:28:59 +093054sysconfdir = join_paths(
55 get_option('prefix'),
56 get_option('sysconfdir'),
57 meson.project_name(),
58)
Brad Bishopb4459912019-11-05 19:39:11 -050059threads = dependency('threads')
Ed Tanous55ae5a82021-08-02 14:00:02 -070060if cpp.has_header('valijson/validator.hpp')
61 valijson = declare_dependency()
62else
63 subproject('valijson', required: false)
64 valijson = declare_dependency(
65 include_directories: 'subprojects/valijson/include'
66 )
67 valijson = valijson.as_system('system')
Brad Bishopff1ddb72020-01-15 12:24:56 -050068endif
Brad Bishopb4459912019-11-05 19:39:11 -050069
70install_data('blacklist.json')
71
Alexander Hansenedc46342025-01-06 17:01:54 +010072# this creates the 'configs' variable
73subdir('configurations')
74
Ed Tanous9dc2cc52021-12-20 16:05:49 -080075filepaths = []
Brad Bishopb4459912019-11-05 19:39:11 -050076foreach c : configs
Ed Tanous9dc2cc52021-12-20 16:05:49 -080077 file = join_paths('configurations', c)
Brad Bishopb4459912019-11-05 19:39:11 -050078 install_data(
Ed Tanous9dc2cc52021-12-20 16:05:49 -080079 file,
Brad Bishopb4459912019-11-05 19:39:11 -050080 install_dir: join_paths(
81 packagedir,
82 'configurations',
83 )
84 )
Ed Tanous9dc2cc52021-12-20 16:05:49 -080085 filepaths += [file]
Brad Bishopb4459912019-11-05 19:39:11 -050086endforeach
87
Matt Spinler7742c872024-05-02 14:13:21 -050088if get_option('validate-json')
89 validate_script = files('scripts/validate_configs.py')
90 autojson = custom_target(
91 'check_syntax',
92 command: [
93 validate_script,
94 '-v',
95 '-k',
96 ],
97 depend_files: files(filepaths),
98 build_by_default: true,
99 capture: true,
100 output: 'validate_configs.log',
101 )
102endif
Ed Tanous9dc2cc52021-12-20 16:05:49 -0800103
Brad Bishopb4459912019-11-05 19:39:11 -0500104schemas = [
105 'global.json',
Brad Bishop66665882020-05-07 17:05:18 -0400106 'legacy.json',
Brad Bishopb9809912020-05-07 17:15:31 -0400107 'openbmc-dbus.json',
Brad Bishop7d05ee52022-05-26 16:27:48 -0400108 'ibm.json',
109 'intel.json',
110 'pid.json',
111 'pid_zone.json',
112 'stepwise.json',
113 'virtual_sensor.json',
Andrew Geissler48edf9a2023-02-21 10:44:14 -0600114 'satellite_controller.json',
Jagpal Singh Gill3671cd22024-11-08 00:07:41 -0800115 'leak_detector.json',
Jagpal Singh Gille6fc3b72024-11-20 18:09:28 -0800116 'firmware.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500117]
118
119foreach s : schemas
120 install_data(
121 join_paths('schemas', s),
122 install_dir: join_paths(
123 packagedir,
124 'configurations',
125 'schemas',
126 )
127 )
128endforeach
129
130subdir('service_files')
131subdir('src')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400132
Jason M. Billsff58eba2020-04-14 16:05:30 -0700133if not build_tests.disabled()
Patrick Venturea62466c2021-02-08 14:55:18 -0800134 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400135 gtest = dependency('gtest', main: true, disabler: true, required: false)
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000136 gmock = dependency('gmock', disabler: true, required: false)
137 if not (gtest.found() and gmock.found()) and build_tests.enabled()
Ed Tanous55ae5a82021-08-02 14:00:02 -0700138 cmake = import('cmake')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400139 gtest_subproject = cmake.subproject('gtest')
140 cm_gtest = gtest_subproject.dependency('gtest')
141 cm_gtest_main = gtest_subproject.dependency('gtest_main')
142 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000143 gmock = gtest_subproject.dependency('gmock')
144
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400145 endif
146
147 test(
148 'test_entity_manager',
149 executable(
150 'test_entity_manager',
151 'test/test_entity-manager.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400152 'src/expression.cpp',
153 'src/utils.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800154 cpp_args: test_boost_args,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400155 dependencies: [
156 boost,
157 gtest,
Andrew Jeffery14a7bc92021-08-02 10:01:22 +0930158 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200159 phosphor_logging_dep,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400160 sdbusplus,
161 valijson,
162 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030163 include_directories: 'src',
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400164 )
165 )
Patrick Venturea62466c2021-02-08 14:55:18 -0800166
167 test(
168 'test_fru_utils',
169 executable(
170 'test_fru_utils',
171 'test/test_fru-utils.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400172 'src/fru_utils.cpp',
Zev Weiss309c0b12022-02-25 01:44:12 +0000173 'src/fru_reader.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800174 cpp_args: test_boost_args,
175 dependencies: [
176 boost,
177 gtest,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200178 phosphor_logging_dep,
Andrew Jeffery5bda1822023-01-27 13:40:21 +1030179 sdbusplus,
Patrick Venturea62466c2021-02-08 14:55:18 -0800180 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030181 include_directories: 'src',
Patrick Venturea62466c2021-02-08 14:55:18 -0800182 )
183 )
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000184
185 test(
186 'test_topology',
187 executable(
188 'test_topology',
189 'test/test_topology.cpp',
190 'src/topology.cpp',
191 cpp_args: test_boost_args,
192 dependencies: [
193 gtest,
194 gmock,
Patrick Williamsaf293612023-04-19 10:27:37 -0500195 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200196 phosphor_logging_dep,
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000197 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030198 include_directories: 'src',
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000199 )
200 )
Jason M. Billsff58eba2020-04-14 16:05:30 -0700201endif