summaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
authorAnders Roxell <anders.roxell@linaro.org>2018-11-12 03:38:55 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-11-15 09:49:35 -0500
commita9b722847872d43595d072d7fd550f08fe6764fd (patch)
tree1a7efb7002ac8b4652f8b1061d65226b83d69716 /scripts/kconfig
parentccda4af0f4b92f7b4c308d3acc262f4a7e3affad (diff)
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>
Diffstat (limited to 'scripts/kconfig')
-rwxr-xr-xscripts/kconfig/merge_config.sh37
1 files changed, 29 insertions, 8 deletions
diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
index 0ef906499646..9b89791b202c 100755
--- a/scripts/kconfig/merge_config.sh
+++ b/scripts/kconfig/merge_config.sh
@@ -22,6 +22,7 @@
22 22
23clean_up() { 23clean_up() {
24 rm -f $TMP_FILE 24 rm -f $TMP_FILE
25 rm -f $MERGE_FILE
25 exit 26 exit
26} 27}
27trap clean_up HUP INT TERM 28trap clean_up HUP INT TERM
@@ -32,6 +33,7 @@ usage() {
32 echo " -m only merge the fragments, do not execute the make command" 33 echo " -m only merge the fragments, do not execute the make command"
33 echo " -n use allnoconfig instead of alldefconfig" 34 echo " -n use allnoconfig instead of alldefconfig"
34 echo " -r list redundant entries when merging fragments" 35 echo " -r list redundant entries when merging fragments"
36 echo " -y make builtin have precedence over modules"
35 echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead." 37 echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead."
36 echo 38 echo
37 echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable." 39 echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
@@ -40,6 +42,7 @@ usage() {
40RUNMAKE=true 42RUNMAKE=true
41ALLTARGET=alldefconfig 43ALLTARGET=alldefconfig
42WARNREDUN=false 44WARNREDUN=false
45BUILTIN=false
43OUTPUT=. 46OUTPUT=.
44CONFIG_PREFIX=${CONFIG_-CONFIG_} 47CONFIG_PREFIX=${CONFIG_-CONFIG_}
45 48
@@ -64,6 +67,11 @@ while true; do
64 shift 67 shift
65 continue 68 continue
66 ;; 69 ;;
70 "-y")
71 BUILTIN=true
72 shift
73 continue
74 ;;
67 "-O") 75 "-O")
68 if [ -d $2 ];then 76 if [ -d $2 ];then
69 OUTPUT=$(echo $2 | sed 's/\/*$//') 77 OUTPUT=$(echo $2 | sed 's/\/*$//')
@@ -106,32 +114,45 @@ SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
106SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p" 114SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
107 115
108TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) 116TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
117MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX)
109 118
110echo "Using $INITFILE as base" 119echo "Using $INITFILE as base"
111cat $INITFILE > $TMP_FILE 120cat $INITFILE > $TMP_FILE
112 121
113# Merge files, printing warnings on overridden values 122# Merge files, printing warnings on overridden values
114for MERGE_FILE in $MERGE_LIST ; do 123for ORIG_MERGE_FILE in $MERGE_LIST ; do
115 echo "Merging $MERGE_FILE" 124 echo "Merging $ORIG_MERGE_FILE"
116 if [ ! -r "$MERGE_FILE" ]; then 125 if [ ! -r "$ORIG_MERGE_FILE" ]; then
117 echo "The merge file '$MERGE_FILE' does not exist. Exit." >&2 126 echo "The merge file '$ORIG_MERGE_FILE' does not exist. Exit." >&2
118 exit 1 127 exit 1
119 fi 128 fi
129 cat $ORIG_MERGE_FILE > $MERGE_FILE
120 CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE) 130 CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
121 131
122 for CFG in $CFG_LIST ; do 132 for CFG in $CFG_LIST ; do
123 grep -q -w $CFG $TMP_FILE || continue 133 grep -q -w $CFG $TMP_FILE || continue
124 PREV_VAL=$(grep -w $CFG $TMP_FILE) 134 PREV_VAL=$(grep -w $CFG $TMP_FILE)
125 NEW_VAL=$(grep -w $CFG $MERGE_FILE) 135 NEW_VAL=$(grep -w $CFG $MERGE_FILE)
126 if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then 136 BUILTIN_FLAG=false
127 echo Value of $CFG is redefined by fragment $MERGE_FILE: 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:
128 echo Previous value: $PREV_VAL 145 echo Previous value: $PREV_VAL
129 echo New value: $NEW_VAL 146 echo New value: $NEW_VAL
130 echo 147 echo
131 elif [ "$WARNREDUN" = "true" ]; then 148 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
133 fi 155 fi
134 sed -i "/$CFG[ =]/d" $TMP_FILE
135 done 156 done
136 cat $MERGE_FILE >> $TMP_FILE 157 cat $MERGE_FILE >> $TMP_FILE
137done 158done