Skip to content

Commit

Permalink
win32/@makefiles: only update "Extensions_static" if needed
Browse files Browse the repository at this point in the history
Where needed is when: the file changes or any of the static
libraries are newer than Extensions_static

Previously it would always be updated, so perl5xx.dll would always
be rebuilt.

With gmake this prevents perl5xx.dll from being rebuilt.

For nmake it unfortunately doesn't, but may prevent updates in later
rebuilds.
  • Loading branch information
tonycoz committed Jul 20, 2023
1 parent e3d42be commit 3088838
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -6477,6 +6477,7 @@ win32/perlhost.h Perl "host" implementation
win32/perllib.c Win32 port
win32/pod.mak Win32 port
win32/runperl.c Win32 port
win32/set_depend_modtime.pl Win32: update target modtime to match deps
win32/vdir.h Perl "host" virtual directory manager for Win32
win32/vmem.h Perl "host" memory manager for Win32
win32/win32.c Win32 port
Expand Down
2 changes: 1 addition & 1 deletion win32/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ Exts_static_general : ..\make_ext.pl $(CONFIGPM) Extension_lib $(GLOBEXE) $(HAVE
$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static !Unicode/Normalize

Extensions_static : list_static_libs.pl Exts_static_general $(NORMALIZE_STATIC)
$(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static
$(MINIPERL) -I..\lib list_static_libs.pl -o Extensions_static

Extensions_nonxs : ..\make_ext.pl ..\pod\perlfunc.pod $(CONFIGPM) $(GLOBEXE)
$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(PLMAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --nonxs !libs
Expand Down
2 changes: 1 addition & 1 deletion win32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ Extensions_reonly: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM
Extensions_static : ..\make_ext.pl ..\lib\buildcustomize.pl list_static_libs.pl $(PERLDEP) $(CONFIGPM) Extensions_nonxs
$(XCOPY) ..\*.h $(COREDIR)\*.*
$(MINIPERL) -I..\lib ..\make_ext.pl "MAKE=$(MAKE)" --dir=$(CPANDIR) --dir=$(DISTDIR) --dir=$(EXTDIR) --static
$(MINIPERL) -I..\lib list_static_libs.pl > Extensions_static
$(MINIPERL) -I..\lib list_static_libs.pl -o Extensions_static

Extensions_nonxs: ..\make_ext.pl ..\lib\buildcustomize.pl $(PERLDEP) $(CONFIGPM) ..\pod\perlfunc.pod
$(XCOPY) ..\*.h $(COREDIR)\*.*
Expand Down
54 changes: 52 additions & 2 deletions win32/list_static_libs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

use Config;

my $out;
if (@ARGV > 1 && $ARGV[0] eq "-o") {
shift;
$out = shift;
}

my @statics = split /\s+/, $Config{static_ext};

my (@extralibs, %extralibs); # collect extralibs, preserving their order
Expand All @@ -13,5 +19,49 @@
open my $fh, '<', $file or die "can't open $file for reading: $!";
push @extralibs, grep {!$extralibs{$_}++} grep {/\S/} split /\s+/, join '', <$fh>;
}
print map {s|/|\\|g;m|([^\\]+)$|;"..\\lib\\auto\\$_\\$1$Config{_a} "} @statics;
print map {"$_ "} @extralibs;

my @libnames = join " ",
map {s|/|\\|g;m|([^\\]+)$|;"..\\lib\\auto\\$_\\$1$Config{_a}"} @statics,
@extralibs;
my $result = join " ", @libnames;

if ($out) {
my $do_update = 0;
# only write if:
# - output doesn't exist
# - there's a change in the content of the file
# - one of the generated static libs is newer than the file
my $out_mtime;
if (open my $fh, "<", $out) {
$out_mtime = (stat $fh)[9];
my $current = do { local $/; <$fh> };
if ($current ne $result) {
++$do_update;
}
close $fh;
}
else {
++$do_update;
}
if (!$do_update && $out_mtime) {
for my $lib (@libnames) {
if ((stat $lib)[9] > $out_mtime) {
++$do_update;
last;
}
}
}

unless ($do_update) {
print "$0: No changes, no libraries changed, nothing to do\n";
exit;
}

open my $fh, ">", $out
or die "Cannot create $out: $!";
print $fh $result;
close $fh or die "Failed to close $out: $!\n";
}
else {
print $result;
}

0 comments on commit 3088838

Please sign in to comment.