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