mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-22 09:57:41 +00:00
[#3732] Migrate tools/print-generated-files.sh away from autotools
This commit is contained in:
parent
3133dc2b58
commit
4a9fcdb2f5
@ -103,9 +103,9 @@ missing-git-attribute:
|
|||||||
script:
|
script:
|
||||||
- git_diff=$(git diff)
|
- 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
|
- 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)
|
- 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:
|
shellcheck:
|
||||||
stage: test
|
stage: test
|
||||||
|
@ -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
|
// 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
|
// 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 <dns/txt_like.h>
|
||||||
#include <util/buffer.h>
|
#include <util/buffer.h>
|
||||||
#include <util/encode/encode.h>
|
#include <util/encode/encode.h>
|
||||||
#include <util/buffer.h>
|
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
30
tools/amend-gitattributes.sh
Executable file
30
tools/amend-gitattributes.sh
Executable file
@ -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
|
@ -1,185 +1,161 @@
|
|||||||
#!/bin/sh
|
#!/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
|
# 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
|
# 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/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
# Get the list of generated files.
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
#
|
#
|
||||||
# ./tools/print-generated-files.sh [-d|--debug] [-h|--help] [-a|--amend]
|
# ./tools/print-generated-files.sh
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Exit with error if commands exit with non-zero and if undefined variables are
|
# Exit with error if commands exit with non-zero and if undefined variables are
|
||||||
# used.
|
# used.
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# Print usage.
|
# If run from premium, it lacks the premium prefix.
|
||||||
print_usage() {
|
for prefix in '' 'premium/'; do
|
||||||
printf \
|
for path in \
|
||||||
'Usage: %s {{options}}
|
'src/hooks/dhcp/cb_cmds/cb_cmds_messages.cc' \
|
||||||
Options:
|
'src/hooks/dhcp/cb_cmds/cb_cmds_messages.h' \
|
||||||
[-d|--debug] enable debug mode, showing every executed command
|
'src/hooks/dhcp/rbac/rbac_messages.cc' \
|
||||||
[-h|--help] print usage (this text)
|
'src/hooks/dhcp/rbac/rbac_messages.h' \
|
||||||
[-a|--amend] amend .gitattributes
|
; do
|
||||||
' \
|
file="${prefix}${path}"
|
||||||
"$(basename "${0}")"
|
if test -f "${file}"; then
|
||||||
}
|
echo "${file}"
|
||||||
|
fi
|
||||||
# Define some ANSI color codes.
|
done
|
||||||
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
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Default parameters
|
printf "\
|
||||||
test -z "${amend+x}" && amend=false
|
src/bin/agent/agent_lexer.cc
|
||||||
|
src/bin/agent/agent_parser.cc
|
||||||
# Change directory to root path.
|
src/bin/agent/agent_parser.h
|
||||||
root_path=$(cd "$(dirname "${0}")/.." && pwd)
|
src/bin/agent/ca_messages.cc
|
||||||
cd "${root_path}"
|
src/bin/agent/ca_messages.h
|
||||||
|
src/bin/agent/location.hh
|
||||||
# Check if given commands are available and if not, then warn the user that they
|
src/bin/d2/d2_lexer.cc
|
||||||
# need to be installed for the script to work and then exit with error code.
|
src/bin/d2/d2_parser.cc
|
||||||
mandatory_commands() {
|
src/bin/d2/d2_parser.h
|
||||||
while test ${#} -gt 0; do
|
src/bin/d2/location.hh
|
||||||
if ! command -v "${1}" > /dev/null 2>&1; then
|
src/bin/dhcp4/dhcp4_lexer.cc
|
||||||
printf "${red}%s${reset} is mandatory.\\n" "${1}" >&2
|
src/bin/dhcp4/dhcp4_messages.cc
|
||||||
exit 3
|
src/bin/dhcp4/dhcp4_messages.h
|
||||||
fi
|
src/bin/dhcp4/dhcp4_parser.cc
|
||||||
shift
|
src/bin/dhcp4/dhcp4_parser.h
|
||||||
done
|
src/bin/dhcp4/location.hh
|
||||||
}
|
src/bin/dhcp6/dhcp6_lexer.cc
|
||||||
|
src/bin/dhcp6/dhcp6_messages.cc
|
||||||
# Print the lines between two matching regex patterns from a file. Excludes the
|
src/bin/dhcp6/dhcp6_messages.h
|
||||||
# lines that contain the patterns themselves. Matches only the first occurrence.
|
src/bin/dhcp6/dhcp6_parser.cc
|
||||||
print_lines_between_matching_patterns() {
|
src/bin/dhcp6/dhcp6_parser.h
|
||||||
mandatory_commands sed
|
src/bin/dhcp6/location.hh
|
||||||
|
src/bin/lfc/lfc_messages.cc
|
||||||
local start_pattern="${1}"; shift
|
src/bin/lfc/lfc_messages.h
|
||||||
local end_pattern="${1}"; shift
|
src/bin/netconf/location.hh
|
||||||
local file="${1}"; shift
|
src/bin/netconf/netconf_lexer.cc
|
||||||
|
src/bin/netconf/netconf_messages.cc
|
||||||
# Escape all slashes.
|
src/bin/netconf/netconf_messages.h
|
||||||
start_pattern=$(printf '%s' "${start_pattern}" | sed 's#\/#\\\/#g')
|
src/bin/netconf/netconf_parser.cc
|
||||||
end_pattern=$(printf '%s' "${end_pattern}" | sed 's#\/#\\\/#g')
|
src/bin/netconf/netconf_parser.h
|
||||||
|
src/hooks/d2/gss_tsig/gss_tsig_messages.cc
|
||||||
# Print with sed.
|
src/hooks/d2/gss_tsig/gss_tsig_messages.h
|
||||||
sed -n "/${start_pattern}/,/${end_pattern}/p;/${end_pattern}/q" "${file}" \
|
src/hooks/dhcp/bootp/bootp_messages.cc
|
||||||
| sed '$d' | tail -n +2
|
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
|
||||||
# Print file name if a file with that name exists.
|
src/hooks/dhcp/ddns_tuning/ddns_tuning_messages.cc
|
||||||
print_file_name() {
|
src/hooks/dhcp/ddns_tuning/ddns_tuning_messages.h
|
||||||
local file_name="${1}"
|
src/hooks/dhcp/flex_id/flex_id_messages.cc
|
||||||
if test -f "${file_name}"; then
|
src/hooks/dhcp/flex_id/flex_id_messages.h
|
||||||
printf '%s\n' "${file_name}" | cut -d '/' -f '2-'
|
src/hooks/dhcp/flex_option/flex_option_messages.cc
|
||||||
fi
|
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
|
||||||
# Generated messages
|
src/hooks/dhcp/high_availability/ha_messages.cc
|
||||||
# shellcheck disable=SC1003
|
src/hooks/dhcp/high_availability/ha_messages.h
|
||||||
# SC1003: Want to escape a single quote? echo 'This is how it'\''s done'
|
src/hooks/dhcp/host_cache/host_cache_messages.cc
|
||||||
# reason: No, we don't want to escape a single quote, we want a backslash.
|
src/hooks/dhcp/host_cache/host_cache_messages.h
|
||||||
print_generated_messages() {
|
src/hooks/dhcp/host_cmds/host_cmds_messages.cc
|
||||||
local makefile_am="${1}"; shift
|
src/hooks/dhcp/host_cmds/host_cmds_messages.h
|
||||||
local directory="${1}"; shift
|
src/hooks/dhcp/lease_cmds/lease_cmds_messages.cc
|
||||||
|
src/hooks/dhcp/lease_cmds/lease_cmds_messages.h
|
||||||
for j in $(grep -F 'messages:' "${makefile_am}" | cut -d ':' -f '2-' | \
|
src/hooks/dhcp/lease_query/lease_query_messages.cc
|
||||||
cut -d '\' -f 1); do
|
src/hooks/dhcp/lease_query/lease_query_messages.h
|
||||||
print_file_name "${directory}/${j}"
|
src/hooks/dhcp/limits/limits_messages.cc
|
||||||
done
|
src/hooks/dhcp/limits/limits_messages.h
|
||||||
|
src/hooks/dhcp/mysql/mysql_cb_messages.cc
|
||||||
# Include message files that span multiple lines in the Makefile.am.
|
src/hooks/dhcp/mysql/mysql_cb_messages.h
|
||||||
for j in $(print_lines_between_matching_patterns 'messages:' '@echo' "${makefile_am}" | \
|
src/hooks/dhcp/mysql/mysql_fb_messages.cc
|
||||||
cut -d ':' -f '2-' | cut -d '\' -f 1); do
|
src/hooks/dhcp/mysql/mysql_fb_messages.h
|
||||||
print_file_name "${directory}/${j}"
|
src/hooks/dhcp/mysql/mysql_hb_messages.cc
|
||||||
done
|
src/hooks/dhcp/mysql/mysql_hb_messages.h
|
||||||
}
|
src/hooks/dhcp/mysql/mysql_lb_messages.cc
|
||||||
|
src/hooks/dhcp/mysql/mysql_lb_messages.h
|
||||||
# Generated parsers
|
src/hooks/dhcp/perfmon/perfmon_messages.cc
|
||||||
print_generated_parsers() {
|
src/hooks/dhcp/perfmon/perfmon_messages.h
|
||||||
local makefile_am="${1}"; shift
|
src/hooks/dhcp/pgsql/pgsql_cb_messages.cc
|
||||||
local directory="${1}"; shift
|
src/hooks/dhcp/pgsql/pgsql_cb_messages.h
|
||||||
|
src/hooks/dhcp/pgsql/pgsql_fb_messages.cc
|
||||||
for j in $(grep -F 'parser:' "${makefile_am}" | cut -d ':' -f '2-'); do
|
src/hooks/dhcp/pgsql/pgsql_fb_messages.h
|
||||||
print_file_name "${directory}/${j}"
|
src/hooks/dhcp/pgsql/pgsql_hb_messages.cc
|
||||||
done
|
src/hooks/dhcp/pgsql/pgsql_hb_messages.h
|
||||||
}
|
src/hooks/dhcp/pgsql/pgsql_lb_messages.cc
|
||||||
|
src/hooks/dhcp/pgsql/pgsql_lb_messages.h
|
||||||
# Other generated files
|
src/hooks/dhcp/ping_check/ping_check_messages.cc
|
||||||
print_built_sources() {
|
src/hooks/dhcp/ping_check/ping_check_messages.h
|
||||||
local makefile_am="${1}"; shift
|
src/hooks/dhcp/radius/radius_messages.cc
|
||||||
local directory="${1}"; shift
|
src/hooks/dhcp/radius/radius_messages.h
|
||||||
|
src/hooks/dhcp/run_script/run_script_messages.cc
|
||||||
for j in $(grep -E 'BUILT_SOURCES (=|\+=)' "${makefile_am}" | cut -d '=' -f '2-'); do
|
src/hooks/dhcp/run_script/run_script_messages.h
|
||||||
print_file_name "${directory}/${j}"
|
src/hooks/dhcp/stat_cmds/stat_cmds_messages.cc
|
||||||
done
|
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
|
||||||
# Print all files of interest sorted alphabetically.
|
src/hooks/dhcp/user_chk/user_chk_messages.cc
|
||||||
print_all_sorted() {
|
src/hooks/dhcp/user_chk/user_chk_messages.h
|
||||||
local built_sources="${1-true}"
|
src/lib/asiodns/asiodns_messages.cc
|
||||||
|
src/lib/asiodns/asiodns_messages.h
|
||||||
for i in $(find . -type f -name 'Makefile.am'); do
|
src/lib/config/config_messages.cc
|
||||||
directory=$(dirname "${i}")
|
src/lib/config/config_messages.h
|
||||||
print_generated_messages "${i}" "${directory}"
|
src/lib/d2srv/d2_messages.cc
|
||||||
print_generated_parsers "${i}" "${directory}"
|
src/lib/d2srv/d2_messages.h
|
||||||
if ${built_sources}; then
|
src/lib/database/db_messages.cc
|
||||||
print_built_sources "${i}" "${directory}"
|
src/lib/database/db_messages.h
|
||||||
fi
|
src/lib/dhcpsrv/alloc_engine_messages.cc
|
||||||
done | sort -uV
|
src/lib/dhcpsrv/alloc_engine_messages.h
|
||||||
}
|
src/lib/dhcpsrv/dhcpsrv_messages.cc
|
||||||
|
src/lib/dhcpsrv/dhcpsrv_messages.h
|
||||||
mandatory_commands cut find grep sort
|
src/lib/dhcpsrv/fuzz_messages.cc
|
||||||
|
src/lib/dhcpsrv/fuzz_messages.h
|
||||||
if "${amend}"; then
|
src/lib/dhcpsrv/hosts_messages.cc
|
||||||
# Write to .gitattributes.
|
src/lib/dhcpsrv/hosts_messages.h
|
||||||
find . -type f -name '.gitattributes' -exec rm -f {} \;
|
src/lib/dhcp_ddns/dhcp_ddns_messages.cc
|
||||||
for i in $(print_all_sorted false); do
|
src/lib/dhcp_ddns/dhcp_ddns_messages.h
|
||||||
# Align to 32 characters.
|
src/lib/eval/eval_messages.cc
|
||||||
name="/$(basename "${i}")"
|
src/lib/eval/eval_messages.h
|
||||||
length=$(( 32 - ${#name} ))
|
src/lib/eval/lexer.cc
|
||||||
|
src/lib/eval/location.hh
|
||||||
printf "%s%${length}s -diff merge=ours\\n" "${name}" ' ' >> \
|
src/lib/eval/parser.cc
|
||||||
"$(dirname "${i}")/.gitattributes"
|
src/lib/eval/parser.h
|
||||||
done
|
src/lib/hooks/hooks_messages.cc
|
||||||
else
|
src/lib/hooks/hooks_messages.h
|
||||||
print_all_sorted
|
src/lib/http/auth_messages.cc
|
||||||
fi
|
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
|
||||||
|
"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user