Skip to content

Commit cfc08ee

Browse files
Add kconfig control commands
Add command to make it easier to modify kconfig files. Functions borrowed from our internal verification scripts. Signed-off-by: Anton Kolesov <[email protected]>
1 parent 11778a0 commit cfc08ee

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

arc-init.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,52 @@ build_expat() {
540540
make_target installing install
541541
}
542542

543+
# $1 - a configuration file or a directory with .config
544+
# $2 - option to enable
545+
kconfig_enable_option() {
546+
local config=$1
547+
if [ -d "$1" ]; then
548+
config=$1/.config
549+
fi
550+
551+
# Delete occurrences of option $2 from $config and append
552+
# "$2=y" to enable this option.
553+
if ! grep -q "$2=y" $config ; then
554+
# Config file must not be empty because sed does not work
555+
# correctly with empty files.
556+
echo >> $config
557+
558+
$SED -i \
559+
-e "/# $2 is not set/d" \
560+
-e "/$2=n/d" \
561+
-e "\$a$2=y" \
562+
$config
563+
fi
564+
}
565+
566+
# $1 - a configuration file or a directory with .config
567+
# $2 - option to disable
568+
kconfig_disable_option() {
569+
local config=$1
570+
if [ -d "$1" ]; then
571+
config=$1/.config
572+
fi
573+
574+
# Delete option $2 from $config and append "$2=n" to disable this
575+
# option by force.
576+
if ! grep -q "$2=n" $config ; then
577+
# Config file must not be empty because sed does not work
578+
# correctly with empty files.
579+
echo >> $config
580+
581+
$SED -i \
582+
-e "/# $2 is not set/d" \
583+
-e "/$2=y/d" \
584+
-e "\$a$2=n" \
585+
$config
586+
fi
587+
}
588+
543589
# Create a common log directory for all logs in this and sub-scripts
544590
LOGDIR="$ARC_GNU/logs"
545591
mkdir -p "$LOGDIR"

0 commit comments

Comments
 (0)