Skip to content

Commit

Permalink
fix: build info not add to code, put the git information in cmake (#49)
Browse files Browse the repository at this point in the history
* fix build info not add to code, put the git information in cmake

* format code
  • Loading branch information
lqxhub authored Oct 19, 2024
1 parent fa167e6 commit 8d41ffd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ ELSEIF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
ENDIF ()
ENDIF ()

EXECUTE_PROCESS(
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

EXECUTE_PROCESS(
COMMAND date "+%Y-%m-%d %H:%M:%S %Z%z"
OUTPUT_VARIABLE BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)

MESSAGE (status "GIT_COMMIT_HASH: ${GIT_COMMIT_HASH}")
MESSAGE (status "GIT_COMMIT_DATE: ${BUILD_DATE}")

ADD_DEFINITIONS(-DKkiwi_GIT_COMMIT_ID=\"${GIT_COMMIT_HASH}\")
ADD_DEFINITIONS(-DKkiwi_BUILD_DATE=\"${BUILD_DATE}\")

IF(CMAKE_BUILD_TYPE STREQUAL "Release")
MESSAGE("Building in Release mode")
ELSE()
Expand Down
6 changes: 0 additions & 6 deletions etc/script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ C_GREEN="\033[32m"

C_END="\033[0m"

BUILD_TIME=$(git log -1 --format=%ai)
BUILD_TIME=${BUILD_TIME: 0: 10}

COMMIT_ID=$(git rev-parse HEAD)
SHORT_COMMIT_ID=${COMMIT_ID: 0: 8}

BUILD_TYPE=Release
VERBOSE=0
CMAKE_FLAGS=""
Expand Down
11 changes: 4 additions & 7 deletions src/kiwi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@
incarnation.
*/

#include "kiwi.h"

#include <getopt.h>
#include <sys/fcntl.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <thread>

#include "praft/praft.h"
#include "pstd/log.h"
#include "pstd/pstd_util.h"

#include "client.h"
#include "config.h"
#include "helper.h"
#include "kiwi.h"
#include "kiwi_logo.h"
#include "praft/praft.h"
#include "pstd/log.h"
#include "pstd/pstd_util.h"
#include "slow_log.h"
#include "store.h"

Expand Down

0 comments on commit 8d41ffd

Please sign in to comment.