[PATCH 3 of 4] scripts: munge .config to handle array variables
Yann E. MORIN
yann.morin.1998@anciens.enib.fr
Wed May 18 22:14:00 GMT 2011
# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
# Date 1305752459 -7200
# Node ID 7d65647be9fd6896e6b39c86f7eeb22e86224d8e
# Parent 1a46434ff82e85dd74dc887998dede600f927be4
scripts: munge .config to handle array variables
Transfrom array variables from pure strings (in the kconfig output)
into proper bash arrays declarations, for feeding to the build scripts.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -15,6 +15,7 @@
kconfig/**.dep
config.gen/
.config
+.config.2
# Temporaries
.*.swp
diff --git a/ct-ng.in b/ct-ng.in
--- a/ct-ng.in
+++ b/ct-ng.in
@@ -135,11 +135,14 @@
@echo "or configure an existing sample."
@false
-show-tuple: .config
+.config.2: .config
+ $(SILENT)$(sed) -r -e 's/^([^=]+_ARRAY)="(.*)"$$/\1=( \2 )/;' $< >$@
+
+show-tuple: .config.2
$(SILENT)$(bash) $(CT_LIB_DIR)/scripts/showTuple.sh
# Actual build
-build: .config
+build: .config.2
$(SILENT)$(CT_LIB_DIR)/scripts/crosstool-NG.sh
build.%:
diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in
+++ b/scripts/crosstool-NG.sh.in
@@ -22,7 +22,7 @@
# Parse the configuration file
# It has some info about the logging facility, so include it early
-. .config
+. .config.2
# Yes! We can do full logging from now on!
# Overide the locale early, in case we ever translate crosstool-NG messages
@@ -103,6 +103,8 @@
# Log real begining of build, now
CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
+# We really need to extract from ,config and not .config.2, as we
+# do want the kconfig's values, not our mangled config with arrays.
CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration"
CT_DoExecLog DEBUG grep -E '^(# |)CT_' .config
CT_EndStep
@@ -138,7 +140,7 @@
# Kludge: If any of the configured options needs CT_TARGET,
# then rescan the options file now:
-. .config
+. .config.2
# Sanity check some directories
CT_TestAndAbort "'CT_PREFIX_DIR' is not set: where should I install?" -z "${CT_PREFIX_DIR}"
@@ -485,6 +487,8 @@
[ ${CT_PARALLEL_JOBS} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}"
[ ${CT_LOAD} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}"
+ # We need to save the real .config with kconfig's value,
+ # not our mangled .config.2 with arrays.
CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin"
CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
diff --git a/scripts/saveSample.sh.in b/scripts/saveSample.sh.in
--- a/scripts/saveSample.sh.in
+++ b/scripts/saveSample.sh.in
@@ -22,10 +22,10 @@
# Parse the configuration file
# Don't use CT_TestOrAbort, it prints the test string to [DEBUG]
-if [ ! -f .config ]; then
+if [ ! -f .config.2 ]; then
CT_Abort "Configuration file not found. Please create one."
fi
-. .config
+. .config.2
# We can not reliably save a sample which either uses local patches
# and/or custom Linux kernel headers. Warn the user about this issue
@@ -55,7 +55,7 @@
# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
# re-parse them:
-. .config
+. .config.2
# Override log options
unset CT_LOG_PROGRESS_BAR CT_LOG_ERROR CT_LOG_INFO CT_LOG_EXTRA CT_LOG_DEBUG LOG_ALL
@@ -72,6 +72,8 @@
mkdir -p "${samp_dir}"
# Save the crosstool-NG config file
+# We need to save the real .config with kconfig's values,
+# not our mangled .config.2 with arrays
"${sed}" -r -e 's|^(CT_PREFIX_DIR)=.*|\1="${HOME}/x-tools/${CT_TARGET}"|;' \
-e 's|^# CT_LOG_TO_FILE is not set$|CT_LOG_TO_FILE=y|;' \
-e 's|^# CT_LOG_FILE_COMPRESS is not set$|CT_LOG_FILE_COMPRESS=y|;' \
diff --git a/scripts/showSamples.sh b/scripts/showSamples.sh
--- a/scripts/showSamples.sh
+++ b/scripts/showSamples.sh
@@ -14,6 +14,7 @@
export GREP_OPTIONS=
# Dump a single sample
+# Note: we can quite safely used the non-mangled .config.2
dump_single_sample() {
local verbose=0
local complibs
diff --git a/scripts/showTuple.sh.in b/scripts/showTuple.sh.in
--- a/scripts/showTuple.sh.in
+++ b/scripts/showTuple.sh.in
@@ -17,7 +17,7 @@
rm -f "${tmp_log_file}"
# Parse the configuration file
-. .config
+. .config.2
# Parse architecture and kernel specific functions
. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list