1project( 2 'openpower-vpd-parser', 3 'c', 4 'cpp', 5 default_options: [ 6 'warning_level=3', 7 'werror=true', 8 'cpp_std=c++23', 9 'buildtype=debugoptimized' 10 ], 11 version: '1.0', 12 meson_version: '>=1.1.1', 13) 14 15add_global_arguments('-Wno-psabi', language : ['c', 'cpp']) 16 17# 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 53phosphor_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' ]) 62 63libvpdecc_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 75compiler = meson.get_compiler('cpp') 76python = find_program('python3', required:true) 77 78if compiler.has_header('CLI/CLI.hpp') 79 CLI11_dep = declare_dependency() 80else 81 CLI11_dep = dependency('CLI11') 82endif 83 84if compiler.has_header('nlohmann/json.hpp') 85 nlohmann_json_dep = declare_dependency() 86else 87 nlohmann_json_dep = dependency('nlohmann-json') 88endif 89 90if not build_tests.disabled() 91 subdir('test') 92endif 93 94configure_file(output: 'config.h', 95 configuration :{ 96 'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"', 97 'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"', 98 'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"', 99 'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"', 100 'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"', 101 'BUSNAME' : '"' + get_option('BUSNAME') + '"', 102 'OBJPATH' : '"' + get_option('OBJPATH') + '"', 103 'IFACE' : '"' + get_option('IFACE') + '"', 104 'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"', 105 'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"', 106 'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"', 107 'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"', 108 'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"', 109 'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"', 110 'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"', 111 'INVENTORY_JSON_EVEREST': '"'+get_option('INVENTORY_JSON_EVEREST')+'"', 112 'DBUS_PROP_JSON': '"'+get_option('DBUS_PROP_JSON')+'"', 113 'SYSTEM_JSON' : '"'+get_option('SYSTEM_JSON')+'"', 114 'BAD_VPD_DIR': '"'+get_option('BAD_VPD_DIR')+'"', 115 'FAN_INTERFACE': '"'+get_option('FAN_INTERFACE')+'"' 116 } 117 ) 118 119common_SOURCES =['common_utility.cpp', 120'vpd-parser/parser_factory.cpp', 121 'vpd-parser/memory_vpd_parser.cpp', 122 'vpd-parser/isdimm_vpd_parser.cpp', 123 'vpd-parser/keyword_vpd_parser.cpp', 124 'vpd-parser/ipz_parser.cpp', 'impl.cpp', 'ibm_vpd_utils.cpp', 125] 126 127if get_option('ibm-parser').allowed() 128 libgpiodcxx = dependency( 129 'libgpiodcxx', 130 default_options: ['bindings=cxx'], 131 ) 132 ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp', 133 'vpd-manager/editor_impl.cpp', 134 ]+common_SOURCES 135 136 vpd_tool_INCLUDE = include_directories('vpd-parser/', 'vpd-manager') 137 138 ibm_vpd_exe = executable( 139 'ibm-read-vpd', 140 ibm_read_vpd_SOURCES, 141 dependencies: [ 142 sdbusplus, 143 phosphor_logging, 144 libgpiodcxx, 145 nlohmann_json_dep, 146 CLI11_dep, 147 ], 148 link_with : libvpdecc, 149 include_directories : vpd_tool_INCLUDE, 150 install: true, 151 cpp_args : '-DIPZ_PARSER' 152 ) 153 154 vpd_tool_SOURCES = ['vpd_tool.cpp', 155 'vpd_tool_impl.cpp', 156 'vpd-manager/editor_impl.cpp', 157 ]+common_SOURCES 158 159 160 vpd_tool_exe = executable( 161 'vpd-tool', 162 vpd_tool_SOURCES, 163 dependencies: [ 164 CLI11_dep, 165 libgpiodcxx, 166 nlohmann_json_dep, 167 phosphor_logging, 168 sdbusplus, 169 ], 170 link_with : libvpdecc, 171 install: true, 172 include_directories : vpd_tool_INCLUDE, 173 cpp_args : '-DIPZ_PARSER' 174 ) 175if get_option('vpd-manager').allowed() 176 subdir('vpd-manager') 177endif 178 179systemd_system_unit_dir = dependency('systemd').get_variable( 180 'systemdsystemunitdir') 181 182udev_dir = dependency('udev').get_variable( 183 'udev_dir') 184 185install_data( 186 'ibm_vpd/system-vpd.service', 187 install_dir: systemd_system_unit_dir) 188 189install_data( 190 'ibm_vpd/ibm-vpd-parser@.service', 191 install_dir: systemd_system_unit_dir) 192 193install_data( 194 'ibm_vpd/com.ibm.VPD.Manager.service', 195 install_dir: systemd_system_unit_dir) 196 197install_data( 198 'ibm_vpd/wait-vpd-parsers.service', 199 install_dir: systemd_system_unit_dir) 200 201install_data( 202 'ibm_vpd/wait-vpd-parsers.sh', 203 install_mode: 'rwxr-xr-x', 204 install_dir: get_option('bindir')) 205 206install_data( 207 ['ibm_vpd/70-ibm-vpd-parser.rules'], 208 install_dir: udev_dir / 'rules.d') 209 210package_datadir = join_paths('share', 'vpd') 211install_subdir('ibm_vpd/fru/', install_dir: package_datadir, strip_directory: true) 212 213else 214 FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML') 215 PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML') 216 217 src_dir = meson.project_source_root() 218 FRU_GEN_SCRIPT = src_dir + '/writefru.py' 219 FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml' 220 221 PROP_GEN_SCRIPT = src_dir + '/extra-properties.py' 222 PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml' 223 224 writefru_hpp = custom_target('writefru.hpp', 225 command:[python, 226 FRU_GEN_SCRIPT, 227 '-i', 228 get_option('FRU_YAML') 229 ], 230 depend_files :['writefru.mako.hpp', 231 'writefru.py', 232 get_option('FRU_YAML') 233 ], 234 output:'writefru.hpp' 235 ) 236 237 extra_properties_gen_hpp = custom_target( 238 'extra-properties-gen.hpp', 239 command:[ 240 python, 241 PROP_GEN_SCRIPT, 242 '-e', 243 get_option('PROP_YAML') 244 ], 245 depend_files : ['extra-properties.mako.hpp', 246 'extra-properties.py', 247 get_option('PROP_YAML') 248 ], 249 output:'extra-properties-gen.hpp' 250 ) 251 252 openpower_read_vpd_SOURCES = ['app.cpp', 253 'args.cpp', 254 'impl.cpp', 255 'vpd-parser/ipz_parser.cpp', 256 'write.cpp', 257 'common_utility.cpp', 258 writefru_hpp, 259 extra_properties_gen_hpp 260 ] 261 262 openpower_read_vpd_exe= executable( 263 'openpower-read-vpd', 264 openpower_read_vpd_SOURCES, 265 dependencies: [ 266 sdbusplus, 267 phosphor_logging, 268 nlohmann_json_dep, 269 ], 270 include_directories : 'vpd-parser/', 271 install: true, 272 ) 273endif 274