Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-ipmi-flash', |
| 3 | 'cpp', |
| 4 | version: '0.1', |
Patrick Williams | 4719ad0 | 2023-07-12 11:15:52 -0500 | [diff] [blame] | 5 | meson_version: '>=1.1.1', |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 6 | default_options: [ |
Patrick Williams | 4719ad0 | 2023-07-12 11:15:52 -0500 | [diff] [blame] | 7 | 'cpp_std=c++23', |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 8 | 'warning_level=3', |
| 9 | 'werror=true', |
| 10 | ]) |
| 11 | |
| 12 | root_inc = include_directories('.') |
| 13 | |
| 14 | # Setting up config data |
| 15 | conf_data = configuration_data() |
| 16 | conf_data.set_quoted('STATIC_HANDLER_STAGED_NAME', get_option('static-handler-staged-name')) |
| 17 | conf_data.set_quoted('PREPARATION_DBUS_SERVICE', get_option('preparation-dbus-service')) |
| 18 | conf_data.set_quoted('VERIFY_DBUS_SERVICE', get_option('verify-dbus-service')) |
| 19 | conf_data.set_quoted('UPDATE_DBUS_SERVICE', get_option('update-dbus-service')) |
| 20 | conf_data.set_quoted('BIOS_STAGED_NAME', get_option('bios-staged-name')) |
| 21 | conf_data.set_quoted('PREPARATION_BIOS_TARGET', get_option('preparation-bios-target')) |
| 22 | conf_data.set_quoted('VERIFY_BIOS_TARGET', get_option('verify-bios-target')) |
| 23 | conf_data.set_quoted('UPDATE_BIOS_TARGET', get_option('update-bios-target')) |
| 24 | |
| 25 | conf_data.set_quoted('TARBALL_STAGED_NAME', get_option('tarball-staged-name')) |
| 26 | conf_data.set_quoted('HASH_FILENAME', get_option('hash-filename')) |
| 27 | conf_data.set_quoted('VERIFY_STATUS_FILENAME', get_option('verify-status-filename')) |
| 28 | conf_data.set_quoted('UPDATE_STATUS_FILENAME', get_option('update-status-filename')) |
| 29 | conf_data.set_quoted('BIOS_VERIFY_STATUS_FILENAME', get_option('bios-verify-status-filename')) |
| 30 | conf_data.set('MAPPED_ADDRESS', get_option('mapped-address')) |
Tim Lee | 2d57d52 | 2023-09-18 11:47:53 +0800 | [diff] [blame] | 31 | conf_data.set('NUVOTON_PCI_DID', get_option('nuvoton-pci-did')) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 32 | |
| 33 | |
| 34 | conf_h = configure_file( |
| 35 | output: 'config.h', |
| 36 | configuration: conf_data) |
| 37 | |
| 38 | # Setup for the test config |
| 39 | if 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') |
| 48 | endif |
| 49 | |
| 50 | if get_option('lpc-type') != 'none' |
| 51 | add_project_arguments('-DENABLE_LPC_BRIDGE', language: 'cpp') |
| 52 | endif |
| 53 | |
| 54 | # Enable LPC and PCI for tests only. |
| 55 | assert( |
| 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 | |
| 61 | if get_option('p2a-type') != 'none' |
| 62 | add_project_arguments('-DENABLE_PCI_BRIDGE', language: 'cpp') |
| 63 | endif |
| 64 | |
| 65 | feature_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 | |
| 76 | foreach 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 |
| 81 | endforeach |
| 82 | |
| 83 | |
| 84 | update_type_combo_map = { |
| 85 | 'static-layout' : '-DENABLE_STATIC_LAYOUT', |
| 86 | 'tarball-ubi' : '-DENABLE_TARBALL_UBI', |
| 87 | } |
| 88 | |
| 89 | foreach 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 |
| 94 | endforeach |
| 95 | |
| 96 | lpc_type_combo_map = { |
| 97 | 'aspeed-lpc' : '-DASPEED_LPC', |
Willy Tu | 7ace08a | 2021-10-31 17:10:30 -0700 | [diff] [blame] | 98 | 'nuvoton-lpc' : '-DNUVOTON_LPC', |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | foreach 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 |
| 106 | endforeach |
| 107 | |
| 108 | pci_type_combo_map = { |
| 109 | 'aspeed-p2a' : '-DASPEED_P2A', |
| 110 | 'nuvoton-p2a-vga' : '-DNUVOTON_P2A_VGA', |
| 111 | 'nuvoton-p2a-mbox' : '-DNUVOTON_P2A_MBOX', |
| 112 | } |
| 113 | |
| 114 | foreach 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 |
| 119 | endforeach |
| 120 | |
| 121 | |
| 122 | sys_lib = static_library( |
| 123 | 'sys', |
| 124 | 'internal/sys.cpp', |
| 125 | implicit_include_directories: false) |
| 126 | |
| 127 | sys_dep = declare_dependency( |
| 128 | link_with: sys_lib) |
| 129 | |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 130 | blobs_dep = dependency('phosphor-ipmi-blobs') |
Patrick Williams | deb85ce | 2023-12-07 14:27:45 -0600 | [diff] [blame] | 131 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
Brandon Kim | ea65e68 | 2022-07-13 23:21:33 +0000 | [diff] [blame] | 132 | |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 133 | if not get_option('tests').disabled() |
| 134 | gtest = dependency('gtest', main: true, disabler: true, required: false) |
| 135 | gmock = dependency('gmock', disabler: true, required: false) |
| 136 | if not gtest.found() or not gmock.found() |
| 137 | gtest_opt = import('cmake').subproject_options() |
| 138 | gtest_opt.append_compile_args('c++', ['-DCMAKE_CXX_FLAGS=-Wno-pedantic']) |
| 139 | gtest_proj = cmake.subproject('googletest', options: gtest_opt, required: false) |
Willy Tu | bcae900 | 2021-09-12 13:58:04 -0700 | [diff] [blame] | 140 | |
| 141 | if gtest_proj.found() |
| 142 | gtest = declare_dependency( |
| 143 | dependencies: [ |
| 144 | dependency('threads'), |
| 145 | gtest_proj.dependency('gtest'), |
| 146 | gtest_proj.dependency('gtest_main'), |
| 147 | ]) |
| 148 | gmock = gtest_proj.dependency('gmock') |
| 149 | endif |
| 150 | endif |
| 151 | endif |
| 152 | |
| 153 | |
| 154 | if not get_option('bmc-blob-handler').disabled() |
| 155 | subdir('bmc') |
| 156 | endif |
| 157 | |
| 158 | if not get_option('host-tool').disabled() |
| 159 | subdir('tools') |
| 160 | endif |
| 161 | |
| 162 | if not get_option('cleanup-delete').disabled() |
| 163 | subdir('cleanup') |
| 164 | endif |