Actually introduce the ability to build the Windows icons into the

Windows puzzle binaries. This checkin involves several distinct
changes:
 - mkfiles.pl now has an extra feature: if an object file is listed
   in Recipe with a trailing question mark, it will be considered
   optional, and silently dropped from the makefile if its primary
   source file isn't present at the time mkfiles.pl runs. This means
   people who check out the puzzles from Subversion and just run
   mkfiles.pl shouldn't get build failures; they just won't get the
   icons.
 - all the .R files now use this feature to include an optional
   Windows resource file.
 - the .rc resource source files are built by icons/Makefile.
 - windows.c finds the icon if present and uses it in place of the
   standard Windows application icon.

[originally from svn r7020]
This commit is contained in:
Simon Tatham
2006-12-27 11:05:20 +00:00
parent d07eb2ea3a
commit be8076a6e6
28 changed files with 78 additions and 49 deletions

View File

@ -130,8 +130,17 @@ readinput: while (1) {
$i eq "[X]" or $i eq "[U]" or $i eq "[MX]") and defined $prog) {
$type = substr($i,1,(length $i)-2);
} else {
push @$listref, $i;
push @allobjs, $i;
if ($i =~ /\?$/) {
# Source files with a trailing question mark are optional:
# the build can proceed fine without them, so we only use
# them if they're present.
$i =~ s/\?$//;
$i = undef unless defined &finddep($i);
}
if (defined $i) {
push @$listref, $i;
push @allobjs, $i;
}
}
}
if ($prog and $type) {
@ -192,23 +201,8 @@ foreach $i (@prognames) {
$programs{$i} = [@list];
foreach $jj (@list) {
$j = $srcname{$jj};
# Dependencies for "x" start with "x.c" or "x.m" (depending on
# which one exists).
# Dependencies for "x.res" start with "x.rc".
# Dependencies for "x.rsrc" start with "x.r".
# Both types of file are pushed on the list of files to scan.
# Libraries (.lib) don't have dependencies at all.
if ($j =~ /^(.*)\.res$/) {
$file = "$1.rc";
$depends{$jj} = [$file];
push @scanlist, $file;
} elsif ($j =~ /^(.*)\.rsrc$/) {
$file = "$1.r";
$depends{$jj} = [$file];
push @scanlist, $file;
} elsif ($j !~ /\./) {
$file = "$j.c";
$file = "$j.m" unless &findfile($file);
$file = &finddep($j);
if (defined $file) {
$depends{$jj} = [$file];
push @scanlist, $file;
}
@ -315,6 +309,32 @@ sub findfile {
return $findfilecache{$name};
}
sub finddep {
my $j = shift @_;
my $file;
# Find the first dependency of an object.
# Dependencies for "x" start with "x.c" or "x.m" (depending on
# which one exists).
# Dependencies for "x.res" start with "x.rc".
# Dependencies for "x.rsrc" start with "x.r".
# Both types of file are pushed on the list of files to scan.
# Libraries (.lib) don't have dependencies at all.
if ($j =~ /^(.*)\.res$/) {
$file = "$1.rc";
} elsif ($j =~ /^(.*)\.rsrc$/) {
$file = "$1.r";
} elsif ($j !~ /\./) {
$file = "$j.c";
$file = "$j.m" unless &findfile($file);
} else {
# For everything else, we assume it's its own dependency.
$file = $j;
}
$file = undef unless &findfile($file);
return $file;
}
sub objects {
my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
my @ret;
@ -655,7 +675,7 @@ if (defined $makefiles{'vc'}) {
"\n";
if ($d->{obj} =~ /\.res$/) {
print "\trc \$(FWHACK) \$(RCFL) -r -DWIN32 -D_WIN32 ".
"-DWINVER=0x0400 ".$d->{deps}->[0]."\n";
"-DWINVER=0x0400 -fo".$d->{obj}." ".$d->{deps}->[0]."\n";
} else {
$deflist = join "", map { " /D$_" } @{$d->{defs}};
print "\tcl \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist".