scripts: munge .config to handle array variables
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu May 19 22:29:49 2011 +0200 (2011-05-19)
changeset 246890595d1c1017
parent 2467 200836977ce6
child 2469 3b08a7927e55
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>
Signed-off-by: "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
.hgignore
ct-ng.in
scripts/crosstool-NG.sh.in
scripts/saveSample.sh.in
scripts/showSamples.sh
scripts/showTuple.sh.in
     1.1 --- a/.hgignore	Wed May 18 23:00:46 2011 +0200
     1.2 +++ b/.hgignore	Thu May 19 22:29:49 2011 +0200
     1.3 @@ -15,6 +15,7 @@
     1.4  kconfig/**.dep
     1.5  config.gen/
     1.6  .config
     1.7 +.config.2
     1.8  
     1.9  # Temporaries
    1.10  .*.swp
     2.1 --- a/ct-ng.in	Wed May 18 23:00:46 2011 +0200
     2.2 +++ b/ct-ng.in	Thu May 19 22:29:49 2011 +0200
     2.3 @@ -135,11 +135,16 @@
     2.4  	@echo "or configure an existing sample."
     2.5  	@false
     2.6  
     2.7 -show-tuple: .config
     2.8 +.config.2: .config
     2.9 +	$(SILENT)$(sed) -r -e 's/^([^=]+_ARRAY)="(.*)"$$/\1=( \2 )/;'   \
    2.10 +	                   -e '/^[^=]+_ARRAY=/s/\\(.)/\1/g;'            \
    2.11 +	                $< >$@
    2.12 +
    2.13 +show-tuple: .config.2
    2.14  	$(SILENT)$(bash) $(CT_LIB_DIR)/scripts/showTuple.sh
    2.15  
    2.16  # Actual build
    2.17 -build: .config
    2.18 +build: .config.2
    2.19  	$(SILENT)$(CT_LIB_DIR)/scripts/crosstool-NG.sh
    2.20  
    2.21  build.%:
     3.1 --- a/scripts/crosstool-NG.sh.in	Wed May 18 23:00:46 2011 +0200
     3.2 +++ b/scripts/crosstool-NG.sh.in	Thu May 19 22:29:49 2011 +0200
     3.3 @@ -22,7 +22,7 @@
     3.4  
     3.5  # Parse the configuration file
     3.6  # It has some info about the logging facility, so include it early
     3.7 -. .config
     3.8 +. .config.2
     3.9  # Yes! We can do full logging from now on!
    3.10  
    3.11  # Overide the locale early, in case we ever translate crosstool-NG messages
    3.12 @@ -103,6 +103,8 @@
    3.13  # Log real begining of build, now
    3.14  CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
    3.15  
    3.16 +# We really need to extract from ,config and not .config.2, as we
    3.17 +# do want the kconfig's values, not our mangled config with arrays.
    3.18  CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration"
    3.19  CT_DoExecLog DEBUG grep -E '^(# |)CT_' .config
    3.20  CT_EndStep
    3.21 @@ -138,7 +140,7 @@
    3.22  
    3.23  # Kludge: If any of the configured options needs CT_TARGET,
    3.24  # then rescan the options file now:
    3.25 -. .config
    3.26 +. .config.2
    3.27  
    3.28  # Sanity check some directories
    3.29  CT_TestAndAbort "'CT_PREFIX_DIR' is not set: where should I install?" -z "${CT_PREFIX_DIR}"
    3.30 @@ -485,6 +487,8 @@
    3.31      [ ${CT_PARALLEL_JOBS} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}"
    3.32      [ ${CT_LOAD} -ne 0 ] && JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}"
    3.33  
    3.34 +    # We need to save the real .config with kconfig's value,
    3.35 +    # not our mangled .config.2 with arrays.
    3.36      CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
    3.37      CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin"
    3.38      CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
     4.1 --- a/scripts/saveSample.sh.in	Wed May 18 23:00:46 2011 +0200
     4.2 +++ b/scripts/saveSample.sh.in	Thu May 19 22:29:49 2011 +0200
     4.3 @@ -22,10 +22,10 @@
     4.4  
     4.5  # Parse the configuration file
     4.6  # Don't use CT_TestOrAbort, it prints the test string to [DEBUG]
     4.7 -if [ ! -f .config ]; then
     4.8 +if [ ! -f .config.2 ]; then
     4.9      CT_Abort "Configuration file not found. Please create one."
    4.10  fi
    4.11 -. .config
    4.12 +. .config.2
    4.13  
    4.14  # We can not reliably save a sample which either uses local patches
    4.15  # and/or custom Linux kernel headers. Warn the user about this issue
    4.16 @@ -55,7 +55,7 @@
    4.17  
    4.18  # Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
    4.19  # re-parse them:
    4.20 -. .config
    4.21 +. .config.2
    4.22  
    4.23  # Override log options
    4.24  unset CT_LOG_PROGRESS_BAR CT_LOG_ERROR CT_LOG_INFO CT_LOG_EXTRA CT_LOG_DEBUG LOG_ALL
    4.25 @@ -72,6 +72,8 @@
    4.26  mkdir -p "${samp_dir}"
    4.27  
    4.28  # Save the crosstool-NG config file
    4.29 +# We need to save the real .config with kconfig's values,
    4.30 +# not our mangled .config.2 with arrays
    4.31  "${sed}" -r -e 's|^(CT_PREFIX_DIR)=.*|\1="${HOME}/x-tools/${CT_TARGET}"|;'      \
    4.32              -e 's|^# CT_LOG_TO_FILE is not set$|CT_LOG_TO_FILE=y|;'             \
    4.33              -e 's|^# CT_LOG_FILE_COMPRESS is not set$|CT_LOG_FILE_COMPRESS=y|;' \
     5.1 --- a/scripts/showSamples.sh	Wed May 18 23:00:46 2011 +0200
     5.2 +++ b/scripts/showSamples.sh	Thu May 19 22:29:49 2011 +0200
     5.3 @@ -14,6 +14,7 @@
     5.4  export GREP_OPTIONS=
     5.5  
     5.6  # Dump a single sample
     5.7 +# Note: we can quite safely used the non-mangled .config.2
     5.8  dump_single_sample() {
     5.9      local verbose=0
    5.10      local complibs
     6.1 --- a/scripts/showTuple.sh.in	Wed May 18 23:00:46 2011 +0200
     6.2 +++ b/scripts/showTuple.sh.in	Thu May 19 22:29:49 2011 +0200
     6.3 @@ -17,7 +17,7 @@
     6.4  rm -f "${tmp_log_file}"
     6.5  
     6.6  # Parse the configuration file
     6.7 -. .config
     6.8 +. .config.2
     6.9  
    6.10  # Parse architecture and kernel specific functions
    6.11  . "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"