[Swift-commit] r6096 - branches/release-0.94/libexec

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Mon Dec 3 16:41:08 CST 2012


Author: davidk
Date: 2012-12-03 16:41:08 -0600 (Mon, 03 Dec 2012)
New Revision: 6096

Modified:
   branches/release-0.94/libexec/_swiftwrap
Log:
Fix for #887


Modified: branches/release-0.94/libexec/_swiftwrap
===================================================================
--- branches/release-0.94/libexec/_swiftwrap	2012-11-29 21:39:48 UTC (rev 6095)
+++ branches/release-0.94/libexec/_swiftwrap	2012-12-03 22:41:08 UTC (rev 6096)
@@ -1,3 +1,4 @@
+
 #!/bin/bash
 # this script must be invoked inside of bash, not plain sh
 # note that this script modifies $IFS
@@ -475,17 +476,33 @@
 	fail 254 "The executable $EXEC does not have the executable bit set"
 fi
 if [ "$KICKSTART" == "" ]; then
+
+    TIMEARGS=(-o swiftapp.resources -f APP_RESOURCES=real_time:%E,real_secs:%e,kernel_secs:%S,user_secs:%U,percent_cpu:%P,max_rss:%M,avg_rss:%t,avg_tot_vm:%K,avg_priv_data:%D,avg_priv_stack:%p,avg_shared_text:%X,page_size:%Z,major_pgfaults:%F,minor_pgfaults:%R,swaps:%W,invol_context_switches:%c,vol_waits%w,fs_reads:%I,fs_writes:%O,sock_recv:%r,sock_send:%s,signals:%k,exit_status:%x,command:%C)
+
+    if [ -x /usr/bin/time ]; then
+        TIMECMD="/usr/bin/time"
+    elif [ -x $HOME/swift.time ]; then
+        TIMECMD="$HOME/swift.time"
+    else
+        TIMECMD=""
+		TIMEARGS=""
+    fi
 	if [ "$STDIN" == "" ]; then
 		if [ "$SWIFT_GEN_SCRIPTS" != "" ]; then
 			genScripts
 		fi
-		"$EXEC" "${CMDARGS[@]}" 1>>"$STDOUT" 2>>"$STDERR"
+        "$TIMECMD" "${TIMEARGS[@]}" "$EXEC" "${CMDARGS[@]}" 1>>"$STDOUT" 2>>"$STDERR"
 	else
 		if [ "$SWIFT_GEN_SCRIPTS" != "" ]; then
 			genScripts
 		fi
-		"$EXEC" "${CMDARGS[@]}" 1>>"$STDOUT" 2>>"$STDERR" <"$STDIN"
+        "$TIMECMD" "${TIMEARGS[@]}" "$EXEC" "${CMDARGS[@]}" 1>>"$STDOUT" 2>>"$STDERR" <"$STDIN"
 	fi
+    TIME_EC=$?
+    if [ "_$TIMECMD" != _ ]; then
+		log "$(cat swiftapp.resources)"
+    fi
+    sh -c "exit $TIME_EC"
 	checkError $? "Application $EXEC failed with an exit code of $?"
 else
 	if [ ! -f "$KICKSTART" ]; then




More information about the Swift-commit mailing list