xref: /openbmc/bmcweb/config/meson.build (revision 433c9193b0d086f009d53a5860f1ee586cf45792)
1# Gather the Configuration data
2
3conf_data = configuration_data()
4
5feature_options = [
6    'basic-auth',
7    'cookie-auth',
8    'experimental-bmcweb-user',
9    'experimental-redfish-dbus-log-subscription',
10    'experimental-redfish-multi-computer-system',
11    'google-api',
12    'host-serial-socket',
13    'http-zstd',
14    'http2',
15    'hypervisor-computer-system',
16    'ibm-management-console',
17    'insecure-disable-auth',
18    'insecure-disable-csrf',
19    'insecure-disable-ssl',
20    'insecure-enable-redfish-query',
21    'insecure-ignore-content-type',
22    'insecure-push-style-notification',
23    'kvm',
24    'mutual-tls-auth',
25    'redfish',
26    'redfish-aggregation',
27    'redfish-allow-deprecated-indicatorled',
28    'redfish-allow-deprecated-power-thermal',
29    'redfish-allow-rotational-fans',
30    'redfish-allow-simple-update',
31    'redfish-bmc-journal',
32    'redfish-cpu-log',
33    'redfish-dbus-log',
34    'redfish-dump-log',
35    'redfish-host-logger',
36    'redfish-new-powersubsystem-thermalsubsystem',
37    'redfish-oem-manager-fan-data',
38    'redfish-provisioning-feature',
39    'redfish-updateservice-use-dbus',
40    'redfish-use-hardcoded-system-location-indicator',
41    'rest',
42    'session-auth',
43    'static-hosting',
44    'tests',
45    'vm-websocket',
46    'xtoken-auth',
47]
48
49string_options = [
50    'dns-resolver',
51    'mutual-tls-common-name-parsing-default',
52    'redfish-manager-uri-name',
53    'redfish-system-uri-name',
54    'redfish-fabric-uri-name',
55    'redfish-eventlog-location',
56]
57
58int_options = ['http-body-limit', 'watchdog-timeout-seconds']
59
60feature_options_string = '\n// Feature options\n'
61string_options_string = '\n// String options\n'
62int_options_string = '\n// Integer options\n'
63
64
65foreach feature_type, feature_list : {
66    'Feature': feature_options,
67    'Numeric': int_options,
68    'String': string_options,
69}
70    summary_dict = {}
71    foreach option_key : feature_list
72        option_key_config = 'BMCWEB_' + option_key.to_upper()
73        option_key_config = option_key_config.replace('-', '_')
74
75        opt = get_option(option_key)
76        if feature_type == 'Feature'
77            opt = opt.allowed()
78            feature_options_string += 'constexpr const bool @0@=@1@;\n'.format(
79                option_key_config,
80                opt.to_string(),
81            )
82        endif
83        if feature_type == 'Numeric'
84            int_options_string += 'constexpr const int @0@=@1@;\n'.format(
85                option_key_config,
86                opt.to_string(),
87            )
88        endif
89        if feature_type == 'String'
90            string_options_string += 'constexpr std::string_view @0@="@1@";\n'.format(
91                option_key_config,
92                opt,
93            )
94        endif
95        summary_dict += {option_key: opt}
96    endforeach
97    summary(summary_dict, section: feature_type + ' Options', bool_yn: true)
98endforeach
99
100# Logging level
101loglvlopt = get_option('bmcweb-logging')
102if get_option('buildtype').startswith('debug') and loglvlopt == 'disabled'
103    # Override logging level as 'debug' if 'bmcweb-logging' is set as 'disabled'
104    loglvlopt = 'debug'
105endif
106loglvlopt = loglvlopt.to_upper()
107string_options_string += 'constexpr std::string_view  BMCWEB_LOGGING_LEVEL' + ' = "' + loglvlopt + '";\n'
108
109# NBD proxy is disabled due to lack of maintenance.  See meson_options.txt
110feature_options_string += 'constexpr const bool BMCWEB_VM_NBDPROXY = false;\n'
111
112conf_data.set(
113    'BMCWEB_OPTIONS',
114    string_options_string + int_options_string + feature_options_string,
115)
116
117conf_h_dep = declare_dependency(
118    include_directories: include_directories('.'),
119    sources: configure_file(
120        input: 'bmcweb_config.h.in',
121        output: 'bmcweb_config.h',
122        configuration: conf_data,
123    ),
124)
125
126# Configure and install systemd unit files
127https_port = get_option('https_port')
128if https_port > 0
129    configure_file(
130        input: 'bmcweb.socket.in',
131        output: 'bmcweb.socket',
132        install_dir: systemd_system_unit_dir,
133        install: true,
134        configuration: configuration_data(
135            {
136                'BMCWEB_PORT': https_port,
137                'HTTP_LEVEL_ALLOWED': 'https',
138                'HTTP_AUTH_LEVEL': 'auth',
139                'HTTP_BIND': '',
140            },
141        ),
142    )
143endif
144
145ports = get_option('additional-ports')
146binds = get_option('additional-bind-to-device')
147auths = get_option('additional-auth')
148foreach index : range(ports.length())
149    port_number = ports[index]
150    bind_to_device = '0.0.0.0'
151    auth = 'auth'
152    if index < binds.length()
153        bind_to_device = binds[index]
154    endif
155
156    if index < auths.length()
157        auth = auths[index]
158    endif
159
160    filename = 'bmcweb_' + port_number + '.socket'
161    configure_file(
162        input: 'bmcweb.socket.in',
163        output: filename,
164        install_dir: systemd_system_unit_dir,
165        install: true,
166        configuration: configuration_data(
167            {
168                'BMCWEB_PORT': port_number,
169                'HTTP_LEVEL_ALLOWED': 'https',
170                'HTTP_BIND': bind_to_device,
171                'HTTP_AUTH_LEVEL': auth,
172            },
173        ),
174    )
175endforeach
176
177if get_option('experimental-bmcweb-user').allowed()
178    user = 'bmcweb'
179    group = 'bmcweb'
180    dynamic_user = 'yes'
181    state_directory = 'bmcweb'
182    work_dir = '-~'
183else
184    user = 'root'
185    group = 'root'
186    dynamic_user = 'no'
187    state_directory = '/home/root'
188    work_dir = '/home/root'
189endif
190
191configure_file(
192    input: 'bmcweb.service.in',
193    output: 'bmcweb.service',
194    install_dir: systemd_system_unit_dir,
195    install: true,
196    configuration: configuration_data(
197        {
198            'MESON_INSTALL_PREFIX': get_option('prefix'),
199            'BMCWEB_USER': user,
200            'BMCWEB_GROUP': group,
201            'BMCWEB_STATE_DIRECTORY': state_directory,
202            'BMCWEB_DYNAMICUSER': dynamic_user,
203            'BMCWEB_WORKING_DIRECTORY': work_dir,
204            'BMCWEB_WATCHDOG_TIMEOUT_SECONDS': get_option(
205                'watchdog-timeout-seconds',
206            ),
207        },
208    ),
209)
210
211# Copy pam-webserver to etc/pam.d
212install_data('pam-webserver', install_dir: '/etc/pam.d/', rename: 'webserver')
213