mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-25 23:15: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
|
# Purpose
|
||||||
#
|
#
|
||||||
# Comments and uncomments #define lines in the given header file and optionally
|
# Comments and uncomments #define lines in the given header file and optionally
|
||||||
# sets their value. This is to provide scripting control of what preprocessor
|
# sets their value or can get the value. This is to provide scripting control of
|
||||||
# symbols, and therefore what build time configuration flags are set in the
|
# what preprocessor symbols, and therefore what build time configuration flags
|
||||||
# 'config.h' file.
|
# are set in the 'config.h' file.
|
||||||
#
|
#
|
||||||
# Usage: config.pl [-f <file> | --file <file>] [-o | --force]
|
# 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.
|
# Full usage description provided below.
|
||||||
#
|
#
|
||||||
@ -43,18 +44,23 @@ use strict;
|
|||||||
my $config_file = "include/mbedtls/config.h";
|
my $config_file = "include/mbedtls/config.h";
|
||||||
my $usage = <<EOU;
|
my $usage = <<EOU;
|
||||||
$0 [-f <file> | --file <file>] [-o | --force]
|
$0 [-f <file> | --file <file>] [-o | --force]
|
||||||
[set <symbol> <value> | unset <symbol> | full | realfull]
|
[set <symbol> <value> | unset <symbol> | get <symbol> |
|
||||||
|
full | realfull]
|
||||||
|
|
||||||
Commands
|
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
|
the configuration file, and optionally making it
|
||||||
of <value>.
|
of <value>.
|
||||||
If the symbol isn't present in the file an error
|
If the symbol isn't present in the file an error
|
||||||
is returned.
|
is returned.
|
||||||
unset <symbol> - Comments out any #define present in the
|
unset <symbol> - Comments out the #define for the given symbol if
|
||||||
configuration file.
|
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
|
full - Uncomments all #define's in the configuration file
|
||||||
excluding some reserved symbols, until the
|
excluding some reserved symbols, until the
|
||||||
'Module configuration options' section
|
'Module configuration options' section
|
||||||
realfull - Uncomments all #define's with no exclusions
|
realfull - Uncomments all #define's with no exclusions
|
||||||
|
|
||||||
@ -122,7 +128,7 @@ while ($arg = shift) {
|
|||||||
die $usage if @ARGV;
|
die $usage if @ARGV;
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ($action eq "unset") {
|
elsif ($action eq "unset" || $action eq "get") {
|
||||||
die $usage unless @ARGV;
|
die $usage unless @ARGV;
|
||||||
$name = shift;
|
$name = shift;
|
||||||
|
|
||||||
@ -195,6 +201,11 @@ for my $line (@config_lines) {
|
|||||||
$line .= "\n";
|
$line .= "\n";
|
||||||
$done = 1;
|
$done = 1;
|
||||||
}
|
}
|
||||||
|
} elsif (!$done && $action eq "get") {
|
||||||
|
if ($line =~ /^\s*#define\s*$name\s*(.*)\s*\b/) {
|
||||||
|
$value = $1;
|
||||||
|
$done = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print $config_write $line;
|
print $config_write $line;
|
||||||
@ -214,6 +225,15 @@ if ($action eq "set"&& $force_option && !$done) {
|
|||||||
|
|
||||||
close $config_write;
|
close $config_write;
|
||||||
|
|
||||||
|
if ($action eq "get" && $done) {
|
||||||
|
if ($value ne '') {
|
||||||
|
print $value;
|
||||||
|
}
|
||||||
|
exit 0;
|
||||||
|
} else {
|
||||||
|
exit -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ($action eq "full" && !$done) {
|
if ($action eq "full" && !$done) {
|
||||||
die "Configuration section was not found in $config_file\n";
|
die "Configuration section was not found in $config_file\n";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user