blob: 5e98a12a65b7f6238b123405c70d61242effc064 [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
47 assert(not get_option('tests').enabled(),
48 'Googletest is required if tests are enabled')
49 endif
50 endif
51endif
52
Andrew Jeffery60b5bd22021-06-15 10:41:28 +093053phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces',
54 default_options: [ 'data_com_ibm=true', 'data_org_open_power=true' ],
55 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'])
56
57phosphor_logging = dependency('phosphor-logging',
58 default_options: [ 'openpower-pel-extension=enabled' ],
59 fallback: ['phosphor-logging', 'phosphor_logging_dep'])
60
61sdbusplus = dependency('sdbusplus', fallback: [ 'sdbusplus', 'sdbusplus_dep' ])
SunnySrivastava19847ef54422019-12-03 02:47:37 -060062
Priyanga Ramasamya4a2adf2022-02-03 05:43:41 -060063libvpdecc_src = files(
64 'vpdecc/vpdecc.c',
65 'vpdecc/vpdecc_support.c'
66)
67
68libvpdecc = shared_library(
69 'vpdecc',
70 libvpdecc_src,
71 version: meson.project_version(),
72 install: true,
73)
74
Andrew Jefferyf3953762021-06-15 11:10:10 +093075if not build_tests.disabled()
76 subdir('test')
77endif
78
SunnySrivastava19847ef54422019-12-03 02:47:37 -060079compiler = meson.get_compiler('cpp')
80python = find_program('python3', required:true)
81
SunnySrivastava19847ef54422019-12-03 02:47:37 -060082compiler.has_header('CLI/CLI.hpp')
83compiler.has_header('nlohmann/json.hpp')
PriyangaRamasamyf8f9c862021-02-22 22:53:35 -060084
SunnySrivastava19847ef54422019-12-03 02:47:37 -060085configure_file(output: 'config.h',
86 configuration :{
Santosh Puranik0246a4d2020-11-04 16:57:39 +053087 'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"',
88 'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"',
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053089 'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"',
SunnySrivastava198443306542020-04-01 02:50:20 -050090 'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"',
91 'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"',
SunnySrivastava1984a7392592020-03-09 10:19:33 -050092 'BUSNAME' : '"' + get_option('BUSNAME') + '"',
93 'OBJPATH' : '"' + get_option('OBJPATH') + '"',
94 'IFACE' : '"' + get_option('IFACE') + '"',
SunnySrivastava198443306542020-04-01 02:50:20 -050095 'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"',
96 'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"',
97 'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"',
PriyangaRamasamy83a1d5d2020-04-30 19:15:43 +053098 'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"',
Santosh Puranik0246a4d2020-11-04 16:57:39 +053099 'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"',
100 'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"',
Santosh Puranik4641bff2020-11-30 20:26:44 +0530101 'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530102 'INVENTORY_JSON_EVEREST': '"'+get_option('INVENTORY_JSON_EVEREST')+'"',
Alpana Kumarif05effd2021-04-07 07:32:53 -0500103 'DBUS_PROP_JSON': '"'+get_option('DBUS_PROP_JSON')+'"',
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -0600104 'SYSTEM_JSON' : '"'+get_option('SYSTEM_JSON')+'"',
PriyangaRamasamy8cc5b152021-06-03 13:05:17 -0500105 'BAD_VPD_DIR': '"'+get_option('BAD_VPD_DIR')+'"',
106 'FAN_INTERFACE': '"'+get_option('FAN_INTERFACE')+'"'
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600107 }
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530108 )
SunnySrivastava198443306542020-04-01 02:50:20 -0500109
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500110common_SOURCES =['common_utility.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530111'vpd-parser/parser_factory.cpp',
112 'vpd-parser/memory_vpd_parser.cpp',
jinuthomas6555e7e2023-02-14 21:48:00 -0600113 'vpd-parser/isdimm_vpd_parser.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530114 'vpd-parser/keyword_vpd_parser.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500115 'vpd-parser/ipz_parser.cpp', 'impl.cpp', 'ibm_vpd_utils.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530116]
117
SunnySrivastava198443306542020-04-01 02:50:20 -0500118if get_option('ibm-parser').enabled()
Alpana Kumari2f793042020-08-18 05:51:03 -0500119 libgpiodcxx = dependency('libgpiodcxx')
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -0500120 ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp',
121 'vpd-manager/editor_impl.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530122 ]+common_SOURCES
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600123
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -0500124 vpd_tool_INCLUDE = include_directories('vpd-parser/', 'vpd-manager')
125
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600126 ibm_vpd_exe = executable(
127 'ibm-read-vpd',
128 ibm_read_vpd_SOURCES,
129 dependencies: [
130 sdbusplus,
131 phosphor_logging,
Alpana Kumari2f793042020-08-18 05:51:03 -0500132 libgpiodcxx,
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600133 ],
Priyanga Ramasamya4a2adf2022-02-03 05:43:41 -0600134 link_with : libvpdecc,
Kantesh Nagaradder38ee9c82023-04-07 00:58:12 -0500135 include_directories : vpd_tool_INCLUDE,
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600136 install: true,
137 cpp_args : '-DIPZ_PARSER'
138 )
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530139
140 vpd_tool_SOURCES = ['vpd_tool.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530141 'vpd_tool_impl.cpp',
142 'vpd-manager/editor_impl.cpp',
143 ]+common_SOURCES
144
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530145
146 vpd_tool_exe = executable(
147 'vpd-tool',
148 vpd_tool_SOURCES,
149 dependencies: [
Alpana Kumari735dee92022-03-25 01:24:40 -0500150 sdbusplus,
Sunny Srivastavaf31a91b2022-06-09 08:11:29 -0500151 phosphor_logging,
Alpana Kumari735dee92022-03-25 01:24:40 -0500152 libgpiodcxx
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530153 ],
Priyanga Ramasamya4a2adf2022-02-03 05:43:41 -0600154 link_with : libvpdecc,
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +0530155 install: true,
Priyanga Ramasamy38031312021-10-07 16:39:13 -0500156 include_directories : vpd_tool_INCLUDE,
157 cpp_args : '-DIPZ_PARSER'
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +0530158 )
SunnySrivastava1984a7392592020-03-09 10:19:33 -0500159if get_option('vpd-manager').enabled()
160 subdir('vpd-manager')
161endif
162
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500163systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williamsc68829a2023-04-12 08:01:19 -0500164 'systemdsystemunitdir')
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500165
166udev_dir = dependency('udev').get_variable(
Patrick Williamsc68829a2023-04-12 08:01:19 -0500167 'udev_dir')
Alpana Kumarib48e6ff2022-04-24 23:42:28 -0500168
169install_data(
170 'ibm_vpd/system-vpd.service',
171 install_dir: systemd_system_unit_dir)
172
173install_data(
174 'ibm_vpd/ibm-vpd-parser@.service',
175 install_dir: systemd_system_unit_dir)
176
177install_data(
178 'ibm_vpd/com.ibm.VPD.Manager.service',
179 install_dir: systemd_system_unit_dir)
180
181install_data(
182 'ibm_vpd/wait-vpd-parsers.service',
183 install_dir: systemd_system_unit_dir)
184
185install_data(
186 'ibm_vpd/wait-vpd-parsers.sh',
187 install_mode: 'rwxr-xr-x',
188 install_dir: get_option('bindir'))
189
190install_data(
191 ['ibm_vpd/70-ibm-vpd-parser.rules'],
192 install_dir: udev_dir / 'rules.d')
193
194package_datadir = join_paths('share', 'vpd')
195install_subdir('ibm_vpd/fru/', install_dir: package_datadir, strip_directory: true)
196
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600197else
198 FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML')
199 PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML')
200
201 src_dir = meson.source_root()
202 FRU_GEN_SCRIPT = src_dir + '/writefru.py'
203 FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml'
204
205 PROP_GEN_SCRIPT = src_dir + '/extra-properties.py'
206 PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml'
207
208 writefru_hpp = custom_target('writefru.hpp',
209 command:[python,
210 FRU_GEN_SCRIPT,
211 '-i',
212 get_option('FRU_YAML')
213 ],
214 depend_files :['writefru.mako.hpp',
215 'writefru.py',
216 get_option('FRU_YAML')
217 ],
218 output:'writefru.hpp'
219 )
220
221 extra_properties_gen_hpp = custom_target(
222 'extra-properties-gen.hpp',
223 command:[
224 python,
225 PROP_GEN_SCRIPT,
226 '-e',
227 get_option('PROP_YAML')
228 ],
229 depend_files : ['extra-properties.mako.hpp',
230 'extra-properties.py',
231 get_option('PROP_YAML')
232 ],
233 output:'extra-properties-gen.hpp'
234 )
235
236 openpower_read_vpd_SOURCES = ['app.cpp',
237 'args.cpp',
238 'impl.cpp',
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500239 'vpd-parser/ipz_parser.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600240 'write.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500241 'common_utility.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600242 writefru_hpp,
243 extra_properties_gen_hpp
244 ]
245
246 openpower_read_vpd_exe= executable(
247 'openpower-read-vpd',
248 openpower_read_vpd_SOURCES,
249 dependencies: [
250 sdbusplus,
251 phosphor_logging,
252 ],
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500253 include_directories : 'vpd-parser/',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600254 install: true,
255 )
256endif