blob: d476f60daa91bdb007f61b1733f537f1e7deab26 [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',
Brad Bishopb4459912019-11-05 19:39:11 -0500116]
117
118foreach s : schemas
119 install_data(
120 join_paths('schemas', s),
121 install_dir: join_paths(
122 packagedir,
123 'configurations',
124 'schemas',
125 )
126 )
127endforeach
128
129subdir('service_files')
130subdir('src')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400131
Jason M. Billsff58eba2020-04-14 16:05:30 -0700132if not build_tests.disabled()
Patrick Venturea62466c2021-02-08 14:55:18 -0800133 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400134 gtest = dependency('gtest', main: true, disabler: true, required: false)
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000135 gmock = dependency('gmock', disabler: true, required: false)
136 if not (gtest.found() and gmock.found()) and build_tests.enabled()
Ed Tanous55ae5a82021-08-02 14:00:02 -0700137 cmake = import('cmake')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400138 gtest_subproject = cmake.subproject('gtest')
139 cm_gtest = gtest_subproject.dependency('gtest')
140 cm_gtest_main = gtest_subproject.dependency('gtest_main')
141 gtest = declare_dependency(dependencies: [cm_gtest, cm_gtest_main, threads])
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000142 gmock = gtest_subproject.dependency('gmock')
143
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400144 endif
145
146 test(
147 'test_entity_manager',
148 executable(
149 'test_entity_manager',
150 'test/test_entity-manager.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400151 'src/expression.cpp',
152 'src/utils.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800153 cpp_args: test_boost_args,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400154 dependencies: [
155 boost,
156 gtest,
Andrew Jeffery14a7bc92021-08-02 10:01:22 +0930157 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200158 phosphor_logging_dep,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400159 sdbusplus,
160 valijson,
161 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030162 include_directories: 'src',
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400163 )
164 )
Patrick Venturea62466c2021-02-08 14:55:18 -0800165
166 test(
167 'test_fru_utils',
168 executable(
169 'test_fru_utils',
170 'test/test_fru-utils.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400171 'src/fru_utils.cpp',
Zev Weiss309c0b12022-02-25 01:44:12 +0000172 'src/fru_reader.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800173 cpp_args: test_boost_args,
174 dependencies: [
175 boost,
176 gtest,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200177 phosphor_logging_dep,
Andrew Jeffery5bda1822023-01-27 13:40:21 +1030178 sdbusplus,
Patrick Venturea62466c2021-02-08 14:55:18 -0800179 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030180 include_directories: 'src',
Patrick Venturea62466c2021-02-08 14:55:18 -0800181 )
182 )
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000183
184 test(
185 'test_topology',
186 executable(
187 'test_topology',
188 'test/test_topology.cpp',
189 'src/topology.cpp',
190 cpp_args: test_boost_args,
191 dependencies: [
192 gtest,
193 gmock,
Patrick Williamsaf293612023-04-19 10:27:37 -0500194 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200195 phosphor_logging_dep,
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000196 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030197 include_directories: 'src',
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000198 )
199 )
Jason M. Billsff58eba2020-04-14 16:05:30 -0700200endif