Skip to content

Commit

Permalink
refactor: compile success without test
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhen3 authored and kernelai committed Dec 8, 2022
1 parent 07a6e0b commit 4693dfe
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 13 deletions.
63 changes: 59 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,65 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized" CACHE STRING

project (pika)

# aux_source_directory(./src DIR_SRCS)

# add_library(slash STATIC ${DIR_SRCS} )
add_subdirectory(third/rocksdb)
add_subdirectory(src/slash)
add_subdirectory(src/pink)
add_subdirectory(src/blackwidow)
add_subdirectory(src/blackwidow)

aux_source_directory(src DIR_SRCS)

## generate version
string(TIMESTAMP TS "%Y-%m-%d %H:%M:%S" UTC)
set(PIKA_BUILD_DATE "${TS}" CACHE STRING "the time we first built pika")

find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE PIKA_GIT_SHA COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD )
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE PIKA_GIT_MOD COMMAND "${GIT_EXECUTABLE}" diff-index HEAD --quiet)
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE PIKA_GIT_DATE COMMAND "${GIT_EXECUTABLE}" log -1 --date=format:"%Y-%m-%d %T" --format="%ad")
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE PIKA_GIT_TAG RESULT_VARIABLE rv COMMAND "${GIT_EXECUTABLE}" symbolic-ref -q --short HEAD OUTPUT_STRIP_TRAILING_WHITESPACE)
if (rv AND NOT rv EQUAL 0)
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE PIKA_GIT_TAG COMMAND "${GIT_EXECUTABLE}" describe --tags --exact-match OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
else()
set(PIKA_GIT_SHA 0)
set(PIKA_GIT_MOD 1)
endif()
string(REGEX REPLACE "[^0-9a-fA-F]+" "" PIKA_GIT_SHA "${PIKA_GIT_SHA}")
string(REGEX REPLACE "[^0-9: /-]+" "" PIKA_GIT_DATE "${PIKA_GIT_DATE}")

message("pika GIT_SHA = ${PIKA_GIT_SHA}")
message("pika GIT_MOD = ${PIKA_GIT_MOD}")
message("pika GIT_DATE = ${PIKA_GIT_DATE}")
message("pika GIT_TAG = ${PIKA_GIT_TAG}")
message("pika BUILD_DATE = ${PIKA_BUILD_DATE}")

set(PIKA_BUILD_VERSION_CC ${CMAKE_BINARY_DIR}/pika_build_version.cc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/build_version.cc.in ${PIKA_BUILD_VERSION_CC} @ONLY)


find_package(Protobuf REQUIRED)
set(PROTO_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/pika_inner_message.proto
)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
message("pika PROTO_SRCS = ${PROTO_SRCS}")
message("pika PROTO_HDRS = ${PROTO_HDRS}")
add_executable(${PROJECT_NAME}
${DIR_SRCS}
${PROTO_SRCS}
${PROTO_HDRS}
${PIKA_BUILD_VERSION_CC})
target_include_directories(${PROJECT_NAME}
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
PUBLIC ${PROJECT_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME}
blackwidow
pink
slash
rocksdb
pthread
gflags
glog
${Protobuf_LIBRARIES}
)
2 changes: 1 addition & 1 deletion include/pika_repl_bgworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "pink/include/bg_thread.h"
#include "pink/include/thread_pool.h"

#include "src/pika_inner_message.pb.h"
#include "pika_inner_message.pb.h"

#include "include/pika_command.h"
#include "include/pika_binlog_transverter.h"
Expand Down
2 changes: 1 addition & 1 deletion include/pika_repl_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "include/pika_repl_client_thread.h"

#include "pink/include/thread_pool.h"
#include "src/pika_inner_message.pb.h"
#include "pika_inner_message.pb.h"

using slash::Status;

Expand Down
2 changes: 1 addition & 1 deletion include/pika_repl_client_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <memory>

#include "include/pika_conf.h"
#include "src/pika_inner_message.pb.h"
#include "pika_inner_message.pb.h"

class SyncMasterPartition;
class SyncSlavePartition;
Expand Down
2 changes: 1 addition & 1 deletion include/pika_repl_server_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "pink/include/pink_thread.h"

#include "include/pika_define.h"
#include "src/pika_inner_message.pb.h"
#include "pika_inner_message.pb.h"

class SyncMasterPartition;

Expand Down
1 change: 1 addition & 0 deletions include/pika_statistic.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define PIKA_STATISTIC_H_

#include <atomic>
#include <string>
#include <unordered_map>

class QpsStatistic {
Expand Down
2 changes: 1 addition & 1 deletion src/blackwidow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ target_include_directories(blackwidow
PUBLIC ${PROJECT_SOURCE_DIR}/../../third/rocksdb
)
target_link_libraries(blackwidow
PUBLIC RocksDB
PUBLIC rocksdb
PUBLIC slash
)
6 changes: 3 additions & 3 deletions src/build_version.cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

#include "include/build_version.h"
const char* pika_build_git_sha =
"pika_git_sha:@@GIT_SHA@@";
const char* pika_build_git_date = "pika_build_git_date:@@GIT_DATE_TIME@@";
const char* pika_build_compile_date = __DATE__;
"pika_git_sha:@PIKA_GIT_SHA@";
const char* pika_build_git_date = "pika_build_git_date:@PIKA_GIT_DATE@";
const char* pika_build_compile_date = "pika_build_date:@PIKA_BUILD_DATE@";
1 change: 1 addition & 0 deletions src/pika_inner_message.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
syntax = "proto2";
package InnerMessage;

enum Type {
Expand Down
2 changes: 1 addition & 1 deletion src/pika_meta.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// of patent rights can be found in the PATENTS file in the same directory.

#include "include/pika_meta.h"
#include "src/pika_inner_message.pb.h"
#include "pika_inner_message.pb.h"

const uint32_t VERSION = 1;

Expand Down

0 comments on commit 4693dfe

Please sign in to comment.