diff --git a/.github/workflows/cpp_workflow.yml b/.github/workflows/cpp_workflow.yml index 5f75d524..8a385b23 100644 --- a/.github/workflows/cpp_workflow.yml +++ b/.github/workflows/cpp_workflow.yml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +env: + RUST_BACKTRACE: 1 + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true jobs: build: @@ -112,7 +115,7 @@ jobs: - name: Build for windows if: runner.os == 'Windows' run: | - mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DTESTS=OFF -DBUILD_SDK=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake ../ + mkdir -p cpp/build && cd cpp/build && cmake -DCMAKE_BUILD_TYPE=Release -DTESTS=OFF -DBUILD_SDK=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake ../ cmake --build . --parallel 3 - name: Build for linux if: runner.os == 'Linux' @@ -132,5 +135,90 @@ jobs: - name: Test if: runner.os != 'Windows' run: | - cd cpp/build && CTEST_OUTPUT_ON_FAILURE=TRUE ctest - make cov \ No newline at end of file + cd cpp/build && CTEST_OUTPUT_ON_FAILURE=TRUE make test + make cov + - uses: actions/upload-artifact@v2 + if: runner.os == 'macos' + with: + name: libppc-crypto-sdk-jni.dylib + path: ./cpp/ppc-crypto-c-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.dylib + - uses: actions/upload-artifact@v2 + if: runner.os == 'Windows' + with: + name: libppc-crypto-sdk-jni.dylib + path: D:\a\WeDPR-Component\cpp\ppc-crypto-c-sdk\bindings\java\src\main\resources\META-INF\native\Release\ppc-crypto-sdk-jni.dll + + build_centos: + name: build_centos full node + runs-on: ${{ matrix.os }} + continue-on-error: true + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04] + container: docker.io/centos:7 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 5 + - uses: actions/cache@v2 + id: deps_cache + with: + path: | + /home/runner/.ccache + /Users/runner/.ccache/ + deps/ + key: centos-notest-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} + restore-keys: | + centos-notest-${{ matrix.os }}-${{ github.base_ref }}-${{ hashFiles('.github/workflows/workflow.yml') }} + centos-notest-${{ matrix.os }}-${{ github.base_ref }}- + centos-notest-${{ matrix.os }}- + - name: Prepare centos tools + run: | + sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo + sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo + sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo + yum install -y java-11-openjdk-devel git make gcc gcc-c++ glibc-static glibc-devel openssl cmake3 ccache devtoolset-11 llvm-toolset-7.0 rh-perl530-perl libzstd-devel zlib-devel flex bison python-devel python3-devel + yum install -y devtoolset-10 devtoolset-11 llvm-toolset-7 rh-perl530-perl cmake3 zlib-devel ccache lcov python-devel python3-devel + yum install -y https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm + yum install -y git + - name: Prepare vcpkg + if: runner.os != 'Windows' + uses: friendlyanon/setup-vcpkg@v1 + with: { committish: 7e3dcf74e37034eea358934a90a11d618520e139 } + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly-2022-07-28 + override: true + - name: Build + run: | + alias cmake='cmake3' + . /opt/rh/devtoolset-10/enable + . /opt/rh/rh-perl530/enable + export LIBCLANG_PATH=/opt/rh/llvm-toolset-7/root/lib64/ + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + . /opt/rh/llvm-toolset-7/enable + mkdir -p cpp/build + cd cpp/build + cmake3 -DCMAKE_BUILD_TYPE=Release -DTESTS=ON -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake ../ + cmake3 --build . --parallel 3 + - name: Test + run: | + export OMP_NUM_THREADS=1 + cd build && CTEST_OUTPUT_ON_FAILURE=TRUE make test + - uses: actions/upload-artifact@v2 + with: + name: ppc-air-node-centos-x64 + path: ./cpp/build/bin/ppc-air-node + - uses: actions/upload-artifact@v2 + with: + name: ppc-pro-node-centos-x64 + path: ./cpp/build/bin/ppc-pro-node + - uses: actions/upload-artifact@v2 + with: + name: ppc-gateway-service-centos-x64 + path: ./cpp/build/bin/ppc-gateway-service + - uses: actions/upload-artifact@v2 + with: + name: libppc-crypto-sdk-jni.so + path: ./cpp/ppc-crypto-c-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.so \ No newline at end of file diff --git a/cpp/cmake/Coverage.cmake b/cpp/cmake/Coverage.cmake new file mode 100644 index 00000000..fb69db2a --- /dev/null +++ b/cpp/cmake/Coverage.cmake @@ -0,0 +1,31 @@ +# ------------------------------------------------------------------------------ +# Copyright (C) 2021 FISCO BCOS. +# SPDX-License-Identifier: Apache-2.0 +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------------------------ +# File: Coverage.cmake +# Function: Define coverage related functions +# ------------------------------------------------------------------------------ +# REMOVE_FILE_PATTERN eg.: +function(config_coverage TARGET REMOVE_FILE_PATTERN) + find_program(LCOV_TOOL lcov) + message(STATUS "lcov tool: ${LCOV_TOOL}") + if (LCOV_TOOL) + add_custom_target(${TARGET} + COMMAND ${LCOV_TOOL} -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -d ${CMAKE_BINARY_DIR}/ + COMMAND ${LCOV_TOOL} -r ${CMAKE_BINARY_DIR}/coverage.info.in ${REMOVE_FILE_PATTERN} -o ${CMAKE_BINARY_DIR}/coverage.info + COMMAND genhtml -q -o ${CMAKE_BINARY_DIR}/CodeCoverage ${CMAKE_BINARY_DIR}/coverage.info) + else () + message(FATAL_ERROR "Can't find lcov tool. Please install lcov") + endif() +endfunction() \ No newline at end of file diff --git a/cpp/cmake/Dependencies.cmake b/cpp/cmake/Dependencies.cmake index 4354187e..ff1000b4 100644 --- a/cpp/cmake/Dependencies.cmake +++ b/cpp/cmake/Dependencies.cmake @@ -41,11 +41,9 @@ endif() ##### the full-dependencies end ##### ##### the sdk-dependencies ##### -if(BUILD_SDK) - # find JNI - set(JAVA_AWT_LIBRARY NotNeeded) - set(JAVA_JVM_LIBRARY NotNeeded) - find_package(JNI REQUIRED) - include_directories(${JNI_INCLUDE_DIRS}) -endif() +# find JNI +set(JAVA_AWT_LIBRARY NotNeeded) +set(JAVA_JVM_LIBRARY NotNeeded) +find_package(JNI REQUIRED) +include_directories(${JNI_INCLUDE_DIRS}) ##### the sdk-dependencies end##### \ No newline at end of file diff --git a/cpp/cmake/Options.cmake b/cpp/cmake/Options.cmake index 0588372d..1b4245ab 100644 --- a/cpp/cmake/Options.cmake +++ b/cpp/cmake/Options.cmake @@ -140,7 +140,6 @@ macro(configure_project) # cpp_features if(ENABLE_CPU_FEATURES) list(APPEND VCPKG_MANIFEST_FEATURES "cpufeatures") - message("##### append cpp_features: ${VCPKG_MANIFEST_FEATURES}") endif() ####### options settings ###### print_config("WeDPR-Component") @@ -154,6 +153,8 @@ macro(print_config NAME) message("-- CMake Cmake version and location ${CMAKE_VERSION} (${CMAKE_COMMAND})") message("-- Compiler C++ compiler version ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") message("-- CMAKE_BUILD_TYPE Build type ${CMAKE_BUILD_TYPE}") + message("-- VCPKG_MANIFEST_FEATURES VCPKG manifest features ${VCPKG_MANIFEST_FEATURES}") + message("-- CMAKE_TOOLCHAIN_FILE Cmake toolchain file ${CMAKE_TOOLCHAIN_FILE}") message("-- TARGET_PLATFORM Target platform ${CMAKE_SYSTEM_NAME} ${ARCHITECTURE}") message("-- BUILD_STATIC Build static ${BUILD_STATIC}") message("-- COVERAGE Build code coverage ${COVERAGE}") diff --git a/cpp/ppc-crypto-c-sdk/bindings/java/src/main/c/CMakeLists.txt b/cpp/ppc-crypto-c-sdk/bindings/java/src/main/c/CMakeLists.txt index 3741b8c1..94a27864 100644 --- a/cpp/ppc-crypto-c-sdk/bindings/java/src/main/c/CMakeLists.txt +++ b/cpp/ppc-crypto-c-sdk/bindings/java/src/main/c/CMakeLists.txt @@ -11,5 +11,4 @@ target_link_libraries(${PPC_CRYPTO_SDK_JNI_STATIC_TARGET} PUBLIC ${PPC_CRYPTO_C_ SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../resources/META-INF/native/) message(STATUS "CMAKE_INSTALL_INCLUDEDIR => ${CMAKE_INSTALL_INCLUDEDIR}") -message(STATUS "CMAKE_CURRENT_SOURCE_DIR => ${CMAKE_CURRENT_SOURCE_DIR}") -message(STATUS "LIB_DIR_PATH => ${CMAKE_CURRENT_SOURCE_DIR}/../resources/META-INF/native/") \ No newline at end of file +message(STATUS "CMAKE_CURRENT_SOURCE_DIR => ${CMAKE_CURRENT_SOURCE_DIR}") \ No newline at end of file