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