xref: /openbmc/bmcweb/config/meson.build (revision f4225d7e8d8679a73d89898d8782bbcfab23fa1b)
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']
54
55feature_options_string = '\n//Feature options\n'
56string_options_string = '\n// String options\n'
57int_options_string = '\n// Integer options\n'
58
59foreach option_key : feature_options + string_options + int_options
60    option_key_config = 'BMCWEB_' + option_key.to_upper()
61    option_key_config = option_key_config.replace('-', '_')
62
63    message(option_key_config)
64
65    opt = get_option(option_key)
66    if string_options.contains(option_key)
67        string_options_string += 'constexpr std::string_view  ' + option_key_config + ' = "' + opt + '";\n'
68    elif int_options.contains(option_key)
69        int_options_string += 'constexpr const int         ' + option_key_config + ' = ' + opt.to_string() + ';\n'
70    else
71        feature_options_string += 'constexpr const bool        ' + option_key_config + ' = ' + opt.allowed().to_string() + ';\n'
72        opt = opt.allowed().to_string()
73    endif
74    summary(option_key, opt, section: 'Features')
75endforeach
76
77# Logging level
78loglvlopt = get_option('bmcweb-logging')
79if get_option('buildtype').startswith('debug') and loglvlopt == 'disabled'
80    # Override logging level as 'debug' if 'bmcweb-logging' is set as 'disabled'
81    loglvlopt = 'debug'
82endif
83loglvlopt = loglvlopt.to_upper()
84string_options_string += 'constexpr std::string_view  BMCWEB_LOGGING_LEVEL' + ' = "' + loglvlopt + '";\n'
85
86# NBD proxy is disabled due to lack of maintenance.  See meson_options.txt
87feature_options_string += 'constexpr const bool        BMCWEB_VM_NBDPROXY = false;\n'
88
89conf_data.set(
90    'BMCWEB_OPTIONS',
91    string_options_string + int_options_string + feature_options_string,
92)
93
94conf_h_dep = declare_dependency(
95    include_directories: include_directories('.'),
96    sources: configure_file(
97        input: 'bmcweb_config.h.in',
98        output: 'bmcweb_config.h',
99        configuration: conf_data,
100    ),
101)
102
103# Configure and install systemd unit files
104https_port = get_option('https_port')
105if https_port > 0
106    configure_file(
107        input: 'bmcweb.socket.in',
108        output: 'bmcweb.socket',
109        install_dir: systemd_system_unit_dir,
110        install: true,
111        configuration: configuration_data(
112            {
113                'BMCWEB_PORT': https_port,
114                'HTTP_LEVEL_ALLOWED': 'https',
115                'HTTP_AUTH_LEVEL': 'auth',
116                'HTTP_BIND': '',
117            },
118        ),
119    )
120endif
121
122ports = get_option('additional-ports')
123binds = get_option('additional-bind-to-device')
124auths = get_option('additional-auth')
125foreach index : range(ports.length())
126    port_number = ports[index]
127    bind_to_device = '0.0.0.0'
128    auth = 'auth'
129    if index < binds.length()
130        bind_to_device = binds[index]
131    endif
132
133    if index < auths.length()
134        auth = auths[index]
135    endif
136
137    filename = 'bmcweb_' + port_number
138    configure_file(
139        input: 'bmcweb.socket.in',
140        output: filename,
141        install_dir: systemd_system_unit_dir,
142        install: true,
143        configuration: configuration_data(
144            {
145                'BMCWEB_HTTPS_PORT': port_number,
146                'HTTP_LEVEL_ALLOWED': 'https',
147                'HTTP_BIND': bind_to_device,
148                'HTTP_AUTH_LEVEL': auth,
149            },
150        ),
151    )
152endforeach
153
154configure_file(
155    input: 'bmcweb.service.in',
156    output: 'bmcweb.service',
157    install_dir: systemd_system_unit_dir,
158    install: true,
159    configuration: configuration_data(
160        {'MESON_INSTALL_PREFIX': get_option('prefix')},
161    ),
162)
163
164# Copy pam-webserver to etc/pam.d
165install_data('pam-webserver', install_dir: '/etc/pam.d/', rename: 'webserver')
166