From 337b1e562e0d8ee5ed682282e70d770a1885b885 Mon Sep 17 00:00:00 2001 From: nebula-bots <88429921+nebula-bots@users.noreply.github.com> Date: Thu, 2 Sep 2021 17:00:57 +0800 Subject: [PATCH] Cleanup package workflow (#18) * Cleanup package scripts * improve clang-format * Format * Format * Check clang home exist Co-authored-by: yixinglu <2520865+yixinglu@users.noreply.github.com> --- .linters/cpp/hooks/pre-commit.sh | 12 +- CMakeLists.txt | 12 +- package/CMakeLists.txt | 239 --------------------------- package/package.sh | 23 +-- resources/CMakeLists.txt | 5 + src/daemons/CMakeLists.txt | 12 ++ src/graph/optimizer/OptimizerUtils.h | 12 +- src/tools/db-dump/CMakeLists.txt | 4 + src/tools/db-upgrade/CMakeLists.txt | 4 + src/tools/meta-dump/CMakeLists.txt | 4 + 10 files changed, 57 insertions(+), 270 deletions(-) delete mode 100644 package/CMakeLists.txt diff --git a/.linters/cpp/hooks/pre-commit.sh b/.linters/cpp/hooks/pre-commit.sh index 0115421e00c..21472b3c5c7 100755 --- a/.linters/cpp/hooks/pre-commit.sh +++ b/.linters/cpp/hooks/pre-commit.sh @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bb9bc850c6..f9905dc68b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}") @@ -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 +) diff --git a/package/CMakeLists.txt b/package/CMakeLists.txt deleted file mode 100644 index 17cee4000f2..00000000000 --- a/package/CMakeLists.txt +++ /dev/null @@ -1,239 +0,0 @@ -# Copyright (c) 2020 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. -# -# CMakeLists.txt file contains a set of directives and instructions describing -# the project's source files and targets (executable, library, or both). -# -# The building can be controlled by defining the following variables on the -# command line. -# -# ENABLE_PACK_ONE -- Package to one or multi packages -# - -# CMake version check -cmake_minimum_required(VERSION 3.5.0) - -# Set the project name -project("Nebula Package") - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake") - -message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}") - -if(NOT NEBULA_SOURCE_DIR) - set(NEBULA_SOURCE_DIR ${CMAKE_BINARY_DIR}/../../) -endif() - -if(NOT NEBULA_BINARY_DIR) - set(NEBULA_BINARY_DIR ${CMAKE_BINARY_DIR}/../) -endif() - -message(STATUS "NEBULA_SOURCE_DIR : ${NEBULA_SOURCE_DIR}") -message(STATUS "NEBULA_BINARY_DIR : ${NEBULA_BINARY_DIR}") - -install( - FILES - ${NEBULA_BINARY_DIR}/bin/nebula-storaged - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - bin - COMPONENT - storage -) - -install( - FILES - ${NEBULA_BINARY_DIR}/bin/nebula-metad - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - bin - COMPONENT - meta -) - -install( - FILES - ${NEBULA_BINARY_DIR}/bin/nebula-graphd - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - bin - COMPONENT - graph -) - -install( - FILES - ${NEBULA_BINARY_DIR}/bin/db_dump - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - bin - COMPONENT - tool -) - -install( - FILES - ${NEBULA_BINARY_DIR}/bin/meta_dump - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - bin - COMPONENT - tool -) - -install( - FILES - ${NEBULA_BINARY_DIR}/bin/db_upgrader - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - bin - COMPONENT - tool -) - -install( - FILES - ${NEBULA_SOURCE_DIR}/conf/nebula-storaged.conf.default - ${NEBULA_SOURCE_DIR}/conf/nebula-storaged.conf.production - ${NEBULA_SOURCE_DIR}/conf/nebula-storaged-listener.conf.production - PERMISSIONS - OWNER_READ - GROUP_READ - WORLD_READ - DESTINATION - etc - COMPONENT - storage -) - -install( - FILES - ${NEBULA_SOURCE_DIR}/conf/nebula-metad.conf.default - ${NEBULA_SOURCE_DIR}/conf/nebula-metad.conf.production - PERMISSIONS - OWNER_READ - GROUP_READ - WORLD_READ - DESTINATION - etc - COMPONENT - meta -) - -install( - FILES - ${NEBULA_SOURCE_DIR}/conf/nebula-graphd.conf.default - ${NEBULA_SOURCE_DIR}/conf/nebula-graphd.conf.production - PERMISSIONS - OWNER_READ - GROUP_READ - WORLD_READ - DESTINATION - etc - COMPONENT - graph -) - -install( - FILES - ${NEBULA_SOURCE_DIR}/scripts/nebula-storaged.service - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - scripts - COMPONENT - storage -) - -install( - FILES - ${NEBULA_SOURCE_DIR}/scripts/nebula-metad.service - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - scripts - COMPONENT - meta -) - -install( - FILES - ${NEBULA_SOURCE_DIR}/scripts/nebula-graphd.service - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - scripts - COMPONENT - graph -) - -install( - FILES - ${NEBULA_SOURCE_DIR}/scripts/nebula.service - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - scripts - COMPONENT - common -) - -install( - FILES - ${NEBULA_SOURCE_DIR}/scripts/utils.sh - PERMISSIONS - OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - DESTINATION - scripts - COMPONENT - common -) - -install( - FILES - ${NEBULA_SOURCE_DIR}/resources/gflags.json - PERMISSIONS - OWNER_WRITE OWNER_READ - GROUP_READ - WORLD_READ - DESTINATION - share/resources - COMPONENT - common -) - -include(CPackage) -package(${ENABLE_PACK_ONE} - "nebula" - "https://github.com/vesoft-inc/nebula/releases" - ${CMAKE_SOURCE_DIR}) diff --git a/package/package.sh b/package/package.sh index 07fb9819f6a..c987aba2244 100755 --- a/package/package.sh +++ b/package/package.sh @@ -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 -n -s -b # @@ -18,7 +19,7 @@ set -e version="" package_one=ON strip_enable="FALSE" -usage="Usage: ${0} -v -n -s -b -g " +usage="Usage: ${0} -v -n -s -b -g -j " project_dir="$(cd "$(dirname "$0")" && pwd)/.." build_dir=${project_dir}/pkg-build enablesanitizer="OFF" @@ -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) @@ -52,6 +53,9 @@ do t) build_type=$OPTARG ;; + j) + jobs=$OPTARG + ;; ?) echo "Invalid option, use default arguments" ;; @@ -114,20 +118,7 @@ function build { # args: 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="" diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 361f2d3096a..eeea0964ef3 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -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 diff --git a/src/daemons/CMakeLists.txt b/src/daemons/CMakeLists.txt index 613a3a5278e..65439480f29 100644 --- a/src/daemons/CMakeLists.txt +++ b/src/daemons/CMakeLists.txt @@ -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 @@ -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 @@ -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 diff --git a/src/graph/optimizer/OptimizerUtils.h b/src/graph/optimizer/OptimizerUtils.h index b7c9bf7892a..02d8efe1bee 100644 --- a/src/graph/optimizer/OptimizerUtils.h +++ b/src/graph/optimizer/OptimizerUtils.h @@ -75,19 +75,15 @@ class OptimizerUtils { // 2. for multiple columns combined index: // * iterate each field of index // * iterate each operand expression of filter condition - // * collect all column hints generated by operand expression for each - // index field - // * process collected column hints, for example, merge the begin and end - // values of + // * collect all column hints generated by operand expression for each index field + // * process collected column hints, for example, merge the begin and end values of // range scan // 3. sort all index results generated by each index // 4. select the largest score index result // 5. process the selected index result: - // * find the first not prefix column hint and ignore all followed hints - // except first + // * find the first not prefix column hint and ignore all followed hints except first // range hint - // * check whether filter conditions are used, if not, place the unused - // expression parts + // * check whether filter conditions are used, if not, place the unused expression parts // into column hint filter // // For logical `OR' condition expression, use above steps to generate diff --git a/src/tools/db-dump/CMakeLists.txt b/src/tools/db-dump/CMakeLists.txt index d19ab21c98c..d5f419ffad2 100644 --- a/src/tools/db-dump/CMakeLists.txt +++ b/src/tools/db-dump/CMakeLists.txt @@ -60,6 +60,10 @@ nebula_add_executable( install( TARGETS db_dump + PERMISSIONS + OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ DESTINATION bin COMPONENT diff --git a/src/tools/db-upgrade/CMakeLists.txt b/src/tools/db-upgrade/CMakeLists.txt index 52dece5cbb3..bf7a64c065f 100644 --- a/src/tools/db-upgrade/CMakeLists.txt +++ b/src/tools/db-upgrade/CMakeLists.txt @@ -57,6 +57,10 @@ nebula_add_executable( install( TARGETS db_upgrader + PERMISSIONS + OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ DESTINATION bin COMPONENT diff --git a/src/tools/meta-dump/CMakeLists.txt b/src/tools/meta-dump/CMakeLists.txt index 0e816950472..64758a8b4f6 100644 --- a/src/tools/meta-dump/CMakeLists.txt +++ b/src/tools/meta-dump/CMakeLists.txt @@ -56,6 +56,10 @@ nebula_add_executable( install( TARGETS meta_dump + PERMISSIONS + OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ DESTINATION bin COMPONENT