updatemakes.sh now updates MS Visual C++ projects as well
This commit is contained in:
parent
421a241ccf
commit
58375b0287
86
helper.pl
86
helper.pl
@ -70,6 +70,76 @@ sub prepare_variable {
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub prepare_msvc_files_xml {
|
||||||
|
my ($all, $exclude_re, $targets) = @_;
|
||||||
|
my $last = [];
|
||||||
|
my $depth = 2;
|
||||||
|
my $files = "<Files>\r\n";
|
||||||
|
for my $full (@$all) {
|
||||||
|
my @items = split /\//, $full; # split by '/'
|
||||||
|
$full =~ s|/|\\|g; # replace '/' bt '\'
|
||||||
|
#XXXXXXXXXXXXX
|
||||||
|
shift @items;
|
||||||
|
pop @items; # drop last one
|
||||||
|
my $current = \@items;
|
||||||
|
if (join(':', @$current) ne join(':', @$last)) {
|
||||||
|
my $common = 0;
|
||||||
|
$common++ while ($last->[$common] && $current->[$common] && $last->[$common] eq $current->[$common]);
|
||||||
|
my $back = @$last - $common;
|
||||||
|
if ($back > 0) {
|
||||||
|
$files .= ("\t" x --$depth) . "</Filter>\r\n" for (1..$back);
|
||||||
|
}
|
||||||
|
my $fwd = [ @$current ]; splice(@$fwd, 0, $common);
|
||||||
|
for my $i (0..scalar(@$fwd) - 1) {
|
||||||
|
$files .= ("\t" x $depth) . "<Filter\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\tName=\"$fwd->[$i]\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t>\r\n";
|
||||||
|
$depth++;
|
||||||
|
}
|
||||||
|
$last = $current;
|
||||||
|
}
|
||||||
|
$files .= ("\t" x $depth) . "<File\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\tRelativePath=\"$full\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t>\r\n";
|
||||||
|
if ($full =~ $exclude_re) {
|
||||||
|
for (@$targets) {
|
||||||
|
$files .= ("\t" x $depth) . "\t<FileConfiguration\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\tName=\"$_\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\tExcludedFromBuild=\"true\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t>\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t<Tool\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t\tName=\"VCCLCompilerTool\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t\tAdditionalIncludeDirectories=\"\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t\tPreprocessorDefinitions=\"\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t/>\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t</FileConfiguration>\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($full eq 'src\ciphers\aes\aes.c') { #hack
|
||||||
|
my %cmd = (
|
||||||
|
'Debug|Win32' => [ 'Debug/aes.obj;Debug/aes_enc.obj', 'cl /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Debug/libtomcrypt.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c $(InputPath)
cl /nologo /DENCRYPT_ONLY /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Debug/libtomcrypt.pch" /YX /Fo"Debug/aes_enc.obj" /Fd"Debug/" /FD /GZ /c $(InputPath)
' ],
|
||||||
|
'Release|Win32' => [ 'Release/aes.obj;Release/aes_enc.obj', 'cl /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Release/libtomcrypt.pch" /YX /Fo"Release/" /Fd"Release/" /FD /GZ /c $(InputPath)
cl /nologo /DENCRYPT_ONLY /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Release/libtomcrypt.pch" /YX /Fo"Release/aes_enc.obj" /Fd"Release/" /FD /GZ /c $(InputPath)
' ],
|
||||||
|
);
|
||||||
|
for (@$targets) {
|
||||||
|
next unless $cmd{$_};
|
||||||
|
$files .= ("\t" x $depth) . "\t<FileConfiguration\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\tName=\"$_\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t>\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t<Tool\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t\tName=\"VCCustomBuildTool\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t\tCommandLine=\"$cmd{$_}[1]\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t\tOutputs=\"$cmd{$_}[0]\"\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t\t/>\r\n";
|
||||||
|
$files .= ("\t" x $depth) . "\t</FileConfiguration>\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$files .= ("\t" x $depth) . "</File>\r\n";
|
||||||
|
}
|
||||||
|
$files .= ("\t" x --$depth) . "</Filter>\r\n" for (@$last);
|
||||||
|
$files .= "\t</Files>";
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
sub patch_makefile {
|
sub patch_makefile {
|
||||||
my ($in_ref, $out_ref, $data) = @_;
|
my ($in_ref, $out_ref, $data) = @_;
|
||||||
open(my $src, '<', $in_ref);
|
open(my $src, '<', $in_ref);
|
||||||
@ -93,18 +163,32 @@ sub patch_makefile {
|
|||||||
|
|
||||||
sub process_makefiles {
|
sub process_makefiles {
|
||||||
my $write = shift;
|
my $write = shift;
|
||||||
|
my $changed_count = 0;
|
||||||
my @c = ();
|
my @c = ();
|
||||||
find({ no_chdir => 1, wanted => sub { push @c, $_ if -f $_ && $_ =~ /\.c$/ && $_ !~ /tab.c$/ } }, 'src');
|
find({ no_chdir => 1, wanted => sub { push @c, $_ if -f $_ && $_ =~ /\.c$/ && $_ !~ /tab.c$/ } }, 'src');
|
||||||
my @h = ();
|
my @h = ();
|
||||||
find({ no_chdir => 1, wanted => sub { push @h, $_ if -f $_ && $_ =~ /\.h$/ && $_ !~ /dh_static.h$/ } }, 'src');
|
find({ no_chdir => 1, wanted => sub { push @h, $_ if -f $_ && $_ =~ /\.h$/ && $_ !~ /dh_static.h$/ } }, 'src');
|
||||||
|
my @all = ();
|
||||||
|
find({ no_chdir => 1, wanted => sub { push @all, $_ if -f $_ && $_ =~ /\.(c|h)$/ } }, 'src');
|
||||||
|
|
||||||
my @o = sort ('src/ciphers/aes/aes_enc.o', map { $_ =~ s/\.c$/.o/; $_ } @c);
|
my @o = sort ('src/ciphers/aes/aes_enc.o', map { $_ =~ s/\.c$/.o/; $_ } @c);
|
||||||
my $var_o = prepare_variable("OBJECTS", @o);
|
my $var_o = prepare_variable("OBJECTS", @o);
|
||||||
(my $var_obj = $var_o) =~ s/\.o\b/.obj/sg;
|
(my $var_obj = $var_o) =~ s/\.o\b/.obj/sg;
|
||||||
my $var_h = prepare_variable("HEADERS", (sort @h, 'testprof/tomcrypt_test.h'));
|
my $var_h = prepare_variable("HEADERS", (sort @h, 'testprof/tomcrypt_test.h'));
|
||||||
|
|
||||||
|
my $msvc_files = prepare_msvc_files_xml(\@all, qr/tab\.c$/, ['Debug|Win32', 'Release|Win32']);
|
||||||
|
for my $m (qw/libtomcrypt_VS2008.vcproj libtomcrypt_VS2005.vcproj/) {
|
||||||
|
my $old = read_file($m);
|
||||||
|
my $new = $old;
|
||||||
|
$new =~ s|<Files>.*</Files>|$msvc_files|s;
|
||||||
|
if ($old ne $new) {
|
||||||
|
write_file($m, $new) if $write;
|
||||||
|
warn "changed: $m\n";
|
||||||
|
$changed_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my @makefiles = qw( makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc );
|
my @makefiles = qw( makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc );
|
||||||
my $changed_count = 0;
|
|
||||||
for my $m (@makefiles) {
|
for my $m (@makefiles) {
|
||||||
my $old = read_file($m);
|
my $old = read_file($m);
|
||||||
my $new;
|
my $new;
|
||||||
|
Loading…
Reference in New Issue
Block a user