Remove regtest actions, introduce build-all actions:
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Oct 31 18:31:01 2008 +0000 (2008-10-31)
changeset 1025fc64f85e41cc
parent 1024 804adb99ead3
child 1026 f9f8d8f1d6d8
Remove regtest actions, introduce build-all actions:
- regtest was not easy to use
- one may wish to simply build all samples
- introduce a per-sample automatic build

/trunk/docs/overview.txt | 19 14 5 0 ++++++++---
/trunk/samples/samples.mk | 92 49 43 0 ++++++++++++++++++++++++++++-------------------------
/trunk/ct-ng.comp | 8 5 3 0 +++--
3 files changed, 68 insertions(+), 51 deletions(-)
ct-ng.comp
docs/overview.txt
samples/samples.mk
     1.1 --- a/ct-ng.comp	Fri Oct 31 18:29:15 2008 +0000
     1.2 +++ b/ct-ng.comp	Fri Oct 31 18:31:01 2008 +0000
     1.3 @@ -8,19 +8,21 @@
     1.4  
     1.5      samples=$(${COMP_WORDS[0]} list-samples 2>/dev/null)
     1.6      show_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1show-/g;')
     1.7 +    build_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1build-/g;')
     1.8  
     1.9      steps=$(${COMP_WORDS[0]} list-steps 2>/dev/null |awk '$1 == "-" { print $2; }')
    1.10      start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;')
    1.11      stop_steps=$(echo "${steps}" |sed -r -e 's/(^| )/+\1/;')
    1.12  
    1.13      actions='help menuconfig oldconfig saveconfig
    1.14 -             list-samples build build. list-steps regtest regtest-local
    1.15 -             regtest-global clean distclean wiki-samples updatetools
    1.16 +             build build. build-all build-all.
    1.17 +             list-samples list-steps
    1.18 +             clean distclean wiki-samples updatetools
    1.19               tarball version'
    1.20  
    1.21      vars="RESTART= STOP="
    1.22  
    1.23 -    ct_ng_opts="${samples} ${show_samples}
    1.24 +    ct_ng_opts="${samples} ${show_samples} ${build_samples}
    1.25                  ${steps} ${start_steps} ${stop_steps}
    1.26                  ${actions} ${vars}"
    1.27  
     2.1 --- a/docs/overview.txt	Fri Oct 31 18:29:15 2008 +0000
     2.2 +++ b/docs/overview.txt	Fri Oct 31 18:31:01 2008 +0000
     2.3 @@ -336,11 +336,11 @@
     2.4  option CT_DEBUG_CT_SAVE_STEPS, and that the previous build effectively went
     2.5  that far.
     2.6  
     2.7 -Testing all toolchains at once |
     2.8 --------------------------------+
     2.9 +Building all toolchains at once |
    2.10 +--------------------------------+
    2.11  
    2.12 -You can test-build all samples; simply call:
    2.13 -  ct-ng regtest
    2.14 +You can build all samples; simply call:
    2.15 +  ct-ng build-all
    2.16  
    2.17  Overriding the number of // jobs |
    2.18  ---------------------------------+
    2.19 @@ -354,7 +354,16 @@
    2.20  
    2.21  You can see the actions that support overriding the number of // jobs in
    2.22  the help menu. Those are the ones with [.#] after them (eg. build[.#] or
    2.23 -regtest[.#], and so on...).
    2.24 +build-all[.#], and so on...).
    2.25 +
    2.26 +Note on // jobs |
    2.27 +----------------+
    2.28 +
    2.29 +The crosstool-NG script 'ct-ng' is a Makefile-script. It does *not* execute
    2.30 +in parallel (there is not much to gain). When speaking of // jobs, we are
    2.31 +refering to the number of // jobs when making the *components*. That is, we
    2.32 +speak of the number of // jobs used to build gcc, glibc, and so on...
    2.33 +
    2.34  
    2.35  _______________________
    2.36                        /
     3.1 --- a/samples/samples.mk	Fri Oct 31 18:29:15 2008 +0000
     3.2 +++ b/samples/samples.mk	Fri Oct 31 18:31:01 2008 +0000
     3.3 @@ -16,16 +16,18 @@
     3.4  	@echo  '  list-samples       - prints the list of all samples (for scripting)'
     3.5  	@echo  '  show-<sample>      - show a brief overview of <sample> (list below)'
     3.6  	@echo  '  <sample>           - preconfigure crosstool-NG with <sample> (list below)'
     3.7 +	@echo  '  build-all[.#]      - Build *all* samples (list below) and install in'
     3.8 +	@echo  '                       $${CT_PREFIX} (which you must set)'
     3.9 +	@echo  '  Available samples:'
    3.10  	@$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
    3.11  
    3.12 -help-build::
    3.13 -	@echo  '  regtest[.#]        - Regtest-build all samples'
    3.14 -	@echo  '  regtest-local[.#]  - Regtest-build all local samples'
    3.15 -	@echo  '  regtest-global[.#] - Regtest-build all global samples'
    3.16 -
    3.17  help-distrib::
    3.18  	@echo  '  wiki-samples       - Print a DokuWiki table of samples'
    3.19  
    3.20 +help-env::
    3.21 +	@echo  '  CT_PREFIX          - directory in which to auto-install samples'
    3.22 +	@echo  '                       (see action "build-all", above).'
    3.23 +
    3.24  # ----------------------------------------------------------
    3.25  # This part deals with printing samples information
    3.26  
    3.27 @@ -59,7 +61,7 @@
    3.28  PHONY += $(CT_SAMPLES)
    3.29  $(CT_SAMPLES):
    3.30  	$(SILENT)cp $(call sample_dir,$@)/crosstool.config .config
    3.31 -	$(SILENT)$(MAKE) -rf $(CT_NG) oldconfig
    3.32 +	$(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) oldconfig
    3.33  	@echo
    3.34  	@echo  '***********************************************************'
    3.35  	@echo
    3.36 @@ -87,44 +89,48 @@
    3.37  	@echo  'Now configured for "$@"'
    3.38  
    3.39  # ----------------------------------------------------------
    3.40 -# And now for building all samples one after the other
    3.41 +# Some helper functions
    3.42  
    3.43 -PHONY += regtest regtest_local regtest_global
    3.44 -regtest: regtest-local regtest-global
    3.45 +# Create the rule to build a sample
    3.46 +# $1: sample tuple
    3.47 +# $2: prefix
    3.48 +define build_sample
    3.49 +	@$(ECHO) '  CP    .config'
    3.50 +	$(SILENT)cp $(call sample_dir,$(1))/crosstool.config .config
    3.51 +	@$(ECHO) '  SED   .config'
    3.52 +	$(SILENT)sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$(2)":;' .config
    3.53 +	$(SILENT)sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config
    3.54 +	$(SILENT)sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config
    3.55 +	$(SILENT)sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config
    3.56 +	$(SILENT)sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config
    3.57 +	$(SILENT)sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config
    3.58 +	$(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) oldconfig
    3.59 +	@$(ECHO) '  BUILD $(1)'
    3.60 +	$(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) build
    3.61 +endef
    3.62  
    3.63 -regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
    3.64 +# ----------------------------------------------------------
    3.65 +# Build samples for use (not regtest!)
    3.66  
    3.67 -regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
    3.68 +# Check that PREFIX is set if building samples
    3.69 +ifneq ($(strip $(MAKECMDGOALS)),)
    3.70 +ifneq ($(strip $(filter $(patsubst %,build-%,$(CT_SAMPLES)) build-all,$(MAKECMDGOALS))),)
    3.71  
    3.72 -regtest.% regtest-local.% regtest-global.%:
    3.73 -	$(SILENT)$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
    3.74 +ifeq ($(strip $(CT_PREFIX)),)
    3.75 +$(error Please set 'CT_PREFIX' to where you want to install generated toolchain samples!)
    3.76 +endif
    3.77  
    3.78 -# One regtest per sample
    3.79 -# We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    3.80 -# work because we want to save the samples as well.
    3.81 -# Also, we don't want to see anylog at all, save for the elapsed time, and we
    3.82 -# want to save the log file in a specific place
    3.83 -# Furthermore, force the location where the toolchain will be installed.
    3.84 -# Finaly, we can't use 'make sample-name' as we need to provide default values
    3.85 -# if the options set has changed, but oldconfig does not like when stdin is
    3.86 -# not a terminal (eg. it is a pipe).
    3.87 -$(patsubst %,regtest_%,$(CT_SAMPLES)):
    3.88 -	$(SILENT)samp=$(patsubst regtest_%,%,$@)                                                        ;   \
    3.89 -	 echo -e "\rBuilding sample \"$${samp}\""                                                       &&  \
    3.90 -	 $(CT_NG) copy_config_$${samp}                                                                  &&  \
    3.91 -	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    3.92 -	 sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config  &&  \
    3.93 -	 sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    3.94 -	 sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    3.95 -	 sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    3.96 -	 sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
    3.97 -	 sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    3.98 -	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    3.99 -	 $(CT_NG) build                                                                                 &&  \
   3.100 -	 echo -e "\rSuccessfully built sample \"$${samp}\""                                             &&  \
   3.101 -	 echo -e "\rMaking tarball for sample \"$${samp}\""                                             &&  \
   3.102 -	 $(CT_NG) tarball                                                                               &&  \
   3.103 -	 echo -e "\rSuccessfully built tarball for sample \"$${samp}\""                                 ;   \
   3.104 -	 echo -e "\rCleaning sample \"$${samp}\""                                                       ;   \
   3.105 -	 $(CT_NG) distclean                                                                             ;   \
   3.106 -	 echo -e "\r"
   3.107 +endif # MAKECMDGOALS contains a build sample rule
   3.108 +endif # MAKECMDGOALS != ""
   3.109 +
   3.110 +# Build a single sample
   3.111 +$(patsubst %,build-%,$(CT_SAMPLES)):
   3.112 +	$(call build_sample,$(patsubst build-%,%,$@),$(CT_PREFIX)/$(patsubst build-%,%,$@))
   3.113 +
   3.114 +# Build al samples
   3.115 +build-all: $(patsubst %,build-%,$(CT_SAMPLES))
   3.116 +
   3.117 +# Build all samples, overiding the number of // jobs per sample
   3.118 +build-all.%:
   3.119 +	$(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
   3.120 +