mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
Add option to do baremetal configuration.
This commit is contained in:
parent
7000e574b6
commit
0d44573e8b
@ -63,6 +63,7 @@ Commands
|
|||||||
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
|
||||||
|
baremetal - Set configuration suitable for baremetal build.
|
||||||
|
|
||||||
Options
|
Options
|
||||||
-f | --file <filename> - The file or file path for the configuration file
|
-f | --file <filename> - The file or file path for the configuration file
|
||||||
@ -94,11 +95,34 @@ MBEDTLS_PKCS11_C
|
|||||||
_ALT\s*$
|
_ALT\s*$
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Things that should be disabled in "baremetal"
|
||||||
|
my @excluded_baremetal = qw(
|
||||||
|
MBEDTLS_NET_C
|
||||||
|
MBEDTLS_TIMING_C
|
||||||
|
MBEDTLS_FS_IO
|
||||||
|
MBEDTLS_ENTROPY_NV_SEED
|
||||||
|
MBEDTLS_HAVE_TIME
|
||||||
|
MBEDTLS_HAVE_TIME_DATE
|
||||||
|
MBEDTLS_DEPRECATED_WARNING
|
||||||
|
MBEDTLS_HAVEGE_C
|
||||||
|
MBEDTLS_THREADING_C
|
||||||
|
MBEDTLS_THREADING_PTHREAD
|
||||||
|
MBEDTLS_MEMORY_BACKTRACE
|
||||||
|
MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||||
|
MBEDTLS_PLATFORM_TIME_ALT
|
||||||
|
MBEDTLS_PLATFORM_FPRINTF_ALT
|
||||||
|
);
|
||||||
|
|
||||||
# Things that should be enabled in "full" even if they match @excluded
|
# Things that should be enabled in "full" even if they match @excluded
|
||||||
my @non_excluded = qw(
|
my @non_excluded = qw(
|
||||||
PLATFORM_[A-Z0-9]+_ALT
|
PLATFORM_[A-Z0-9]+_ALT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Things that should be enabled in "baremetal"
|
||||||
|
my @non_excluded_baremetal = qw(
|
||||||
|
MBEDTLS_NO_PLATFORM_ENTROPY
|
||||||
|
);
|
||||||
|
|
||||||
# Process the command line arguments
|
# Process the command line arguments
|
||||||
|
|
||||||
my $force_option = 0;
|
my $force_option = 0;
|
||||||
@ -123,7 +147,7 @@ while ($arg = shift) {
|
|||||||
# ...else assume it's a command
|
# ...else assume it's a command
|
||||||
$action = $arg;
|
$action = $arg;
|
||||||
|
|
||||||
if ($action eq "full" || $action eq "realfull") {
|
if ($action eq "full" || $action eq "realfull" || $action eq "baremetal" ) {
|
||||||
# No additional parameters
|
# No additional parameters
|
||||||
die $usage if @ARGV;
|
die $usage if @ARGV;
|
||||||
|
|
||||||
@ -166,7 +190,12 @@ open my $config_read, '<', $config_file or die "read $config_file: $!\n";
|
|||||||
my @config_lines = <$config_read>;
|
my @config_lines = <$config_read>;
|
||||||
close $config_read;
|
close $config_read;
|
||||||
|
|
||||||
my ($exclude_re, $no_exclude_re);
|
# Add required baremetal symbols to the list that is included.
|
||||||
|
if ( $action eq "baremetal" ) {
|
||||||
|
@non_excluded = ( @non_excluded, @non_excluded_baremetal );
|
||||||
|
}
|
||||||
|
|
||||||
|
my ($exclude_re, $no_exclude_re, $exclude_baremetal_re);
|
||||||
if ($action eq "realfull") {
|
if ($action eq "realfull") {
|
||||||
$exclude_re = qr/^$/;
|
$exclude_re = qr/^$/;
|
||||||
$no_exclude_re = qr/./;
|
$no_exclude_re = qr/./;
|
||||||
@ -174,6 +203,9 @@ if ($action eq "realfull") {
|
|||||||
$exclude_re = join '|', @excluded;
|
$exclude_re = join '|', @excluded;
|
||||||
$no_exclude_re = join '|', @non_excluded;
|
$no_exclude_re = join '|', @non_excluded;
|
||||||
}
|
}
|
||||||
|
if ( $action eq "baremetal" ) {
|
||||||
|
$exclude_baremetal_re = join '|', @excluded_baremetal;
|
||||||
|
}
|
||||||
|
|
||||||
my $config_write = undef;
|
my $config_write = undef;
|
||||||
if ($action ne "get") {
|
if ($action ne "get") {
|
||||||
@ -182,17 +214,19 @@ if ($action ne "get") {
|
|||||||
|
|
||||||
my $done;
|
my $done;
|
||||||
for my $line (@config_lines) {
|
for my $line (@config_lines) {
|
||||||
if ($action eq "full" || $action eq "realfull") {
|
if ($action eq "full" || $action eq "realfull" || $action eq "baremetal" ) {
|
||||||
if ($line =~ /name SECTION: Module configuration options/) {
|
if ($line =~ /name SECTION: Module configuration options/) {
|
||||||
$done = 1;
|
$done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$done && $line =~ m!^//\s?#define! &&
|
if (!$done && $line =~ m!^//\s?#define! &&
|
||||||
( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) ) {
|
( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) &&
|
||||||
|
( $action ne "baremetal" || ( $line !~ /$exclude_baremetal_re/ ) ) ) {
|
||||||
$line =~ s!^//\s?!!;
|
$line =~ s!^//\s?!!;
|
||||||
}
|
}
|
||||||
if (!$done && $line =~ m!^\s?#define! &&
|
if (!$done && $line =~ m!^\s?#define! &&
|
||||||
! ( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) ) {
|
! ( ( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) &&
|
||||||
|
( $action ne "baremetal" || ( $line !~ /$exclude_baremetal_re/ ) ) ) ) {
|
||||||
$line =~ s!^!//!;
|
$line =~ s!^!//!;
|
||||||
}
|
}
|
||||||
} elsif ($action eq "unset") {
|
} elsif ($action eq "unset") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user