[Nasm-commits] [nasm:nasm-2.15.xx] mkdep.pl: fix internalization/externalization

nasm-bot for H. Peter Anvin (Intel) hpa at zytor.com
Thu Jun 4 19:57:08 PDT 2020


Commit-ID:  dc1a6c5306d4a978206b25f9ffbc1827561facd3
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=dc1a6c5306d4a978206b25f9ffbc1827561facd3
Author:     H. Peter Anvin (Intel) <hpa at zytor.com>
AuthorDate: Thu, 4 Jun 2020 18:28:27 -0700
Committer:  H. Peter Anvin (Intel) <hpa at zytor.com>
CommitDate: Thu, 4 Jun 2020 18:30:27 -0700

mkdep.pl: fix internalization/externalization

At some point internalization/externalization of dependencies
apparently broke.

Signed-off-by: H. Peter Anvin (Intel) <hpa at zytor.com>


---
 tools/mkdep.pl | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/tools/mkdep.pl b/tools/mkdep.pl
index 1966660d..b60b1b05 100755
--- a/tools/mkdep.pl
+++ b/tools/mkdep.pl
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 ## --------------------------------------------------------------------------
 ##
-##   Copyright 1996-2017 The NASM Authors - All Rights Reserved
+##   Copyright 1996-2020 The NASM Authors - All Rights Reserved
 ##   See the file AUTHORS included with the NASM distribution for
 ##   the specific copyright holders.
 ##
@@ -109,6 +109,8 @@ sub alldeps($$) {
 sub convert_file($$) {
     my($file,$sep) = @_;
 
+    print STDERR "convert_file: $file\n";
+
     my @fspec = (basename($file));
     while ( ($file = dirname($file)) ne File::Spec->curdir() &&
 	    $file ne File::Spec->rootdir() ) {
@@ -140,16 +142,15 @@ sub _insert_deps($$) {
     my $cont = "\\";
     my $include_command = undef;
     my $selfrule = 0;
-    my $do_external = 0;
     my $maxline = 78;		# Seems like a reasonable default
     my %exclude = ();		# Don't exclude anything
     my @genhdrs = ();
     my $external = undef;
     my $raw_output = 0;
     my @outfile = ();
-    my $done = 0;
+    my $is_external = 0;
 
-    while ( defined($line = <$in>) && !$done ) {
+    while ( defined($line = <$in>) ) {
 	if ( $line =~ /^([^\s\#\$\:]+\.h):/ ) {
 	    # Note: we trust the first Makefile given best
 	    my $fpath = $1;
@@ -179,10 +180,11 @@ sub _insert_deps($$) {
 		$selfrule = !!$val;
 	    }
 	} elsif ( $line =~ /^(\s*\#?\s*EXTERNAL_DEPENDENCIES\s*=\s*)([01])\s*$/ ) {
+	    # If this line is not present, we cannot externalize
 	    $is_external = $externalize ? 1 : $force_inline ? 0 : $2+0;
 	    $line = $1.$is_external."\n";
 	} elsif ( $line eq $barrier ) {
-	    $done = 1;		# Stop reading input at barrier line
+	    last;		# Stop reading at barrier line
 	}
 
 	push @outfile, $line;
@@ -190,17 +192,20 @@ sub _insert_deps($$) {
     close($in);
 
     $is_external = $is_external && defined($external);
+    undef $external if ( !$is_external );
 
     if ( !$is_external || $externalize ) {
 	print $out @outfile;
-    } else {
-	print $out $barrier;	# Start generated file with barrier
     }
 
+    print $out $barrier;
+
     if ( $externalize ) {
-	if ( $is_external && defined($include_command) ) {
+	# Just strip internal file dependency information
+	if (defined($include_command)) {
 	    print $out "$include_command $external\n";
 	}
+	unlink($external);
 	return undef;
     }
 
@@ -210,6 +215,8 @@ sub _insert_deps($$) {
 	my $ofile;
 	my @deps;
 
+	next unless (defined($dfile));
+
 	if ( $selfrule && $dfile eq $external ) {
 	    $ofile = convert_file($dfile, $sep).':';
 	    @deps = sort(keys(%deps));


More information about the Nasm-commits mailing list