Merge pull request #8175 from ronald-cron-arm/fix-query-config-generation-with-cmake

Fix query_config.c generation with CMake build system
This commit is contained in:
Ronald Cron 2023-09-12 06:03:01 +00:00 committed by GitHub
commit 9b9ac4c6ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View file

@ -45,11 +45,13 @@ if(GEN_FILES)
${PERL} ${PERL}
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl
${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h
${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt
${CMAKE_CURRENT_BINARY_DIR}/query_config.c ${CMAKE_CURRENT_BINARY_DIR}/query_config.c
DEPENDS DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl
${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h
${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt
) )
# this file will also be used in another directory, so create a target, see # this file will also be used in another directory, so create a target, see

View file

@ -7,15 +7,16 @@
# form (if any). This facilitates querying the compile time configuration of # form (if any). This facilitates querying the compile time configuration of
# the library, for example, for testing. # the library, for example, for testing.
# #
# The query_config.c is generated from the current configuration at # The query_config.c is generated from the default configuration files
# include/mbedtls/mbedtls_config.h. The idea is that the mbedtls_config.h contains ALL the # include/mbedtls/mbedtls_config.h and include/psa/crypto_config.h.
# The idea is that mbedtls_config.h and crypto_config.h contain ALL the
# compile time configurations available in Mbed TLS (commented or uncommented). # compile time configurations available in Mbed TLS (commented or uncommented).
# This script extracts the configuration macros from the mbedtls_config.h and this # This script extracts the configuration macros from the two files and this
# information is used to automatically generate the body of the query_config() # information is used to automatically generate the body of the query_config()
# function by using the template in scripts/data_files/query_config.fmt. # function by using the template in scripts/data_files/query_config.fmt.
# #
# Usage: scripts/generate_query_config.pl without arguments, or # Usage: scripts/generate_query_config.pl without arguments, or
# generate_query_config.pl mbedtls_config_file template_file output_file [psa_crypto_config_file] # generate_query_config.pl mbedtls_config_file psa_crypto_config_file template_file output_file
# #
# Copyright The Mbed TLS Contributors # Copyright The Mbed TLS Contributors
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
@ -34,29 +35,25 @@
use strict; use strict;
my ($mbedtls_config_file, $query_config_format_file, $query_config_file, $psa_crypto_config_file); my ($mbedtls_config_file, $psa_crypto_config_file, $query_config_format_file, $query_config_file);
my $default_mbedtls_config_file = "./include/mbedtls/mbedtls_config.h"; my $default_mbedtls_config_file = "./include/mbedtls/mbedtls_config.h";
my $default_psa_crypto_config_file = "./include/psa/crypto_config.h";
my $default_query_config_format_file = "./scripts/data_files/query_config.fmt"; my $default_query_config_format_file = "./scripts/data_files/query_config.fmt";
my $default_query_config_file = "./programs/test/query_config.c"; my $default_query_config_file = "./programs/test/query_config.c";
my $default_psa_crypto_config_file = "./include/psa/crypto_config.h";
if( @ARGV ) { if( @ARGV ) {
die "Invalid number of arguments - usage: $0 [CONFIG_FILE TEMPLATE_FILE OUTPUT_FILE]" if scalar @ARGV != 3; die "Invalid number of arguments - usage: $0 [MBED_TLS_CONFIG_FILE PSA_CRYPTO_CONFIG_FILE TEMPLATE_FILE OUTPUT_FILE]" if scalar @ARGV != 4;
($mbedtls_config_file, $query_config_format_file, $query_config_file) = @ARGV; ($mbedtls_config_file, $psa_crypto_config_file, $query_config_format_file, $query_config_file) = @ARGV;
-f $mbedtls_config_file or die "No such file: $mbedtls_config_file"; -f $mbedtls_config_file or die "No such file: $mbedtls_config_file";
-f $psa_crypto_config_file or die "No such file: $psa_crypto_config_file";
-f $query_config_format_file or die "No such file: $query_config_format_file"; -f $query_config_format_file or die "No such file: $query_config_format_file";
if (defined($psa_crypto_config_file) && length($psa_crypto_config_file)) {
-f $psa_crypto_config_file or die "No such file: $psa_crypto_config_file";
} else {
$psa_crypto_config_file = (-f $default_psa_crypto_config_file) ? $default_psa_crypto_config_file : undef;
}
} else { } else {
$mbedtls_config_file = $default_mbedtls_config_file; $mbedtls_config_file = $default_mbedtls_config_file;
$psa_crypto_config_file = $default_psa_crypto_config_file;
$query_config_format_file = $default_query_config_format_file; $query_config_format_file = $default_query_config_format_file;
$query_config_file = $default_query_config_file; $query_config_file = $default_query_config_file;
$psa_crypto_config_file = $default_psa_crypto_config_file;
unless(-f $mbedtls_config_file && -f $query_config_format_file && -f $psa_crypto_config_file) { unless(-f $mbedtls_config_file && -f $query_config_format_file && -f $psa_crypto_config_file) {
chdir '..' or die; chdir '..' or die;