Merge pull request #5303 from yuhaoth/pr/add_list_config_function

Add list config function
This commit is contained in:
paul-elliott-arm 2021-12-10 18:30:06 +00:00 committed by GitHub
commit f434994d83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 9 deletions

View file

@ -99,6 +99,10 @@
#define MACRO_NAME_TO_STR(macro) \
mbedtls_printf( "%s", strlen( #macro "" ) > 0 ? #macro "\n" : "" )
#define STRINGIFY(macro) #macro
#define OUTPUT_MACRO_NAME_VALUE(macro) mbedtls_printf( #macro "%s\n", \
( STRINGIFY(macro) "" )[0] != 0 ? "=" STRINGIFY(macro) : "" )
#if defined(_MSC_VER)
/*
* Visual Studio throws the warning 4003 because many Mbed TLS feature macros
@ -118,6 +122,10 @@ CHECK_CONFIG /* If the symbol is not found, return an error */
return( 1 );
}
void list_config( void )
{
LIST_CONFIG
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif /* _MSC_VER */

View file

@ -68,6 +68,7 @@ open(CONFIG_FILE, "$config_file") or die "Opening config file '$config_file': $!
# This variable will contain the string to replace in the CHECK_CONFIG of the
# format file
my $config_check = "";
my $list_config = "";
while (my $line = <CONFIG_FILE>) {
if ($line =~ /^(\/\/)?\s*#\s*define\s+(MBEDTLS_\w+).*/) {
@ -84,6 +85,11 @@ while (my $line = <CONFIG_FILE>) {
$config_check .= " }\n";
$config_check .= "#endif /* $name */\n";
$config_check .= "\n";
$list_config .= "#if defined($name)\n";
$list_config .= " OUTPUT_MACRO_NAME_VALUE($name);\n";
$list_config .= "#endif /* $name */\n";
$list_config .= "\n";
}
}
@ -95,6 +101,7 @@ close(FORMAT_FILE);
# Replace the body of the query_config() function with the code we just wrote
$query_config_format =~ s/CHECK_CONFIG/$config_check/g;
$query_config_format =~ s/LIST_CONFIG/$list_config/g;
# Rewrite the query_config.c file
open(QUERY_CONFIG_FILE, ">$query_config_file") or die "Opening destination file '$query_config_file': $!";