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').allowed(), 48 'Googletest is required if tests are enabled') 49 endif 50 endif 51endif 52 53nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 54 55phosphor_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' ]) 64 65libvpdecc_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 77compiler = meson.get_compiler('cpp') 78python = find_program('python3', required:true) 79 80if compiler.has_header('CLI/CLI.hpp') 81 CLI11_dep = declare_dependency() 82else 83 CLI11_dep = dependency('CLI11') 84endif 85 86if not build_tests.disabled() 87 subdir('test') 88endif 89 90configure_file(output: 'config.h', 91 configuration :{ 92 'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"', 93 'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"', 94 'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"', 95 'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"', 96 'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"', 97 'BUSNAME' : '"' + get_option('BUSNAME') + '"', 98 'OBJPATH' : '"' + get_option('OBJPATH') + '"', 99 'IFACE' : '"' + get_option('IFACE') + '"', 100 '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')+'"', 103 'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"', 104 'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"', 105 'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"', 106 'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"', 107 'INVENTORY_JSON_EVEREST': '"'+get_option('INVENTORY_JSON_EVEREST')+'"', 108 'DBUS_PROP_JSON': '"'+get_option('DBUS_PROP_JSON')+'"', 109 'SYSTEM_JSON' : '"'+get_option('SYSTEM_JSON')+'"', 110 'BAD_VPD_DIR': '"'+get_option('BAD_VPD_DIR')+'"', 111 'FAN_INTERFACE': '"'+get_option('FAN_INTERFACE')+'"' 112 } 113 ) 114 115common_SOURCES =['common_utility.cpp', 116'vpd-parser/parser_factory.cpp', 117 'vpd-parser/memory_vpd_parser.cpp', 118 'vpd-parser/isdimm_vpd_parser.cpp', 119 'vpd-parser/keyword_vpd_parser.cpp', 120 'vpd-parser/ipz_parser.cpp', 'impl.cpp', 'ibm_vpd_utils.cpp', 121] 122 123if get_option('ibm-parser').allowed() 124 libgpiodcxx = dependency( 125 'libgpiodcxx', 126 default_options: ['bindings=cxx'], 127 ) 128 ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp', 129 'vpd-manager/editor_impl.cpp', 130 ]+common_SOURCES 131 132 vpd_tool_INCLUDE = include_directories('vpd-parser/', 'vpd-manager') 133 134 ibm_vpd_exe = executable( 135 'ibm-read-vpd', 136 ibm_read_vpd_SOURCES, 137 dependencies: [ 138 sdbusplus, 139 phosphor_logging, 140 libgpiodcxx, 141 nlohmann_json_dep, 142 CLI11_dep, 143 ], 144 link_with : libvpdecc, 145 include_directories : vpd_tool_INCLUDE, 146 install: true, 147 cpp_args : '-DIPZ_PARSER' 148 ) 149 150 vpd_tool_SOURCES = ['vpd_tool.cpp', 151 'vpd_tool_impl.cpp', 152 'vpd-manager/editor_impl.cpp', 153 ]+common_SOURCES 154 155 156 vpd_tool_exe = executable( 157 'vpd-tool', 158 vpd_tool_SOURCES, 159 dependencies: [ 160 CLI11_dep, 161 libgpiodcxx, 162 nlohmann_json_dep, 163 phosphor_logging, 164 sdbusplus, 165 ], 166 link_with : libvpdecc, 167 install: true, 168 include_directories : vpd_tool_INCLUDE, 169 cpp_args : '-DIPZ_PARSER' 170 ) 171if get_option('vpd-manager').allowed() 172 subdir('vpd-manager') 173endif 174 175systemd_system_unit_dir = dependency('systemd').get_variable( 176 'systemdsystemunitdir') 177 178udev_dir = dependency('udev').get_variable( 179 'udev_dir') 180 181rules = ['rules/70-ibm-vpd-parser.rules'] 182 183install_data(rules, install_mode: 'rw-r--r--', install_dir: udev_dir/'rules.d') 184 185services = ['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'] 191 192install_data(services, install_dir: systemd_system_unit_dir) 193 194scripts = ['scripts/wait-vpd-parsers.sh'] 195 196install_data(scripts, 197 install_mode: 'rwxr-xr-x', 198 install_dir: get_option('bindir')) 199 200package_datadir = join_paths('share', 'vpd') 201install_subdir('config/ibm', install_dir: package_datadir, strip_directory: true) 202 203else 204 FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML') 205 PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML') 206 207 src_dir = meson.project_source_root() 208 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', 245 'vpd-parser/ipz_parser.cpp', 246 'write.cpp', 247 'common_utility.cpp', 248 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, 258 nlohmann_json_dep, 259 ], 260 include_directories : 'vpd-parser/', 261 install: true, 262 ) 263endif 264