From eae28ee8af1196739707057e99c37cc2d488cb4f Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Sun, 17 Jun 2007 11:13:48 +0000 Subject: Add the "regtest" make target: call "make regtest", and all samples wil be built, and a tarball made for each of them. First sample to fail causes the test to stop. diff --git a/samples/Makefile b/samples/Makefile index dede048..e1e2d49 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -1,15 +1,48 @@ -# Build a list of all available samples +# Makefile to manage samples -CT_SAMPLES = $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(filter-out %Makefile,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))) -.PHONY: $(SAMPLES) -$(CT_SAMPLES): - @cp "$(CT_TOP_DIR)/samples/$(@)/crosstool.config" "$(CT_TOP_DIR)/.config" - @$(MAKE) oldconfig +# Build the list of available samples +CT_SAMPLES = $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config)) help:: @echo 'Preconfigured targets:' @$(CT_TOP_DIR)/scripts/showSamples.sh $(CT_SAMPLES) @echo '' +# How we do build one sample +.PHONY: $(CT_SAMPLES) +$(CT_SAMPLES): + @cp "$(CT_TOP_DIR)/samples/$(@)/crosstool.config" "$(CT_TOP_DIR)/.config" + @$(MAKE) oldconfig + +# And now for building all samples one after the other +# We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't +# work because we want to save the samples as well. +# Also, we don't want to see anylog at all, save for the elapsed time, and we +# want to save the log file in a specific place +# Furthermore, force the location where the toolchain will be installed. +# Finaly, we can't use 'make sample-name' as we need to provide default values +# if the options set has changed, but oldconfig does not like when stdin is +# not a terminal (eg. it is a pipe). +.PHONY: regtest +regtest: + @for samp in $(CT_SAMPLES); do \ + echo "Building sample \"$${samp}\"" && \ + cp "$(CT_TOP_DIR)/samples/$${samp}/crosstool.config" "$(CT_TOP_DIR)/.config" && \ + yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1 && \ + sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config && \ + sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config && \ + sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config && \ + sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config && \ + sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config && \ + sed -i -r -e 's:^.*(CT_LOG_FILE).*$$:\1="$${CT_PREFIX_DIR}/build.log":;' .config && \ + sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config && \ + yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1 && \ + make -C $(CT_TOP_DIR) && \ + make -C $(CT_TOP_DIR) tarball && \ + chmod -R u+w $(CT_TOP_DIR)/targets && \ + rm -rf $(CT_TOP_DIR)/targets; \ + done + @make distclean + saveconfig: - @$(CT_TOP_DIR)/scripts/saveSample.sh + $(CT_TOP_DIR)/scripts/saveSample.sh diff --git a/scripts/tarball.sh b/scripts/tarball.sh index 4e4a2ef..febc2a6 100755 --- a/scripts/tarball.sh +++ b/scripts/tarball.sh @@ -9,8 +9,9 @@ # We need the functions first: . "${CT_TOP_DIR}/scripts/functions" -exec 6>&1 +# Don't care about any log file exec >/dev/null +rm -f "${tmp_log_file}" # Parse the configuration file: . ${CT_TOP_DIR}/.config @@ -21,34 +22,30 @@ CT_DoBuildTargetTriplet # re-parse them: . "${CT_TOP_DIR}/.config" -# Override log level -unset CT_LOG_ERROR CT_LOG_WARN CT_LOG_EXTRA CT_LOG_DEBUG -CT_LOG_INFO=y -CT_LOG_LEVEL_MAX="INFO" - -# Build the files' base names -CT_KERNEL_FILE="${CT_KERNEL}-${CT_KERNEL_VERSION}" -CT_BINUTILS_FILE="binutils-${CT_BINUTILS_VERSION}" -CT_LIBC_FILE="${CT_LIBC}-${CT_LIBC_VERSION}" -for addon in ${CT_LIBC_ADDONS_LIST}; do - CT_LIBC_ADDONS_FILES="${CT_LIBC_ADDONS_FILES} ${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" -done -[ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && CT_LIBC_ADDONS_FILES="${CT_LIBC_ADDONS_FILES} ${CT_LIBC}-ports-${CT_LIBC_VERSION}" -[ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] && CT_LIBC_ADDONS_FILES="${CT_LIBC_ADDONS_FILES} ${CT_LIBC}-locales-030818" -[ "${CT_CC_USE_CORE}" = "y" ] && CT_CC_CORE_FILE="${CT_CC_CORE}-${CT_CC_CORE_VERSION}" -CT_CC_FILE="${CT_CC}-${CT_CC_VERSION}" -[ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ] && CT_LIBFLOAT_FILE="libfloat-990616" - -# Build a one-line list of the files to ease scanning below +# Build a one-line list of files to include +CT_DoStep DEBUG "Building list of tarballs to add" CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs" -CT_TARBALLS=" " -for file_var in CT_KERNEL_FILE CT_BINUTILS_FILE CT_LIBC_FILE CT_LIBC_ADDONS_FILES CT_CC_CORE_FILE CT_CC_FILE CT_LIBFLOAT_FILE; do - for file in ${!file_var}; do - ext=`CT_GetFileExtension "${file}"` - CT_TestAndAbort "Missing tarball for: \"${file}\"" -z "${ext}" - CT_TARBALLS="${CT_TARBALLS}${file}${ext} " +CT_TARBALLS="" +for dir in '' tools debug; do + CT_DoStep DEBUG "Scanning directory \"${dir}\"" + for script in "${CT_TOP_DIR}/scripts/build/${dir}/"*.sh; do + CT_DoStep DEBUG "Testing component \"${script}\"" + [ -n "${script}" ] || continue + unset do_print_file_name + . "${script}" + for file in `do_print_filename`; do + CT_DoLog DEBUG "Finding tarball for \"${file}\"" + [ -n "${file}" ] || continue + ext=`CT_GetFileExtension "${file}"` + CT_TestOrAbort "Missing tarball for: \"${file}\"" -f "${CT_TOP_DIR}/targets/tarballs/${file}${ext}" + CT_DoLog DEBUG "Found \"${file}${ext}\"" + CT_TARBALLS="${CT_TARBALLS} ${file}${ext}" + done + CT_EndStep done -done + CT_EndStep +done +CT_EndStep # We need to emulate a build directory: CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build" @@ -61,27 +58,39 @@ CT_Pushd "${CT_TOP_DIR}/.." botdir=`pwd` -# Build the list of files to exclude: -echo "${topdir}/log.*" >"${tempdir}/${CT_TARGET}.list" -echo "${topdir}/targets/*-*-*-*" >>"${tempdir}/${CT_TARGET}.list" -for t in `ls -1 "${topdir}/targets/tarballs/"`; do - case "${CT_TARBALLS}" in - *" ${t} "*) ;; - *) echo "${topdir}/targets/tarballs/${t}" >>"${tempdir}/${CT_TARGET}.list" - esac -done - -CT_DoLog INFO "Saving crosstool" -tar cfj "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" \ - --no-wildcards-match-slash \ - -X "${tempdir}/${CT_TARGET}.list" \ - "${topdir}" 2>/dev/null +# Build the list of files to exclude +CT_DoLog DEBUG "Building list of files to exclude" +exclude_list="${tempdir}/${CT_TARGET}.list" +{ echo ".svn"; \ + echo "${topdir}/log.*"; \ + echo "${topdir}/targets/src"; \ + echo "${topdir}/targets/tst"; \ + echo "${topdir}/targets/*-*-*-*"; \ + for t in `ls -1 "${topdir}/targets/tarballs/"`; do \ + case " ${CT_TARBALLS} " in \ + *" ${t} "*) ;; \ + *) echo "${topdir}/targets/tarballs/${t}";; \ + esac; \ + done; \ +} >"${exclude_list}" + +# Render the install directory writable +chmod u+w "${CT_PREFIX_DIR}" + +CT_DoLog INFO "Saving crosstool-ng into the toolchain directory" +tar cvjf "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" \ + --no-wildcards-match-slash \ + -X "${exclude_list}" \ + "${topdir}" 2>&1 |CT_DoLog ALL CT_Popd -# Save the generated toolchain -CT_DoLog INFO "Saving the generated toolchain" -tar cfj "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}" 2>/dev/null +CT_DoLog INFO "Saving the toolchain" +tar cvjf "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}" 2>&1 |CT_DoLog ALL +CT_DoLog DEBUG "Getting rid of working directories" rm -f "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" rm -rf "${tempdir}" + +# Render the install directory non-writable +chmod u-w "${CT_PREFIX_DIR}" -- cgit v0.10.2-6-g49f6