blob: c5aa0bf96237330d30e5d28a2aab485a985806cf [file] [log] [blame]
SunnySrivastava19847ef54422019-12-03 02:47:37 -06001project(
2 'openpower-vpd-parser',
3 'c',
4 'cpp',
5 default_options: [
Priyanga Ramasamy9d149342020-07-16 23:41:26 +05306 'warning_level=3',
7 'werror=true',
Patrick Williamsd8577732023-07-21 10:05:00 -05008 'cpp_std=c++23',
PriyangaRamasamyf272efc2021-03-03 23:24:31 -06009 'buildtype=debugoptimized'
SunnySrivastava19847ef54422019-12-03 02:47:37 -060010 ],
Patrick Williams8e532c12021-10-06 15:34:56 -050011 version: '1.0',
Patrick Williamsd8577732023-07-21 10:05:00 -050012 meson_version: '>=1.1.1',
SunnySrivastava19847ef54422019-12-03 02:47:37 -060013)
14
Andrew Jeffery3aec4782021-06-15 11:45:23 +093015add_global_arguments('-Wno-psabi', language : ['c', 'cpp'])
16
Andrew Jefferyf3953762021-06-15 11:10:10 +093017# Disable FORTIFY_SOURCE when compiling with no optimization
18if(get_option('optimization') == '0')
19 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
20 message('Disabling FORTIFY_SOURCE as optimization is set to 0')
21endif
22
23# Setup googletest before we import any projects that also depend on it to make
24# sure we have control over its configuration
25build_tests = get_option('tests')
26if not build_tests.disabled()
27 gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
28 gmock_dep = dependency('gmock', disabler: true, required: false)
29 if not gtest_dep.found() or not gmock_dep.found()
30 cmake = import('cmake')
31 gtest_opts = cmake.subproject_options()
32 gtest_opts.set_override_option('warning_level', '1')
33 gtest_opts.set_override_option('werror', 'false')
34 gtest_proj = cmake.subproject('googletest',
35 options: gtest_opts,
36 required: false)
37 if gtest_proj.found()
38 gtest_dep = declare_dependency(
39 dependencies: [
40 dependency('threads'),
41 gtest_proj.dependency('gtest'),
42 gtest_proj.dependency('gtest_main'),
43 ]
44 )
45 gmock_dep = gtest_proj.dependency('gmock')
46 else
Patrick Williams468e8c52023-11-29 06:44:43 -060047 assert(not get_option('tests').allowed(),
Andrew Jefferyf3953762021-06-15 11:10:10 +093048 'Googletest is required if tests are enabled')
49 endif
50 endif
51endif
52
Patrick Williams920566b2023-12-08 06:39:32 -060053nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
54
Andrew Jeffery60b5bd22021-06-15 10:41:28 +093055phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces',
56 default_options: [ 'data_com_ibm=true', 'data_org_open_power=true' ],
57 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'])
58
59phosphor_logging = dependency('phosphor-logging',
60 default_options: [ 'openpower-pel-extension=enabled' ],
61 fallback: ['phosphor-logging', 'phosphor_logging_dep'])
62
63sdbusplus = dependency('sdbusplus', fallback: [ 'sdbusplus', 'sdbusplus_dep' ])
SunnySrivastava19847ef54422019-12-03 02:47:37 -060064
Priyanga Ramasamya4a2adf2022-02-03 05:43:41 -060065libvpdecc_src = files(
66 'vpdecc/vpdecc.c',
67 'vpdecc/vpdecc_support.c'
68)
69
70libvpdecc = shared_library(
71 'vpdecc',
72 libvpdecc_src,
73 version: meson.project_version(),
74 install: true,
75)
76
SunnySrivastava19847ef54422019-12-03 02:47:37 -060077compiler = meson.get_compiler('cpp')
78python = find_program('python3', required:true)
79
Patrick Williamsdc3c3c32023-09-07 05:59:18 -050080if compiler.has_header('CLI/CLI.hpp')
81 CLI11_dep = declare_dependency()
82else
83 CLI11_dep = dependency('CLI11')
84endif
85
Patrick Williamsdc3c3c32023-09-07 05:59:18 -050086if not build_tests.disabled()
87 subdir('test')
88endif
PriyangaRamasamyf8f9c862021-02-22 22:53:35 -060089
SunnySrivastava19847ef54422019-12-03 02:47:37 -060090configure_file(output: 'config.h',
91 configuration :{
Santosh Puranik0246a4d2020-11-04 16:57:39 +053092 'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"',
93 'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"',
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053094 'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"',
SunnySrivastava198443306542020-04-01 02:50:20 -050095 'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"',
96 'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"',
SunnySrivastava1984a7392592020-03-09 10:19:33 -050097 'BUSNAME' : '"' + get_option('BUSNAME') + '"',
98 'OBJPATH' : '"' + get_option('OBJPATH') + '"',
99 'IFACE' : '"' + get_option('IFACE') + '"',
SunnySrivastava198443306542020-04-01 02:50:20 -0500100 'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"',
101 'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"',
102 'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"',
PriyangaRamasamy83a1d5d2020-04-30 19:15:43 +0530103 'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"',
Santosh Puranik0246a4d2020-11-04 16:57:39 +0530104 'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"',
105 'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"',
Santosh Puranik4641bff2020-11-30 20:26:44 +0530106 'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530107 'INVENTORY_JSON_EVEREST': '"'+get_option('INVENTORY_JSON_EVEREST')+'"',
Alpana Kumarif05effd2021-04-07 07:32:53 -0500108 'DBUS_PROP_JSON': '"'+get_option('DBUS_PROP_JSON')+'"',
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -0600109 'SYSTEM_JSON' : '"'+get_option('SYSTEM_JSON')+'"',
PriyangaRamasamy8cc5b152021-06-03 13:05:17 -0500110 'BAD_VPD_DIR': '"'+get_option('BAD_VPD_DIR')+'"',
111 'FAN_INTERFACE': '"'+get_option('FAN_INTERFACE')+'"'
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600112 }
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530113 )
SunnySrivastava198443306542020-04-01 02:50:20 -0500114
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500115common_SOURCES =['common_utility.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530116'vpd-parser/parser_factory.cpp',
117 'vpd-parser/memory_vpd_parser.cpp',
jinuthomas6555e7e2023-02-14 21:48:00 -0600118 'vpd-parser/isdimm_vpd_parser.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530119 'vpd-parser/keyword_vpd_parser.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500120 'vpd-parser/ipz_parser.cpp', 'impl.cpp', 'ibm_vpd_utils.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530121]
122
Patrick Williams12259992023-09-11 10:09:23 -0500123if get_option('ibm-parser').allowed()
Patrick Williamsabe481e2023-09-07 05:47:20 -0500124 libgpiodcxx = dependency(
125 'libgpiodcxx',
126 default_options: ['bindings=cxx'],
127 )
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -0500128 ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp',
129 'vpd-manager/editor_impl.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530130 ]+common_SOURCES
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600131
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -0500132 vpd_tool_INCLUDE = include_directories('vpd-parser/', 'vpd-manager')
133
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600134 ibm_vpd_exe = executable(
135 'ibm-read-vpd',
136 ibm_read_vpd_SOURCES,
137 dependencies: [
138 sdbusplus,
139 phosphor_logging,
Alpana Kumari2f793042020-08-18 05:51:03 -0500140 libgpiodcxx,
Patrick Williamsdc3c3c32023-09-07 05:59:18 -0500141 nlohmann_json_dep,
142 CLI11_dep,
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600143 ],
Priyanga Ramasamya4a2adf2022-02-03 05:43:41 -0600144 link_with : libvpdecc,
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -0500145 include_directories : vpd_tool_INCLUDE,
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600146 install: true,
147 cpp_args : '-DIPZ_PARSER'
148 )
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530149
150 vpd_tool_SOURCES = ['vpd_tool.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530151 'vpd_tool_impl.cpp',
152 'vpd-manager/editor_impl.cpp',
153 ]+common_SOURCES
154
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530155
156 vpd_tool_exe = executable(
157 'vpd-tool',
158 vpd_tool_SOURCES,
159 dependencies: [
Patrick Williamsdc3c3c32023-09-07 05:59:18 -0500160 CLI11_dep,
161 libgpiodcxx,
162 nlohmann_json_dep,
Sunny Srivastavaf31a91b2022-06-09 08:11:29 -0500163 phosphor_logging,
Patrick Williamsdc3c3c32023-09-07 05:59:18 -0500164 sdbusplus,
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530165 ],
Priyanga Ramasamya4a2adf2022-02-03 05:43:41 -0600166 link_with : libvpdecc,
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530167 install: true,
Priyanga Ramasamy38031312021-10-07 16:39:13 -0500168 include_directories : vpd_tool_INCLUDE,
169 cpp_args : '-DIPZ_PARSER'
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530170 )
Patrick Williams12259992023-09-11 10:09:23 -0500171if get_option('vpd-manager').allowed()
SunnySrivastava1984a7392592020-03-09 10:19:33 -0500172 subdir('vpd-manager')
173endif
174
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500175systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williamsc68829a2023-04-12 08:01:19 -0500176 'systemdsystemunitdir')
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500177
178udev_dir = dependency('udev').get_variable(
Patrick Williamsc68829a2023-04-12 08:01:19 -0500179 'udev_dir')
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500180
Priyanga Ramasamy29fbea92023-10-04 01:28:10 -0500181rules = ['rules/70-ibm-vpd-parser.rules']
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500182
Priyanga Ramasamy29fbea92023-10-04 01:28:10 -0500183install_data(rules, install_mode: 'rw-r--r--', install_dir: udev_dir/'rules.d')
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500184
Priyanga Ramasamy29fbea92023-10-04 01:28:10 -0500185services = ['service_files/system-vpd.service',
186 'service_files/ibm-vpd-parser@.service',
187 'service_files/com.ibm.VPD.Manager.service',
188 'service_files/wait-vpd-parsers.service',
189 'service_files/ibm-isdimm-vpd-parser@.service',
190 'service_files/ibm-spi-vpd-parser@.service']
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500191
Priyanga Ramasamy29fbea92023-10-04 01:28:10 -0500192install_data(services, install_dir: systemd_system_unit_dir)
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500193
Priyanga Ramasamy29fbea92023-10-04 01:28:10 -0500194scripts = ['scripts/wait-vpd-parsers.sh']
195
196install_data(scripts,
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500197 install_mode: 'rwxr-xr-x',
198 install_dir: get_option('bindir'))
199
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500200package_datadir = join_paths('share', 'vpd')
girik494ff072023-10-05 23:19:47 -0500201install_subdir('config/ibm/', install_mode: 'rwxr-xr-x', install_dir: package_datadir, strip_directory: true)
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500202
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600203else
204 FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML')
205 PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML')
206
Patrick Williamsc57a9a32023-09-07 05:49:05 -0500207 src_dir = meson.project_source_root()
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600208 FRU_GEN_SCRIPT = src_dir + '/writefru.py'
209 FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml'
210
211 PROP_GEN_SCRIPT = src_dir + '/extra-properties.py'
212 PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml'
213
214 writefru_hpp = custom_target('writefru.hpp',
215 command:[python,
216 FRU_GEN_SCRIPT,
217 '-i',
218 get_option('FRU_YAML')
219 ],
220 depend_files :['writefru.mako.hpp',
221 'writefru.py',
222 get_option('FRU_YAML')
223 ],
224 output:'writefru.hpp'
225 )
226
227 extra_properties_gen_hpp = custom_target(
228 'extra-properties-gen.hpp',
229 command:[
230 python,
231 PROP_GEN_SCRIPT,
232 '-e',
233 get_option('PROP_YAML')
234 ],
235 depend_files : ['extra-properties.mako.hpp',
236 'extra-properties.py',
237 get_option('PROP_YAML')
238 ],
239 output:'extra-properties-gen.hpp'
240 )
241
242 openpower_read_vpd_SOURCES = ['app.cpp',
243 'args.cpp',
244 'impl.cpp',
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500245 'vpd-parser/ipz_parser.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600246 'write.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500247 'common_utility.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600248 writefru_hpp,
249 extra_properties_gen_hpp
250 ]
251
252 openpower_read_vpd_exe= executable(
253 'openpower-read-vpd',
254 openpower_read_vpd_SOURCES,
255 dependencies: [
256 sdbusplus,
257 phosphor_logging,
Patrick Williamsdc3c3c32023-09-07 05:59:18 -0500258 nlohmann_json_dep,
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600259 ],
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500260 include_directories : 'vpd-parser/',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600261 install: true,
262 )
263endif