From 2c3b6d2b71c3a9bcbef5157ec9eb4217b25cf685 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Thu, 19 May 2011 22:29:49 +0200 Subject: scripts: munge .config to handle array variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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" Signed-off-by: "Benoît THÉBAUDEAU" diff --git a/.hgignore b/.hgignore index d8b62b3..a8b6e23 100644 --- a/.hgignore +++ b/.hgignore @@ -15,6 +15,7 @@ kconfig/**.o kconfig/**.dep config.gen/ .config +.config.2 # Temporaries .*.swp diff --git a/ct-ng.in b/ct-ng.in index 0233622..096e134 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -135,11 +135,16 @@ help-env:: @echo "or configure an existing sample." @false -show-tuple: .config +.config.2: .config + $(SILENT)$(sed) -r -e 's/^([^=]+_ARRAY)="(.*)"$$/\1=( \2 )/;' \ + -e '/^[^=]+_ARRAY=/s/\\(.)/\1/g;' \ + $< >$@ + +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 index 648ff45..e2ff8af 100644 --- 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 @@ CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S) # 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 @@ CT_DoBuildTargetTuple # 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 @@ if [ -z "${CT_RESTART}" ]; then [ ${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 index 2dfdf52..9e012aa 100644 --- a/scripts/saveSample.sh.in +++ b/scripts/saveSample.sh.in @@ -22,10 +22,10 @@ rm -f "${tmp_log_file}" # 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 @@ CT_DoBuildTargetTuple # 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 @@ samp_dir="samples/${samp_name}" 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 index 32986a6..d96d0c5 100755 --- 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 index c7df08c..9753bb5 100644 --- a/scripts/showTuple.sh.in +++ b/scripts/showTuple.sh.in @@ -17,7 +17,7 @@ exec >/dev/null 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" -- cgit v0.10.2-6-g49f6