]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Update how we build bind.keys.h (both POSIX and Windows)
authorOndřej Surý <ondrej@isc.org>
Thu, 21 May 2020 09:50:56 +0000 (11:50 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 28 May 2020 06:07:57 +0000 (08:07 +0200)
The code in util/bindkeys.pl was overly complicated and it could not be
reused on Windows because redirecting stdin and stdout at the same time
from perl is overly complicated.

Now the util/bindkeys.pl accepts the input file as the first and only
argument and prints the header file to stdout.  This allows the same
utility to be used from automake and win32/Configure script.

Makefile.am
util/bindkeys.pl
win32utils/Configure

index 5cd00bd25f6bb47ad3403e152b8acb77e7612230..6ea8e8d4caafe0541db0d33d362fe14cd18a8c54 100644 (file)
@@ -6,7 +6,7 @@ BUILT_SOURCES = bind.keys.h
 CLEANFILES = bind.keys.h
 
 bind.keys.h: bind.keys Makefile
-       ${PERL} ${top_srcdir}/util/bindkeys.pl ${top_srcdir}/bind.keys > $@
+       ${PERL} ${top_srcdir}/util/bindkeys.pl ${top_srcdir}/bind.keys > $@
 
 dist_sysconf_DATA = bind.keys
 
index 55d6cb2cc9f65947771583f587647bb027194c7a..d2b8631974e4673e3bf38cb0db0003250ad1295a 100755 (executable)
 use strict;
 use warnings;
 
-my $lines;
-while (<>) {
+print "#pragma once\n";
+print "#define TRUST_ANCHORS \"\\\n";
+
+my $fn = shift or die "Usage: $0 FILENAME\n";
+open(my $fh, '<', $fn) or die "cannot open file $ARGV[1]\n";
+while (<$fh>) {
     chomp;
-    if (/\/\* .Id:.* \*\//) {
-       next;
-    }
     s/\"/\\\"/g;
-    s/$/\\n\\/;
-    $lines .= $_ . "\n";
+    print $_ . "\\n\\\n";
 }
-
-my $mkey = "#define TRUST_ANCHORS \\\n\t\"\\\n" . $lines . "\"\n";
-
-print "#ifndef BIND_KEYS_H\n";
-print "#define BIND_KEYS_H 1\n";
-print $mkey;
-print "#endif /* BIND_KEYS_H */\n";
+close($fh);
+print "\"\n";
index 2fb04b27119ee80258fe097c9e98c1a64737c892..68c6900f8d38698d1c43e358ca1de62d31e62ddf 100644 (file)
@@ -2405,6 +2405,18 @@ sub setupproject {
     close F;
 }
 
+# Make bind.keys.h
+# Keep this in sync with util/bindkeys.pl
+
+sub makebindkeysh {
+    my $bindkeysh = `perl.exe ..\\util\\bindkeys.pl ..\\bind.keys`;
+    die "Failed to generate bind.keys.h!\n" unless (length($bindkeysh));
+
+    open(my $fout, ">" . "..\\bind.keys.h") || die $!;
+    print $fout $bindkeysh;
+    close($fout);
+}
+
 # Build install files
 
 sub makeinstallfile {
@@ -2614,6 +2626,8 @@ if (($want_win32 eq "yes") || ($want_x64 eq "yes")) {
 
     makeinstallfile();
 
+    makebindkeysh();
+
     print "Configured.\n";
 } else {
     print "add win32 or x64 to commit configuration to build files\n";