Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add root dir etc for misc #381

Merged
merged 6 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/import_braft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4

- name: Build
run: bash ci/build.sh
run: bash ./etc/script/ci/build.sh

- name: Check Format
working-directory: ${{ github.workspace }}/build
Expand All @@ -27,12 +27,12 @@ jobs:
- uses: actions/checkout@v4

- name: Build --verbose
env:
env:
CPLUS_INCLUDE_PATH: /opt/homebrew/include
run: |
brew install autoconf
brew install go
sh build.sh
bash ./etc/script/build.sh

- name: Run Go E2E Tests
working-directory: ${{ github.workspace }}/build-release
Expand All @@ -50,7 +50,7 @@ jobs:

- name: Build
run: |
bash build.sh --verbose
bash ./etc/script/build.sh --verbos

- name: Run Go E2E Tests
working-directory: ${{ github.workspace }}/build-release
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pikiwidb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4

- name: Build
run: bash ci/build.sh
run: bash ./etc/script/ci/build.sh

- name: Check Format
working-directory: ${{ github.workspace }}/build
Expand All @@ -30,7 +30,7 @@ jobs:
run: |
brew install autoconf
brew install go
sh build.sh --verbose
bash ./etc/script/build.sh --verbose

- name: GTest
working-directory: ${{ github.workspace }}/build-release
Expand All @@ -54,7 +54,7 @@ jobs:

- name: Build
run: |
bash build.sh --verbose
bash ./etc/script/build.sh --verbose

- name: GTest
working-directory: ${{ github.workspace }}/build-release
Expand All @@ -67,4 +67,4 @@ jobs:
run: |
cd ../tests
go mod tidy
go test -timeout 15m
go test -timeout 15m
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Build
run: |
bash build.sh
bash ./etc/script/build.sh

- name: Calculate checksum and rename binary
working-directory: ${{ github.workspace }}/bin
Expand Down
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
*.obj
*pb.cc
*pb.h
build
cmake-build-debug
cmake-build-release
deps-debug/
deps-release/
cmake-build-debug/
cmake-build-release/
cmake-build-release-release/
build/
build-debug/
build-release/

# Precompiled Headers
*.gch
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A C++20 implementation of Redis Server, use RocksDB for persist storage.(not inc
## Requirements

* C++20
* Linux or OS X
* Linux or OS X or FreeBSD

## compile

Expand All @@ -28,14 +28,14 @@ scl enable devtoolset-11 bash
Execute this command to start compiling Pikiwidb:

```bash
./build.sh
sh ./etc/script/build.sh
```

Pikiwidb is compiled by default in release mode, which does not support debugging. If debugging is needed, compile in debug mode.

```bash
./clear.sh
./build.sh --debug
sh ./etc/script/build.sh --clear
sh ./etc/script/build.sh --debug
```

## Support module for write your own extensions
Expand Down
8 changes: 4 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ C++20 实现的增强版 Redis 服务器,使用 RocksDB 作为持久化存储引
## 环境需求

* C++20、CMake
* Linux 或 MAC OS
* Linux 或 MAC OS 或 FreeBSD

## 编译

Expand All @@ -28,14 +28,14 @@ scl enable devtoolset-11 bash
执行以下命令开始编译 PikiwiDB:

```bash
./build.sh
sh ./etc/script/build.sh
```

PikiwiDB 默认以 release 模式编译,不支持调试。如果需要调试,请以 debug 模式编译。

```bash
./clear.sh
./build.sh --debug
sh ./etc/script/build.sh --clear
sh ./etc/script/build.sh --debug
```

## 与 Redis 完全兼容
Expand Down
87 changes: 0 additions & 87 deletions build.sh

This file was deleted.

14 changes: 0 additions & 14 deletions clear.sh

This file was deleted.

5 changes: 4 additions & 1 deletion cmake/rocksdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ ExternalProject_Add(
extern_rocksdb
${EXTERNAL_PROJECT_LOG_ARGS}
GIT_REPOSITORY https://github.com/facebook/rocksdb.git
GIT_TAG v8.3.3
GIT_TAG v9.4.0
URL https://github.com/facebook/rocksdb/archive/refs/tags/v9.4.0.tar.gz
URL_HASH MD5=ce19cb3e2b6db927ef88cbf25c42097e
DOWNLOAD_NO_PROGRESS 1
DEPENDS
gflags
snappy
Expand Down
File renamed without changes.
127 changes: 127 additions & 0 deletions etc/script/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/bin/bash

#color code
C_RED="\033[31m"
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=""
MAKE_FLAGS=""
PREFIX="cmake-build"

PWD=`pwd`
PROJECT_HOME="${PWD}/"
CONF="${PROJECT_HOME}/etc/conf/pikiwidb.conf"

function build() {
if [ ! -f "/proc/cpuinfo" ];then
CPU_CORE=$(sysctl -n hw.ncpu)
else
CPU_CORE=$(cat /proc/cpuinfo| grep "processor"| wc -l)
fi
if [ ${CPU_CORE} -eq 0 ]; then
CPU_CORE=1
fi

echo "cpu core ${CPU_CORE}"

echo "BUILD_TYPE:" $BUILD_TYPE
echo "CMAKE_FLAGS:" $CMAKE_FLAGS
echo "MAKE_FLAGS:" $MAKE_FLAGS

if [ "${BUILD_TYPE}" == "Release" ]; then
PREFIX="${PREFIX}-release"
else
PREFIX="${PREFIX}-debug"
fi

cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${CMAKE_FLAGS} -S . -B ${PREFIX}
cmake --build ${PREFIX} -- ${MAKE_FLAGS} -j ${CPU_CORE}
AlexStocks marked this conversation as resolved.
Show resolved Hide resolved

if [ $? -eq 0 ]; then
# echo -e "pikiwidb compile complete, output file ${C_GREEN} ${PREFIX}/bin/pikiwidb ${C_END}"
echo -e "pikiwidb compile complete, output file ${C_GREEN} ./bin/pikiwidb ${C_END}"
else
echo -e "${C_RED} pikiwidb compile fail ${C_END}"
exit 1
fi
}

# ":?" makes sure the bash var is not empty.
function clear() {
rm -rf ${PROJECT_HOME:?}/deps-debug
rm -rf ${PROJECT_HOME:?}/deps-release
rm -rf ${PROJECT_HOME:?}/cmake-build-debug
rm -rf ${PROJECT_HOME:?}/cmake-build-release
rm -rf ${PROJECT_HOME:?}/cmake-build-release-release
rm -rf ${PROJECT_HOME:?}/build
rm -rf ${PROJECT_HOME:?}/build-release
rm -rf ${PROJECT_HOME:?}/build-debug
rm -rf ${PROJECT_HOME:?}/bin
exit 0
}

function show_help() {
echo "
sh $0 --debug compile with debug
sh $0 --clear clear compilation directory
sh $0 -h|--help show help
sh $0 --prefix compile output path
sh $0 --verbose compile with verbose
"
exit 0
}

# ARGS=`getopt -a -o h -l help,debug,verbose,prefix: -- "$@"`
# Convert the parsed arguments into an array
# eval set -- "$ARGS"

while true; do
# echo "hello first arg $1"
case "$1" in
-c|--clear)
clear
shift ;;

--debug)
BUILD_TYPE=debug
;;

-h|--help)
show_help
;;

--prefix)
if [[ -n $2 ]]; then
PREFIX=$2
else
echo "you should provide a value for --prefix as output path"
exit 0
fi
AlexStocks marked this conversation as resolved.
Show resolved Hide resolved
shift;;

--verbose)
CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
MAKE_FLAGS="${MAKE_FLAGS} VERBOSE=1"
;;

--)
shift
break;;

*)
break;;
esac
shift
done

build
File renamed without changes.
2 changes: 1 addition & 1 deletion pikiwidbtests.sh → etc/script/pikiwidbtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function setup_pikiwidb_bin {
exit 1
fi
cp $PIKIWIDB_BIN src/redis-server
cp ./pikiwidb.conf tests/assets/default.conf
cp ./etc/conf/pikiwidb.conf tests/assets/default.conf
}


Expand Down
Loading
Loading