summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2007-05-17 16:22:51 (GMT)
committerYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2007-05-17 16:22:51 (GMT)
commit8d3f0a8781cc25e75db3db4a9195816e7d3da902 (patch)
tree12a82d97590ca0d646ab8df9ddcadc74f547defd /scripts
parent721da92158c37cd044ccccd3b37d1e8d0c183f39 (diff)
Debug facilities:
- add a framework to easily add new ones - add gdb as a first debug facility - add patches for gdb After the kernel checked its installed headers, clean up the mess of .checked.* files. Reorder scripts/crosstool.sh: - dump the configuration early - renice early - get info about build system early, when setting up the environment - when in cross or native, the host tools are those of the build system, and only in this case - elapsed time calculations moved to scripts/functions Remove handling of the color: it's gone once and for all. Update tools/addToolVersion.sh: - handle debug facilities - commonalise some code - remove dead tools (cygwin, tcc) Point to my address for bug reports.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/debug.sh34
-rw-r--r--scripts/build/debug/gdb.sh124
-rw-r--r--scripts/build/kernel_linux.sh2
-rwxr-xr-xscripts/crosstool.sh129
-rw-r--r--scripts/functions41
5 files changed, 246 insertions, 84 deletions
diff --git a/scripts/build/debug.sh b/scripts/build/debug.sh
new file mode 100644
index 0000000..4a3a6cf
--- /dev/null
+++ b/scripts/build/debug.sh
@@ -0,0 +1,34 @@
+# Wrapper to build the debug facilities
+
+# List all debug facilities, and parse their scripts
+CT_DEBUG_FACILITY_LIST=
+for f in "${CT_TOP_DIR}/scripts/build/debug/"*.sh; do
+ is_enabled=
+ . "${f}"
+ f=`basename "${f}" .sh`
+ if [ "${is_enabled}" = "y" ]; then
+ CT_DEBUG_FACILITY_LIST="${CT_DEBUG_FACILITY_LIST} ${f}"
+ fi
+done
+
+# Download the debug facilities
+do_debug_get() {
+ for f in ${CT_DEBUG_FACILITY_LIST}; do
+ do_debug_${f}_get
+ done
+}
+
+# Extract and patch the debug facilities
+do_debug_extract() {
+ for f in ${CT_DEBUG_FACILITY_LIST}; do
+ do_debug_${f}_extract
+ done
+}
+
+# Build the debug facilities
+do_debug() {
+ for f in ${CT_DEBUG_FACILITY_LIST}; do
+ do_debug_${f}_build
+ done
+}
+
diff --git a/scripts/build/debug/gdb.sh b/scripts/build/debug/gdb.sh
new file mode 100644
index 0000000..457e899
--- /dev/null
+++ b/scripts/build/debug/gdb.sh
@@ -0,0 +1,124 @@
+# Build script for the gdb debug facility
+
+is_enabled="${CT_GDB}"
+
+do_debug_gdb_suffix() {
+ case "${CT_GDB_VERSION}" in
+ snapshot) ;;
+ *) echo "-${CT_GDB_VERSION}";;
+ esac
+}
+
+do_debug_gdb_get() {
+ CT_GetFile "gdb`do_debug_gdb_suffix`" \
+ ftp://ftp.gnu.org/pub/gnu/gdb \
+ ftp://sources.redhat.com/pub/gdb/releases \
+ ftp://sources.redhat.com/pub/gdb/old-releases \
+ ftp://sources.redhat.com/pub/gdb/snapshots/current
+}
+
+do_debug_gdb_extract() {
+ CT_ExtractAndPatch "gdb`do_debug_gdb_suffix`"
+}
+
+do_debug_gdb_build() {
+ gdb_src_dir="${CT_SRC_DIR}/gdb`do_debug_gdb_suffix`"
+
+ extra_config=
+ # Version 6.3 and below behave badly with gdbmi
+ case "${CT_GDB_VERSION}" in
+ 6.2*|6.3) extra_config="${extra_config} --disable-gdbmi";;
+ esac
+
+ if [ "${CT_GDB_CROSS}" = "y" ]; then
+ CT_DoStep EXTRA "Installing cross-gdb"
+ CT_DoLog EXTRA "Configuring cross-gdb"
+
+ mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
+ cd "${CT_BUILD_DIR}/build-gdb-cross"
+
+ "${gdb_src_dir}/configure" \
+ --build=${CT_BUILD} \
+ --host=${CT_HOST} \
+ --target=${CT_TARGET} \
+ --prefix="${CT_INSTALL_DIR}" \
+ --with-build-sysroot="${CT_SYSROOT_DIR}" \
+ --enable-threads \
+ ${extra_config} 2>&1 |CT_DoLog ALL
+
+ CT_DoLog EXTRA "Building cross-gdb"
+ make ${PARALLELMFLAGS} 2>&1 |CT_DoLog ALL
+
+ CT_DoLog EXTRA "Installing cross-gdb"
+ make install 2>&1 |CT_DoLog ALL
+
+ CT_EndStep
+
+ CT_DoStep EXTRA "Installing gdbserver"
+ CT_DoLog EXTRA "Configuring gdbserver"
+
+ mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver"
+ cd "${CT_BUILD_DIR}/build-gdb-gdbserver"
+
+ # Workaround for bad versions, where the configure
+ # script for gdbserver is not executable...
+ # Bah, GNU folks strike again... :-(
+ chmod +x "${gdb_src_dir}/gdb/gdbserver/configure"
+
+ "${gdb_src_dir}/gdb/gdbserver/configure" \
+ --build=${CT_BUILD} \
+ --host=${CT_TARGET} \
+ --target=${CT_TARGET} \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --includedir="${CT_HEADERS_DIR}" \
+ --with-build-sysroot="${CT_SYSROOT_DIR}" \
+ --program-prefix= \
+ --without-uiout \
+ --disable-tui \
+ --disable-gdbtk \
+ --without-x \
+ --without-included-gettext \
+ ${extra_config} 2>&1 |CT_DoLog ALL
+
+ CT_DoLog EXTRA "Building gdbserver"
+ make ${PARALLELMFLAGS} CC=${CT_TARGET}-gcc 2>&1 |CT_DoLog ALL
+
+ CT_DoLog EXTRA "Installing gdbserver"
+ make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install 2>&1 |CT_DoLog ALL
+
+ CT_EndStep
+ fi
+
+ if [ "${CT_GDB_NATIVE}" = "y" ]; then
+ CT_DoStep EXTRA "Installing native gdb"
+ CT_DoLog EXTRA "Configuring native gdb"
+
+ mkdir -p "${CT_BUILD_DIR}/build-gdb-cross"
+ cd "${CT_BUILD_DIR}/build-gdb-cross"
+
+ "${gdb_src_dir}/configure" \
+ --build=${CT_BUILD} \
+ --host=${CT_TARGET} \
+ --target=${CT_TARGET} \
+ --prefix=/usr \
+ --with-build-sysroot="${CT_SYSROOT_DIR}" \
+ --without-uiout \
+ --disable-tui \
+ --disable-gdbtk \
+ --without-x \
+ --disable-sim \
+ --enable-gdbserver \
+ --without-included-gettext \
+ ${extra_config} 2>&1 |CT_DoLog ALL
+
+ CT_DoLog EXTRA "Building native gdb"
+ make ${PARALLELMFLAGS} CC=${CT_TARGET}-gcc 2>&1 |CT_DoLog ALL
+
+ CT_DoLog EXTRA "Installing native gdb"
+ make DESTDIR="${CT_DEBUG_INSTALL_DIR}" install 2>&1 |CT_DoLog ALL
+
+ CT_EndStep
+ fi
+}
diff --git a/scripts/build/kernel_linux.sh b/scripts/build/kernel_linux.sh
index fd50d23..8c0c7ef 100644
--- a/scripts/build/kernel_linux.sh
+++ b/scripts/build/kernel_linux.sh
@@ -117,6 +117,8 @@ do_kernel_install() {
INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \
${V_OPT} \
headers_check 2>&1 |CT_DoLog ALL
+
+ find "${CT_SYSROOT_DIR}" -type f -name '.check*' -exec rm {} \;
}
# Install kernel headers from oldish Mazur's sanitised headers.
diff --git a/scripts/crosstool.sh b/scripts/crosstool.sh
index ce40bd1..173c1be 100755
--- a/scripts/crosstool.sh
+++ b/scripts/crosstool.sh
@@ -10,14 +10,14 @@
# What this file does is prepare the environment, based upon the user-choosen
# options. It also checks the existing environment for un-friendly variables,
-# and checks for needed tools. It eventually calls the main build script.
+# and builds the tools.
-# User must set CT_TOP_DIR in is environment!
-# Once we can build out-of-tree, then this will have to go.
+# CT_TOP_DIR is set by the makefile. If we don't have it, something's gone horribly wrong...
if [ -z "${CT_TOP_DIR}" -o ! -d "${CT_TOP_DIR}" ]; then
# We don't have the functions right now, because we don't have CT_TOP_DIR.
# Do the print stuff by hand:
- echo "CT_TOP_DIR not set. You must set CT_TOP_DIR to the top directory where crosstool is installed."
+ echo "CT_TOP_DIR not set, or not a directory. Something's gone horribly wrong."
+ echo "Please send a bug report (see README)"
exit 1
fi
@@ -30,34 +30,22 @@ CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
# Log to a temporary file until we have built our environment
CT_ACTUAL_LOG_FILE="${CT_TOP_DIR}/$$.log"
-# Parse the configuration file
+# Are we configured? We'll need that later...
CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
+
+# Parse the configuration file
+# It has some info about the logging facility, so include it early
. "${CT_TOP_DIR}/.config"
-# Override the color scheme if needed
-if [ "${CT_LOG_USE_COLORS}" = "y" ]; then
- CT_ERROR_COLOR="${_A_NOR}${_A_BRI}${_F_RED}"
- CT_WARN_COLOR="${_A_NOR}${_A_BRI}${_F_YEL}"
- CT_INFO_COLOR="${_A_NOR}${_A_BRI}${_F_GRN}"
- CT_EXTRA_COLOR="${_A_NOR}${_A_DIM}${_F_GRN}"
- CT_DEBUG_COLOR="${_A_NOR}${_A_BRI}${_F_BLU}"
- CT_ALL_COLOR="${_A_NOR}${_A_DIM}${_F_WHI}"
- CT_NORMAL_COLOR="${_A_NOR}"
-else
- CT_ERROR_COLOR=
- CT_WARN_COLOR=
- CT_INFO_COLOR=
- CT_EXTRA_COLOR=
- CT_DEBUG_COLOR=
- CT_ALL_COLOR=
- CT_NORMAL_COLOR=
-fi
+# renice oursleves
+renice ${CT_NICE} $$ |CT_DoLog DEBUG
# Yes! We can do full logging from now on!
CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
-# renice oursleves
-renice ${CT_NICE} $$ |CT_DoLog DEBUG
+CT_DoStep DEBUG "Dumping crosstool-NG configuration"
+cat ${CT_TOP_DIR}/.config |egrep '^(# |)CT_' |CT_DoLog DEBUG
+CT_EndStep
# Some sanity checks in the environment and needed tools
CT_DoLog INFO "Checking environment sanity"
@@ -89,15 +77,15 @@ CT_HasOrAbort sed
CT_HasOrAbort bison
CT_HasOrAbort flex
-CT_DoStep DEBUG "Dumping crosstool-NG configuration"
-cat ${CT_TOP_DIR}/.config |egrep '^(# |)CT_' |CT_DoLog DEBUG
-CT_EndStep
-
CT_DoLog INFO "Building environment variables"
# Target triplet: CT_TARGET needs a little love:
CT_DoBuildTargetTriplet
+# Kludge: If any of the configured options needs CT_TARGET,
+# then rescan the options file now:
+. "${CT_TOP_DIR}/.config"
+
# Now, build up the variables from the user-configured options.
CT_KERNEL_FILE="${CT_KERNEL}-${CT_KERNEL_VERSION}"
CT_BINUTILS_FILE="binutils-${CT_BINUTILS_VERSION}"
@@ -111,14 +99,11 @@ CT_CC_FILE="${CT_CC}-${CT_CC_VERSION}"
CT_LIBC_FILE="${CT_LIBC}-${CT_LIBC_VERSION}"
[ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ] && CT_LIBFLOAT_FILE="libfloat-990616"
-# Kludge: If any of the configured options needs CT_TARGET,
-# then rescan the options file now:
-. "${CT_TOP_DIR}/.config"
-
# Where will we work?
CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
CT_SRC_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/src"
CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
+CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
# Make all path absolute, it so much easier!
CT_LOCAL_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_LOCAL_TARBALLS_DIR}\"`"
@@ -133,25 +118,52 @@ if [ -d "${CT_INSTALL_DIR}" ]; then
CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not removable" ! -w `dirname "${CT_INSTALL_DIR}"`
fi
+# Good, now grab a bit of informations on the system we're being run on,
+# just in case something goes awok, and it's not our fault:
+CT_SYS_USER="`id -un`"
+CT_SYS_HOSTNAME=`hostname -f 2>/dev/null || true`
+# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
+CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-`uname -n`}"
+CT_SYS_KERNEL=`uname -s`
+CT_SYS_REVISION=`uname -r`
+# MacOS X lacks '-o' :
+CT_SYS_OS=`uname -o || echo "Unknown (maybe MacOS-X)"`
+CT_SYS_MACHINE=`uname -m`
+CT_SYS_PROCESSOR=`uname -p`
+CT_SYS_GCC=`gcc -dumpversion`
+CT_SYS_TARGET=`${CT_TOP_DIR}/tools/config.guess`
+CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
+
+CT_DoLog EXTRA "Preparing working directories"
+
# Get rid of pre-existing installed toolchain and previous build directories.
# We need to do that _before_ we can safely log, because the log file will
# most probably be in the toolchain directory.
if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
+ chmod -R u+w "${CT_TARBALLS_DIR}.$$"
nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
fi
if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
+ chmod -R u+w "${CT_SRC_DIR}.$$"
nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
fi
if [ -d "${CT_BUILD_DIR}" ]; then
mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
+ chmod -R u+w "${CT_BUILD_DIR}.$$"
nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
fi
if [ -d "${CT_INSTALL_DIR}" ]; then
mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
+ chmod -R u+w "${CT_INSTALL_DIR}.$$"
nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
fi
+if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
+ mv "${CT_DEBUG_INSTALL_DIR}" "${CT_DEBUG_INSTALL_DIR}.$$"
+ chmod -R u+w "${CT_DEBUG_INSTALL_DIR}.$$"
+ nohup rm -rf "${CT_DEBUG_INSTALL_DIR}.$$" >/dev/null 2>&1 &
+fi
# Note: we'll always install the core compiler in its own directory, so as to
# not mix the two builds: core and final. Anyway, its generic, wether we use
@@ -163,24 +175,9 @@ mkdir -p "${CT_TARBALLS_DIR}"
mkdir -p "${CT_SRC_DIR}"
mkdir -p "${CT_BUILD_DIR}"
mkdir -p "${CT_INSTALL_DIR}"
+mkdir -p "${CT_DEBUG_INSTALL_DIR}"
mkdir -p "${CT_CC_CORE_PREFIX_DIR}"
-# Good, now grab a bit of informations on the system we're being run,
-# just in case something goes awok, and it's not our fault:
-CT_SYS_HOSTNAME=`hostname -f 2>/dev/null || true`
-# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
-CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-`uname -n`}"
-CT_SYS_KERNEL=`uname -s`
-CT_SYS_REVISION=`uname -r`
-# MacOS X lacks '-o' :
-CT_SYS_OS=`uname -o || echo "Unknown (maybe MacOS-X)"`
-CT_SYS_MACHINE=`uname -m`
-CT_SYS_PROCESSOR=`uname -p`
-CT_SYS_USER="`id -un`"
-CT_SYS_DATE=`CT_DoDate +%Y%m%d.%H%M%S`
-CT_SYS_GCC=`gcc -dumpversion`
-CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_SYS_DATE} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
-
# Redirect log to the actual log file now we can
# It's quite understandable that the log file will be installed in the install
# directory, so we must first ensure it exists and is writeable (above) before
@@ -270,9 +267,11 @@ esac
# Do that:
CT_DoLog EXTRA "Making build system tools available"
mkdir -p "${CT_PREFIX_DIR}/bin"
-for tool in ar; do
+for tool in ar gcc; do
ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
- ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}"
+ case "${CT_TOOLCHAIN_TYPE}" in
+ cross|native) ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}";;
+ esac
done
# Ha. cygwin host have an .exe suffix (extension) for executables.
@@ -317,6 +316,7 @@ CT_EndStep
. "${CT_TOP_DIR}/scripts/build/libc_${CT_LIBC}.sh"
. "${CT_TOP_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh"
. "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
+. "${CT_TOP_DIR}/scripts/build/debug.sh"
# Now for the job by itself. Go have a coffee!
CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
@@ -326,6 +326,7 @@ do_cc_core_get
do_libfloat_get
do_libc_get
do_cc_get
+do_debug_get
CT_EndStep
if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
@@ -336,10 +337,11 @@ if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
CT_DoStep INFO "Extracting and patching toolchain components"
do_kernel_extract
do_binutils_extract
- do_libc_extract
- do_libfloat_extract
do_cc_core_extract
+ do_libfloat_extract
+ do_libc_extract
do_cc_extract
+ do_debug_extract
CT_EndStep
if [ "${CT_ONLY_EXTRACT}" != "y" ]; then
@@ -353,6 +355,7 @@ if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
do_libc
do_cc
do_libc_finish
+ do_debug
# Create the aliases to the target tools
if [ -n "${CT_TARGET_ALIAS}" ]; then
@@ -370,18 +373,22 @@ if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
if [ "${CT_REMOVE_DOCS}" = "y" ]; then
CT_DoLog INFO "Removing installed documentation"
rm -rf "${CT_PREFIX_DIR}/"{man,info}
+ rm -rf "${CT_DEBUG_INSTALL_DIR}/usr/"{man,info}
fi
fi
fi
-CT_STOP_DATE=`CT_DoDate +%s%N`
-CT_STOP_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
-CT_DoLog INFO "Build completed at ${CT_STOP_DATE_HUMAN}"
-elapsed=$((CT_STOP_DATE-CT_STAR_DATE))
-elapsed_min=$((elapsed/(60*1000*1000*1000)))
-elapsed_sec=`printf "%02d" $(((elapsed%(60*1000*1000*1000))/(1000*1000*1000)))`
-elapsed_csec=`printf "%02d" $(((elapsed%(1000*1000*1000))/(10*1000*1000)))`
-CT_DoLog INFO "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
+# OK, now we're done, set the toolchain read-only
+# Don't log, the log file may become read-only any moment...
+chmod -R a-w "${CT_INSTALL_DIR}"
+
+# We stil have some small bits to log
+chmod u+w "${CT_LOG_FILE}"
+
+CT_DoEnd INFO
+
+# All files should now be read-only, log-file included
+chmod a-w "${CT_LOG_FILE}"
# Restore a 'normal' color setting
echo -en "${CT_NORMAL_COLOR}"
diff --git a/scripts/functions b/scripts/functions
index 3ba6a3f..66d9ad8 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -13,6 +13,8 @@ CT_OnError() {
CT_DoLog ERROR " called from \"${BASH_SOURCE[${depth}]}\" at line # ${BASH_LINENO[${depth}-1]} in function \"${FUNCNAME[${depth}]}\""
done
CT_DoLog ERROR "Look at \"${CT_ACTUAL_LOG_FILE}\" for more info on this error."
+ CT_STEP_COUNT=1
+ CT_DoEnd ERROR
exit $ret
}
trap CT_OnError ERR
@@ -28,25 +30,6 @@ CT_LOG_LEVEL_EXTRA=3
CT_LOG_LEVEL_DEBUG=4
CT_LOG_LEVEL_ALL=5
-# Attributes
-_A_NOR="\\033[0m"
-_A_BRI="\\033[1m"
-_A_DIM="\\033[2m"
-_A_UND="\\033[4m"
-_A_BRB="\\033[5m"
-_A_REV="\\033[7m"
-_A_HID="\\033[8m"
-
-# Fore colors
-_F_BLK="\\033[30m"
-_F_RED="\\033[31m"
-_F_GRN="\\033[32m"
-_F_YEL="\\033[33m"
-_F_BLU="\\033[34m"
-_F_MAG="\\033[35m"
-_F_CYA="\\033[36m"
-_F_WHI="\\033[37m"
-
# A function to log what is happening
# Different log level are available:
# - ERROR: A serious, fatal error occurred
@@ -84,10 +67,8 @@ CT_DoLog() {
l="`printf \"[%-5s]%*s%s%s\" \"${cur_L}\" \"${indent}\" \" \" \"${line}\"`"
# There will always be a log file, be it /dev/null
echo -e "${l}" >>"${CT_ACTUAL_LOG_FILE}"
- color="CT_${cur_L}_COLOR"
- normal="CT_NORMAL_COLOR"
if [ ${cur_l} -le ${max_level} ]; then
- echo -e "\r${!color}${l}${!normal}"
+ echo -e "\r${l}"
fi
if [ "${CT_LOG_PROGRESS_BAR}" = "y" ]; then
str=`CT_DoDate +%s`
@@ -105,7 +86,21 @@ CT_DoLog() {
return 0
}
-# Abort the execution with a error message
+# Tail message to be logged whatever happens
+# Usage: CT_DoEnd <level>
+CT_DoEnd()
+{
+ CT_STOP_DATE=`CT_DoDate +%s%N`
+ CT_STOP_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
+ CT_DoLog INFO "Build completed at ${CT_STOP_DATE_HUMAN}"
+ elapsed=$((CT_STOP_DATE-CT_STAR_DATE))
+ elapsed_min=$((elapsed/(60*1000*1000*1000)))
+ elapsed_sec=`printf "%02d" $(((elapsed%(60*1000*1000*1000))/(1000*1000*1000)))`
+ elapsed_csec=`printf "%02d" $(((elapsed%(1000*1000*1000))/(10*1000*1000)))`
+ CT_DoLog INFO "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
+}
+
+# Abort the execution with an error message
# Usage: CT_Abort <message>
CT_Abort() {
CT_DoLog ERROR "$1" >&2