From 198bca233a86182302bd6a29fb9f9fc68c60f94c Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 16 Dec 2015 18:27:32 +0000 Subject: [PATCH] Switch Makefile.vc to using batch-mode inference rules. 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 | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mkfiles.pl b/mkfiles.pl index 683f4b1d..66df0ae2 100755 --- a/mkfiles.pl +++ b/mkfiles.pl @@ -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".