mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 15:55:37 +01:00
Adds 'get' command to scripts/config.pl to retrieve config state
Adds 'get' command to indicate if the option is enabled in the given configuration file, and to returns it's value if one has been set.
This commit is contained in:
parent
d96e526093
commit
4ae869139a
@ -7,12 +7,13 @@
|
||||
# Purpose
|
||||
#
|
||||
# Comments and uncomments #define lines in the given header file and optionally
|
||||
# sets their value. This is to provide scripting control of what preprocessor
|
||||
# symbols, and therefore what build time configuration flags are set in the
|
||||
# 'config.h' file.
|
||||
# sets their value or can get the value. This is to provide scripting control of
|
||||
# what preprocessor symbols, and therefore what build time configuration flags
|
||||
# are set in the 'config.h' file.
|
||||
#
|
||||
# Usage: config.pl [-f <file> | --file <file>] [-o | --force]
|
||||
# [set <symbol> <value> | unset <symbol> | full | realfull]
|
||||
# [set <symbol> <value> | unset <symbol> | get <symbol> |
|
||||
# full | realfull]
|
||||
#
|
||||
# Full usage description provided below.
|
||||
#
|
||||
@ -43,16 +44,21 @@ use strict;
|
||||
my $config_file = "include/mbedtls/config.h";
|
||||
my $usage = <<EOU;
|
||||
$0 [-f <file> | --file <file>] [-o | --force]
|
||||
[set <symbol> <value> | unset <symbol> | full | realfull]
|
||||
[set <symbol> <value> | unset <symbol> | get <symbol> |
|
||||
full | realfull]
|
||||
|
||||
Commands
|
||||
set <symbol> [<value] - Uncomments or adds a #define for the <symnol> to
|
||||
set <symbol> [<value>] - Uncomments or adds a #define for the <symbol> to
|
||||
the configuration file, and optionally making it
|
||||
of <value>.
|
||||
If the symbol isn't present in the file an error
|
||||
is returned.
|
||||
unset <symbol> - Comments out any #define present in the
|
||||
configuration file.
|
||||
unset <symbol> - Comments out the #define for the given symbol if
|
||||
present in the configuration file.
|
||||
get <symbol> - Finds the #define for the given symbol, returning
|
||||
an exitcode of 0 if the symbol is found, and -1 if
|
||||
not. The value of the symbol is output if one is
|
||||
specified in the configuration file.
|
||||
full - Uncomments all #define's in the configuration file
|
||||
excluding some reserved symbols, until the
|
||||
'Module configuration options' section
|
||||
@ -122,7 +128,7 @@ while ($arg = shift) {
|
||||
die $usage if @ARGV;
|
||||
|
||||
}
|
||||
elsif ($action eq "unset") {
|
||||
elsif ($action eq "unset" || $action eq "get") {
|
||||
die $usage unless @ARGV;
|
||||
$name = shift;
|
||||
|
||||
@ -195,6 +201,11 @@ for my $line (@config_lines) {
|
||||
$line .= "\n";
|
||||
$done = 1;
|
||||
}
|
||||
} elsif (!$done && $action eq "get") {
|
||||
if ($line =~ /^\s*#define\s*$name\s*(.*)\s*\b/) {
|
||||
$value = $1;
|
||||
$done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
print $config_write $line;
|
||||
@ -214,6 +225,15 @@ if ($action eq "set"&& $force_option && !$done) {
|
||||
|
||||
close $config_write;
|
||||
|
||||
if ($action eq "get" && $done) {
|
||||
if ($value ne '') {
|
||||
print $value;
|
||||
}
|
||||
exit 0;
|
||||
} else {
|
||||
exit -1;
|
||||
}
|
||||
|
||||
if ($action eq "full" && !$done) {
|
||||
die "Configuration section was not found in $config_file\n";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user