[binutils-gdb] [gdb/build] Rename gdb/gdb-gdb.py.in to gdb/gdb-gdb.py

Tom de Vries via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <20260825120831.2CA064BA2E05__2481.01073536731$1787659750$gmane$org@sourceware.org>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=839a4fed68a58ca6cd8a8584cf8cfb337f587418

commit 839a4fed68a58ca6cd8a8584cf8cfb337f587418
Author: Tom de Vries <[email protected]>
Date:   Tue Aug 25 14:08:27 2026 +0200

    [gdb/build] Rename gdb/gdb-gdb.py.in to gdb/gdb-gdb.py
    
    Currently, $build/gdb/gdb-gdb.py is generated from $src/gdb/gdb-gdb.py.in, but
    there's no real need for it: they are identical.
    
    Fix this by:
    - renaming gdb/gdb-gdb.py.in to gdb/gdb-gdb.py
    - using AC_CONFIG_LINKS to get $build/gdb/gdb-gdb.py
    
    Because pre-commit type classification does not consider gdb/gdb-gdb.py.in a
    python file:
    ...
    $ identify-cli gdb/gdb-gdb.py.in
    ["file", "non-executable", "text"]
    ...
    .pre-commit-config.yaml has a types_or override to stop pre-commit from
    ignoring the file.  Unfortunately, that never worked for flake8, which needed
    a types override instead [1].
    
    Update .pre-commit-config.yaml to reflect the new situation:
    - drop the files match for gdb/gdb-gdb.py.in
    - drop the types_or override that's no longer necessary
    
    Tested on x86_64-linux, by doing a clean build and testing gdb.gdb/*.exp.
    
    Suggested-By: Simon Marchi <[email protected]> [1]
    
    [1] https://sourceware.org/pipermail/gdb-patches/2026-August/229394.html

Diff:
---
 .pre-commit-config.yaml                 | 9 +--------
 gdb/Makefile.in                         | 7 ++-----
 gdb/configure                           | 6 ++++--
 gdb/configure.ac                        | 3 ++-
 gdb/{gdb-gdb.py.in => gdb-gdb.py}       | 0
 gdb/testsuite/gdb.gdb/python-helper.exp | 8 +++++++-
 6 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 3cccec45ef7..bd392a57514 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -48,32 +48,25 @@ default_stages: [pre-commit]
 repos:
   # Python hooks.  Run these for (in glob notation):
   #
-  #  - gdb/gdb-gdb.py.in
   #  - gdb/*.py
   #  - gdb/python/**/*.py
   #  - gdb/testsuite/*.py
   #
-  # Because gdb/gdb-gdb.py.in is not classified as python, we use
-  # 'types_or: [file]' to override the default type for these hooks.
-  #
   - repo: https://github.com/psf/black-pre-commit-mirror
     rev: 26.5.1
     hooks:
       - id: black
-        types_or: &gdb_python_types [file]
-        files: &gdb_python_files '^gdb/.*\.py(\.in)?$'
+        files: &gdb_python_files '^gdb/.*\.py$'
   - repo: https://github.com/pycqa/flake8
     rev: 7.3.0
     hooks:
       - id: flake8
-        types_or: *gdb_python_types
         files: *gdb_python_files
         args: [--config, gdb/setup.cfg]
   - repo: https://github.com/pycqa/isort
     rev: 9.0.0b1
     hooks:
       - id: isort
-        types_or: *gdb_python_types
         files: *gdb_python_files
         # Isort's .pre-commit-hooks.yaml sets stages, overriding default_stages,
         # so this hook needs an explicit setting.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 0457ad7926d..c6bfc2949fc 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2088,7 +2088,7 @@ generated_files = \
 # Flags needed to compile Python code
 PYTHON_CFLAGS = @PYTHON_CFLAGS@
 
-all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb gcore gstack gdb-add-index
+all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.gdb gcore gstack gdb-add-index
 	@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=$(SUBDIRS)" subdir_do
 
 # Rule for compiling .c files in the top-level gdb directory.
@@ -2425,7 +2425,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
 distclean: clean
 	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(CLEANDIRS)" subdir_do
 	rm -f nm.h config.status config.h stamp-h b jit-reader.h gcore gstack gstack.in stamp-nmh
-	rm -f gdb-gdb.py gdb-gdb.gdb
+	rm -f gdb-gdb.gdb
 	rm -f y.output yacc.acts yacc.tmp y.tab.h
 	rm -f config.log config.cache
 	rm -f config.lt libtool
@@ -2490,9 +2490,6 @@ gstack gcore gdb-add-index: % : %.in version.c
 	sed -e "s,@VERSION@,$$vv," $< > $@
 	@chmod +x $@
 
-gdb-gdb.py: $(srcdir)/gdb-gdb.py.in config.status
-	$(ECHO_GEN) $(SHELL) config.status $(SILENT_FLAG) $@
-
 gdb-gdb.gdb: $(srcdir)/gdb-gdb.gdb.in config.status
 	$(ECHO_GEN) $(SHELL) config.status $(SILENT_FLAG) $@
 
diff --git a/gdb/configure b/gdb/configure
index 6107a9fe25a..7dc7781cb09 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -33716,7 +33716,9 @@ ac_config_files="$ac_config_files gstack.in:gstack-1.in"
 
 ac_config_files="$ac_config_files gdb-add-index.in:contrib/gdb-add-index.sh"
 
-ac_config_files="$ac_config_files Makefile gdb-gdb.gdb gdb-gdb.py doc/Makefile data-directory/Makefile"
+ac_config_files="$ac_config_files Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile"
+
+ac_config_links="$ac_config_links gdb-gdb.py:gdb-gdb.py"
 
 
 cat >confcache <<\_ACEOF
@@ -34816,9 +34818,9 @@ do
     "gdb-add-index.in") CONFIG_FILES="$CONFIG_FILES gdb-add-index.in:contrib/gdb-add-index.sh" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "gdb-gdb.gdb") CONFIG_FILES="$CONFIG_FILES gdb-gdb.gdb" ;;
-    "gdb-gdb.py") CONFIG_FILES="$CONFIG_FILES gdb-gdb.py" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
     "data-directory/Makefile") CONFIG_FILES="$CONFIG_FILES data-directory/Makefile" ;;
+    "gdb-gdb.py") CONFIG_LINKS="$CONFIG_LINKS gdb-gdb.py:gdb-gdb.py" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 4f870ba0bd8..c70aa30fc96 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2404,6 +2404,7 @@ GDB_AC_TRANSFORM([gcore], [GCORE_TRANSFORM_NAME])
 AC_CONFIG_FILES([gcore.in:gcore-1.in])
 AC_CONFIG_FILES([gstack.in:gstack-1.in])
 AC_CONFIG_FILES([gdb-add-index.in:contrib/gdb-add-index.sh])
-AC_CONFIG_FILES([Makefile gdb-gdb.gdb gdb-gdb.py doc/Makefile data-directory/Makefile])
+AC_CONFIG_FILES([Makefile gdb-gdb.gdb doc/Makefile data-directory/Makefile])
+AC_CONFIG_LINKS([gdb-gdb.py:gdb-gdb.py])
 
 AC_OUTPUT
diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py
similarity index 100%
rename from gdb/gdb-gdb.py.in
rename to gdb/gdb-gdb.py
diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
index d1cca48cbb8..d84e4816699 100644
--- a/gdb/testsuite/gdb.gdb/python-helper.exp
+++ b/gdb/testsuite/gdb.gdb/python-helper.exp
@@ -29,10 +29,16 @@ if { [build_executable "failed to build" $testfile $srcfile {debug c++}] } {
     return
 }
 
+proc file_or_link {f} {
+    set type [file type $f]
+    return [expr {[string eq $type "file"] \
+		      || [string eq $type "link"]}]
+}
+
 # Find the helper script in the GDB build directory.
 set py_helper_script [file dirname $GDB]/gdb-gdb.py
 if { ![file readable $py_helper_script] \
-	 || [file type $py_helper_script] != "file" } {
+	 || ![file_or_link $py_helper_script] } {
     untested "failed to find gdb-gdb.py helper script"
     return
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.