chiark / gitweb /
Actually introduce the ability to build the Windows icons into the
authorSimon Tatham <anakin@pobox.com>
Wed, 27 Dec 2006 11:05:20 +0000 (11:05 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 27 Dec 2006 11:05:20 +0000 (11:05 +0000)
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]

28 files changed:
Recipe
blackbox.R
bridges.R
cube.R
dominosa.R
fifteen.R
flip.R
guess.R
icons/Makefile
inertia.R
lightup.R
loopy.R
map.R
mines.R
mkfiles.pl
net.R
netslide.R
pattern.R
pegs.R
rect.R
samegame.R
sixteen.R
slant.R
solo.R
tents.R
twiddle.R
untangle.R
windows.c

diff --git a/Recipe b/Recipe
index c946a8d5ab4992184b10ccbdf7ce2eca6a794617..42618eb4b707d1434315735c7dc2a5488d6231a9 100644 (file)
--- a/Recipe
+++ b/Recipe
@@ -13,6 +13,8 @@
 !makefile cygwin Makefile.cyg
 !makefile osx Makefile.osx
 
+!srcdir icons/
+
 WINDOWS  = windows printing
          + user32.lib gdi32.lib comctl32.lib comdlg32.lib winspool.lib
 COMMON   = midend drawing misc malloc random version
index 7ea69a64de397f6095639a67563b140b9df28246..884fe440ba63ded39324c5651d6cdb935fbf08af 100644 (file)
@@ -2,7 +2,7 @@
 
 blackbox : [X] GTK COMMON blackbox
 
-blackbox : [G] WINDOWS COMMON blackbox
+blackbox : [G] WINDOWS COMMON blackbox blackbox.res?
 
 ALL += blackbox
 
index 479819555f8d2b9b55f6649437c7bc5508a22591..f11fd4194d166fea2c83a6e1684d7329eab41563 100644 (file)
--- a/bridges.R
+++ b/bridges.R
@@ -4,7 +4,7 @@ BRIDGES  = bridges dsf
 
 bridges  : [X] GTK COMMON BRIDGES
 
-bridges  : [G] WINDOWS COMMON BRIDGES
+bridges  : [G] WINDOWS COMMON BRIDGES bridges.res?
 
 ALL += BRIDGES
 
diff --git a/cube.R b/cube.R
index 2c548a49ef6a745fea81d31648f2cf5cf5bcb41b..cc10fde33f112c4a4147d8ae9f76bc48e80f2e69 100644 (file)
--- a/cube.R
+++ b/cube.R
@@ -2,7 +2,7 @@
 
 cube     : [X] GTK COMMON cube
 
-cube     : [G] WINDOWS COMMON cube
+cube     : [G] WINDOWS COMMON cube cube.res?
 
 ALL += cube
 
index 30f35ff2c861be524f24af0a71a495cba7afbf08..3bc8e34c87ac7ae61efdc2cabe4d5b3495314042 100644 (file)
@@ -2,7 +2,7 @@
 
 dominosa : [X] GTK COMMON dominosa
 
-dominosa : [G] WINDOWS COMMON dominosa
+dominosa : [G] WINDOWS COMMON dominosa dominosa.res?
 
 ALL += dominosa
 
index 3fc0093851bbf1c82ad1647b3e00c8fe89a96949..fd371d71969eed9441af87097ec73331febb45e4 100644 (file)
--- a/fifteen.R
+++ b/fifteen.R
@@ -2,7 +2,7 @@
 
 fifteen  : [X] GTK COMMON fifteen
 
-fifteen  : [G] WINDOWS COMMON fifteen
+fifteen  : [G] WINDOWS COMMON fifteen fifteen.res?
 
 ALL += fifteen
 
diff --git a/flip.R b/flip.R
index 0570cb18e50abd66196f2adffe6d8d51b6230562..91764de2e005760dcbfc7b2e60421be75f85483a 100644 (file)
--- a/flip.R
+++ b/flip.R
@@ -4,7 +4,7 @@ FLIP     = flip tree234
 
 flip     : [X] GTK COMMON FLIP
 
-flip     : [G] WINDOWS COMMON FLIP
+flip     : [G] WINDOWS COMMON FLIP flip.res?
 
 ALL += FLIP
 
diff --git a/guess.R b/guess.R
index 3df2b43a28fd47c081feae31dd5f0733b4da3ce3..fa98337ea3004ccf65de750e42755aa01e03eeea 100644 (file)
--- a/guess.R
+++ b/guess.R
@@ -2,7 +2,7 @@
 
 guess    : [X] GTK COMMON guess
 
-guess    : [G] WINDOWS COMMON guess
+guess    : [G] WINDOWS COMMON guess guess.res?
 
 ALL += guess
 
index 934b792b5444ea9b1d674d1c5f145c14c2e0bd11..233f7679a1d865cf66eb10ffc645bb4b494f4561 100644 (file)
@@ -19,6 +19,7 @@ P16D24 = $(patsubst %,%-16d24.png,$(PUZZLES))
 P16D8 = $(patsubst %,%-16d8.png,$(PUZZLES))
 P16D4 = $(patsubst %,%-16d4.png,$(PUZZLES))
 ICONS = $(patsubst %,%.ico,$(PUZZLES))
+RC = $(patsubst %,%.rc,$(PUZZLES))
 
 BIN = ../
 PIC = ./
@@ -26,7 +27,7 @@ PIC = ./
 base: $(BASE)
 web: $(WEB)
 pngicons: $(P48D24) $(P32D24) $(P16D24)
-icons: $(ICONS)
+winicons: $(ICONS) $(RC)
 
 # Build the base puzzle screenshots from which all the other images
 # are derived. Some of them involve showing a move animation
@@ -108,12 +109,16 @@ $(P16D4): %-16d4.png: %-ibase.png
        convert -colors 16 -map $(PIC)win16pal.xpm tmp2.png $@
        rm -f tmp.png tmp2.png
 
-# And build the actual icons themselves, by feeding all those PNGs
-# to my icon builder script.
+# Build the actual Windows icons themselves, by feeding all those
+# PNGs to my icon builder script.
 $(ICONS): %.ico: %-48d24.png %-48d8.png %-48d4.png \
                  %-32d24.png %-32d8.png %-32d4.png \
                  %-16d24.png %-16d8.png %-16d4.png
        $(PIC)icon.pl $? > $@
 
+# Build the .RC files which bind the icons into the applications.
+$(RC): %.rc:
+       echo '200 ICON "$*.ico"' > $@
+
 clean:
-       rm -f *.png *.ico
+       rm -f *.png *.ico *.rc
index 6146bc914c785306a98ef49c958272b323e1ed4f..33e1841e0ca5c8f842bfe8c229d41bd1747f0b4c 100644 (file)
--- a/inertia.R
+++ b/inertia.R
@@ -2,7 +2,7 @@
 
 inertia  : [X] GTK COMMON inertia
 
-inertia  : [G] WINDOWS COMMON inertia
+inertia  : [G] WINDOWS COMMON inertia inertia.res?
 
 ALL += inertia
 
index 9c22e177ea1f877f0b5c8e7f64559df860b0b5b5..17a2c6cc4b5a75366d9bedf5e687ae063dab9411 100644 (file)
--- a/lightup.R
+++ b/lightup.R
@@ -4,7 +4,7 @@ LIGHTUP  = lightup combi
 
 lightup  : [X] GTK COMMON LIGHTUP
 
-lightup  : [G] WINDOWS COMMON LIGHTUP
+lightup  : [G] WINDOWS COMMON LIGHTUP lightup.res?
 
 lightupsolver : [U] lightup[STANDALONE_SOLVER] combi STANDALONE
 lightupsolver : [C] lightup[STANDALONE_SOLVER] combi STANDALONE
diff --git a/loopy.R b/loopy.R
index e390409a55d4c9a2a9c40d3c3f82d141fc88a2e0..37e64b66a54a84263f60e9312b83f6b763869940 100644 (file)
--- a/loopy.R
+++ b/loopy.R
@@ -4,7 +4,7 @@ LOOPY    = loopy tree234 dsf
 
 loopy    : [X] GTK COMMON LOOPY
 
-loopy    : [G] WINDOWS COMMON LOOPY
+loopy    : [G] WINDOWS COMMON LOOPY loopy.res?
 
 ALL += LOOPY
 
diff --git a/map.R b/map.R
index d6007384bac9c4b0f9e916ade21d7d39e6c1176a..7752ec2d1544754cc50d312a2ad32e934114bd75 100644 (file)
--- a/map.R
+++ b/map.R
@@ -4,7 +4,7 @@ MAP      = map dsf
 
 map      : [X] GTK COMMON MAP
 
-map      : [G] WINDOWS COMMON MAP
+map      : [G] WINDOWS COMMON MAP map.res?
 
 mapsolver :     [U] map[STANDALONE_SOLVER] dsf STANDALONE m.lib
 mapsolver :     [C] map[STANDALONE_SOLVER] dsf STANDALONE
diff --git a/mines.R b/mines.R
index 244b0bbfae97ff29204ecd952fe21e907bc57037..46913de62913ecb72365abf1d2ce0ee855092499 100644 (file)
--- a/mines.R
+++ b/mines.R
@@ -4,7 +4,7 @@ MINES    = mines tree234
 
 mines    : [X] GTK COMMON MINES
 
-mines    : [G] WINDOWS COMMON MINES
+mines    : [G] WINDOWS COMMON MINES mines.res?
 
 mineobfusc :    [U] mines[STANDALONE_OBFUSCATOR] tree234 STANDALONE
 mineobfusc :    [C] mines[STANDALONE_OBFUSCATOR] tree234 STANDALONE
index a107737d74548799c4b53f3a588311073bcc3756..c81d64d51f538c1a8abb305223755f5a7b65cc9e 100755 (executable)
@@ -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".
diff --git a/net.R b/net.R
index 945d7ff4d240ef9c85a234ce15200252020c0d5f..ec7c8a3484f8d5489009a4746662853570dcf92c 100644 (file)
--- a/net.R
+++ b/net.R
@@ -6,7 +6,7 @@ net      : [X] GTK COMMON NET
 
 # The Windows Net shouldn't be called `net.exe' since Windows
 # already has a reasonably important utility program by that name!
-netgame  : [G] WINDOWS COMMON NET
+netgame  : [G] WINDOWS COMMON NET net.res?
 
 ALL += NET
 
index a27eb95103e2bd39e035c4dd099fb36c059a4ff6..69e643dbcb8098db0314f10b69680fe241aa55ef 100644 (file)
@@ -4,7 +4,7 @@ NETSLIDE = netslide tree234
 
 netslide : [X] GTK COMMON NETSLIDE
 
-netslide : [G] WINDOWS COMMON NETSLIDE
+netslide : [G] WINDOWS COMMON NETSLIDE netslide.res?
 
 ALL += NETSLIDE
 
index 0645db588053902a0d933c99831473fc0ec7ba29..13dbfe2aad859e8d6987f60770489c7fffb5d98b 100644 (file)
--- a/pattern.R
+++ b/pattern.R
@@ -2,7 +2,7 @@
 
 pattern  : [X] GTK COMMON pattern
 
-pattern  : [G] WINDOWS COMMON pattern
+pattern  : [G] WINDOWS COMMON pattern pattern.res?
 
 patternsolver : [U] pattern[STANDALONE_SOLVER] STANDALONE
 patternsolver : [C] pattern[STANDALONE_SOLVER] STANDALONE
diff --git a/pegs.R b/pegs.R
index 0284f696a8e503e8f574f82c435e8dd29f5022ff..a1ab945c139a59708cd5523d9ec6d4351c9d6710 100644 (file)
--- a/pegs.R
+++ b/pegs.R
@@ -4,7 +4,7 @@ PEGS     = pegs tree234
 
 pegs     : [X] GTK COMMON PEGS
 
-pegs     : [G] WINDOWS COMMON PEGS
+pegs     : [G] WINDOWS COMMON PEGS pegs.res?
 
 ALL += PEGS
 
diff --git a/rect.R b/rect.R
index 498233da5d2770ff090390fea1f967d58d5b09be..20d3b49553dc1f52531ea53a8bfbc29989fc5b1d 100644 (file)
--- a/rect.R
+++ b/rect.R
@@ -2,7 +2,7 @@
 
 rect     : [X] GTK COMMON rect
 
-rect     : [G] WINDOWS COMMON rect
+rect     : [G] WINDOWS COMMON rect rect.res?
 
 ALL += rect
 
index c6a088b2253e5513892392364e5f525e4c2e97db..c3905bda3ef3c0b9cdc2a1a43788f5209097874a 100644 (file)
@@ -2,7 +2,7 @@
 
 samegame : [X] GTK COMMON samegame
 
-samegame : [G] WINDOWS COMMON samegame
+samegame : [G] WINDOWS COMMON samegame samegame.res?
 
 ALL += samegame
 
index dfddaea3493ae4c459ee85a4935b50bdf3fb9118..46147afd09746e295e37f1bdb97913537c7edcb4 100644 (file)
--- a/sixteen.R
+++ b/sixteen.R
@@ -2,7 +2,7 @@
 
 sixteen  : [X] GTK COMMON sixteen
 
-sixteen  : [G] WINDOWS COMMON sixteen
+sixteen  : [G] WINDOWS COMMON sixteen sixteen.res?
 
 ALL += sixteen
 
diff --git a/slant.R b/slant.R
index a1cc33f4e64728bf01ac2c69dadafc359e51eb48..b735ec47c33396436e1de58a8ebeb4c23668839f 100644 (file)
--- a/slant.R
+++ b/slant.R
@@ -4,7 +4,7 @@ SLANT    = slant dsf
 
 slant    : [X] GTK COMMON SLANT
 
-slant    : [G] WINDOWS COMMON SLANT
+slant    : [G] WINDOWS COMMON SLANT slant.res?
 
 slantsolver :   [U] slant[STANDALONE_SOLVER] dsf STANDALONE
 slantsolver :   [C] slant[STANDALONE_SOLVER] dsf STANDALONE
diff --git a/solo.R b/solo.R
index 8e6aa57f4e3e9676e629e3990b7f81c094297fc3..6fe4ea07abfa919f57b0e6d8cb776e8f655748aa 100644 (file)
--- a/solo.R
+++ b/solo.R
@@ -2,7 +2,7 @@
 
 solo     : [X] GTK COMMON solo
 
-solo     : [G] WINDOWS COMMON solo
+solo     : [G] WINDOWS COMMON solo solo.res?
 
 solosolver :    [U] solo[STANDALONE_SOLVER] STANDALONE
 solosolver :    [C] solo[STANDALONE_SOLVER] STANDALONE
diff --git a/tents.R b/tents.R
index 269dd7dd1b3210adca4871e9f1354d34a745657c..ab6066f4c11493c61993258f96228a4c637677ee 100644 (file)
--- a/tents.R
+++ b/tents.R
@@ -4,7 +4,7 @@ TENTS    = tents maxflow
 
 tents    : [X] GTK COMMON TENTS
 
-tents    : [G] WINDOWS COMMON TENTS
+tents    : [G] WINDOWS COMMON TENTS tents.res?
 
 ALL += TENTS
 
index a7b26b35cefaf72c896748d9b848de1f730734f1..c525953890234f0e9b252afed67dbda28edea9f5 100644 (file)
--- a/twiddle.R
+++ b/twiddle.R
@@ -2,7 +2,7 @@
 
 twiddle  : [X] GTK COMMON twiddle
 
-twiddle  : [G] WINDOWS COMMON twiddle
+twiddle  : [G] WINDOWS COMMON twiddle twiddle.res?
 
 ALL += twiddle
 
index fdbd6c45cdd9e91511dd4f48345199a8b57bd9c0..8c467d6f17d2b1c9c603b490140623fb1bc6e0f2 100644 (file)
@@ -4,7 +4,7 @@ UNTANGLE = untangle tree234
 
 untangle : [X] GTK COMMON UNTANGLE
 
-untangle : [G] WINDOWS COMMON UNTANGLE
+untangle : [G] WINDOWS COMMON UNTANGLE untangle.res?
 
 ALL += UNTANGLE
 
index ebaa1b690b54c5bb9f39bc0ccff29036e21aea03..d282d724f1b8695dcc684767366ffa8e317afda0 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -2441,7 +2441,9 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
        wndclass.cbClsExtra = 0;
        wndclass.cbWndExtra = 0;
        wndclass.hInstance = inst;
-       wndclass.hIcon = LoadIcon(inst, IDI_APPLICATION);
+       wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(200));
+       if (!wndclass.hIcon)           /* in case resource file is absent */
+           wndclass.hIcon = LoadIcon(inst, IDI_APPLICATION);
        wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
        wndclass.hbrBackground = NULL;
        wndclass.lpszMenuName = NULL;