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