[Buildroot] [PATCH 1/3] support/kconfig: Support running merge_config.sh from a different directory

Charlie Jenkins charlie at rivosinc.com
Fri Apr 11 02:35:18 UTC 2025


Use the "-C" option to cd into a directory before merging, similar to
the "-C" option to make.

Signed-off-by: Charlie Jenkins <charlie at rivosinc.com>
---
 support/kconfig/merge_config.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/support/kconfig/merge_config.sh b/support/kconfig/merge_config.sh
index 14917806a391a386240b41f585baa68ca3bd99bc..daaa055b70dbe790578148255b490b6010815c30 100755
--- a/support/kconfig/merge_config.sh
+++ b/support/kconfig/merge_config.sh
@@ -34,6 +34,7 @@ usage() {
 	echo "  -r    list redundant entries when merging fragments"
 	echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
 	echo "  -e    colon-separated list of br2-external trees to use (optional)"
+	echo "  -C    change to directory before doing anything else"
 	echo
 	echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_
 	environment variable."
@@ -81,6 +82,11 @@ while true; do
 		shift 2
 		continue
 		;;
+	"-C")
+		BASE_DIRECTORY=$2
+		shift 2
+		continue
+		;;
 	*)
 		break
 		;;
@@ -92,6 +98,12 @@ if [ "$#" -lt 1 ] ; then
 	exit
 fi
 
+ORIGINAL_DIR=$PWD
+
+if [ ! -z "$BASE_DIRECTORY" ]; then
+	cd "$BASE_DIRECTORY" || exit
+fi
+
 if [ -z "$KCONFIG_CONFIG" ]; then
 	if [ "$OUTPUT" != . ]; then
 		KCONFIG_CONFIG=$(readlink -m -- "$OUTPUT/.config")
@@ -179,4 +191,8 @@ for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
 	fi
 done
 
+if [ -z "$BASE_DIRECTORY" ]; then
+	cd "$ORIGINAL_DIR" || clean_up
+fi
+
 clean_up

-- 
2.43.0



More information about the buildroot mailing list