blob: 83a1f4fb577718a6d53aed189b2599d76fa5d515 [file] [log] [blame]
Willy Tubcae9002021-09-12 13:58:04 -07001project(
2 'phosphor-ipmi-flash',
3 'cpp',
4 version: '0.1',
Patrick Williams4719ad02023-07-12 11:15:52 -05005 meson_version: '>=1.1.1',
Willy Tubcae9002021-09-12 13:58:04 -07006 default_options: [
Patrick Williams4719ad02023-07-12 11:15:52 -05007 'cpp_std=c++23',
Willy Tubcae9002021-09-12 13:58:04 -07008 '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'))
Tim Lee2d57d522023-09-18 11:47:53 +080031conf_data.set('NUVOTON_PCI_DID', get_option('nuvoton-pci-did'))
Willy Tubcae9002021-09-12 13:58:04 -070032
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',
Willy Tu7ace08a2021-10-31 17:10:30 -070098 'nuvoton-lpc' : '-DNUVOTON_LPC',
Willy Tubcae9002021-09-12 13:58:04 -070099}
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
Willy Tubcae9002021-09-12 13:58:04 -0700130blobs_dep = dependency('phosphor-ipmi-blobs')
Patrick Williamsdeb85ce2023-12-07 14:27:45 -0600131nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Brandon Kimea65e682022-07-13 23:21:33 +0000132
Willy Tubcae9002021-09-12 13:58:04 -0700133if 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 Tubcae9002021-09-12 13:58:04 -0700140
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
151endif
152
153
154if not get_option('bmc-blob-handler').disabled()
155 subdir('bmc')
156endif
157
158if not get_option('host-tool').disabled()
159 subdir('tools')
160endif
161
162if not get_option('cleanup-delete').disabled()
163 subdir('cleanup')
164endif