]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3732] Migrate tools/print-generated-files.sh away from autotools
authorAndrei Pavel <andrei@isc.org>
Fri, 4 Apr 2025 08:08:18 +0000 (11:08 +0300)
committerAndrei Pavel <andrei@isc.org>
Fri, 25 Apr 2025 06:33:06 +0000 (09:33 +0300)
.gitlab-ci.yml
src/lib/dns/rdataclass.cc
tools/amend-gitattributes.sh [new file with mode: 0755]
tools/print-generated-files.sh

index 8d04fc1df9c3310af51546ed016ae0a990d33061..a5b0af3fc2c85c95c3db43e39ff308662b9c1716 100644 (file)
@@ -103,9 +103,9 @@ missing-git-attribute:
   script:
     - git_diff=$(git diff)
     - if test -n "${git_diff}"; then printf '%s\n\ngit diff should be empty here under all circumstances. CI broken?\n' "${git_diff}"; exit 1; fi
-    - ./tools/print-generated-files.sh -a
+    - ./tools/amend-gitattributes.sh
     - git_diff=$(git diff)
-    - if test -n "${git_diff}"; then printf '%s\n\n.gitattributes are missing a generated file. Please run "./tools/print-generated-files.sh -a" and commit the resulting change to fix them.\n' "${git_diff}"; exit 1; fi
+    - if test -n "${git_diff}"; then printf '%s\n\n.gitattributes are missing a generated file. Please run "./tools/amend-gitattributes.sh" and commit the resulting change to fix them.\n' "${git_diff}"; exit 1; fi
 
 shellcheck:
   stage: test
index b2d05f5ef37cdf2470f854b185387b223d457df7..1bf515cb0da166345a028689f29cfa4f05a46b94 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-2025 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -24,7 +24,6 @@
 #include <dns/txt_like.h>
 #include <util/buffer.h>
 #include <util/encode/encode.h>
-#include <util/buffer.h>
 
 #include <cerrno>
 #include <cstring>
diff --git a/tools/amend-gitattributes.sh b/tools/amend-gitattributes.sh
new file mode 100755 (executable)
index 0000000..d9552aa
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# Copyright (C) 2025 Internet Systems Consortium, Inc. ("ISC")
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Exit with error if commands exit with non-zero and if undefined variables are
+# used.
+set -eu
+
+root_path=$(cd "$(dirname "${0}")/.." && pwd)
+cd "${root_path}"
+
+# Write to .gitattributes.
+find . -type f -name '.gitattributes' -exec rm -f {} \;
+for i in $(./tools/print-generated-files.sh); do
+    # We need to be lenient because we call this script in premium too. Files might not exist.
+    if test ! -f "${i}"; then
+        continue
+    fi
+
+    # Align to 32 characters.
+    dir=$(dirname "${i}")
+    name="/$(basename "${i}")"
+    length=$(( 32 - ${#name} ))
+
+    printf "%s%${length}s -diff merge=ours\\n" "${name}" ' ' >> "${dir}/.gitattributes"
+done
index 9397094a0278034329a373b9a3e0179ab941f66e..6d89f2d49e6692bbe74e2a9d7a4390d3fb68bc6b 100755 (executable)
 #!/bin/sh
 
-# Copyright (C) 2020-2024 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2020-2025 Internet Systems Consortium, Inc. ("ISC")
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+# Get the list of generated files.
+
 # Usage:
 #
-# ./tools/print-generated-files.sh [-d|--debug] [-h|--help] [-a|--amend]
-#
-# Run from the root of the repository to get the list of generated files. They
-# may or may not be part of the repository. These consist of messages, parser
-# files and built sources (as called in Makefile.am files). While messages and
-# parser files are included with the source files, the built sources are only
-# created when building or some of them included in the Kea installation.
-
-# shellcheck disable=SC2013
-# SC2013: To read lines rather than words, pipe/redirect to a 'while read' loop.
-# reason: `while read` reads lines, we need to read words
-
-# shellcheck disable=SC2044
-# SC2044: For loops over find output are fragile. Use find -exec or a while read loop.
-# reason: I need to embed complicated logic inside the for, avoiding SC2044
-# makes us run into other problems.
+# ./tools/print-generated-files.sh
 
 # Exit with error if commands exit with non-zero and if undefined variables are
 # used.
 set -eu
 
-# Print usage.
-print_usage() {
-  printf \
-'Usage: %s {{options}}
-Options:
-  [-d|--debug]                 enable debug mode, showing every executed command
-  [-h|--help]                  print usage (this text)
-  [-a|--amend]                 amend .gitattributes
-' \
-    "$(basename "${0}")"
-}
-
-# Define some ANSI color codes.
-if test -t 1; then
-  red='\033[91m'
-  reset='\033[0m'
-else
-  red=
-  reset=
-fi
-
-# Parse parameters.
-while test ${#} -gt 0; do
-  case "${1}" in
-    # [-d|--debug]                 enable debug mode, showing every executed command
-    '-d'|'--debug') set -vx ;;
-
-    # [-h|--help]                  print usage (this text)
-    '-h'|'--help') print_usage; exit 0 ;;
-
-    # [-a|--amend]                 amend .gitattributes
-    '-a'|'--amend') amend=true ;;
-
-    # Unrecognized argument
-    *)
-    printf "${red}ERROR: Unrecognized argument '%s'${reset}\\n" "${1}" 1>&2; print_usage; exit 1 ;;
-  esac; shift
+# If run from premium, it lacks the premium prefix.
+for prefix in '' 'premium/'; do
+    for path in \
+        'src/hooks/dhcp/cb_cmds/cb_cmds_messages.cc' \
+        'src/hooks/dhcp/cb_cmds/cb_cmds_messages.h' \
+        'src/hooks/dhcp/rbac/rbac_messages.cc' \
+        'src/hooks/dhcp/rbac/rbac_messages.h' \
+    ; do
+        file="${prefix}${path}"
+        if test -f "${file}"; then
+            echo "${file}"
+        fi
+    done
 done
 
-# Default parameters
-test -z "${amend+x}" && amend=false
-
-# Change directory to root path.
-root_path=$(cd "$(dirname "${0}")/.." && pwd)
-cd "${root_path}"
-
-# Check if given commands are available and if not, then warn the user that they
-# need to be installed for the script to work and then exit with error code.
-mandatory_commands() {
-  while test ${#} -gt 0; do
-    if ! command -v "${1}" > /dev/null 2>&1; then
-      printf "${red}%s${reset} is mandatory.\\n" "${1}" >&2
-      exit 3
-    fi
-    shift
-  done
-}
-
-# Print the lines between two matching regex patterns from a file. Excludes the
-# lines that contain the patterns themselves. Matches only the first occurrence.
-print_lines_between_matching_patterns() {
-  mandatory_commands sed
-
-  local start_pattern="${1}"; shift
-  local end_pattern="${1}"; shift
-  local file="${1}"; shift
-
-  # Escape all slashes.
-  start_pattern=$(printf '%s' "${start_pattern}" | sed 's#\/#\\\/#g')
-  end_pattern=$(printf '%s' "${end_pattern}" | sed 's#\/#\\\/#g')
-
-  # Print with sed.
-  sed -n "/${start_pattern}/,/${end_pattern}/p;/${end_pattern}/q" "${file}" \
-    | sed '$d' | tail -n +2
-}
-
-# Print file name if a file with that name exists.
-print_file_name() {
-  local file_name="${1}"
-  if test -f "${file_name}"; then
-    printf '%s\n' "${file_name}" | cut -d '/' -f '2-'
-  fi
-}
-
-# Generated messages
-# shellcheck disable=SC1003
-# SC1003: Want to escape a single quote? echo 'This is how it'\''s done'
-# reason: No, we don't want to escape a single quote, we want a backslash.
-print_generated_messages() {
-  local makefile_am="${1}"; shift
-  local directory="${1}"; shift
-
-  for j in $(grep -F 'messages:' "${makefile_am}" | cut -d ':' -f '2-' | \
-    cut -d '\' -f 1); do
-    print_file_name "${directory}/${j}"
-  done
-
-  # Include message files that span multiple lines in the Makefile.am.
-  for j in $(print_lines_between_matching_patterns 'messages:' '@echo' "${makefile_am}" | \
-    cut -d ':' -f '2-' | cut -d '\' -f 1); do
-    print_file_name "${directory}/${j}"
-  done
-}
-
-# Generated parsers
-print_generated_parsers() {
-  local makefile_am="${1}"; shift
-  local directory="${1}"; shift
-
-  for j in $(grep -F 'parser:' "${makefile_am}" | cut -d ':' -f '2-'); do
-    print_file_name "${directory}/${j}"
-  done
-}
-
-# Other generated files
-print_built_sources() {
-  local makefile_am="${1}"; shift
-  local directory="${1}"; shift
-
-  for j in $(grep -E 'BUILT_SOURCES (=|\+=)' "${makefile_am}" | cut -d '=' -f '2-'); do
-    print_file_name "${directory}/${j}"
-  done
-}
-
-# Print all files of interest sorted alphabetically.
-print_all_sorted() {
-  local built_sources="${1-true}"
-
-  for i in $(find . -type f -name 'Makefile.am'); do
-    directory=$(dirname "${i}")
-    print_generated_messages "${i}" "${directory}"
-    print_generated_parsers "${i}" "${directory}"
-    if ${built_sources}; then
-      print_built_sources "${i}" "${directory}"
-    fi
-  done | sort -uV
-}
-
-mandatory_commands cut find grep sort
-
-if "${amend}"; then
-  # Write to .gitattributes.
-  find . -type f -name '.gitattributes' -exec rm -f {} \;
-  for i in $(print_all_sorted false); do
-    # Align to 32 characters.
-    name="/$(basename "${i}")"
-    length=$(( 32 - ${#name} ))
-
-    printf "%s%${length}s -diff merge=ours\\n" "${name}" ' ' >> \
-      "$(dirname "${i}")/.gitattributes"
-  done
-else
-  print_all_sorted
-fi
+printf "\
+src/bin/agent/agent_lexer.cc
+src/bin/agent/agent_parser.cc
+src/bin/agent/agent_parser.h
+src/bin/agent/ca_messages.cc
+src/bin/agent/ca_messages.h
+src/bin/agent/location.hh
+src/bin/d2/d2_lexer.cc
+src/bin/d2/d2_parser.cc
+src/bin/d2/d2_parser.h
+src/bin/d2/location.hh
+src/bin/dhcp4/dhcp4_lexer.cc
+src/bin/dhcp4/dhcp4_messages.cc
+src/bin/dhcp4/dhcp4_messages.h
+src/bin/dhcp4/dhcp4_parser.cc
+src/bin/dhcp4/dhcp4_parser.h
+src/bin/dhcp4/location.hh
+src/bin/dhcp6/dhcp6_lexer.cc
+src/bin/dhcp6/dhcp6_messages.cc
+src/bin/dhcp6/dhcp6_messages.h
+src/bin/dhcp6/dhcp6_parser.cc
+src/bin/dhcp6/dhcp6_parser.h
+src/bin/dhcp6/location.hh
+src/bin/lfc/lfc_messages.cc
+src/bin/lfc/lfc_messages.h
+src/bin/netconf/location.hh
+src/bin/netconf/netconf_lexer.cc
+src/bin/netconf/netconf_messages.cc
+src/bin/netconf/netconf_messages.h
+src/bin/netconf/netconf_parser.cc
+src/bin/netconf/netconf_parser.h
+src/hooks/d2/gss_tsig/gss_tsig_messages.cc
+src/hooks/d2/gss_tsig/gss_tsig_messages.h
+src/hooks/dhcp/bootp/bootp_messages.cc
+src/hooks/dhcp/bootp/bootp_messages.h
+src/hooks/dhcp/class_cmds/class_cmds_messages.cc
+src/hooks/dhcp/class_cmds/class_cmds_messages.h
+src/hooks/dhcp/ddns_tuning/ddns_tuning_messages.cc
+src/hooks/dhcp/ddns_tuning/ddns_tuning_messages.h
+src/hooks/dhcp/flex_id/flex_id_messages.cc
+src/hooks/dhcp/flex_id/flex_id_messages.h
+src/hooks/dhcp/flex_option/flex_option_messages.cc
+src/hooks/dhcp/flex_option/flex_option_messages.h
+src/hooks/dhcp/forensic_log/legal_log_messages.cc
+src/hooks/dhcp/forensic_log/legal_log_messages.h
+src/hooks/dhcp/high_availability/ha_messages.cc
+src/hooks/dhcp/high_availability/ha_messages.h
+src/hooks/dhcp/host_cache/host_cache_messages.cc
+src/hooks/dhcp/host_cache/host_cache_messages.h
+src/hooks/dhcp/host_cmds/host_cmds_messages.cc
+src/hooks/dhcp/host_cmds/host_cmds_messages.h
+src/hooks/dhcp/lease_cmds/lease_cmds_messages.cc
+src/hooks/dhcp/lease_cmds/lease_cmds_messages.h
+src/hooks/dhcp/lease_query/lease_query_messages.cc
+src/hooks/dhcp/lease_query/lease_query_messages.h
+src/hooks/dhcp/limits/limits_messages.cc
+src/hooks/dhcp/limits/limits_messages.h
+src/hooks/dhcp/mysql/mysql_cb_messages.cc
+src/hooks/dhcp/mysql/mysql_cb_messages.h
+src/hooks/dhcp/mysql/mysql_fb_messages.cc
+src/hooks/dhcp/mysql/mysql_fb_messages.h
+src/hooks/dhcp/mysql/mysql_hb_messages.cc
+src/hooks/dhcp/mysql/mysql_hb_messages.h
+src/hooks/dhcp/mysql/mysql_lb_messages.cc
+src/hooks/dhcp/mysql/mysql_lb_messages.h
+src/hooks/dhcp/perfmon/perfmon_messages.cc
+src/hooks/dhcp/perfmon/perfmon_messages.h
+src/hooks/dhcp/pgsql/pgsql_cb_messages.cc
+src/hooks/dhcp/pgsql/pgsql_cb_messages.h
+src/hooks/dhcp/pgsql/pgsql_fb_messages.cc
+src/hooks/dhcp/pgsql/pgsql_fb_messages.h
+src/hooks/dhcp/pgsql/pgsql_hb_messages.cc
+src/hooks/dhcp/pgsql/pgsql_hb_messages.h
+src/hooks/dhcp/pgsql/pgsql_lb_messages.cc
+src/hooks/dhcp/pgsql/pgsql_lb_messages.h
+src/hooks/dhcp/ping_check/ping_check_messages.cc
+src/hooks/dhcp/ping_check/ping_check_messages.h
+src/hooks/dhcp/radius/radius_messages.cc
+src/hooks/dhcp/radius/radius_messages.h
+src/hooks/dhcp/run_script/run_script_messages.cc
+src/hooks/dhcp/run_script/run_script_messages.h
+src/hooks/dhcp/stat_cmds/stat_cmds_messages.cc
+src/hooks/dhcp/stat_cmds/stat_cmds_messages.h
+src/hooks/dhcp/subnet_cmds/subnet_cmds_messages.cc
+src/hooks/dhcp/subnet_cmds/subnet_cmds_messages.h
+src/hooks/dhcp/user_chk/user_chk_messages.cc
+src/hooks/dhcp/user_chk/user_chk_messages.h
+src/lib/asiodns/asiodns_messages.cc
+src/lib/asiodns/asiodns_messages.h
+src/lib/config/config_messages.cc
+src/lib/config/config_messages.h
+src/lib/d2srv/d2_messages.cc
+src/lib/d2srv/d2_messages.h
+src/lib/database/db_messages.cc
+src/lib/database/db_messages.h
+src/lib/dhcpsrv/alloc_engine_messages.cc
+src/lib/dhcpsrv/alloc_engine_messages.h
+src/lib/dhcpsrv/dhcpsrv_messages.cc
+src/lib/dhcpsrv/dhcpsrv_messages.h
+src/lib/dhcpsrv/fuzz_messages.cc
+src/lib/dhcpsrv/fuzz_messages.h
+src/lib/dhcpsrv/hosts_messages.cc
+src/lib/dhcpsrv/hosts_messages.h
+src/lib/dhcp_ddns/dhcp_ddns_messages.cc
+src/lib/dhcp_ddns/dhcp_ddns_messages.h
+src/lib/eval/eval_messages.cc
+src/lib/eval/eval_messages.h
+src/lib/eval/lexer.cc
+src/lib/eval/location.hh
+src/lib/eval/parser.cc
+src/lib/eval/parser.h
+src/lib/hooks/hooks_messages.cc
+src/lib/hooks/hooks_messages.h
+src/lib/http/auth_messages.cc
+src/lib/http/auth_messages.h
+src/lib/http/http_messages.cc
+src/lib/http/http_messages.h
+src/lib/log/logimpl_messages.cc
+src/lib/log/logimpl_messages.h
+src/lib/log/log_messages.cc
+src/lib/log/log_messages.h
+src/lib/log/tests/log_test_messages.cc
+src/lib/log/tests/log_test_messages.h
+src/lib/process/process_messages.cc
+src/lib/process/process_messages.h
+src/lib/tcp/tcp_messages.cc
+src/lib/tcp/tcp_messages.h
+"