]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Switch Makefile.vc to using batch-mode inference rules.
authorSimon Tatham <anakin@pobox.com>
Wed, 16 Dec 2015 18:27:32 +0000 (18:27 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 16 Dec 2015 18:49:07 +0000 (18:49 +0000)
This enables it to combine the compilation of multiple source files
into a single 'cl' command with multiple input file arguments, which
speeds up the build noticeably.

(I think nmake could be doing a lot more to improve this - for a
start, I haven't found any way to let it aggregate compilations of
source files in more than one directory, and also, it seems to me that
it really ought to be able to reduce down to just _one_ invocation of
cl by choosing the best topological sort of its build operations,
whereas in fact it looks as if it's sorting the operations _before_
doing the aggregation. But even so, it's a big improvement on the
previous build time.)

mkfiles.pl

index 683f4b1d1e69dcd087ad57d15f1f9f6d4e93bce7..66df0ae20aa100d8672784fb2d64ae0128efe34c 100755 (executable)
@@ -672,13 +672,27 @@ if (defined $makefiles{'vc'}) {
         $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
         print &splitline(sprintf("%s: %s", $d->{obj},
                                  join " ", @$extradeps, @{$d->{deps}})), "\n";
-        if ($d->{obj} =~ /.obj$/) {
-           print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n";
-       } else {
-           print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
+        if ($d->{obj} =~ /.res$/) {
+           print "\trc /Fo@{[$d->{obj}]} \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
        }
     }
     print "\n";
+    foreach $srcdir ("", @srcdirs) {
+        if ($srcdir ne "") {
+            $srcdir =~ s!/!\\!g;
+            $srcdir = $dirpfx . $srcdir;
+            $srcdir =~ s!\\\.\\!\\!;
+            $srcdir = "{$srcdir}"
+        }
+        # The double colon at the end of the line makes this a
+        # 'batch-mode inference rule', which means that nmake will
+        # aggregate multiple invocations of the rule and issue just
+        # one cl command with multiple source-file arguments. That
+        # noticeably speeds up builds, since starting up the cl
+        # process is a noticeable overhead and now has to be done far
+        # fewer times.
+        print "${srcdir}.c.obj::\n\tcl /Fo\$(BUILDDIR) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c \$<\n\n";
+    }
     print &def($makefile_extra{'vc'}->{'end'});
     print "\nclean: tidy\n".
       "\t-del *.exe\n\n".