1project( 2 'phosphor-ipmi-flash', 3 'cpp', 4 version: '0.1', 5 meson_version: '>=1.1.1', 6 default_options: [ 7 'cpp_std=c++23', 8 'warning_level=3', 9 'werror=true', 10 ]) 11 12root_inc = include_directories('.') 13 14# Setting up config data 15conf_data = configuration_data() 16conf_data.set_quoted('STATIC_HANDLER_STAGED_NAME', get_option('static-handler-staged-name')) 17conf_data.set_quoted('PREPARATION_DBUS_SERVICE', get_option('preparation-dbus-service')) 18conf_data.set_quoted('VERIFY_DBUS_SERVICE', get_option('verify-dbus-service')) 19conf_data.set_quoted('UPDATE_DBUS_SERVICE', get_option('update-dbus-service')) 20conf_data.set_quoted('BIOS_STAGED_NAME', get_option('bios-staged-name')) 21conf_data.set_quoted('PREPARATION_BIOS_TARGET', get_option('preparation-bios-target')) 22conf_data.set_quoted('VERIFY_BIOS_TARGET', get_option('verify-bios-target')) 23conf_data.set_quoted('UPDATE_BIOS_TARGET', get_option('update-bios-target')) 24 25conf_data.set_quoted('TARBALL_STAGED_NAME', get_option('tarball-staged-name')) 26conf_data.set_quoted('HASH_FILENAME', get_option('hash-filename')) 27conf_data.set_quoted('VERIFY_STATUS_FILENAME', get_option('verify-status-filename')) 28conf_data.set_quoted('UPDATE_STATUS_FILENAME', get_option('update-status-filename')) 29conf_data.set_quoted('BIOS_VERIFY_STATUS_FILENAME', get_option('bios-verify-status-filename')) 30conf_data.set('MAPPED_ADDRESS', get_option('mapped-address')) 31conf_data.set('NUVOTON_PCI_DID', get_option('nuvoton-pci-did')) 32 33 34conf_h = configure_file( 35 output: 'config.h', 36 configuration: conf_data) 37 38# Setup for the test config 39if not get_option('tests').disabled() 40 add_project_arguments('-DENABLE_STATIC_LAYOUT', language: 'cpp') 41 add_project_arguments('-DENABLE_TARBALL_UBI', language: 'cpp') 42 add_project_arguments('-DASPEED_P2A', language: 'cpp') 43 add_project_arguments('-DENABLE_PCI_BRIDGE', language: 'cpp') 44 add_project_arguments('-DASPEED_LPC', language: 'cpp') 45 add_project_arguments('-DNUVOTON_LPC', language: 'cpp') 46 add_project_arguments('-DENABLE_LPC_BRIDGE', language: 'cpp') 47 add_project_arguments('-DENABLE_HOST_BIOS', language: 'cpp') 48endif 49 50if get_option('lpc-type') != 'none' 51 add_project_arguments('-DENABLE_LPC_BRIDGE', language: 'cpp') 52endif 53 54# Enable LPC and PCI for tests only. 55assert( 56 not get_option('tests').disabled() \ 57 or get_option('lpc-type') == 'none' \ 58 or get_option('p2a-type') == 'none', 59 'Invalid configuration enabling both PCI and LPC.') 60 61if get_option('p2a-type') != 'none' 62 add_project_arguments('-DENABLE_PCI_BRIDGE', language: 'cpp') 63endif 64 65feature_map = { 66 'host-bios' : '-DENABLE_HOST_BIOS', 67 'ppc' : '-DENABLE_PPC', 68 'reboot-update' : '-DENABLE_REBOOT_UPDATE', 69 'update-status' : '-DENABLE_UPDATE_STATUS', 70 'net-bridge' : '-DENABLE_NET_BRIDGE', 71} 72 73# Get the options status and build a project summary to show which flags are 74# being enabled during the configuration time. 75 76foreach option_key, option_value : feature_map 77 if get_option(option_key) 78 add_project_arguments(option_value, language: 'cpp') 79 summary(option_key, option_value, section : 'Enabled Features') 80 endif 81endforeach 82 83 84update_type_combo_map = { 85 'static-layout' : '-DENABLE_STATIC_LAYOUT', 86 'tarball-ubi' : '-DENABLE_TARBALL_UBI', 87} 88 89foreach option_key, option_value : update_type_combo_map 90 if get_option('update-type') == option_key 91 add_project_arguments(option_value, language: 'cpp') 92 summary(option_key, option_value, section : 'Enabled Firmware Update Features') 93 endif 94endforeach 95 96lpc_type_combo_map = { 97 'aspeed-lpc' : '-DASPEED_LPC', 98 'nuvoton-lpc' : '-DNUVOTON_LPC', 99} 100 101foreach option_key, option_value : lpc_type_combo_map 102 if get_option('lpc-type') == option_key 103 add_project_arguments(option_value, language: 'cpp') 104 summary(option_key, option_value, section : 'Enabled LPC Features') 105 endif 106endforeach 107 108pci_type_combo_map = { 109 'aspeed-p2a' : '-DASPEED_P2A', 110 'nuvoton-p2a-vga' : '-DNUVOTON_P2A_VGA', 111 'nuvoton-p2a-mbox' : '-DNUVOTON_P2A_MBOX', 112} 113 114foreach option_key, option_value : pci_type_combo_map 115 if get_option('p2a-type') == option_key 116 add_project_arguments(option_value, language: 'cpp') 117 summary(option_key, option_value, section : 'Enabled PCI Features') 118 endif 119endforeach 120 121 122sys_lib = static_library( 123 'sys', 124 'internal/sys.cpp', 125 implicit_include_directories: false) 126 127sys_dep = declare_dependency( 128 link_with: sys_lib) 129 130blobs_dep = dependency('phosphor-ipmi-blobs') 131 132cpp = meson.get_compiler('cpp') 133 134if cpp.has_header('nlohmann/json.hpp') 135 json_dep = declare_dependency() 136else 137 json_dep = dependency('nlohmann_json') 138endif 139 140if not get_option('tests').disabled() 141 gtest = dependency('gtest', main: true, disabler: true, required: false) 142 gmock = dependency('gmock', disabler: true, required: false) 143 if not gtest.found() or not gmock.found() 144 gtest_opt = import('cmake').subproject_options() 145 gtest_opt.append_compile_args('c++', ['-DCMAKE_CXX_FLAGS=-Wno-pedantic']) 146 gtest_proj = cmake.subproject('googletest', options: gtest_opt, required: false) 147 148 if gtest_proj.found() 149 gtest = declare_dependency( 150 dependencies: [ 151 dependency('threads'), 152 gtest_proj.dependency('gtest'), 153 gtest_proj.dependency('gtest_main'), 154 ]) 155 gmock = gtest_proj.dependency('gmock') 156 endif 157 endif 158endif 159 160 161if not get_option('bmc-blob-handler').disabled() 162 subdir('bmc') 163endif 164 165if not get_option('host-tool').disabled() 166 subdir('tools') 167endif 168 169if not get_option('cleanup-delete').disabled() 170 subdir('cleanup') 171endif 172