Skip to content

Commit

Permalink
Cleanup package workflow (#2528)
Browse files Browse the repository at this point in the history
* Cleanup package scripts

* improve clang-format

* Format

* Format

* Check clang home exist
  • Loading branch information
yixinglu authored Aug 18, 2021
1 parent bdb6c37 commit a8a4e84
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 270 deletions.
12 changes: 7 additions & 5 deletions .linters/cpp/hooks/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ fi
echo "Performing C++ code format check..."

CLANG_HOME=/opt/vesoft/toolset/clang/10.0.0/
res=$(git diff -U0 --no-color --staged | $CLANG_HOME/share/clang/clang-format-diff.py -p1 -binary $CLANG_HOME/bin/clang-format)
if [[ ! -z $res ]]; then
echo "The code format is not well..."
echo $res
exit 1

if [ ! -d "$CLANG_HOME" ]; then
echo "The $CLANG_HOME directory is not found, and the source changes cannot be automatically formatted."
exit 0
fi

git diff -U0 --no-color --staged | $CLANG_HOME/share/clang/clang-format-diff.py -i -p1 -binary $CLANG_HOME/bin/clang-format
git add $CHECK_FILES
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ add_custom_target(

add_custom_target(
clang-format
COMMAND "find" "src/" "-type" "f" "\\(" "-iname" "\\*.h" "-o" "-iname" "\\*.cpp" "\\)" "-exec" "clang-format" "-i" "{}" "\\;"
COMMAND "find" "src/" "-type" "f" "\\(" "-iname" "\\*.h" "-o" "-iname" "\\*.cpp" "\\)" "|" "xargs" "clang-format" "-i"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
)

if (ENABLE_NATIVE)
message(STATUS "ENABLE_NATIVE is ${ENABLE_NATIVE}")
Expand Down Expand Up @@ -92,3 +92,11 @@ nebula_add_subdirectory(src)
nebula_add_subdirectory(conf)
nebula_add_subdirectory(resources)
nebula_add_subdirectory(scripts)

include(CPackage)
package(
${ENABLE_PACK_ONE}
"nebula"
"https://github.com/vesoft-inc/nebula/releases"
${CMAKE_SOURCE_DIR}/package
)
239 changes: 0 additions & 239 deletions package/CMakeLists.txt

This file was deleted.

23 changes: 7 additions & 16 deletions package/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# -b: Branch, default master
# -d: Whether to enable sanitizer, default OFF
# -t: Build type, default Release
# -j: Number of threads, default $(nproc)
#
# usage: ./package.sh -v <version> -n <ON/OFF> -s <TRUE/FALSE> -b <BRANCH>
#
Expand All @@ -18,7 +19,7 @@ set -e
version=""
package_one=ON
strip_enable="FALSE"
usage="Usage: ${0} -v <version> -n <ON/OFF> -s <TRUE/FALSE> -b <BRANCH> -g <ON/OFF>"
usage="Usage: ${0} -v <version> -n <ON/OFF> -s <TRUE/FALSE> -b <BRANCH> -g <ON/OFF> -j <jobs>"
project_dir="$(cd "$(dirname "$0")" && pwd)/.."
build_dir=${project_dir}/pkg-build
enablesanitizer="OFF"
Expand All @@ -27,7 +28,7 @@ build_type="Release"
branch="master"
jobs=$(nproc)

while getopts v:n:s:b:d:t:g: opt;
while getopts v:n:s:b:d:t:j:g: opt;
do
case $opt in
v)
Expand All @@ -52,6 +53,9 @@ do
t)
build_type=$OPTARG
;;
j)
jobs=$OPTARG
;;
?)
echo "Invalid option, use default arguments"
;;
Expand Down Expand Up @@ -114,20 +118,7 @@ function build {

# args: <strip_enable>
function package {
# The package CMakeLists.txt in ${project_dir}/package/build
package_dir=${build_dir}/package/
if [[ -d $package_dir ]]; then
rm -rf ${package_dir:?}/*
else
mkdir ${package_dir}
fi
pushd ${package_dir}
cmake \
-DNEBULA_BUILD_VERSION=${version} \
-DENABLE_PACK_ONE=${package_one} \
-DCMAKE_INSTALL_PREFIX=/usr/local/nebula \
${project_dir}/package/

pushd ${build_dir}
strip_enable=$1

args=""
Expand Down
5 changes: 5 additions & 0 deletions resources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) 2021 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License,
# attached with Common Clause Condition 1.0, found in the LICENSES directory.

install(
FILES
gflags.json
Expand Down
12 changes: 12 additions & 0 deletions src/daemons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ nebula_add_executable(
install(
TARGETS
nebula-graphd
PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
DESTINATION
bin
COMPONENT
Expand All @@ -141,6 +145,10 @@ install(
install(
TARGETS
nebula-storaged
PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
DESTINATION
bin
COMPONENT
Expand All @@ -150,6 +158,10 @@ install(
install(
TARGETS
nebula-metad
PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
DESTINATION
bin
COMPONENT
Expand Down
Loading

0 comments on commit a8a4e84

Please sign in to comment.