summaryrefslogtreecommitdiff
path: root/config/meson.build
blob: eb29cf631caa429d276b79141a82e0a518e889c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Gather the Configuration data

conf_data = configuration_data()

feature_options = [
    'basic-auth',
    'cookie-auth',
    'experimental-redfish-dbus-log-subscription',
    'experimental-redfish-multi-computer-system',
    'google-api',
    'host-serial-socket',
    'http-zstd',
    'http2',
    'hypervisor-computer-system',
    'ibm-management-console',
    'insecure-disable-auth',
    'insecure-disable-csrf',
    'insecure-disable-ssl',
    'insecure-enable-redfish-query',
    'insecure-ignore-content-type',
    'insecure-push-style-notification',
    'kvm',
    'mutual-tls-auth',
    'redfish',
    'redfish-aggregation',
    'redfish-allow-deprecated-indicatorled',
    'redfish-allow-deprecated-power-thermal',
    'redfish-allow-simple-update',
    'redfish-bmc-journal',
    'redfish-cpu-log',
    'redfish-dbus-log',
    'redfish-dump-log',
    'redfish-host-logger',
    'redfish-new-powersubsystem-thermalsubsystem',
    'redfish-oem-manager-fan-data',
    'redfish-provisioning-feature',
    'redfish-updateservice-use-dbus',
    'redfish-use-3-digit-messageid',
    'rest',
    'session-auth',
    'static-hosting',
    'tests',
    'vm-websocket',
    'xtoken-auth',
]

string_options = [
    'dns-resolver',
    'mutual-tls-common-name-parsing-default',
    'redfish-manager-uri-name',
    'redfish-system-uri-name',
]

int_options = ['http-body-limit', 'watchdog-timeout-seconds']

feature_options_string = '\n// Feature options\n'
string_options_string = '\n// String options\n'
int_options_string = '\n// Integer options\n'


foreach feature_type, feature_list : {
    'Feature': feature_options,
    'Numeric': int_options,
    'String': string_options,
}
    summary_dict = {}
    foreach option_key : feature_list
        option_key_config = 'BMCWEB_' + option_key.to_upper()
        option_key_config = option_key_config.replace('-', '_')

        opt = get_option(option_key)
        if feature_type == 'Feature'
            opt = opt.allowed()
            feature_options_string += 'constexpr const bool @0@=@1@;\n'.format(
                option_key_config,
                opt.to_string(),
            )
        endif
        if feature_type == 'Numeric'
            int_options_string += 'constexpr const int @0@=@1@;\n'.format(
                option_key_config,
                opt.to_string(),
            )
        endif
        if feature_type == 'String'
            string_options_string += 'constexpr std::string_view @0@="@1@";\n'.format(
                option_key_config,
                opt,
            )
        endif
        summary_dict += {option_key: opt}
    endforeach
    summary(summary_dict, section: feature_type + ' Options', bool_yn: true)
endforeach

# Logging level
loglvlopt = get_option('bmcweb-logging')
if get_option('buildtype').startswith('debug') and loglvlopt == 'disabled'
    # Override logging level as 'debug' if 'bmcweb-logging' is set as 'disabled'
    loglvlopt = 'debug'
endif
loglvlopt = loglvlopt.to_upper()
string_options_string += 'constexpr std::string_view  BMCWEB_LOGGING_LEVEL' + ' = "' + loglvlopt + '";\n'

# NBD proxy is disabled due to lack of maintenance.  See meson_options.txt
feature_options_string += 'constexpr const bool BMCWEB_VM_NBDPROXY = false;\n'

conf_data.set(
    'BMCWEB_OPTIONS',
    string_options_string + int_options_string + feature_options_string,
)

conf_h_dep = declare_dependency(
    include_directories: include_directories('.'),
    sources: configure_file(
        input: 'bmcweb_config.h.in',
        output: 'bmcweb_config.h',
        configuration: conf_data,
    ),
)

# Configure and install systemd unit files
https_port = get_option('https_port')
if https_port > 0
    configure_file(
        input: 'bmcweb.socket.in',
        output: 'bmcweb.socket',
        install_dir: systemd_system_unit_dir,
        install: true,
        configuration: configuration_data(
            {
                'BMCWEB_PORT': https_port,
                'HTTP_LEVEL_ALLOWED': 'https',
                'HTTP_AUTH_LEVEL': 'auth',
                'HTTP_BIND': '',
            },
        ),
    )
endif

ports = get_option('additional-ports')
binds = get_option('additional-bind-to-device')
auths = get_option('additional-auth')
foreach index : range(ports.length())
    port_number = ports[index]
    bind_to_device = '0.0.0.0'
    auth = 'auth'
    if index < binds.length()
        bind_to_device = binds[index]
    endif

    if index < auths.length()
        auth = auths[index]
    endif

    filename = 'bmcweb_' + port_number + '.socket'
    configure_file(
        input: 'bmcweb.socket.in',
        output: filename,
        install_dir: systemd_system_unit_dir,
        install: true,
        configuration: configuration_data(
            {
                'BMCWEB_PORT': port_number,
                'HTTP_LEVEL_ALLOWED': 'https',
                'HTTP_BIND': bind_to_device,
                'HTTP_AUTH_LEVEL': auth,
            },
        ),
    )
endforeach

configure_file(
    input: 'bmcweb.service.in',
    output: 'bmcweb.service',
    install_dir: systemd_system_unit_dir,
    install: true,
    configuration: configuration_data(
        {
            'MESON_INSTALL_PREFIX': get_option('prefix'),
            'BMCWEB_WATCHDOG_TIMEOUT_SECONDS': get_option(
                'watchdog-timeout-seconds',
            ),
        },
    ),
)

# Copy pam-webserver to etc/pam.d
install_data('pam-webserver', install_dir: '/etc/pam.d/', rename: 'webserver')