scripts+samples: fix listings the samples

Since we use defconfigs to save the samples, listing all the
samples can no longer be done by passing all the sample names
at one to the script; we need to pass them one-by-one after
we expand the sample's defconfig ibnto a complete .config.

Reported-by: Bryan Hundven <bryanhundven@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
This commit is contained in:
Yann E. MORIN" 2012-07-23 22:02:23 +02:00
parent a427e20308
commit 542bb18409
2 changed files with 56 additions and 42 deletions

View File

@ -44,7 +44,7 @@ show-config: .config
PHONY += $(patsubst %,show-%,$(CT_SAMPLES)) PHONY += $(patsubst %,show-%,$(CT_SAMPLES))
$(patsubst %,show-%,$(CT_SAMPLES)): config_files $(patsubst %,show-%,$(CT_SAMPLES)): config_files
@KCONFIG_CONFIG=$$(pwd)/.config.sample \ @KCONFIG_CONFIG=$$(pwd)/.config.sample \
$(CONF) --defconfig=$(call sample_dir,$(patsubst show-%,%,$(@)))/crosstool.config \ $(CONF) --defconfig=$(call sample_dir,$(patsubst show-%,%,$(@)))/crosstool.config \
$(KCONFIG_TOP) >/dev/null $(KCONFIG_TOP) >/dev/null
@$(CT_LIB_DIR)/scripts/showSamples.sh -v $(patsubst show-%,%,$(@)) @$(CT_LIB_DIR)/scripts/showSamples.sh -v $(patsubst show-%,%,$(@))
@rm -f .config.sample @rm -f .config.sample
@ -55,18 +55,45 @@ show-all: $(patsubst %,show-%,$(CT_SAMPLES))
# print the list of all available samples # print the list of all available samples
PHONY += list-samples PHONY += list-samples
list-samples: FORCE list-samples: list-samples-pre $(patsubst %,list-%,$(CT_SAMPLES))
$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES) @echo ' L (Local) : sample was found in current directory'
@echo ' G (Global) : sample was installed with crosstool-NG'
@echo ' X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
@echo ' B (BROKEN) : sample is currently broken'
PHONY += list-samples-pre
list-samples-pre: FORCE
@echo 'Status Sample name'
PHONY += $(patsubst %,list-%,$(CT_SAMPLES))
$(patsubst %,list-%,$(CT_SAMPLES)): config_files
@KCONFIG_CONFIG=$$(pwd)/.config.sample \
$(CONF) --defconfig=$(call sample_dir,$(patsubst list-%,%,$(@)))/crosstool.config \
$(KCONFIG_TOP) >/dev/null
@$(CT_LIB_DIR)/scripts/showSamples.sh $(patsubst list-%,%,$(@))
@rm -f .config.sample
PHONY += list-samples-short PHONY += list-samples-short
list-samples-short: FORCE list-samples-short: FORCE
$(SILENT)for s in $(CT_SAMPLES); do \ $(SILENT)for s in $(CT_SAMPLES); do \
printf "$${s}\n"; \ printf "%s\n" "$${s}"; \
done done
PHONY += wiki-samples PHONY += wiki-samples
wiki-samples: wiki-samples: wiki-samples-pre $(patsubst %,wiki-%,$(CT_SAMPLES)) wiki-samples-post
$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)
wiki-samples-pre: FORCE
$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w
wiki-samples-post: FORCE
$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -W $(CT_SAMPLES)
$(patsubst %,wiki-%,$(CT_SAMPLES)): config_files
$(SILENT)KCONFIG_CONFIG=$$(pwd)/.config.sample \
$(CONF) --defconfig=$(call sample_dir,$(patsubst wiki-%,%,$(@)))/crosstool.config \
$(KCONFIG_TOP) >/dev/null
$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w $(patsubst wiki-%,%,$(@))
$(SILENT)rm -f .config.sample
# ---------------------------------------------------------- # ----------------------------------------------------------
# This part deals with saving/restoring samples # This part deals with saving/restoring samples

View File

@ -9,6 +9,7 @@
[ "$1" = "-v" ] && opt="$1" && shift [ "$1" = "-v" ] && opt="$1" && shift
[ "$1" = "-w" ] && opt="$1" && shift [ "$1" = "-w" ] && opt="$1" && shift
[ "$1" = "-W" ] && opt="$1" && shift
# GREP_OPTIONS screws things up. # GREP_OPTIONS screws things up.
export GREP_OPTIONS= export GREP_OPTIONS=
@ -17,16 +18,15 @@ export GREP_OPTIONS=
# Note: we use the specific .config.sample config file # Note: we use the specific .config.sample config file
dump_single_sample() { dump_single_sample() {
local verbose=0 local verbose=0
local wiki=0
local complibs local complibs
[ "$1" = "-v" ] && verbose=1 && shift [ "$1" = "-v" ] && verbose=1 && shift
[ "$1" = "-w" ] && wiki=1 && shift [ "$1" = "-w" ] && wiki=1 && shift
local width="$1" local sample="$1"
local sample="$2"
case "${sample}" in case "${sample}" in
current) current)
sample_type="l" sample_type="l"
sample="$( ${CT_NG} show-tuple )" sample="$( ${CT_NG} show-tuple )"
width="${#sample}"
;; ;;
*) if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then *) if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then
sample_top="${CT_TOP_DIR}" sample_top="${CT_TOP_DIR}"
@ -38,20 +38,20 @@ dump_single_sample() {
;; ;;
esac esac
. $(pwd)/.config.sample . $(pwd)/.config.sample
if [ -z "${wiki}" ]; then if [ ${wiki} -eq 0 ]; then
t_width=14 width=14
printf "%-*s [%s" ${width} "${sample}" "${sample_type}" printf "[%s" "${sample_type}"
[ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf " " [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf "."
[ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf " " [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf "."
echo "]" printf "] %s\n" "${sample}"
if [ ${verbose} -ne 0 ]; then if [ ${verbose} -ne 0 ]; then
case "${CT_TOOLCHAIN_TYPE}" in case "${CT_TOOLCHAIN_TYPE}" in
cross) ;; cross) ;;
canadian) canadian)
printf " %-*s : %s\n" ${t_width} "Host" "${CT_HOST}" printf " %-*s : %s\n" ${width} "Host" "${CT_HOST}"
;; ;;
esac esac
printf " %-*s : %s\n" ${t_width} "OS" "${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}" printf " %-*s : %s\n" ${width} "OS" "${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}"
if [ -n "${CT_GMP}" \ if [ -n "${CT_GMP}" \
-o -n "${CT_MPFR}" \ -o -n "${CT_MPFR}" \
-o -n "${CT_PPL}" \ -o -n "${CT_PPL}" \
@ -65,7 +65,7 @@ dump_single_sample() {
-o -n "${CT_MPC_TARGET}" \ -o -n "${CT_MPC_TARGET}" \
-o -n "${CT_LIBELF_TARGET}" \ -o -n "${CT_LIBELF_TARGET}" \
]; then ]; then
printf " %-*s :" ${t_width} "Companion libs" printf " %-*s :" ${width} "Companion libs"
complibs=1 complibs=1
fi fi
[ -z "${CT_GMP}" -a -z "${CT_GMP_TARGET}" ] || printf " gmp-%s" "${CT_GMP_VERSION}" [ -z "${CT_GMP}" -a -z "${CT_GMP_TARGET}" ] || printf " gmp-%s" "${CT_GMP_VERSION}"
@ -75,8 +75,8 @@ dump_single_sample() {
[ -z "${CT_MPC}" -a -z "${CT_MPC_TARGET}" ] || printf " mpc-%s" "${CT_MPC_VERSION}" [ -z "${CT_MPC}" -a -z "${CT_MPC_TARGET}" ] || printf " mpc-%s" "${CT_MPC_VERSION}"
[ -z "${CT_LIBELF}" -a -z "${CT_LIBELF_TARGET}" ] || printf " libelf-%s" "${CT_LIBELF_VERSION}" [ -z "${CT_LIBELF}" -a -z "${CT_LIBELF_TARGET}" ] || printf " libelf-%s" "${CT_LIBELF_VERSION}"
[ -z "${complibs}" ] || printf "\n" [ -z "${complibs}" ] || printf "\n"
printf " %-*s : %s\n" ${t_width} "binutils" "binutils-${CT_BINUTILS_VERSION}" printf " %-*s : %s\n" ${width} "binutils" "binutils-${CT_BINUTILS_VERSION}"
printf " %-*s : %s" ${t_width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C" printf " %-*s : %s" ${width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C"
[ "${CT_CC_LANG_CXX}" = "y" ] && printf ",C++" [ "${CT_CC_LANG_CXX}" = "y" ] && printf ",C++"
[ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran" [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
[ "${CT_CC_LANG_JAVA}" = "y" ] && printf ",Java" [ "${CT_CC_LANG_JAVA}" = "y" ] && printf ",Java"
@ -85,8 +85,8 @@ dump_single_sample() {
[ "${CT_CC_LANG_OBJCXX}" = "y" ] && printf ",Objective-C++" [ "${CT_CC_LANG_OBJCXX}" = "y" ] && printf ",Objective-C++"
[ -n "${CT_CC_LANG_OTHERS}" ] && printf ",${CT_CC_LANG_OTHERS}" [ -n "${CT_CC_LANG_OTHERS}" ] && printf ",${CT_CC_LANG_OTHERS}"
printf ")\n" printf ")\n"
printf " %-*s : %s\n" ${t_width} "C library" "${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}" printf " %-*s : %s\n" ${width} "C library" "${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}"
printf " %-*s :" ${t_width} "Tools" printf " %-*s :" ${width} "Tools"
[ "${CT_TOOL_sstrip}" ] && printf " sstrip" [ "${CT_TOOL_sstrip}" ] && printf " sstrip"
[ "${CT_DEBUG_dmalloc}" ] && printf " dmalloc-${CT_DMALLOC_VERSION}" [ "${CT_DEBUG_dmalloc}" ] && printf " dmalloc-${CT_DMALLOC_VERSION}"
[ "${CT_DEBUG_duma}" ] && printf " duma-${CT_DUMA_VERSION}" [ "${CT_DEBUG_duma}" ] && printf " duma-${CT_DUMA_VERSION}"
@ -153,13 +153,7 @@ dump_single_sample() {
fi fi
} }
# Get largest sample width if [ "${opt}" = "-w" -a ${#} -eq 0 ]; then
width=0
for sample in "${@}"; do
[ ${#sample} -gt ${width} ] && width=${#sample}
done
if [ "${opt}" = -w ]; then
printf "^ %s |||||||||||||||\n" "$( date "+%Y%m%d.%H%M %z" )" printf "^ %s |||||||||||||||\n" "$( date "+%Y%m%d.%H%M %z" )"
printf "^ Target " printf "^ Target "
printf "^ Host " printf "^ Host "
@ -174,20 +168,13 @@ if [ "${opt}" = -w ]; then
printf "^ Initially\\\\\\\\ reported by " printf "^ Initially\\\\\\\\ reported by "
printf "^ Last\\\\\\\\ updated " printf "^ Last\\\\\\\\ updated "
echo "^" echo "^"
elif [ -z "${opt}" ]; then exit 0
printf "%-*s Status\n" ${width} "Sample name" elif [ "${opt}" = "-W" ]; then
printf "^ Total: ${#} samples || **X**: sample uses features marked as being EXPERIMENTAL.\\\\\\\\ **B**: sample is currently BROKEN. |||||||||||||"
echo ""
exit 0
fi fi
for sample in "${@}"; do for sample in "${@}"; do
( dump_single_sample ${opt} ${width} "${sample}" ) ( dump_single_sample ${opt} "${sample}" )
done done
if [ "${opt}" = -w ]; then
printf "^ Total: ${#@} samples || **X**: sample uses features marked as being EXPERIMENTAL.\\\\\\\\ **B**: sample is currently BROKEN. |||||||||||||"
echo ""
elif [ -z "${opt}" ]; then
echo ' L (Local) : sample was found in current directory'
echo ' G (Global) : sample was installed with crosstool-NG'
echo ' X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
echo ' B (BROKEN) : sample is currently broken'
fi