This is an automated email from the ASF dual-hosted git repository. lordgamez pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
The following commit(s) were added to refs/heads/main by this push: new d363846d5 MINIFICPP-2117 Fix bustache build in C++20 mode d363846d5 is described below commit d363846d5e20e195373797c3d9e8ed550f4ecbbe Author: Martin Zink <martinz...@apache.org> AuthorDate: Wed Jul 26 16:25:56 2023 +0200 MINIFICPP-2117 Fix bustache build in C++20 mode - replace BundledSpdlog.cmake with FetchedSpdlog and use external fmt - directly include fmt/format.h instead of spdlog.h in various places - bumb fmt for warning fixes Co-authored-by: Márton Szász <szasz...@gmail.com> Signed-off-by: Gabor Gyimesi <gamezb...@gmail.com> This closes #1617 --- .github/workflows/ci.yml | 4 +- CMakeLists.txt | 3 +- README.md | 6 -- aptitude.sh | 2 - arch.sh | 2 - bootstrap.sh | 1 - centos.sh | 2 - cmake/BuildTests.cmake | 4 -- cmake/BundledBustache.cmake | 58 ----------------- cmake/BundledSpdlog.cmake | 76 ---------------------- .../CMakeLists.txt => cmake/Bustache.cmake | 27 +++----- .../bustache/CMakeLists.txt => cmake/Spdlog.cmake | 28 +++----- .../bustache/CMakeLists.txt => cmake/fmt.cmake | 26 ++------ darwin.sh | 2 - debian.sh | 2 - docker/Dockerfile | 2 - docker/bionic/Dockerfile | 2 +- docker/centos/Dockerfile | 1 - docker/fedora/Dockerfile | 2 +- docker/focal/Dockerfile | 2 +- docker/rockylinux/Dockerfile | 1 - extensions/bustache/ApplyTemplate.cpp | 9 ++- extensions/bustache/CMakeLists.txt | 7 +- .../bustache/tests}/ApplyTemplateTests.cpp | 48 ++++++-------- .../bustache/tests}/CMakeLists.txt | 1 + .../http-curl/tests/C2PropertiesUpdateTests.cpp | 2 +- extensions/systemd/ConsumeJournald.cpp | 6 +- extensions/systemd/ConsumeJournald.h | 2 +- fedora.sh | 2 - libminifi/include/utils/file/FileUtils.h | 1 + libminifi/test/Catch.h | 2 +- libminifi/test/TestBase.cpp | 2 +- .../LineByLineInputOutputStreamCallbackTests.cpp | 2 +- minifi_main/MiNiFiWindowsService.h | 2 + 34 files changed, 68 insertions(+), 271 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8adc5d8a5..c3826e626 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -141,7 +141,7 @@ jobs: - id: install_deps run: | sudo apt update - sudo apt install -y ccache libfl-dev libboost-all-dev libpcap-dev + sudo apt install -y ccache libfl-dev libpcap-dev echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV echo -e "127.0.0.1\t$HOSTNAME" | sudo tee -a /etc/hosts > /dev/null - name: build @@ -203,7 +203,7 @@ jobs: echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" | sudo tee -a /etc/apt/sources.list echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" | sudo tee -a /etc/apt/sources.list sudo apt update - sudo apt install -y ccache libfl-dev libpcap-dev libboost-all-dev libusb-1.0-0-dev libpng-dev libgps-dev clang-14 clang-tidy-14 libc++-14-dev libc++abi-14-dev libsqliteodbc lua5.3 liblua5.3-dev flake8 parallel + sudo apt install -y ccache libfl-dev libpcap-dev libusb-1.0-0-dev libpng-dev libgps-dev clang-14 clang-tidy-14 libc++-14-dev libc++abi-14-dev libsqliteodbc lua5.3 liblua5.3-dev flake8 parallel echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV echo -e "127.0.0.1\t$HOSTNAME" | sudo tee -a /etc/hosts > /dev/null - name: build diff --git a/CMakeLists.txt b/CMakeLists.txt index 13a2b9924..bb20647ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -281,8 +281,7 @@ else() endif() # spdlog -include(BundledSpdlog) -use_bundled_spdlog(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +include(Spdlog) # yaml-cpp include(BundledYamlCpp) diff --git a/README.md b/README.md index df1a6ad72..a10391a55 100644 --- a/README.md +++ b/README.md @@ -216,8 +216,6 @@ dnf install cmake \ xz-devel \ doxygen \ zlib-devel -# (Optional) for building OpenCV or Bustache support -dnf install boost-devel # (Optional) for building Python support dnf install python36-devel # (Optional) for building Lua support @@ -253,8 +251,6 @@ apt install cmake \ libbz2-dev liblzma-dev \ doxygen \ zlib1g-dev -# (Optional) for building OpenCV or Bustache support -apt install libboost-all-dev # (Optional) for building Python support apt install libpython3-dev # (Optional) for building Lua support @@ -290,8 +286,6 @@ brew install cmake \ zlib brew install curl brew link curl --force -# (Optional) for building OpenCV or Bustache support -brew install boost # (Optional) for building USB Camera support brew install libusb libpng # (Optional) for building docker image/running system integration tests diff --git a/aptitude.sh b/aptitude.sh index 80f800a82..388fde05d 100644 --- a/aptitude.sh +++ b/aptitude.sh @@ -98,8 +98,6 @@ build_deps(){ INSTALLED+=("libgps-dev") elif [ "$FOUND_VALUE" = "libarchive" ]; then INSTALLED+=("liblzma-dev") - elif [ "$FOUND_VALUE" = "boost" ]; then - INSTALLED+=("libboost-dev") elif [ "$FOUND_VALUE" = "opensslbuild" ]; then INSTALLED+=("perl") fi diff --git a/arch.sh b/arch.sh index 635fb251b..72eca4606 100644 --- a/arch.sh +++ b/arch.sh @@ -76,8 +76,6 @@ build_deps(){ INSTALLED+=("gpsd") elif [ "$FOUND_VALUE" = "libarchive" ]; then INSTALLED+=("libarchive") - elif [ "$FOUND_VALUE" = "boost" ]; then - INSTALLED+=("boost") elif [ "$FOUND_VALUE" = "opensslbuild" ]; then INSTALLED+=("perl") fi diff --git a/bootstrap.sh b/bootstrap.sh index 54d809c2a..466251b68 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -314,7 +314,6 @@ add_option OPENWSMAN_ENABLED ${FALSE} "ENABLE_OPENWSMAN" # Since the following extensions have limitations on add_option BUSTACHE_ENABLED ${FALSE} "ENABLE_BUSTACHE" "2.6" ${TRUE} -add_dependency BUSTACHE_ENABLED "boost" add_option OPC_ENABLED ${FALSE} "ENABLE_OPC" add_dependency OPC_ENABLED "mbedtls" diff --git a/centos.sh b/centos.sh index 000a47800..6d13ad798 100644 --- a/centos.sh +++ b/centos.sh @@ -110,8 +110,6 @@ build_deps() { INSTALLED+=("bzip2-devel") elif [ "$FOUND_VALUE" = "libssh2" ]; then INSTALLED+=("libssh2-devel") - elif [ "$FOUND_VALUE" = "boost" ]; then - INSTALLED+=("boost-devel") elif [ "$FOUND_VALUE" = "opensslbuild" ]; then INSTALLED+=("perl") fi diff --git a/cmake/BuildTests.cmake b/cmake/BuildTests.cmake index 010aa2968..388805d8a 100644 --- a/cmake/BuildTests.cmake +++ b/cmake/BuildTests.cmake @@ -152,10 +152,6 @@ if(NOT WIN32 AND ENABLE_NANOFI) MATH(EXPR UNIT_TEST_COUNT "${UNIT_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) - if (Boost_FOUND) - target_link_libraries(${testfilename} ${Boost_SYSTEM_LIBRARY}) - target_link_libraries(${testfilename} ${Boost_FILESYSTEM_LIBRARY}) - endif() ENDFOREACH() message("-- Finished building ${UNIT_TEST_COUNT} NanoFi unit test file(s)...") endif() diff --git a/cmake/BundledBustache.cmake b/cmake/BundledBustache.cmake deleted file mode 100644 index 5c2140a0a..000000000 --- a/cmake/BundledBustache.cmake +++ /dev/null @@ -1,58 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -function(use_bundled_bustache SOURCE_DIR BINARY_DIR) - # Define byproducts - if (WIN32) - set(BYPRODUCT "lib/bustache.lib") - else() - set(BYPRODUCT "lib/libbustache.a") - endif() - - # Set build options - set(BUSTACHE_BYPRODUCT_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/bustache-install") - - set(BUSTACHE_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${BUSTACHE_BYPRODUCT_DIR}" - "-DBUSTACHE_ENABLE_TESTING=OFF") - - append_third_party_passthrough_args(BUSTACHE_CMAKE_ARGS "${BUSTACHE_CMAKE_ARGS}") - - # Build project - ExternalProject_Add( - bustache-external - GIT_REPOSITORY "https://github.com/jamboree/bustache.git" - GIT_TAG "42dee8ef9bbcae7e9a33500a116cfd9c314662d6" - SOURCE_DIR "${BINARY_DIR}/thirdparty/bustache-src" - CMAKE_ARGS ${BUSTACHE_CMAKE_ARGS} - BUILD_BYPRODUCTS "${BUSTACHE_BYPRODUCT_DIR}/${BYPRODUCT}" - EXCLUDE_FROM_ALL TRUE - LIST_SEPARATOR % # This is needed for passing semicolon-separated lists - ) - - # Set variables - set(BUSTACHE_FOUND "YES" CACHE STRING "" FORCE) - set(BUSTACHE_INCLUDE_DIR "${BUSTACHE_BYPRODUCT_DIR}/include" CACHE STRING "" FORCE) - set(BUSTACHE_LIBRARY "${BUSTACHE_BYPRODUCT_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) - - # Create imported targets - add_library(BUSTACHE::libbustache STATIC IMPORTED) - set_target_properties(BUSTACHE::libbustache PROPERTIES IMPORTED_LOCATION "${BUSTACHE_LIBRARY}") - add_dependencies(BUSTACHE::libbustache bustache-external) - file(MAKE_DIRECTORY ${BUSTACHE_INCLUDE_DIR}) - set_property(TARGET BUSTACHE::libbustache APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${BUSTACHE_INCLUDE_DIR}) -endfunction(use_bundled_bustache) diff --git a/cmake/BundledSpdlog.cmake b/cmake/BundledSpdlog.cmake deleted file mode 100644 index 974cbbaa6..000000000 --- a/cmake/BundledSpdlog.cmake +++ /dev/null @@ -1,76 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -function(use_bundled_spdlog SOURCE_DIR BINARY_DIR) - # Define byproducts - if (WIN32) - if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - set(BYPRODUCT "lib/spdlogd.lib") - else() - set(BYPRODUCT "lib/spdlog.lib") - endif() - else() - include(GNUInstallDirs) - string(REPLACE "/" ";" LIBDIR_LIST ${CMAKE_INSTALL_LIBDIR}) - list(GET LIBDIR_LIST 0 LIBDIR) - if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - set(BYPRODUCT "${LIBDIR}/libspdlogd.a") - else() - set(BYPRODUCT "${LIBDIR}/libspdlog.a") - endif() - endif() - - # Set build options - set(SPDLOG_SOURCE_DIR "${BINARY_DIR}/thirdparty/spdlog-src") - set(SPDLOG_INSTALL_DIR "${BINARY_DIR}/thirdparty/spdlog-install") - set(SPDLOG_LIBRARY "${SPDLOG_INSTALL_DIR}/${BYPRODUCT}") - set(SPDLOG_CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} - "-DCMAKE_INSTALL_PREFIX=${SPDLOG_INSTALL_DIR}" - "-DSPDLOG_BUILD_EXAMPLE=OFF" - "-DSPDLOG_BUILD_TESTS=OFF" - "-DSPDLOG_BUILD_TESTING=OFF" - "-DSPDLOG_BUILD_BENCH=OFF" - "-DSPDLOG_BUILD_SHARED=OFF") - - # Build project - ExternalProject_Add( - spdlog-external - URL "https://github.com/gabime/spdlog/archive/v1.8.0.zip" - SOURCE_DIR "${SPDLOG_SOURCE_DIR}" - CMAKE_ARGS ${SPDLOG_CMAKE_ARGS} - BUILD_BYPRODUCTS "${SPDLOG_LIBRARY}" - EXCLUDE_FROM_ALL TRUE - ) - - # Set variables - set(SPDLOG_FOUND "YES" CACHE STRING "" FORCE) - set(SPDLOG_INCLUDE_DIR "${SPDLOG_INSTALL_DIR}/include" CACHE STRING "" FORCE) - set(SPDLOG_LIBRARY "${SPDLOG_INSTALL_DIR}/${BYPRODUCT}" CACHE STRING "" FORCE) - set(SPDLOG_LIBRARIES ${SPDLOG_LIBRARY} CACHE STRING "" FORCE) - - # Create imported targets - add_library(spdlog STATIC IMPORTED) - add_dependencies(spdlog spdlog-external) - file(MAKE_DIRECTORY ${SPDLOG_INCLUDE_DIR}) - set_target_properties(spdlog PROPERTIES - IMPORTED_LOCATION "${SPDLOG_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SPDLOG_INCLUDE_DIR}") - - if (NOT WIN32) - set_property(TARGET spdlog APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "SPDLOG_ENABLE_SYSLOG" "SPDLOG_COMPILED_LIB") - endif() -endfunction(use_bundled_spdlog) diff --git a/extensions/bustache/CMakeLists.txt b/cmake/Bustache.cmake similarity index 53% copy from extensions/bustache/CMakeLists.txt copy to cmake/Bustache.cmake index 85c8c5cf6..a2e8d84dd 100644 --- a/extensions/bustache/CMakeLists.txt +++ b/cmake/Bustache.cmake @@ -16,22 +16,11 @@ # specific language governing permissions and limitations # under the License. # - -if (NOT (ENABLE_ALL OR ENABLE_BUSTACHE)) - return() -endif() - -include(BundledBustache) -use_bundled_bustache(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) - -include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) - -file(GLOB SOURCES "*.cpp") - -add_library(minifi-bustache-extensions SHARED ${SOURCES}) - -target_link_libraries(minifi-bustache-extensions ${LIBMINIFI}) -target_link_libraries(minifi-bustache-extensions BUSTACHE::libbustache) - -register_extension(minifi-bustache-extensions "BUSTACHE EXTENSIONS" BUSTACHE-EXTENSIONS "This enables bustache functionality including ApplyTemplate." "${TEST_DIR}/bustache-tests") -register_extension_linter(minifi-bustache-extensions-linter) +include(FetchContent) +include(fmt) +set(BUSTACHE_USE_FMT ON CACHE STRING "" FORCE) +FetchContent_Declare(Bustache + GIT_REPOSITORY https://github.com/jamboree/bustache.git + GIT_TAG ee39a375d49677af9728722bfabf63eaed3c82fd +) +FetchContent_MakeAvailable(Bustache) diff --git a/extensions/bustache/CMakeLists.txt b/cmake/Spdlog.cmake similarity index 53% copy from extensions/bustache/CMakeLists.txt copy to cmake/Spdlog.cmake index 85c8c5cf6..578e0d812 100644 --- a/extensions/bustache/CMakeLists.txt +++ b/cmake/Spdlog.cmake @@ -16,22 +16,12 @@ # specific language governing permissions and limitations # under the License. # - -if (NOT (ENABLE_ALL OR ENABLE_BUSTACHE)) - return() -endif() - -include(BundledBustache) -use_bundled_bustache(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) - -include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) - -file(GLOB SOURCES "*.cpp") - -add_library(minifi-bustache-extensions SHARED ${SOURCES}) - -target_link_libraries(minifi-bustache-extensions ${LIBMINIFI}) -target_link_libraries(minifi-bustache-extensions BUSTACHE::libbustache) - -register_extension(minifi-bustache-extensions "BUSTACHE EXTENSIONS" BUSTACHE-EXTENSIONS "This enables bustache functionality including ApplyTemplate." "${TEST_DIR}/bustache-tests") -register_extension_linter(minifi-bustache-extensions-linter) +include(FetchContent) +include(fmt) +set(SPDLOG_FMT_EXTERNAL ON CACHE STRING "" FORCE) +FetchContent_Declare(Spdlog + URL https://github.com/gabime/spdlog/archive/refs/tags/v1.12.0.tar.gz + URL_HASH SHA256=4dccf2d10f410c1e2feaff89966bfc49a1abb29ef6f08246335b110e001e09a9 + FIND_PACKAGE_ARGS + ) +FetchContent_MakeAvailable(Spdlog) diff --git a/extensions/bustache/CMakeLists.txt b/cmake/fmt.cmake similarity index 53% copy from extensions/bustache/CMakeLists.txt copy to cmake/fmt.cmake index 85c8c5cf6..cbf2c66f8 100644 --- a/extensions/bustache/CMakeLists.txt +++ b/cmake/fmt.cmake @@ -16,22 +16,10 @@ # specific language governing permissions and limitations # under the License. # - -if (NOT (ENABLE_ALL OR ENABLE_BUSTACHE)) - return() -endif() - -include(BundledBustache) -use_bundled_bustache(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) - -include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) - -file(GLOB SOURCES "*.cpp") - -add_library(minifi-bustache-extensions SHARED ${SOURCES}) - -target_link_libraries(minifi-bustache-extensions ${LIBMINIFI}) -target_link_libraries(minifi-bustache-extensions BUSTACHE::libbustache) - -register_extension(minifi-bustache-extensions "BUSTACHE EXTENSIONS" BUSTACHE-EXTENSIONS "This enables bustache functionality including ApplyTemplate." "${TEST_DIR}/bustache-tests") -register_extension_linter(minifi-bustache-extensions-linter) +include(FetchContent) +FetchContent_Declare(Fmt + URL https://github.com/fmtlib/fmt/archive/refs/tags/10.1.0.tar.gz + URL_HASH SHA256=deb0a3ad2f5126658f2eefac7bf56a042488292de3d7a313526d667f3240ca0a + FIND_PACKAGE_ARGS + ) +FetchContent_MakeAvailable(Fmt) diff --git a/darwin.sh b/darwin.sh index 21cb161b1..de797a546 100644 --- a/darwin.sh +++ b/darwin.sh @@ -91,8 +91,6 @@ build_deps(){ INSTALLED+=("flex") elif [ "$FOUND_VALUE" = "python" ]; then INSTALLED+=("python") - elif [ "$FOUND_VALUE" = "boost" ]; then - INSTALLED+=("boost") elif [ "$FOUND_VALUE" = "lua" ]; then INSTALLED+=("lua") elif [ "$FOUND_VALUE" = "jnibuild" ]; then diff --git a/debian.sh b/debian.sh index 4b09cc4f2..412530014 100644 --- a/debian.sh +++ b/debian.sh @@ -87,8 +87,6 @@ build_deps(){ INSTALLED+=("liblzma-dev") elif [ "$FOUND_VALUE" = "libssh2" ]; then INSTALLED+=("libssh2-1-dev") - elif [ "$FOUND_VALUE" = "boost" ]; then - INSTALLED+=("libboost-dev") elif [ "$FOUND_VALUE" = "opensslbuild" ]; then INSTALLED+=("perl") fi diff --git a/docker/Dockerfile b/docker/Dockerfile index e3ee1022e..934f0a3f1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -56,7 +56,6 @@ RUN apk --no-cache add gcc \ libusb-dev \ gpsd-dev \ python3-dev \ - boost-dev \ doxygen \ ccache \ lua-dev @@ -110,7 +109,6 @@ RUN addgroup -g ${GID} ${USER} && adduser -u ${UID} -D -G ${USER} -g "" ${USER} if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_JNI=ON"; then apk add --no-cache openjdk8-jre-base; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_PCAP=ON"; then apk add --no-cache libpcap; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_USB_CAMERA=ON"; then apk add --no-cache libpng libusb; fi && \ - if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_OPENCV=ON" || echo "$MINIFI_OPTIONS" | grep -q "ENABLE_BUSTACHE=ON"; then apk add --no-cache boost; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_LUA_SCRIPTING=ON"; then apk add --no-cache lua; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_PYTHON_SCRIPTING=ON"; then apk add --no-cache python3; fi diff --git a/docker/bionic/Dockerfile b/docker/bionic/Dockerfile index d3ee06f1d..dc9a33163 100644 --- a/docker/bionic/Dockerfile +++ b/docker/bionic/Dockerfile @@ -32,7 +32,7 @@ ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-$MINIFI_VERSION ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ RUN apt-get update \ - && DEBIAN_FRONTEND="noninteractive" apt-get install -y openjdk-8-jdk openjdk-8-source sudo git maven autogen autoconf automake pkgconf libtool libfl-dev libboost-all-dev libusb-1.0-0-dev \ + && DEBIAN_FRONTEND="noninteractive" apt-get install -y openjdk-8-jdk openjdk-8-source sudo git maven autogen autoconf automake pkgconf libtool libfl-dev libusb-1.0-0-dev \ libpng-dev libgps-dev libsqliteodbc liblua5.3-dev \ && mkdir -p $MINIFI_BASE_DIR COPY . ${MINIFI_BASE_DIR} diff --git a/docker/centos/Dockerfile b/docker/centos/Dockerfile index 19449ff62..cbea8a309 100644 --- a/docker/centos/Dockerfile +++ b/docker/centos/Dockerfile @@ -48,7 +48,6 @@ RUN yum -y install epel-release && yum -y install sudo git which make libarchive if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_JNI=ON"; then yum -y install java-1.8.0-openjdk maven; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_PCAP=ON"; then yum -y install libpcap-devel; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_USB_CAMERA=ON"; then yum -y install libpng-devel libusbx-devel; fi && \ - if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_OPENCV=ON" || echo "$MINIFI_OPTIONS" | grep -q "ENABLE_BUSTACHE=ON"; then yum -y install boost-devel; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_LUA_SCRIPTING=ON"; then yum -y install lua-devel; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_PYTHON_SCRIPTING=ON"; then yum -y install python36-devel; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_SFTP=ON" && [ "${DOCKER_SKIP_TESTS}" == "OFF" ]; then yum -y install java-1.8.0-openjdk maven; fi diff --git a/docker/fedora/Dockerfile b/docker/fedora/Dockerfile index b9e78cad0..5821ccbdc 100644 --- a/docker/fedora/Dockerfile +++ b/docker/fedora/Dockerfile @@ -33,7 +33,7 @@ ENV MINIFI_HOME $MINIFI_BASE_DIR/nifi-minifi-cpp-$MINIFI_VERSION RUN echo "fastestmirror=True" | tee -a /etc/dnf/dnf.conf RUN for iter in {1..10}; do yum update -y && \ yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel flex bison make patch sudo git which maven libtool autoconf automake java-1.8.0-openjdk java-1.8.0-openjdk-devel sudo \ - git which maven make libarchive boost-devel lua-devel libusb-devel libpng-devel gpsd-devel libpcap-devel perl && \ + git which maven make libarchive lua-devel libusb-devel libpng-devel gpsd-devel libpcap-devel perl && \ yum clean all && exit_code=0 && break || exit_code=$? && echo "yum error: retry $iter in 10s" && sleep 10; done; \ (exit $exit_code) diff --git a/docker/focal/Dockerfile b/docker/focal/Dockerfile index 4af6bbfab..6eab97b31 100644 --- a/docker/focal/Dockerfile +++ b/docker/focal/Dockerfile @@ -33,7 +33,7 @@ ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ RUN apt update \ && DEBIAN_FRONTEND="noninteractive" apt install -y openjdk-8-jdk openjdk-8-source python3.9-dev sudo git maven autogen autoconf automake cmake software-properties-common pkgconf libtool \ - libfl-dev libboost-all-dev libusb-1.0-0-dev libpng-dev libgps-dev libsqliteodbc liblua5.3-dev\ + libfl-dev libusb-1.0-0-dev libpng-dev libgps-dev libsqliteodbc liblua5.3-dev\ && mkdir -p "${MINIFI_BASE_DIR}" COPY . ${MINIFI_BASE_DIR} diff --git a/docker/rockylinux/Dockerfile b/docker/rockylinux/Dockerfile index fe02f5ce8..a88e335ae 100644 --- a/docker/rockylinux/Dockerfile +++ b/docker/rockylinux/Dockerfile @@ -45,7 +45,6 @@ RUN dnf -y install epel-release && dnf -y install sudo git which make libarchive if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_JNI=ON"; then dnf -y install java-1.8.0-openjdk maven; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_PCAP=ON"; then dnf -y install libpcap-devel; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_USB_CAMERA=ON"; then dnf -y install libpng-devel libusbx-devel; fi && \ - if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_OPENCV=ON" || echo "$MINIFI_OPTIONS" | grep -q "ENABLE_BUSTACHE=ON"; then dnf -y install boost-devel; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_LUA_SCRIPTING=ON"; then dnf -y --enablerepo=powertools install lua-devel; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_PYTHON_SCRIPTING=ON"; then dnf -y install python3-devel; fi && \ if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_SFTP=ON" && [ "${DOCKER_SKIP_TESTS}" == "OFF" ]; then dnf -y install java-1.8.0-openjdk maven; fi diff --git a/extensions/bustache/ApplyTemplate.cpp b/extensions/bustache/ApplyTemplate.cpp index 447dcd03a..42995f504 100644 --- a/extensions/bustache/ApplyTemplate.cpp +++ b/extensions/bustache/ApplyTemplate.cpp @@ -19,15 +19,14 @@ */ #include "ApplyTemplate.h" -#include <filesystem> -#include <fstream> -#include <iostream> +#include <unordered_map> #include <memory> #include <string> #include <utility> #include "core/Resource.h" #include "bustache/model.hpp" +#include "bustache/render/string.hpp" namespace org::apache::nifi::minifi::processors { @@ -55,14 +54,14 @@ void ApplyTemplate::onTrigger(const std::shared_ptr<core::ProcessContext> &conte }(); bustache::format format(template_file_contents); - bustache::object data; + std::unordered_map<std::string, std::string> data; for (const auto &attr : flow_file->getAttributes()) { data[attr.first] = attr.second; } // TODO(calebj) write ostream reciever for format() to prevent excessive copying - std::string ostring = to_string(format(data)); + std::string ostring = bustache::to_string(format(data)); output_stream->write(gsl::make_span(ostring).as_span<const std::byte>()); return gsl::narrow<int64_t>(ostring.length()); }); diff --git a/extensions/bustache/CMakeLists.txt b/extensions/bustache/CMakeLists.txt index 85c8c5cf6..5185e3ab4 100644 --- a/extensions/bustache/CMakeLists.txt +++ b/extensions/bustache/CMakeLists.txt @@ -21,8 +21,7 @@ if (NOT (ENABLE_ALL OR ENABLE_BUSTACHE)) return() endif() -include(BundledBustache) -use_bundled_bustache(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) +include(Bustache) include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt) @@ -31,7 +30,7 @@ file(GLOB SOURCES "*.cpp") add_library(minifi-bustache-extensions SHARED ${SOURCES}) target_link_libraries(minifi-bustache-extensions ${LIBMINIFI}) -target_link_libraries(minifi-bustache-extensions BUSTACHE::libbustache) +target_link_libraries(minifi-bustache-extensions bustache) -register_extension(minifi-bustache-extensions "BUSTACHE EXTENSIONS" BUSTACHE-EXTENSIONS "This enables bustache functionality including ApplyTemplate." "${TEST_DIR}/bustache-tests") +register_extension(minifi-bustache-extensions "BUSTACHE EXTENSIONS" BUSTACHE-EXTENSIONS "This enables bustache functionality including ApplyTemplate." "extensions/bustache/tests") register_extension_linter(minifi-bustache-extensions-linter) diff --git a/libminifi/test/bustache-tests/ApplyTemplateTests.cpp b/extensions/bustache/tests/ApplyTemplateTests.cpp similarity index 70% rename from libminifi/test/bustache-tests/ApplyTemplateTests.cpp rename to extensions/bustache/tests/ApplyTemplateTests.cpp index 01f101042..0a908c2fa 100644 --- a/libminifi/test/bustache-tests/ApplyTemplateTests.cpp +++ b/extensions/bustache/tests/ApplyTemplateTests.cpp @@ -24,8 +24,8 @@ #include <set> #include <iostream> -#include "../TestBase.h" -#include "../Catch.h" +#include "TestBase.h" +#include "Catch.h" #include "core/Core.h" #include "core/FlowFile.h" @@ -34,7 +34,7 @@ #include "core/ProcessSession.h" #include "core/ProcessorNode.h" #include "repository/VolatileContentRepository.h" -#include "../unit/ProvenanceTestHelper.h" +#include "unit/ProvenanceTestHelper.h" #include "ApplyTemplate.h" #include "processors/GetFile.h" @@ -50,8 +50,8 @@ const char* EXPECT_OUTPUT = "TemplateBegins\nExampleValue\nTemplateEnds"; TEST_CASE("Test Creation of ApplyTemplate", "[ApplyTemplateCreate]") { TestController testController; - std::shared_ptr<core::Processor> processor = std::make_shared<org::apache::nifi::minifi::processors::ApplyTemplate>("processorname"); - REQUIRE(processor->getName() == "processorname"); + std::shared_ptr<core::Processor> processor = std::make_shared<org::apache::nifi::minifi::processors::ApplyTemplate>("processor_name"); + REQUIRE(processor->getName() == "processor_name"); REQUIRE(processor->getUUID()); } @@ -70,49 +70,43 @@ TEST_CASE("Test usage of ApplyTemplate", "[ApplyTemplateTest]") { std::shared_ptr<TestPlan> plan = testController.createPlan(); std::shared_ptr<TestRepository> repo = std::make_shared<TestRepository>(); - std::string get_file_source_dir = testController.createTempDirectory(); - std::string template_source_dir = testController.createTempDirectory(); - std::string put_file_destination_dir = testController.createTempDirectory(); + auto get_file_source_dir = testController.createTempDirectory(); + auto template_source_dir = testController.createTempDirectory(); + auto put_file_destination_dir = testController.createTempDirectory(); REQUIRE_FALSE(get_file_source_dir.empty()); REQUIRE_FALSE(template_source_dir.empty()); REQUIRE_FALSE(put_file_destination_dir.empty()); std::shared_ptr<core::Processor> getfile = plan->addProcessor("GetFile", "getFile"); - plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory, get_file_source_dir); + plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::Directory, get_file_source_dir.string()); plan->setProperty(getfile, org::apache::nifi::minifi::processors::GetFile::KeepSourceFile, "true"); - std::shared_ptr<core::Processor> maprocessor = plan->addProcessor("ExtractText", "testExtractText", core::Relationship("success", "description"), true); - plan->setProperty(maprocessor, org::apache::nifi::minifi::processors::ExtractText::Attribute, TEST_ATTR); + std::shared_ptr<core::Processor> extract_text = plan->addProcessor("ExtractText", "testExtractText", core::Relationship("success", "description"), true); + plan->setProperty(extract_text, org::apache::nifi::minifi::processors::ExtractText::Attribute, TEST_ATTR); - std::shared_ptr<core::Processor> atprocessor = plan->addProcessor("ApplyTemplate", "testApplyTemplate", core::Relationship("success", "description"), true); + std::shared_ptr<core::Processor> apply_template = plan->addProcessor("ApplyTemplate", "testApplyTemplate", core::Relationship("success", "description"), true); - std::shared_ptr<core::Processor> putfile = plan->addProcessor("PutFile", "putfile", core::Relationship("success", "description"), true); - plan->setProperty(putfile, org::apache::nifi::minifi::processors::PutFile::Directory, put_file_destination_dir); - plan->setProperty(putfile, org::apache::nifi::minifi::processors::PutFile::ConflictResolution, + std::shared_ptr<core::Processor> put_file = plan->addProcessor("PutFile", "put_file", core::Relationship("success", "description"), true); + plan->setProperty(put_file, org::apache::nifi::minifi::processors::PutFile::Directory, put_file_destination_dir.string()); + plan->setProperty(put_file, org::apache::nifi::minifi::processors::PutFile::ConflictResolution, org::apache::nifi::minifi::processors::PutFile::CONFLICT_RESOLUTION_STRATEGY_REPLACE); // Write attribute value to file for GetFile->ExtractText - std::stringstream ss1; - ss1 << get_file_source_dir << "/" << TEST_FILE; - std::string test_path = ss1.str(); - std::ofstream test_file(test_path); + std::ofstream test_file(get_file_source_dir / TEST_FILE); REQUIRE(test_file.is_open()); test_file << TEST_VALUE; test_file.close(); // Write template to file - std::stringstream ss2; - ss2 << template_source_dir << "/" << TEMPLATE_FILE; - std::string template_path = ss2.str(); - + auto template_path = template_source_dir / TEMPLATE_FILE; std::ofstream template_file(template_path); REQUIRE(template_file.is_open()); template_file << TEMPLATE; template_file.close(); - plan->setProperty(atprocessor, org::apache::nifi::minifi::processors::ApplyTemplate::Template, template_path); + plan->setProperty(apply_template, org::apache::nifi::minifi::processors::ApplyTemplate::Template, template_path.string()); // Run processor chain plan->runNextProcessor(); // GetFile @@ -121,11 +115,7 @@ TEST_CASE("Test usage of ApplyTemplate", "[ApplyTemplateTest]") { plan->runNextProcessor(); // PutFile // Read contents of file - std::stringstream ss3; - ss3 << put_file_destination_dir << "/" << TEST_FILE; - std::string output_path = ss3.str(); - - std::ifstream output_file(output_path); + std::ifstream output_file(put_file_destination_dir / TEST_FILE); std::stringstream output_buf; output_buf << output_file.rdbuf(); std::string output_contents = output_buf.str(); diff --git a/libminifi/test/bustache-tests/CMakeLists.txt b/extensions/bustache/tests/CMakeLists.txt similarity index 94% rename from libminifi/test/bustache-tests/CMakeLists.txt rename to extensions/bustache/tests/CMakeLists.txt index 782ad7fa9..b184d16ce 100644 --- a/libminifi/test/bustache-tests/CMakeLists.txt +++ b/extensions/bustache/tests/CMakeLists.txt @@ -24,6 +24,7 @@ FOREACH(testfile ${BUSTACHE_INTEGRATION_TESTS}) add_executable("${testfilename}" "${testfile}") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/bustache") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors") + target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") target_include_directories(${testfilename} SYSTEM PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/bustache/include") target_link_libraries(${testfilename} minifi-bustache-extensions) diff --git a/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp b/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp index a4f742147..6e43045e7 100644 --- a/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp +++ b/extensions/http-curl/tests/C2PropertiesUpdateTests.cpp @@ -24,7 +24,7 @@ #include "utils/gsl.h" #include "utils/IntegrationTestUtils.h" #include "EmptyFlow.h" -#include "spdlog/spdlog.h" +#include "fmt/format.h" #include "spdlog/sinks/stdout_sinks.h" #include "spdlog/sinks/ostream_sink.h" #include "spdlog/sinks/dist_sink.h" diff --git a/extensions/systemd/ConsumeJournald.cpp b/extensions/systemd/ConsumeJournald.cpp index 42c20fea2..ae23b90f0 100644 --- a/extensions/systemd/ConsumeJournald.cpp +++ b/extensions/systemd/ConsumeJournald.cpp @@ -21,7 +21,7 @@ #include <algorithm> #include "date/date.h" -#include "spdlog/spdlog.h" // TODO(szaszm): make fmt directly available +#include "fmt/format.h" #include "utils/GeneralUtils.h" #include "utils/OptionalUtils.h" #include "core/ProcessContext.h" @@ -32,8 +32,8 @@ namespace org::apache::nifi::minifi::extensions::systemd { namespace chr = std::chrono; -ConsumeJournald::ConsumeJournald(std::string name, const utils::Identifier &id, std::unique_ptr<libwrapper::LibWrapper>&& libwrapper) - :core::Processor{std::move(name), id}, libwrapper_{std::move(libwrapper)} +ConsumeJournald::ConsumeJournald(std::string_view name, const utils::Identifier &id, std::unique_ptr<libwrapper::LibWrapper>&& libwrapper) + :core::Processor{name, id}, libwrapper_{std::move(libwrapper)} {} void ConsumeJournald::initialize() { diff --git a/extensions/systemd/ConsumeJournald.h b/extensions/systemd/ConsumeJournald.h index 9572f6823..00724d3af 100644 --- a/extensions/systemd/ConsumeJournald.h +++ b/extensions/systemd/ConsumeJournald.h @@ -114,7 +114,7 @@ class ConsumeJournald final : public core::Processor { ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS - explicit ConsumeJournald(std::string name, const utils::Identifier& id = {}, std::unique_ptr<libwrapper::LibWrapper>&& = libwrapper::createLibWrapper()); + explicit ConsumeJournald(std::string_view name, const utils::Identifier& id = {}, std::unique_ptr<libwrapper::LibWrapper>&& = libwrapper::createLibWrapper()); ConsumeJournald(const ConsumeJournald&) = delete; ConsumeJournald(ConsumeJournald&&) = delete; ConsumeJournald& operator=(const ConsumeJournald&) = delete; diff --git a/fedora.sh b/fedora.sh index 61048156d..2ba5fc4c0 100644 --- a/fedora.sh +++ b/fedora.sh @@ -82,8 +82,6 @@ build_deps(){ INSTALLED+=("xz-devel") elif [ "$FOUND_VALUE" = "libssh2" ]; then INSTALLED+=("libssh2-devel") - elif [ "$FOUND_VALUE" = "boost" ]; then - INSTALLED+=("boost-devel") elif [ "$FOUND_VALUE" = "opensslbuild" ]; then INSTALLED+=("perl") fi diff --git a/libminifi/include/utils/file/FileUtils.h b/libminifi/include/utils/file/FileUtils.h index 1c6ed935d..98a0af584 100644 --- a/libminifi/include/utils/file/FileUtils.h +++ b/libminifi/include/utils/file/FileUtils.h @@ -44,6 +44,7 @@ #include <sys/utime.h> // _utime64 #include <tchar.h> // _tcscpy,_tcscat,_tcscmp #include <windows.h> // winapi +#include <io.h> #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN diff --git a/libminifi/test/Catch.h b/libminifi/test/Catch.h index 71794c3a3..f2cc9d347 100644 --- a/libminifi/test/Catch.h +++ b/libminifi/test/Catch.h @@ -20,7 +20,7 @@ #include <optional> #include <string> #include <chrono> -#include "spdlog/spdlog.h" +#include "fmt/format.h" #include "catch2/catch_test_macros.hpp" #include "catch2/matchers/catch_matchers.hpp" diff --git a/libminifi/test/TestBase.cpp b/libminifi/test/TestBase.cpp index b93864f99..d27661178 100644 --- a/libminifi/test/TestBase.cpp +++ b/libminifi/test/TestBase.cpp @@ -39,7 +39,7 @@ #include "utils/span.h" #include "LogUtils.h" -#include "spdlog/spdlog.h" +#include "fmt/format.h" #include "spdlog/sinks/stdout_sinks.h" #include "spdlog/sinks/ostream_sink.h" #include "spdlog/sinks/dist_sink.h" diff --git a/libminifi/test/unit/LineByLineInputOutputStreamCallbackTests.cpp b/libminifi/test/unit/LineByLineInputOutputStreamCallbackTests.cpp index 1e1abd80e..6d86fb56c 100644 --- a/libminifi/test/unit/LineByLineInputOutputStreamCallbackTests.cpp +++ b/libminifi/test/unit/LineByLineInputOutputStreamCallbackTests.cpp @@ -20,7 +20,7 @@ #include "../Catch.h" #include "core/logging/LoggerConfiguration.h" #include "io/BufferStream.h" -#include "spdlog/spdlog.h" +#include "fmt/format.h" #include "utils/span.h" using minifi::utils::LineByLineInputOutputStreamCallback; diff --git a/minifi_main/MiNiFiWindowsService.h b/minifi_main/MiNiFiWindowsService.h index 8e99d7319..93a950524 100644 --- a/minifi_main/MiNiFiWindowsService.h +++ b/minifi_main/MiNiFiWindowsService.h @@ -21,6 +21,8 @@ #include <memory> +using HANDLE = void*; + #include "core/Core.h" struct GetTerminationEventHandleReturnType {