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

MINIFICPP-2346-P2: Added Support to Create MiNiFi Conan2 Package, Easier Integration into C++ RT Infra #1813

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 0 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
-DENABLE_CIVET=ON
-DENABLE_COAP=OFF
-DENABLE_CONTROLLER=ON
-DENABLE_CURL=ON
-DENABLE_ELASTICSEARCH=ON
-DENABLE_ENCRYPT_CONFIG=ON
-DENABLE_EXPRESSION_LANGUAGE=ON
Expand Down Expand Up @@ -60,7 +59,6 @@ jobs:
-DMINIFI_ADVANCED_ASAN_BUILD=OFF
-DMINIFI_ADVANCED_CODE_COVERAGE=OFF
-DMINIFI_FAIL_ON_WARNINGS=OFF
-DMINIFI_OPENSSL=ON
-DMINIFI_USE_REAL_ODBC_TEST_DRIVER=ON
-DPORTABLE=ON
-DSKIP_TESTS=OFF
Expand Down Expand Up @@ -145,7 +143,6 @@ jobs:
-DENABLE_COAP=OFF
-DENABLE_CONTROLLER=ON
-DENABLE_COVERAGE=
-DENABLE_CURL=ON
-DENABLE_ELASTICSEARCH=ON
-DENABLE_ENCRYPT_CONFIG=ON
-DENABLE_EXPRESSION_LANGUAGE=ON
Expand Down Expand Up @@ -180,7 +177,6 @@ jobs:
-DFORCE_COLORED_OUTPUT=ON
-DINSTALLER_MERGE_MODULES=OFF
-DMINIFI_FAIL_ON_WARNINGS=OFF
-DMINIFI_OPENSSL=ON
-DMSI_REDISTRIBUTE_UCRT_NONASL=OFF
-DPORTABLE=ON
-DSKIP_TESTS=OFF
Expand Down Expand Up @@ -260,7 +256,6 @@ jobs:
-DENABLE_CIVET=ON
-DENABLE_COAP=OFF
-DENABLE_CONTROLLER=ON
-DENABLE_CURL=ON
-DENABLE_ELASTICSEARCH=OFF
-DENABLE_ENCRYPT_CONFIG=ON
-DENABLE_EXPRESSION_LANGUAGE=ON
Expand Down Expand Up @@ -292,7 +287,6 @@ jobs:
-DENABLE_USB_CAMERA=OFF
-DFORCE_COLORED_OUTPUT=ON
-DMINIFI_FAIL_ON_WARNINGS=ON
-DMINIFI_OPENSSL=ON
-DPORTABLE=ON
-DSKIP_TESTS=OFF
-DMINIFI_USE_REAL_ODBC_TEST_DRIVER=OFF
Expand Down Expand Up @@ -367,7 +361,6 @@ jobs:
-DENABLE_CIVET=ON
-DENABLE_COAP=ON
-DENABLE_CONTROLLER=ON
-DENABLE_CURL=ON
-DENABLE_ELASTICSEARCH=ON
-DENABLE_ENCRYPT_CONFIG=ON
-DENABLE_EXPRESSION_LANGUAGE=ON
Expand Down Expand Up @@ -400,7 +393,6 @@ jobs:
-DENABLE_USB_CAMERA=ON
-DFORCE_COLORED_OUTPUT=ON
-DMINIFI_FAIL_ON_WARNINGS=ON
-DMINIFI_OPENSSL=ON
-DPORTABLE=ON
-DSKIP_TESTS=OFF
-DMINIFI_USE_REAL_ODBC_TEST_DRIVER=OFF
Expand Down
91 changes: 46 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ else()
message(VERBOSE "No custom malloc implementation")
endif()

# OpenSSL
include(GetOpenSSL)
get_openssl("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/ssl")


if (ENABLE_BZIP2 AND (ENABLE_LIBARCHIVE OR (ENABLE_ROCKSDB AND NOT WIN32)))
include(BundledBZip2)
use_bundled_bzip2(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
Expand All @@ -244,39 +250,29 @@ if(NOT WIN32)
use_bundled_osspuuid(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
endif()

# OpenSSL
if (MINIFI_OPENSSL)
include(BundledOpenSSL)
use_openssl("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/ssl")
list(APPEND MINIFI_CPP_COMPILE_DEFINITIONS OPENSSL_SUPPORT)
endif()

# libsodium
include(BundledLibSodium)
use_bundled_libsodium("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")

list(APPEND MINIFI_CPP_COMPILE_DEFINITIONS SODIUM_STATIC=1)

# zlib
include(BundledZLIB)
use_bundled_zlib(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
include(GetZLIB)
get_zlib(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/zlib/dummy")

# uthash
add_library(ut INTERFACE)
target_include_directories(ut SYSTEM INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/ut")

# cURL
if(ENABLE_CURL)
include(BundledLibcURL)
use_bundled_curl(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/curl/dummy")
list(APPEND MINIFI_CPP_COMPILE_DEFINITIONS ENABLE_CURL)
endif()
include(GetLibCURL)
get_curl(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/curl/dummy")

# spdlog
include(Spdlog)
include(GetSpdlog)
get_spdlog()

# yaml-cpp
include(BundledYamlCpp)
Expand Down Expand Up @@ -355,14 +351,15 @@ include(Extensions)

add_subdirectory(libminifi)

if ((ENABLE_OPENWSMAN AND ENABLE_CIVET AND ENABLE_CURL) OR ENABLE_ALL OR ENABLE_AZURE)
include(BundledLibXml2)
use_bundled_libxml2(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
if ((ENABLE_OPENWSMAN AND ENABLE_CIVET) OR ENABLE_ALL OR ENABLE_AZURE)
include(GetLibXml2)
get_libxml2(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/libxml2/dummy")
endif()

if (ENABLE_ALL OR ENABLE_PROMETHEUS OR ENABLE_CIVET)
include(CivetWeb)
include(GetCivetWeb)
get_civetweb()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/civetweb/dummy")
endif()

Expand All @@ -375,6 +372,7 @@ foreach(extension-dir ${extension-directories})
endforeach()

## NOW WE CAN ADD LIBRARIES AND EXTENSIONS TO MAIN

add_subdirectory(minifi_main)

if (ENABLE_NANOFI)
Expand All @@ -385,7 +383,7 @@ if (ENABLE_ENCRYPT_CONFIG)
add_subdirectory(encrypt-config)
endif()

if (ENABLE_CURL AND ENABLE_CONTROLLER)
if (ENABLE_CONTROLLER)
add_subdirectory(controller)
endif()

Expand Down Expand Up @@ -579,13 +577,9 @@ if (NOT WIN32)
endif()
endif()

install(FILES LICENSE NOTICE
DESTINATION .
COMPONENT bin)
install(FILES LICENSE NOTICE DESTINATION . COMPONENT bin)
file(GLOB markdown_docs "*.md")
install(FILES ${markdown_docs}
DESTINATION .
COMPONENT bin)
install(FILES ${markdown_docs} DESTINATION . COMPONENT bin)

include(CPackComponent)

Expand All @@ -603,9 +597,11 @@ set(CPACK_PACKAGE_VENDOR "Apache NiFi")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
if(NOT MINIFI_BUILD_CONAN_PACKAGE)
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
endif()
if(NOT WIN32)
set(CPACK_PACKAGE_FILE_NAME "${ASSEMBLY_BASE_NAME}")
set(CPACK_GENERATOR "TGZ")
Expand Down Expand Up @@ -638,7 +634,6 @@ set(EXTENSIONS_ENABLED_BY_DEFAULT (
minifi-expression-language-extensions
minifi-gcp
minifi-grafana-loki
minifi-http-curl
minifi-archive-extensions
minifi-mqtt-extensions
minifi-rdkafka-extensions
Expand Down Expand Up @@ -679,24 +674,30 @@ include(CPack)

if (NOT SKIP_TESTS)
include(BuildTests)
endif()

## Add KeyValueStorageService tests
registerTest("${TEST_DIR}/keyvalue-tests")
add_subdirectory("${TEST_DIR}/libtest")

registerTest("${TEST_DIR}/flow-tests")
add_subdirectory("${TEST_DIR}/unit")

registerTest("${TEST_DIR}/schema-tests")
add_subdirectory("${TEST_DIR}/integration")

if (ENABLE_ROCKSDB AND ENABLE_LIBARCHIVE)
registerTest("${TEST_DIR}/persistence-tests")
endif()
## Add KeyValueStorageService tests
add_subdirectory("${TEST_DIR}/keyvalue-tests")

add_subdirectory("${TEST_DIR}/flow-tests")

registerTest("minifi_main/tests")
add_subdirectory("${TEST_DIR}/schema-tests")

registerTest("encrypt-config/tests")
if (ENABLE_ROCKSDB AND ENABLE_LIBARCHIVE)
add_subdirectory("${TEST_DIR}/persistence-tests")
endif()

add_subdirectory("minifi_main/tests")

registerTest("controller/tests")
add_subdirectory("encrypt-config/tests")

add_subdirectory("controller/tests")
endif()

include(BuildDocs)

Expand Down Expand Up @@ -746,10 +747,10 @@ if (MINIFI_ADVANCED_CODE_COVERAGE)
set(GCOVR_ADDITIONAL_ARGS --gcov-ignore-parse-errors=negative_hits.warn --gcov-ignore-errors=no_working_dir_found)
setup_target_for_coverage_gcovr_html(
NAME coverage
EXCLUDE "build/*" "cmake/*" "minifi_main/*" "nanofi/*" "thirdparty/*" "libminifi/test/*" "extensions/http-curl/tests/*" "encrypt-config/tests/*" "extensions/aws/tests/*"
EXCLUDE "build/*" "cmake/*" "minifi_main/*" "nanofi/*" "thirdparty/*" "libminifi/test/*" "encrypt-config/tests/*" "extensions/aws/tests/*"
"extensions/civetweb/tests/*" "extensions/coap/tests/*" "extensions/elasticsearch/tests/*" "extensions/expression-language/tests/*" "extensions/gcp/tests/*" "extensions/grafana-loki/tests/*"
"extensions/kubernetes/tests/*" "extensions/librdkafka/tests/*" "extensions/lua/tests/*" "extensions/mqtt/tests/*" "extensions/opencv/tests/*" "extensions/procfs/tests/*" "extensions/prometheus/tests/*"
"extensions/script/tests/*" "extensions/sftp/tests/*" "extensions/splunk/tests/*" "extensions/standard-processors/tests/*" "extensions/systemd/tests/*" "extensions/test-processors/*"
"libminifi/include/utils/IntegrationTestUtils.h" "libminifi/include/utils/TestUtils.h" "controller/MiNiFiController.cpp"
"controller/MiNiFiController.cpp"
)
endif()
14 changes: 6 additions & 8 deletions Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
To enable all extensions for your platform, you may use -DENABLE_ALL=TRUE OR select the option to "Enable all Extensions" in the bootstrap script. [ReadMe](https://github.com/apache/nifi-minifi-cpp/#bootstrapping)

# Extension internals
Extensions are dynamic libraries loaded at runtime by the agent. An extension makes its
Extensions are dynamic libraries loaded at runtime by the agent. An extension makes its
capabilities (classes) available to the system through registrars. Registration must happen in source files, not headers.

```C++
Expand All @@ -32,19 +32,17 @@ REGISTER_RESOURCE(HTTPClient, InternalResource);
REGISTER_RESOURCE(RESTSender, DescriptionOnly);
```

Some extensions (e.g. `http-curl`) require initialization before use.
Some extensions (e.g. `OpenCVExtension`) require initialization before use.
You need to create `init` and `deinit` functions and register them using `REGISTER_EXTENSION`.

```C++
static bool init(const core::extension::ExtensionConfig& /*config*/) override {
return curl_global_init(CURL_GLOBAL_DEFAULT) == CURLE_OK;
static bool init(const std::shared_ptr<org::apache::nifi::minifi::Configure>& /*config*/) {
return org::apache::nifi::minifi::utils::Environment::setEnvironmentVariable("OPENCV_FFMPEG_CAPTURE_OPTIONS", "rtsp_transport;udp", false /*overwrite*/);
}

static void deinit() override {
curl_global_cleanup();
}
static void deinit() {}

REGISTER_EXTENSION("HttpCurlExtension", init, deinit);
REGISTER_EXTENSION("OpenCVExtension", init, deinit);
```

If you don't use `REGISTER_EXTENSION`, the registered resources still become available, so make sure to register the extension if you need special initialization.
Expand Down
Loading