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