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.)
This commit is contained in:
Simon Tatham 2015-12-16 18:27:32 +00:00
Родитель 7f95ebc0bf
Коммит 198bca233a
1 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@ -672,13 +672,27 @@ if (defined $makefiles{'vc'}) {
$extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : []; $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
print &splitline(sprintf("%s: %s", $d->{obj}, print &splitline(sprintf("%s: %s", $d->{obj},
join " ", @$extradeps, @{$d->{deps}})), "\n"; join " ", @$extradeps, @{$d->{deps}})), "\n";
if ($d->{obj} =~ /.obj$/) { if ($d->{obj} =~ /.res$/) {
print "\tcl \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c ".$d->{deps}->[0],"\n\n"; print "\trc /Fo@{[$d->{obj}]} \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
} else {
print "\trc \$(RCFL) -r \$(RCFLAGS) ".$d->{deps}->[0],"\n\n";
} }
} }
print "\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 &def($makefile_extra{'vc'}->{'end'});
print "\nclean: tidy\n". print "\nclean: tidy\n".
"\t-del *.exe\n\n". "\t-del *.exe\n\n".