From 0c6baf3c95c8e8e364ad8175daaf6d62d0020e78 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Fri, 13 May 2022 11:28:26 +0800 Subject: [PATCH] refine directory of build-time (#42717) --- CMakeLists.txt | 4 ++-- tools/get_build_time.sh | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51c0ef35f1e..433081ee225 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,8 +256,8 @@ option(WITH_CUSTOM_DEVICE "Compile with custom device support" OFF) option(WITH_ARM_BRPC "Supprot Brpc in Arm" OFF) if(WITH_RECORD_BUILDTIME) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_CURRENT_SOURCE_DIR}/tools/get_build_time.sh") - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CMAKE_CURRENT_SOURCE_DIR}/tools/get_build_time.sh") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_CURRENT_SOURCE_DIR}/tools/get_build_time.sh ${CMAKE_CURRENT_BINARY_DIR}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CMAKE_CURRENT_SOURCE_DIR}/tools/get_build_time.sh ${CMAKE_CURRENT_BINARY_DIR}") else() include(ccache) # set ccache for compilation ; if WITH_RECORD_BUILDTIME=ON can't use ccache endif() diff --git a/tools/get_build_time.sh b/tools/get_build_time.sh index 1563fefff37..496c8c12d6c 100755 --- a/tools/get_build_time.sh +++ b/tools/get_build_time.sh @@ -14,9 +14,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -CUR_ROOT=$(dirname "$0")/.. +CMAKE_BINARY_DIR=$1 +shift start=$(date +%s.%N) duration=$("/usr/bin/time" -f "%C, %E elapsed, %U user, %S sys" "$@" 2>&1) end=$(date +%s.%N) -echo ${duration}, 'start', $start, 'end', $end, 'process', $$ >> $CUR_ROOT/build/build-time +echo ${duration}, 'start', $start, 'end', $end, 'process', $$ >> $CMAKE_BINARY_DIR/build-time -- GitLab