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