From 5b4557c6f29375cf48ec615aa7d5ecd496561c92 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 30 Nov 2025 09:25:48 +0100 Subject: [PATCH] startup.tcl: extend the file search among rename The renaming of boards and targets is often requiring the simple replacement of '_' with '-'. To avoid listing such replacements in 'tcl/file_renaming.cfg', add the automatic check in 'proc find' allowing till two replacements of '_' with '-'. Change-Id: I2623ea78d9c61d86189afcae2553c2910bda8389 Signed-off-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/9278 Reviewed-by: Marc Schink Reviewed-by: Nishanth Menon Tested-by: jenkins --- src/helper/startup.tcl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/helper/startup.tcl b/src/helper/startup.tcl index 89ed71b90..be01d71b3 100644 --- a/src/helper/startup.tcl +++ b/src/helper/startup.tcl @@ -31,23 +31,39 @@ proc find {filename} { # - path/to/a/certain/vendor_config_file # - path/to/a/certain/vendor-config_file - # replaced with + # replaced either with # - path/to/a/certain/vendor/config_file + # or + # - path/to/a/certain/vendor/config-file regsub {([/\\])([^/\\_-]*)[_-]([^/\\]*$)} $filename "\\1\\2\\1\\3" f if {[catch {_find_internal $f} t]==0} { echo "WARNING: '$filename' is deprecated, use '$f' instead" return $t } + regsub {([/\\])([^/\\_]*)_([^/\\]*$)} $f "\\1\\2-\\3" f + regsub {([/\\])([^/\\_]*)_([^/\\]*$)} $f "\\1\\2-\\3" f + if {[catch {_find_internal $f} t]==0} { + echo "WARNING: '$filename' is deprecated, use '$f' instead" + return $t + } foreach vendor {nordic ti sifive st} { # - path/to/a/certain/config_file - # replaced with + # replaced either with # - path/to/a/certain/${vendor}/config_file + # or + # - path/to/a/certain/${vendor}/config-file regsub {([/\\])([^/\\]*$)} $filename "\\1$vendor\\1\\2" f if {[catch {_find_internal $f} t]==0} { echo "WARNING: '$filename' is deprecated, use '$f' instead" return $t } + regsub {([/\\])([^/\\_]*)_([^/\\]*$)} $f "\\1\\2-\\3" f + regsub {([/\\])([^/\\_]*)_([^/\\]*$)} $f "\\1\\2-\\3" f + if {[catch {_find_internal $f} t]==0} { + echo "WARNING: '$filename' is deprecated, use '$f' instead" + return $t + } } # at last, check for explicit renaming