1project( 2 'openpower-vpd-parser', 3 'c', 4 'cpp', 5 default_options: [ 6 'warning_level=3', 7 'werror=true', 8 'cpp_std=c++17', 9 'buildtype=debugoptimized' 10 ], 11 version: '1.0' 12) 13 14add_global_arguments('-Wno-psabi', language : ['c', 'cpp']) 15 16# Disable FORTIFY_SOURCE when compiling with no optimization 17if(get_option('optimization') == '0') 18 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c']) 19 message('Disabling FORTIFY_SOURCE as optimization is set to 0') 20endif 21 22# Setup googletest before we import any projects that also depend on it to make 23# sure we have control over its configuration 24build_tests = get_option('tests') 25if not build_tests.disabled() 26 gtest_dep = dependency('gtest', main: true, disabler: true, required: false) 27 gmock_dep = dependency('gmock', disabler: true, required: false) 28 if not gtest_dep.found() or not gmock_dep.found() 29 cmake = import('cmake') 30 gtest_opts = cmake.subproject_options() 31 gtest_opts.set_override_option('warning_level', '1') 32 gtest_opts.set_override_option('werror', 'false') 33 gtest_proj = cmake.subproject('googletest', 34 options: gtest_opts, 35 required: false) 36 if gtest_proj.found() 37 gtest_dep = declare_dependency( 38 dependencies: [ 39 dependency('threads'), 40 gtest_proj.dependency('gtest'), 41 gtest_proj.dependency('gtest_main'), 42 ] 43 ) 44 gmock_dep = gtest_proj.dependency('gmock') 45 else 46 assert(not get_option('tests').enabled(), 47 'Googletest is required if tests are enabled') 48 endif 49 endif 50endif 51 52phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces', 53 default_options: [ 'data_com_ibm=true', 'data_org_open_power=true' ], 54 fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep']) 55 56phosphor_logging = dependency('phosphor-logging', 57 default_options: [ 'openpower-pel-extension=enabled' ], 58 fallback: ['phosphor-logging', 'phosphor_logging_dep']) 59 60sdbusplus = dependency('sdbusplus', fallback: [ 'sdbusplus', 'sdbusplus_dep' ]) 61 62if not build_tests.disabled() 63 subdir('test') 64endif 65 66compiler = meson.get_compiler('cpp') 67python = find_program('python3', required:true) 68 69compiler.has_header('CLI/CLI.hpp') 70compiler.has_header('nlohmann/json.hpp') 71 72configure_file(output: 'config.h', 73 configuration :{ 74 'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"', 75 'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"', 76 'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"', 77 'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"', 78 'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"', 79 'BUSNAME' : '"' + get_option('BUSNAME') + '"', 80 'OBJPATH' : '"' + get_option('OBJPATH') + '"', 81 'IFACE' : '"' + get_option('IFACE') + '"', 82 'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"', 83 'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"', 84 'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"', 85 'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"', 86 'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"', 87 'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"', 88 'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"', 89 'INVENTORY_JSON_EVEREST': '"'+get_option('INVENTORY_JSON_EVEREST')+'"', 90 'DBUS_PROP_JSON': '"'+get_option('DBUS_PROP_JSON')+'"', 91 'SYSTEM_JSON' : '"'+get_option('SYSTEM_JSON')+'"', 92 'BAD_VPD_DIR': '"'+get_option('BAD_VPD_DIR')+'"', 93 'FAN_INTERFACE': '"'+get_option('FAN_INTERFACE')+'"' 94 } 95 ) 96 97common_SOURCES =['common_utility.cpp', 98'vpd-parser/parser_factory.cpp', 99 'vpd-parser/memory_vpd_parser.cpp', 100 'vpd-parser/keyword_vpd_parser.cpp', 101 'vpd-parser/ipz_parser.cpp', 'impl.cpp', 'ibm_vpd_utils.cpp', 102 'vpdecc/vpdecc.c', 'vpdecc/vpdecc_support.c' 103] 104 105if get_option('ibm-parser').enabled() 106 libgpiodcxx = dependency('libgpiodcxx') 107 ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp' 108 ]+common_SOURCES 109 110 ibm_vpd_exe = executable( 111 'ibm-read-vpd', 112 ibm_read_vpd_SOURCES, 113 dependencies: [ 114 sdbusplus, 115 phosphor_logging, 116 libgpiodcxx, 117 ], 118 include_directories : 'vpd-parser/', 119 install: true, 120 cpp_args : '-DIPZ_PARSER' 121 ) 122 123 vpd_tool_SOURCES = ['vpd_tool.cpp', 124 'vpd_tool_impl.cpp', 125 'vpd-manager/editor_impl.cpp', 126 ]+common_SOURCES 127 128 vpd_tool_INCLUDE = include_directories('vpd-parser/', 'vpd-manager') 129 130 vpd_tool_exe = executable( 131 'vpd-tool', 132 vpd_tool_SOURCES, 133 dependencies: [ 134 sdbusplus 135 ], 136 install: true, 137 include_directories : vpd_tool_INCLUDE 138 ) 139if get_option('vpd-manager').enabled() 140 subdir('vpd-manager') 141endif 142 143else 144 FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML') 145 PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML') 146 147 src_dir = meson.source_root() 148 FRU_GEN_SCRIPT = src_dir + '/writefru.py' 149 FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml' 150 151 PROP_GEN_SCRIPT = src_dir + '/extra-properties.py' 152 PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml' 153 154 writefru_hpp = custom_target('writefru.hpp', 155 command:[python, 156 FRU_GEN_SCRIPT, 157 '-i', 158 get_option('FRU_YAML') 159 ], 160 depend_files :['writefru.mako.hpp', 161 'writefru.py', 162 get_option('FRU_YAML') 163 ], 164 output:'writefru.hpp' 165 ) 166 167 extra_properties_gen_hpp = custom_target( 168 'extra-properties-gen.hpp', 169 command:[ 170 python, 171 PROP_GEN_SCRIPT, 172 '-e', 173 get_option('PROP_YAML') 174 ], 175 depend_files : ['extra-properties.mako.hpp', 176 'extra-properties.py', 177 get_option('PROP_YAML') 178 ], 179 output:'extra-properties-gen.hpp' 180 ) 181 182 openpower_read_vpd_SOURCES = ['app.cpp', 183 'args.cpp', 184 'impl.cpp', 185 'vpd-parser/ipz_parser.cpp', 186 'write.cpp', 187 'common_utility.cpp', 188 writefru_hpp, 189 extra_properties_gen_hpp 190 ] 191 192 openpower_read_vpd_exe= executable( 193 'openpower-read-vpd', 194 openpower_read_vpd_SOURCES, 195 dependencies: [ 196 sdbusplus, 197 phosphor_logging, 198 ], 199 include_directories : 'vpd-parser/', 200 install: true, 201 ) 202endif 203