From d66f900ba27661c23cbf0a32b17ac346cc0189b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 9 May 2014 13:40:14 +0200 Subject: [PATCH] Simplify usage of generate scripts --- scripts/bump_version.sh | 4 ++-- scripts/generate_errors.pl | 27 ++++++++++++++++++++++++--- scripts/generate_features.pl | 23 ++++++++++++++++++++--- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index a160e11e0..5c2f268bd 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -85,10 +85,10 @@ do done [ $VERBOSE ] && echo "Re-generating library/error.c" -scripts/generate_errors.pl include/polarssl scripts/data_files library/error.c +scripts/generate_errors.pl [ $VERBOSE ] && echo "Re-generating library/version_features.c" -scripts/generate_features.pl include/polarssl scripts/data_files library/version_features.c +scripts/generate_features.pl [ $VERBOSE ] && echo "Re-generating visualc files" scripts/generate_visualc_files.pl diff --git a/scripts/generate_errors.pl b/scripts/generate_errors.pl index 1bea6e687..962e03262 100755 --- a/scripts/generate_errors.pl +++ b/scripts/generate_errors.pl @@ -1,11 +1,32 @@ #!/usr/bin/perl + +# Generate error.c # +# Usage: ./generate_errors.pl or scripts/generate_errors.pl without arguments, +# or generate_errors.pl include_dir data_dir error_file use strict; -my $include_dir = shift or die "Missing include directory"; -my $data_dir = shift or die "Missing data directory"; -my $error_file = shift or die "Missing destination file"; +my ($include_dir, $data_dir, $error_file); + +if( @ARGV ) { + die "Invalid number of arguments" if scalar @ARGV != 3; + ($include_dir, $data_dir, $error_file) = @ARGV; + + -d $include_dir or die "No such directory: $include_dir\n"; + -d $data_dir or die "No such directory: $data_dir\n"; +} else { + $include_dir = 'include/polarssl'; + $data_dir = 'scripts/data_files'; + $error_file = 'library/error.c'; + + unless( -d $include_dir && -d $data_dir ) { + chdir '..' or die; + -d $include_dir && -d $data_dir + or die "Without arguments, must be run from root or scripts\n" + } +} + my $error_format_file = $data_dir.'/error.fmt'; my @low_level_modules = ( "AES", "ASN1", "BLOWFISH", "CAMELLIA", "BIGNUM", diff --git a/scripts/generate_features.pl b/scripts/generate_features.pl index a72247da4..b6d04b4eb 100755 --- a/scripts/generate_features.pl +++ b/scripts/generate_features.pl @@ -3,9 +3,26 @@ use strict; -my $include_dir = shift or die "Missing include directory"; -my $data_dir = shift or die "Missing data directory"; -my $feature_file = shift or die "Missing destination file"; +my ($include_dir, $data_dir, $feature_file); + +if( @ARGV ) { + die "Invalid number of arguments" if scalar @ARGV != 3; + ($include_dir, $data_dir, $feature_file) = @ARGV; + + -d $include_dir or die "No such directory: $include_dir\n"; + -d $data_dir or die "No such directory: $data_dir\n"; +} else { + $include_dir = 'include/polarssl'; + $data_dir = 'scripts/data_files'; + $feature_file = 'library/version_features.c'; + + unless( -d $include_dir && -d $data_dir ) { + chdir '..' or die; + -d $include_dir && -d $data_dir + or die "Without arguments, must be run from root or scripts\n" + } +} + my $feature_format_file = $data_dir.'/version_features.fmt'; my @sections = ( "System support", "PolarSSL modules",