Skip to content

Commit a9b7228

Browse files
roxellmasahir0y
authored andcommitted
scripts/kconfig/merge_config: don't redefine 'y' to 'm'
In today's merge_config.sh the order of the config fragment files dictates the output of a config option. With this approach we will get different .config files depending on the order of the config fragment files. So doing something like: $ ./merge/kconfig/merge_config.sh selftest.config drm.config Where selftest.config defines DRM=y and drm.config defines DRM=m, the result will be "DRM=m". Rework to add a switch to get builtin '=y' precedence over modules '=m', this will result in "DRM=y". If we do something like this: $ ./merge/kconfig/merge_config.sh -y selftest.config drm.config Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent ccda4af commit a9b7228

1 file changed

Lines changed: 29 additions & 8 deletions

File tree

‎scripts/kconfig/merge_config.sh‎

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
clean_up() {
2424
rm -f $TMP_FILE
25+
rm -f $MERGE_FILE
2526
exit
2627
}
2728
trap clean_up HUP INT TERM
@@ -32,6 +33,7 @@ usage() {
3233
echo " -m only merge the fragments, do not execute the make command"
3334
echo " -n use allnoconfig instead of alldefconfig"
3435
echo " -r list redundant entries when merging fragments"
36+
echo " -y make builtin have precedence over modules"
3537
echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead."
3638
echo
3739
echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
@@ -40,6 +42,7 @@ usage() {
4042
RUNMAKE=true
4143
ALLTARGET=alldefconfig
4244
WARNREDUN=false
45+
BUILTIN=false
4346
OUTPUT=.
4447
CONFIG_PREFIX=${CONFIG_-CONFIG_}
4548

@@ -64,6 +67,11 @@ while true; do
6467
shift
6568
continue
6669
;;
70+
"-y")
71+
BUILTIN=true
72+
shift
73+
continue
74+
;;
6775
"-O")
6876
if [ -d $2 ];then
6977
OUTPUT=$(echo $2 | sed 's/\/*$//')
@@ -106,32 +114,45 @@ SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
106114
SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
107115

108116
TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
117+
MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX)
109118

110119
echo "Using $INITFILE as base"
111120
cat $INITFILE > $TMP_FILE
112121

113122
# Merge files, printing warnings on overridden values
114-
for MERGE_FILE in $MERGE_LIST ; do
115-
echo "Merging $MERGE_FILE"
116-
if [ ! -r "$MERGE_FILE" ]; then
117-
echo "The merge file '$MERGE_FILE' does not exist. Exit." >&2
123+
for ORIG_MERGE_FILE in $MERGE_LIST ; do
124+
echo "Merging $ORIG_MERGE_FILE"
125+
if [ ! -r "$ORIG_MERGE_FILE" ]; then
126+
echo "The merge file '$ORIG_MERGE_FILE' does not exist. Exit." >&2
118127
exit 1
119128
fi
129+
cat $ORIG_MERGE_FILE > $MERGE_FILE
120130
CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
121131

122132
for CFG in $CFG_LIST ; do
123133
grep -q -w $CFG $TMP_FILE || continue
124134
PREV_VAL=$(grep -w $CFG $TMP_FILE)
125135
NEW_VAL=$(grep -w $CFG $MERGE_FILE)
126-
if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
127-
echo Value of $CFG is redefined by fragment $MERGE_FILE:
136+
BUILTIN_FLAG=false
137+
if [ "$BUILTIN" = "true" ] && [ "${NEW_VAL#CONFIG_*=}" = "m" ] && [ "${PREV_VAL#CONFIG_*=}" = "y" ]; then
138+
echo Previous value: $PREV_VAL
139+
echo New value: $NEW_VAL
140+
echo -y passed, will not demote y to m
141+
echo
142+
BUILTIN_FLAG=true
143+
elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
144+
echo Value of $CFG is redefined by fragment $ORIG_MERGE_FILE:
128145
echo Previous value: $PREV_VAL
129146
echo New value: $NEW_VAL
130147
echo
131148
elif [ "$WARNREDUN" = "true" ]; then
132-
echo Value of $CFG is redundant by fragment $MERGE_FILE:
149+
echo Value of $CFG is redundant by fragment $ORIG_MERGE_FILE:
150+
fi
151+
if [ "$BUILTIN_FLAG" = "false" ]; then
152+
sed -i "/$CFG[ =]/d" $TMP_FILE
153+
else
154+
sed -i "/$CFG[ =]/d" $MERGE_FILE
133155
fi
134-
sed -i "/$CFG[ =]/d" $TMP_FILE
135156
done
136157
cat $MERGE_FILE >> $TMP_FILE
137158
done

0 commit comments

Comments
 (0)