2013-09-16 11:33:42 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2013-09-20 13:11:44 +00:00
|
|
|
# create individual project files for example programs
|
|
|
|
# for VS6 and VS2010
|
2014-05-07 15:51:20 +00:00
|
|
|
#
|
|
|
|
# Must be run from PolarSSL root or scripts directory.
|
|
|
|
# Takes no argument.
|
2013-09-20 13:11:44 +00:00
|
|
|
|
2013-09-16 11:33:42 +00:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
2014-05-07 15:51:20 +00:00
|
|
|
my $vs6_dir = "visualc/VS6";
|
2013-09-16 11:33:42 +00:00
|
|
|
my $vs6_ext = "dsp";
|
2014-05-07 15:51:20 +00:00
|
|
|
my $vs6_app_tpl_file = "scripts/data_files/vs6-app-template.$vs6_ext";
|
2013-09-16 11:33:42 +00:00
|
|
|
|
2014-05-07 15:51:20 +00:00
|
|
|
my $vsx_dir = "visualc/VS2010";
|
2013-09-16 11:33:42 +00:00
|
|
|
my $vsx_ext = "vcxproj";
|
2014-05-07 15:51:20 +00:00
|
|
|
my $vsx_app_tpl_file = "scripts/data_files/vs2010-app-template.$vsx_ext";
|
|
|
|
|
|
|
|
my $programs_dir = 'programs';
|
2013-09-16 11:33:42 +00:00
|
|
|
|
|
|
|
exit( main() );
|
|
|
|
|
2014-05-07 15:51:20 +00:00
|
|
|
sub check_dirs {
|
|
|
|
return -d $vs6_dir
|
|
|
|
&& -d $vsx_dir
|
|
|
|
&& -d $programs_dir;
|
|
|
|
}
|
|
|
|
|
2013-09-16 11:33:42 +00:00
|
|
|
sub slurp_file {
|
|
|
|
my ($filename) = @_;
|
|
|
|
|
|
|
|
local $/ = undef;
|
|
|
|
open my $fh, '<', $filename or die "Could not read $filename\n";
|
|
|
|
my $content = <$fh>;
|
|
|
|
close $fh;
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub gen_app {
|
|
|
|
my ($path, $template, $dir, $ext) = @_;
|
|
|
|
|
|
|
|
$path =~ s!/!\\!g;
|
|
|
|
(my $appname = $path) =~ s/.*\\//;
|
|
|
|
|
|
|
|
my $content = $template;
|
|
|
|
$content =~ s/<PATHNAME>/$path/g;
|
|
|
|
$content =~ s/<APPNAME>/$appname/g;
|
|
|
|
|
|
|
|
open my $app_fh, '>', "$dir/$appname.$ext";
|
|
|
|
print $app_fh $content;
|
|
|
|
close $app_fh;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub get_app_list {
|
2014-05-07 15:51:20 +00:00
|
|
|
my $app_list = `cd $programs_dir && make list`;
|
2013-09-16 11:33:42 +00:00
|
|
|
die "make list failed: $!\n" if $?;
|
|
|
|
|
|
|
|
return split /\s+/, $app_list;
|
|
|
|
}
|
|
|
|
|
2014-05-07 15:51:20 +00:00
|
|
|
sub gen_app_files {
|
|
|
|
my $vs6_tpl = slurp_file( $vs6_app_tpl_file );
|
|
|
|
my $vsx_tpl = slurp_file( $vsx_app_tpl_file );
|
2013-09-16 11:33:42 +00:00
|
|
|
|
|
|
|
for my $app ( get_app_list() ) {
|
|
|
|
gen_app( $app, $vs6_tpl, $vs6_dir, $vs6_ext );
|
|
|
|
gen_app( $app, $vsx_tpl, $vsx_dir, $vsx_ext );
|
|
|
|
}
|
2014-05-07 15:51:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub main {
|
|
|
|
if( ! check_dirs() ) {
|
|
|
|
chdir '..' or die;
|
|
|
|
check_dirs or die "Must but run from PolarSSL root or scripts dir\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "Generating apps files: ";
|
|
|
|
gen_app_files();
|
|
|
|
print "done.\n";
|
2013-09-16 11:33:42 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|