This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Change log behaviour


Trevor, All,

On Monday 14 March 2011 22:37:15 Yann E. MORIN wrote:
> On Saturday 05 March 2011 06:14:46 Trevor Woerner wrote:
> > # HG changeset patch
> > # User Trevor Woerner <twoerner@gmail.com>
> > # Date 1299301856 18000
> > # Node ID 3beab6987d73cf9c011064ebb5866c75b7fd4509
> > # Parent  cd7bcbbd5cc9f2d3fafe5ac38fa15d6db1c31d14
> > Change log behaviour.
> > 
> > Generate the (uncompressed) log file in the location where the build
> > is being performed. Once the build is done, copy the log to the
> > install location and, optionally, compress it (at the install location)
> > if configured to do so while leaving the log in the build location
> > uncompressed.
> 
> That's not quite enough, unfortunately. In this case, you'll be missing
> the save/restore of the build.log in case restarting the build (see the
> option DEBUG_CT_SAVE_STEPS).
> 
> I'll do the change here, and push later tonight...

What about the attached?

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
diff --git a/ct-ng.in b/ct-ng.in
--- a/ct-ng.in
+++ b/ct-ng.in
@@ -165,7 +165,7 @@
 PHONY += clean
 clean::
 	@$(ECHO) "  CLEAN log"
-	$(SILENT)rm -f log.* .config.* ..config*
+	$(SILENT)rm -f build.log .config.* ..config*
 
 PHONY += distclean
 distclean:: clean
diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in
+++ b/scripts/crosstool-NG.sh.in
@@ -222,8 +222,6 @@
 # Don't eradicate directories if we need to restart
 if [ -z "${CT_RESTART}" ]; then
     # 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
         CT_DoForceRmdir "${CT_TARBALLS_DIR}"
     fi
@@ -264,25 +262,9 @@
 CT_DoExecLog DEBUG rm -f "${CT_PREFIX_DIR}/foo"
 
 # Kludge: CT_INSTALL_DIR and CT_PREFIX_DIR might have grown read-only if
-# the previous build was successful. To be able to move the logfile there,
-# switch them back to read/write
+# the previous build was successful.
 CT_DoExecLog ALL chmod -R u+w "${CT_INSTALL_DIR}" "${CT_PREFIX_DIR}"
 
-# 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
-# we can log there
-exec >/dev/null
-case "${CT_LOG_TO_FILE}" in
-    y)  CT_LOG_FILE="${CT_PREFIX_DIR}/build.log"
-        cat "${tmp_log_file}" >>"${CT_LOG_FILE}"
-        rm -f "${tmp_log_file}"
-        exec >>"${CT_LOG_FILE}"
-        ;;
-    *)  rm -f "${tmp_log_file}"
-        ;;
-esac
-
 # Setting up the rest of the environment only if not restarting
 if [ -z "${CT_RESTART}" ]; then
     case "${CT_SYSROOT_NAME}" in
@@ -624,7 +606,13 @@
 CT_DoLog INFO "Finishing installation (may take a few seconds)..."
 exec >/dev/null 2>&1
 
-[ "${CT_LOG_FILE_COMPRESS}" = y ] && bzip2 -9 "${CT_LOG_FILE}"
+if [ "${CT_LOG_TO_FILE}" = "y" ]; then
+    if [ "${CT_LOG_FILE_COMPRESS}" = y ]; then
+        bzip2 -9 -c "${tmp_log_file}"
+    else
+        cat "${tmp_log_file}"
+    fi >"${CT_PREFIX_DIR}/build.log"
+fi
 [ "${CT_INSTALL_DIR_RO}" = "y"  ] && chmod -R a-w "${CT_INSTALL_DIR}"
 [ "${CT_TEST_SUITE}" = "y" ] && chmod -R u+w "${CT_TEST_SUITE_DIR}"
 
diff --git a/scripts/functions b/scripts/functions
--- a/scripts/functions
+++ b/scripts/functions
@@ -15,7 +15,7 @@
     for((depth=2; ${BASH_LINENO[$((${depth}-1))]}>0; depth++)); do
         CT_DoLog ERROR "      called from '${BASH_SOURCE[${depth}]}' at line # ${BASH_LINENO[${depth}-1]} in function '${FUNCNAME[${depth}]}'"
     done
-    [ "${CT_LOG_TO_FILE}" = "y" ] && CT_DoLog ERROR "Look at '${CT_LOG_FILE}' for more info on this error."
+    [ "${CT_LOG_TO_FILE}" = "y" ] && CT_DoLog ERROR "Look at '${tmp_log_file}' for more info on this error."
     CT_STEP_COUNT=1
     CT_DoEnd ERROR
     exit $ret
@@ -40,8 +40,9 @@
 # Log policy:
 #  - first of all, save stdout so we can see the live logs: fd #6
 exec 6>&1
-#  - then point stdout to the log file (temporary for now)
-tmp_log_file="${CT_TOP_DIR}/log.$$"
+#  - then point stdout to the log file
+tmp_log_file="${CT_TOP_DIR}/build.log"
+rm -f "${tmp_log_file}"
 exec >>"${tmp_log_file}"
 
 # The different log levels:
@@ -1024,15 +1025,13 @@
     CT_DoTarballIfExists "${CT_CC_CORE_SHARED_PREFIX_DIR}" "${state_dir}/cc_core_shared_prefix_dir"
     CT_DoTarballIfExists "${CT_PREFIX_DIR}" "${state_dir}/prefix_dir" --exclude '*.log'
 
-    if [ "${CT_LOG_TO_FILE}" = "y" ]; then
-        CT_DoLog STATE "  Saving log file"
-        exec >/dev/null
-        case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
-            y)  gzip -3 -c "${CT_LOG_FILE}"  >"${state_dir}/log.gz";;
-            *)  cat "${CT_LOG_FILE}" >"${state_dir}/log";;
-        esac
-        exec >>"${CT_LOG_FILE}"
-    fi
+    CT_DoLog STATE "  Saving log file"
+    exec >/dev/null
+    case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
+        y)  gzip -3 -c "${tmp_log_file}"  >"${state_dir}/log.gz";;
+        *)  cat "${tmp_log_file}" >"${state_dir}/log";;
+    esac
+    exec >>"${tmp_log_file}"
 }
 
 # This function restores a previously saved state
@@ -1072,15 +1071,13 @@
     CT_STOP="${old_STOP}"
     unset old_stop old_restart
 
-    if [ "${CT_LOG_TO_FILE}" = "y" ]; then
-        CT_DoLog STATE "  Restoring log file"
-        exec >/dev/null
-        case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
-            y)  zcat "${state_dir}/log.gz" >"${CT_LOG_FILE}";;
-            *)  cat "${state_dir}/log" >"${CT_LOG_FILE}";;
-        esac
-        cat "${state_dir}/tail.log" >>"${CT_LOG_FILE}"
-        exec >>"${CT_LOG_FILE}"
-        rm -f "${state_dir}/tail.log"
-    fi
+    CT_DoLog STATE "  Restoring log file"
+    exec >/dev/null
+    case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in
+        y)  zcat "${state_dir}/log.gz" >"${tmp_log_file}";;
+        *)  cat "${state_dir}/log" >"${tmp_log_file}";;
+    esac
+    cat "${state_dir}/tail.log" >>"${tmp_log_file}"
+    exec >>"${tmp_log_file}"
+    rm -f "${state_dir}/tail.log"
 }

--
For unsubscribe information see http://sourceware.org/lists.html#faq

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]