blob: f789a0d244ed0d0067088e81e7f0f01fcf6fd497 [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]
20build_tests = get_option('tests')
Brad Bishope3a12b62020-01-15 11:56:29 -050021cpp = meson.get_compiler('cpp')
Brad Bishop787e8282020-01-15 12:16:53 -050022boost = dependency('boost', required: false)
23if not boost.found()
Patrick Williams37304f02025-02-01 08:38:32 -050024 subproject('boost', required: false)
25 boost = declare_dependency(include_directories: 'subprojects/boost_1_71_0')
26 boost = boost.as_system('system')
Brad Bishop787e8282020-01-15 12:16:53 -050027endif
Brad Bishop92daaaa2020-01-20 15:45:01 -050028if get_option('fru-device')
29 i2c = cpp.find_library('i2c')
30endif
Andrew Jeffery14a7bc92021-08-02 10:01:22 +093031
Chris Sides2ab73412024-10-15 16:04:11 -050032if get_option('devicetree-vpd')
Patrick Williams37304f02025-02-01 08:38:32 -050033 phosphor_dbus_interfaces_dep = dependency(
34 'phosphor-dbus-interfaces',
35 include_type: 'system',
36 )
Chris Sides2ab73412024-10-15 16:04:11 -050037endif
38
Patrick Williams7e119822023-12-07 11:38:19 -060039nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Alexander Hansenc3db2c32024-08-20 15:01:38 +020040sdbusplus = dependency('sdbusplus', include_type: 'system')
41phosphor_logging_dep = dependency('phosphor-logging')
Andrew Jeffery14a7bc92021-08-02 10:01:22 +093042
Brad Bishopb4459912019-11-05 19:39:11 -050043systemd = dependency('systemd')
Patrick Williamsee1db762023-04-12 08:05:58 -050044systemd_system_unit_dir = systemd.get_variable(
Brad Bishopb4459912019-11-05 19:39:11 -050045 'systemdsystemunitdir',
Patrick Williams37304f02025-02-01 08:38:32 -050046 pkgconfig_define: ['prefix', get_option('prefix')],
47)
Brad Bishopb4459912019-11-05 19:39:11 -050048packagedir = join_paths(
49 get_option('prefix'),
50 get_option('datadir'),
51 meson.project_name(),
52)
Andrew Jefferya9c58922021-06-01 09:28:59 +093053sysconfdir = join_paths(
54 get_option('prefix'),
55 get_option('sysconfdir'),
56 meson.project_name(),
57)
Brad Bishopb4459912019-11-05 19:39:11 -050058threads = dependency('threads')
Ed Tanous55ae5a82021-08-02 14:00:02 -070059if cpp.has_header('valijson/validator.hpp')
60 valijson = declare_dependency()
61else
62 subproject('valijson', required: false)
63 valijson = declare_dependency(
Patrick Williams37304f02025-02-01 08:38:32 -050064 include_directories: 'subprojects/valijson/include',
Ed Tanous55ae5a82021-08-02 14:00:02 -070065 )
66 valijson = valijson.as_system('system')
Brad Bishopff1ddb72020-01-15 12:24:56 -050067endif
Brad Bishopb4459912019-11-05 19:39:11 -050068
69install_data('blacklist.json')
70
Alexander Hansenedc46342025-01-06 17:01:54 +010071# this creates the 'configs' variable
72subdir('configurations')
73
Ed Tanous9dc2cc52021-12-20 16:05:49 -080074filepaths = []
Brad Bishopb4459912019-11-05 19:39:11 -050075foreach c : configs
Ed Tanous9dc2cc52021-12-20 16:05:49 -080076 file = join_paths('configurations', c)
Patrick Williams37304f02025-02-01 08:38:32 -050077 install_data(file, install_dir: join_paths(packagedir, 'configurations'))
Ed Tanous9dc2cc52021-12-20 16:05:49 -080078 filepaths += [file]
Brad Bishopb4459912019-11-05 19:39:11 -050079endforeach
80
Matt Spinler7742c872024-05-02 14:13:21 -050081if get_option('validate-json')
82 validate_script = files('scripts/validate_configs.py')
83 autojson = custom_target(
Patrick Williams37304f02025-02-01 08:38:32 -050084 'check_syntax',
85 command: [validate_script, '-v', '-k'],
86 depend_files: files(filepaths),
87 build_by_default: true,
88 capture: true,
89 output: 'validate_configs.log',
Matt Spinler7742c872024-05-02 14:13:21 -050090 )
91endif
Ed Tanous9dc2cc52021-12-20 16:05:49 -080092
Brad Bishopb4459912019-11-05 19:39:11 -050093schemas = [
94 'global.json',
Brad Bishop66665882020-05-07 17:05:18 -040095 'legacy.json',
Brad Bishopb9809912020-05-07 17:15:31 -040096 'openbmc-dbus.json',
Brad Bishop7d05ee52022-05-26 16:27:48 -040097 'ibm.json',
98 'intel.json',
Yikai Tsai7dc140d2025-02-21 13:12:12 +080099 'mctp.json',
Brad Bishop7d05ee52022-05-26 16:27:48 -0400100 'pid.json',
101 'pid_zone.json',
102 'stepwise.json',
103 'virtual_sensor.json',
Andrew Geissler48edf9a2023-02-21 10:44:14 -0600104 'satellite_controller.json',
Jagpal Singh Gill3671cd22024-11-08 00:07:41 -0800105 'leak_detector.json',
Jagpal Singh Gille6fc3b72024-11-20 18:09:28 -0800106 'firmware.json',
Brad Bishopb4459912019-11-05 19:39:11 -0500107]
108
109foreach s : schemas
110 install_data(
111 join_paths('schemas', s),
Patrick Williams37304f02025-02-01 08:38:32 -0500112 install_dir: join_paths(packagedir, 'configurations', 'schemas'),
Brad Bishopb4459912019-11-05 19:39:11 -0500113 )
114endforeach
115
116subdir('service_files')
117subdir('src')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400118
Jason M. Billsff58eba2020-04-14 16:05:30 -0700119if not build_tests.disabled()
Patrick Venturea62466c2021-02-08 14:55:18 -0800120 test_boost_args = boost_args + ['-DBOOST_ASIO_DISABLE_THREADS']
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400121 gtest = dependency('gtest', main: true, disabler: true, required: false)
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000122 gmock = dependency('gmock', disabler: true, required: false)
123 if not (gtest.found() and gmock.found()) and build_tests.enabled()
Ed Tanous55ae5a82021-08-02 14:00:02 -0700124 cmake = import('cmake')
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400125 gtest_subproject = cmake.subproject('gtest')
126 cm_gtest = gtest_subproject.dependency('gtest')
127 cm_gtest_main = gtest_subproject.dependency('gtest_main')
Patrick Williams37304f02025-02-01 08:38:32 -0500128 gtest = declare_dependency(
129 dependencies: [cm_gtest, cm_gtest_main, threads],
130 )
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000131 gmock = gtest_subproject.dependency('gmock')
132
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400133 endif
134
135 test(
136 'test_entity_manager',
137 executable(
138 'test_entity_manager',
139 'test/test_entity-manager.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400140 'src/expression.cpp',
141 'src/utils.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800142 cpp_args: test_boost_args,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400143 dependencies: [
144 boost,
145 gtest,
Andrew Jeffery14a7bc92021-08-02 10:01:22 +0930146 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200147 phosphor_logging_dep,
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400148 sdbusplus,
149 valijson,
150 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030151 include_directories: 'src',
Patrick Williams37304f02025-02-01 08:38:32 -0500152 ),
Brad Bishopb9f50cd2020-10-14 09:54:58 -0400153 )
Patrick Venturea62466c2021-02-08 14:55:18 -0800154
155 test(
156 'test_fru_utils',
157 executable(
158 'test_fru_utils',
159 'test/test_fru-utils.cpp',
Brad Bishope45d8c72022-05-25 15:12:53 -0400160 'src/fru_utils.cpp',
Zev Weiss309c0b12022-02-25 01:44:12 +0000161 'src/fru_reader.cpp',
Patrick Venturea62466c2021-02-08 14:55:18 -0800162 cpp_args: test_boost_args,
Patrick Williams37304f02025-02-01 08:38:32 -0500163 dependencies: [boost, gtest, phosphor_logging_dep, sdbusplus],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030164 include_directories: 'src',
Patrick Williams37304f02025-02-01 08:38:32 -0500165 ),
Patrick Venturea62466c2021-02-08 14:55:18 -0800166 )
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000167
168 test(
169 'test_topology',
170 executable(
171 'test_topology',
172 'test/test_topology.cpp',
173 'src/topology.cpp',
174 cpp_args: test_boost_args,
175 dependencies: [
176 gtest,
177 gmock,
Patrick Williamsaf293612023-04-19 10:27:37 -0500178 nlohmann_json_dep,
Alexander Hansenc3db2c32024-08-20 15:01:38 +0200179 phosphor_logging_dep,
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000180 ],
Andrew Jefferya5d25dc2023-01-27 12:28:22 +1030181 include_directories: 'src',
Patrick Williams37304f02025-02-01 08:38:32 -0500182 ),
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +0000183 )
Jason M. Billsff58eba2020-04-14 16:05:30 -0700184endif