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",