Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 1 | project( |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 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 | ) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 8 | |
| 9 | root_inc = include_directories('.') |
| 10 | |
| 11 | # Setting up config data |
| 12 | conf_data = configuration_data() |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 13 | conf_data.set_quoted( |
| 14 | 'STATIC_HANDLER_STAGED_NAME', |
| 15 | get_option('static-handler-staged-name'), |
| 16 | ) |
| 17 | conf_data.set_quoted( |
| 18 | 'PREPARATION_DBUS_SERVICE', |
| 19 | get_option('preparation-dbus-service'), |
| 20 | ) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 21 | conf_data.set_quoted('VERIFY_DBUS_SERVICE', get_option('verify-dbus-service')) |
| 22 | conf_data.set_quoted('UPDATE_DBUS_SERVICE', get_option('update-dbus-service')) |
| 23 | conf_data.set_quoted('BIOS_STAGED_NAME', get_option('bios-staged-name')) |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 24 | conf_data.set_quoted( |
| 25 | 'PREPARATION_BIOS_TARGET', |
| 26 | get_option('preparation-bios-target'), |
| 27 | ) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 28 | conf_data.set_quoted('VERIFY_BIOS_TARGET', get_option('verify-bios-target')) |
| 29 | conf_data.set_quoted('UPDATE_BIOS_TARGET', get_option('update-bios-target')) |
| 30 | |
| 31 | conf_data.set_quoted('TARBALL_STAGED_NAME', get_option('tarball-staged-name')) |
| 32 | conf_data.set_quoted('HASH_FILENAME', get_option('hash-filename')) |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 33 | conf_data.set_quoted( |
| 34 | 'VERIFY_STATUS_FILENAME', |
| 35 | get_option('verify-status-filename'), |
| 36 | ) |
| 37 | conf_data.set_quoted( |
| 38 | 'UPDATE_STATUS_FILENAME', |
| 39 | get_option('update-status-filename'), |
| 40 | ) |
| 41 | conf_data.set_quoted( |
| 42 | 'BIOS_VERIFY_STATUS_FILENAME', |
| 43 | get_option('bios-verify-status-filename'), |
| 44 | ) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 45 | conf_data.set('MAPPED_ADDRESS', get_option('mapped-address')) |
Tim Lee | 2d57d52 | 2023-09-18 11:47:53 +0800 | [diff] [blame] | 46 | conf_data.set('NUVOTON_PCI_DID', get_option('nuvoton-pci-did')) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 47 | |
| 48 | |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 49 | conf_h = configure_file(output: 'config.h', configuration: conf_data) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 50 | |
| 51 | # Setup for the test config |
Patrick Williams | acbf875 | 2025-01-30 17:48:00 -0500 | [diff] [blame] | 52 | if get_option('tests').allowed() |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 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') |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 61 | endif |
| 62 | |
| 63 | if get_option('lpc-type') != 'none' |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 64 | add_project_arguments('-DENABLE_LPC_BRIDGE', language: 'cpp') |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 65 | endif |
| 66 | |
| 67 | # Enable LPC and PCI for tests only. |
| 68 | assert( |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 69 | get_option('tests').allowed() \ |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 70 | or get_option('lpc-type') == 'none' \ |
| 71 | or get_option('p2a-type') == 'none', |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 72 | 'Invalid configuration enabling both PCI and LPC.', |
| 73 | ) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 74 | |
| 75 | if get_option('p2a-type') != 'none' |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 76 | add_project_arguments('-DENABLE_PCI_BRIDGE', language: 'cpp') |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 77 | endif |
| 78 | |
| 79 | feature_map = { |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 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', |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 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 | |
| 90 | foreach option_key, option_value : feature_map |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 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 |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 95 | endforeach |
| 96 | |
| 97 | |
| 98 | update_type_combo_map = { |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 99 | 'static-layout' : '-DENABLE_STATIC_LAYOUT', |
| 100 | 'tarball-ubi' : '-DENABLE_TARBALL_UBI', |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | foreach option_key, option_value : update_type_combo_map |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 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 |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 112 | endforeach |
| 113 | |
| 114 | lpc_type_combo_map = { |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 115 | 'aspeed-lpc' : '-DASPEED_LPC', |
| 116 | 'nuvoton-lpc' : '-DNUVOTON_LPC', |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | foreach option_key, option_value : lpc_type_combo_map |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 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 |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 124 | endforeach |
| 125 | |
| 126 | pci_type_combo_map = { |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 127 | 'aspeed-p2a' : '-DASPEED_P2A', |
| 128 | 'nuvoton-p2a-vga' : '-DNUVOTON_P2A_VGA', |
| 129 | 'nuvoton-p2a-mbox' : '-DNUVOTON_P2A_MBOX', |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | foreach option_key, option_value : pci_type_combo_map |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 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 |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 137 | endforeach |
| 138 | |
| 139 | |
| 140 | sys_lib = static_library( |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 141 | 'sys', |
| 142 | 'internal/sys.cpp', |
| 143 | implicit_include_directories: false, |
| 144 | ) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 145 | |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 146 | sys_dep = declare_dependency(link_with: sys_lib) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 147 | |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 148 | blobs_dep = dependency('phosphor-ipmi-blobs') |
Patrick Williams | deb85ce | 2023-12-07 14:27:45 -0600 | [diff] [blame] | 149 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
Brandon Kim | ea65e68 | 2022-07-13 23:21:33 +0000 | [diff] [blame] | 150 | |
Patrick Williams | acbf875 | 2025-01-30 17:48:00 -0500 | [diff] [blame] | 151 | if get_option('tests').allowed() |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 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 | ) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 162 | |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 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 |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 173 | endif |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 174 | endif |
| 175 | |
| 176 | |
Patrick Williams | acbf875 | 2025-01-30 17:48:00 -0500 | [diff] [blame] | 177 | if get_option('bmc-blob-handler').allowed() |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 178 | subdir('bmc') |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 179 | endif |
| 180 | |
Patrick Williams | acbf875 | 2025-01-30 17:48:00 -0500 | [diff] [blame] | 181 | if get_option('host-tool').allowed() |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 182 | subdir('tools') |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 183 | endif |
| 184 | |
Patrick Williams | acbf875 | 2025-01-30 17:48:00 -0500 | [diff] [blame] | 185 | if get_option('cleanup-delete').allowed() |
Patrick Williams | 32e9ea1 | 2025-02-01 08:37:51 -0500 | [diff] [blame^] | 186 | subdir('cleanup') |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 187 | endif |