Repository: nifi-minifi-cpp Updated Branches: refs/heads/master a82ac26a1 -> f3febb3da
MINIFICPP-643: Make updates to correct build, allow openssl, and enforce a force build command for windows This closes #419. Signed-off-by: Aldrin Piri <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/f3febb3d Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/f3febb3d Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/f3febb3d Branch: refs/heads/master Commit: f3febb3da8f8805a0d486284ade05b93dfd6f714 Parents: a82ac26 Author: Marc Parisi <[email protected]> Authored: Wed Oct 17 14:24:18 2018 -0400 Committer: Aldrin Piri <[email protected]> Committed: Thu Oct 18 10:45:07 2018 -0400 ---------------------------------------------------------------------- CMakeLists.txt | 21 +++- CMakeSettings.json | 124 +++++++++++-------- README.md | 2 + appveyor.yml | 2 +- controller/CMakeLists.txt | 4 +- extensions/librdkafka/CMakeLists.txt | 2 - extensions/rocksdb-repos/CMakeLists.txt | 2 - extensions/windows-event-log/CMakeLists.txt | 2 - libminifi/CMakeLists.txt | 2 +- .../include/controllers/SSLContextService.h | 2 + libminifi/include/core/Core.h | 4 +- libminifi/include/core/Resource.h | 2 + libminifi/src/c2/C2Agent.cpp | 4 +- .../Simple-Windows-Posix-Semaphore/semaphore.h | 4 +- 14 files changed, 106 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index bb07922..4b0f7a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,10 +37,15 @@ endif() option(ENABLE_PYTHON "Instructs the build system to enable building shared objects for the python lib" OFF) option(USE_SYSTEM_BZIP2 "Instructs the build system to search for and use a bzip2 library available in the host system" ON) option(BUILD_ROCKSDB "Instructs the build system to use RocksDB from the third party directory" ON) +option(FORCE_WINDOWS "Instructs the build system to force Windows builds when WIN32 is specified" OFF) include(FeatureSummary) include(ExternalProject) +if (OPENSSL_ROOT_DIR ) + set(OPENSSL_PASSTHROUGH "-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}") +endif() + set(PASSTHROUGH_CMAKE_ARGS -DANDROID_ABI=${ANDROID_ABI} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DANDROID_STL=${ANDROID_STL} @@ -57,6 +62,7 @@ set(PASSTHROUGH_CMAKE_ARGS -DANDROID_ABI=${ANDROID_ABI} -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY} -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=${CMAKE_FIND_ROOT_PATH_MODE_INCLUDE} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + ${OPENSSL_PASSTHROUGH} -G${CMAKE_GENERATOR}) # Use ccache if present @@ -71,6 +77,9 @@ endif(CCACHE_FOUND) # Enable usage of the VERSION specifier include(CheckCXXCompilerFlag) if (WIN32) + if (NOT FORCE_WINDOWS) + message(FATAL_ERROR "Windows builds can only be built with FORCE_WINDOWS") + endif() add_definitions(-DWIN32_LEAN_AND_MEAN) if ((MSVC_VERSION GREATER "1900") OR (MSVC_VERSION EQUAL "1900")) CHECK_CXX_COMPILER_FLAG("/std:c++14" _cpp_latest_flag_supported) @@ -160,6 +169,8 @@ else() # Include OpenSSL find_package (OpenSSL REQUIRED) + + if (OPENSSL_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENSSL_SUPPORT") @@ -273,15 +284,17 @@ if(NOT DISABLE_CURL AND (NOT USE_SYSTEM_CURL)) BUILD_BYPRODUCTS "thirdparty/${BYPRODUCT}" ) - if(NOT USE_SYSTEM_OPENSSL) + if(USE_SYSTEM_OPENSSL STREQUAL "OFF") add_dependencies(curl-external libressl-portable) endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/curl/dummy") add_library(curl STATIC IMPORTED) set_target_properties(curl PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${BYPRODUCT}") - if (OPENSSL_FOUND) - set_target_properties(curl PROPERTIES INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBRARIES}) + if (OPENSSL_FOUND) + if (NOT WIN32) + set_target_properties(curl PROPERTIES INTERFACE_LINK_LIBRARIES ${OPENSSL_LIBRARIES}) + endif() endif(OPENSSL_FOUND) add_dependencies(curl curl-external) set(CURL_FOUND "YES") @@ -303,7 +316,7 @@ set(CIVETWEB_ENABLE_CXX ON CACHE BOOL "Enable civet C++ library") set(CIVETWEB_ENABLE_SSL OFF CACHE BOOL "DISABLE SSL") SET(WITH_TOOLS OFF CACHE BOOL "Do not build RocksDB tools") -if (NOT APPLE) +if (ENABLE_PYTHON) SET(BUILD_SHARED_LIBS ON CACHE BOOL "build yaml cpp shared lib") endif() SET(WITH_TESTS OFF CACHE BOOL "Build RocksDB library (not repo) tests") http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/CMakeSettings.json ---------------------------------------------------------------------- diff --git a/CMakeSettings.json b/CMakeSettings.json index bc10fcd..a995e25 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -10,61 +10,73 @@ "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", "cmakeCommandArgs": "", "buildCommandArgs": "-v:minimal -m:8", - "variables": [ - { - "name": "OPENSSL_OFF", - "value": "ON" - }, - { - "name": "USE_SYSTEM_ZLIB", - "value": "OFF" - }, - { - "name": "USE_SYSTEM_CURL", - "value": "OFF" - }, - { - "name": "USE_SYSTEM_UUID", - "value": "OFF" - }, - { - "name": "DISABLE_ROCKSDB", - "value": "FALSE" - }, - { - "name": "ENABLE_WEL", - "value": "TRUE" - }, - { - "name": "ENABLE_LIBRDKAFKA", - "value": "OFF" - }, - { - "name": "DISABLE_CURL", - "value": "OFF" - }, - { - "name": "DISABLE_LIBARCHIVE", - "value": "TRUE" - }, - { - "name": "DISABLE_SCRIPTING", - "value": "TRUE" - }, - { - "name": "EXCLUDE_BOOST", - "value": "TRUE" - }, - { - "name": "DISABLE_EXPRESSION_LANGUAGE", - "value": "TRUE" - }, - { - "name": "SKIP_TESTS", - "value": "TRUE" - } + "variables": [ + { + "name": "OPENSSL_OFF", + "value": "OFF" + }, + { + "name": "USE_SYSTEM_OPENSSL", + "value": "ON" + }, + { + "name": "OPENSSL_ROOT_DIR", + "value": "C:\\OpenSSL-Win64" + }, + { + "name": "USE_SYSTEM_ZLIB", + "value": "OFF" + }, + { + "name": "USE_SYSTEM_CURL", + "value": "OFF" + }, + { + "name": "USE_SYSTEM_UUID", + "value": "OFF" + }, + { + "name": "FORCE_WINDOWS", + "value": "ON" + }, + { + "name": "DISABLE_ROCKSDB", + "value": "FALSE" + }, + { + "name": "ENABLE_WEL", + "value": "TRUE" + }, + { + "name": "ENABLE_LIBRDKAFKA", + "value": "OFF" + }, + { + "name": "DISABLE_CURL", + "value": "OFF" + }, + { + "name": "DISABLE_LIBARCHIVE", + "value": "TRUE" + }, + { + "name": "DISABLE_SCRIPTING", + "value": "TRUE" + }, + { + "name": "EXCLUDE_BOOST", + "value": "TRUE" + }, + { + "name": "DISABLE_EXPRESSION_LANGUAGE", + "value": "TRUE" + }, + { + "name": "SKIP_TESTS", + "value": "TRUE" + } - ], + ], "ctestCommandArgs": "" }, { @@ -94,6 +106,10 @@ "value": "OFF" }, { + "name": "FORCE_WINDOWS", + "value": "ON" + }, + { "name": "DISABLE_ROCKSDB", "value": "FALSE" }, http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index 1277934..ead8dba 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,8 @@ MiNiFi - C++ supports the following processors: ## Caveats * 0.5.0 represents a GA-release. We follow semver so you can expect API and ABI compatibility within minor releases. See [semver's website](https://semver.org/) for more information * Build and usage currently only supports Linux and OS X environments. MiNiFi C++ can be built and run through the Windows Subsystem for Linux but we provide no support for this platform. +* Native Windows builds are possible with limited support. Please note that you must enable them manually with -DFORCE_WINDOWS=ON on a windows platform. OPENSSL_ROOT_DIR must be specified + to support OpenSSL support within your build. * Provenance events generation is supported and are persisted using RocksDB. Volatile repositories can be used on systems without persistent storage. ## System Requirements http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/appveyor.yml ---------------------------------------------------------------------- diff --git a/appveyor.yml b/appveyor.yml index 09ed52d..0f1e3af 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,7 +22,7 @@ build_script: - cd C:\projects\nifi-minifi-cpp - mkdir build & exit 0 - cd build - - cmake -g"Ninja" -DWIN32=WIN32 -DOPENSSL_OFF=ON -DUSE_SYSTEM_ZLIB=OFF -DUSE_SYSTEM_CURL=OFF -DUSE_SYSTEM_UUID=OFF -DDISABLE_ROCKSDB=ON -DDISABLE_CURL=ON -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DEXCLUDE_BOOST=ON -DDISABLE_EXPRESSION_LANGUAGE=ON -DENABLE_WEL=TRUE -DSKIP_TESTS=ON .. + - cmake -g"Ninja" -DWIN32=WIN32 -DOPENSSL_OFF=ON -DUSE_SYSTEM_ZLIB=OFF -DFORCE_WINDOWS=ON -DUSE_SYSTEM_CURL=OFF -DUSE_SYSTEM_UUID=OFF -DDISABLE_ROCKSDB=ON -DDISABLE_CURL=ON -DDISABLE_LIBARCHIVE=ON -DDISABLE_SCRIPTING=ON -DEXCLUDE_BOOST=ON -DDISABLE_EXPRESSION_LANGUAGE=ON -DENABLE_WEL=TRUE -DSKIP_TESTS=ON .. set msbuild_platform=x64 - msbuild nifi-minifi-cpp.sln http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/controller/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/controller/CMakeLists.txt b/controller/CMakeLists.txt index 3142434..f00f6be 100644 --- a/controller/CMakeLists.txt +++ b/controller/CMakeLists.txt @@ -58,8 +58,10 @@ endif() find_package(UUID REQUIRED) # Include OpenSSL -find_package(OpenSSL REQUIRED) +find_package(OpenSSL ) +if (OPENSSL_FOUND) include_directories(${OPENSSL_INCLUDE_DIR}) +endif(OPENSSL_FOUND) # Link against minifi, yaml-cpp, civetweb-cpp, uuid, openssl, jsoncpp and rocksdb target_link_libraries(minificontroller core-minifi) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/extensions/librdkafka/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/extensions/librdkafka/CMakeLists.txt b/extensions/librdkafka/CMakeLists.txt index 50d89df..aaa4683 100644 --- a/extensions/librdkafka/CMakeLists.txt +++ b/extensions/librdkafka/CMakeLists.txt @@ -36,8 +36,6 @@ endif() # Include UUID find_package(UUID REQUIRED) target_link_libraries(minifi-rdkafka-extensions ${LIBMINIFI} ${UUID_LIBRARIES}) -find_package(OpenSSL REQUIRED) -include_directories(${OPENSSL_INCLUDE_DIR}) target_link_libraries(minifi-rdkafka-extensions ${CMAKE_DL_LIBS} ) if (LibRdKafka_FOUND AND NOT BUILD_LIBRDKAFKA) target_link_libraries(minifi-rdkafka-extensions ${LibRdKafka_LIBRARIES} ) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/extensions/rocksdb-repos/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/extensions/rocksdb-repos/CMakeLists.txt b/extensions/rocksdb-repos/CMakeLists.txt index c82b730..34faace 100644 --- a/extensions/rocksdb-repos/CMakeLists.txt +++ b/extensions/rocksdb-repos/CMakeLists.txt @@ -43,8 +43,6 @@ endif() # Include UUID find_package(UUID REQUIRED) target_link_libraries(minifi-rocksdb-repos ${LIBMINIFI} ${UUID_LIBRARIES}) -find_package(OpenSSL REQUIRED) -include_directories(${OPENSSL_INCLUDE_DIR}) target_link_libraries(minifi-rocksdb-repos ${CMAKE_DL_LIBS} ) if (ROCKSDB_FOUND AND NOT BUILD_ROCKSDB) target_link_libraries(minifi-rocksdb-repos ${ROCKSDB_LIBRARIES} ) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/extensions/windows-event-log/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/extensions/windows-event-log/CMakeLists.txt b/extensions/windows-event-log/CMakeLists.txt index 5e0545e..19e08a2 100644 --- a/extensions/windows-event-log/CMakeLists.txt +++ b/extensions/windows-event-log/CMakeLists.txt @@ -34,8 +34,6 @@ endif() # Include UUID find_package(UUID REQUIRED) target_link_libraries(minifi-wel ${LIBMINIFI} ${UUID_LIBRARIES}) -find_package(OpenSSL REQUIRED) -include_directories(${OPENSSL_INCLUDE_DIR}) target_link_libraries(minifi-wel ${CMAKE_DL_LIBS} ) find_package(ZLIB REQUIRED) include_directories(${ZLIB_INCLUDE_DIRS}) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/libminifi/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/libminifi/CMakeLists.txt b/libminifi/CMakeLists.txt index 11eec1c..9afcd6b 100644 --- a/libminifi/CMakeLists.txt +++ b/libminifi/CMakeLists.txt @@ -22,7 +22,7 @@ cmake_minimum_required (VERSION 2.6) project(nifi-libcore-minifi) set(PROJECT_NAME "nifi-libcore-minifi") set(PROJECT_VERSION_MAJOR 0) -set(PROJECT_VERSION_MINOR 5) +set(PROJECT_VERSION_MINOR 6) set(PROJECT_VERSION_PATCH 0) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/libminifi/include/controllers/SSLContextService.h ---------------------------------------------------------------------- diff --git a/libminifi/include/controllers/SSLContextService.h b/libminifi/include/controllers/SSLContextService.h index 4fa24c7..c8677e0 100644 --- a/libminifi/include/controllers/SSLContextService.h +++ b/libminifi/include/controllers/SSLContextService.h @@ -17,7 +17,9 @@ */ #ifndef LIBMINIFI_INCLUDE_CONTROLLERS_SSLCONTEXTSERVICE_H_ #define LIBMINIFI_INCLUDE_CONTROLLERS_SSLCONTEXTSERVICE_H_ +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 +#endif #ifdef OPENSSL_SUPPORT #include <openssl/err.h> #include <openssl/ssl.h> http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/libminifi/include/core/Core.h ---------------------------------------------------------------------- diff --git a/libminifi/include/core/Core.h b/libminifi/include/core/Core.h index 0a3c97d..c8d7b9a 100644 --- a/libminifi/include/core/Core.h +++ b/libminifi/include/core/Core.h @@ -55,7 +55,9 @@ #endif #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif // can't include cxxabi #else #include <cxxabi.h> http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/libminifi/include/core/Resource.h ---------------------------------------------------------------------- diff --git a/libminifi/include/core/Resource.h b/libminifi/include/core/Resource.h index f72d1fe..5acb844 100644 --- a/libminifi/include/core/Resource.h +++ b/libminifi/include/core/Resource.h @@ -18,7 +18,9 @@ #ifndef LIBMINIFI_INCLUDE_CORE_RESOURCE_H_ #define LIBMINIFI_INCLUDE_CORE_RESOURCE_H_ +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 +#endif #include "ClassLoader.h" http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/libminifi/src/c2/C2Agent.cpp ---------------------------------------------------------------------- diff --git a/libminifi/src/c2/C2Agent.cpp b/libminifi/src/c2/C2Agent.cpp index 8db6894..ebb4549 100644 --- a/libminifi/src/c2/C2Agent.cpp +++ b/libminifi/src/c2/C2Agent.cpp @@ -62,7 +62,7 @@ C2Agent::C2Agent(const std::shared_ptr<core::controller::ControllerServiceProvid auto time_since = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_run_).count(); // place priority on messages to send to the c2 server - if ( protocol_ != nullptr && request_mutex.try_lock_until(now + std::chrono::seconds(1)) ) { + if ( protocol_.load() != nullptr && request_mutex.try_lock_until(now + std::chrono::seconds(1)) ) { if (requests.size() > 0) { int count = 0; do { @@ -555,7 +555,7 @@ void C2Agent::handle_update(const C2ContentResponse &resp) { auto urlStr = url->second.to_string(); std::string file_path = urlStr; - if (nullptr != protocol_ && file_path.find("http") != std::string::npos) { + if (nullptr != protocol_.load() && file_path.find("http") != std::string::npos) { C2Payload &&response = protocol_.load()->consumePayload(urlStr, payload, RECEIVE, false); auto raw_data = response.getRawData(); http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/f3febb3d/thirdparty/Simple-Windows-Posix-Semaphore/semaphore.h ---------------------------------------------------------------------- diff --git a/thirdparty/Simple-Windows-Posix-Semaphore/semaphore.h b/thirdparty/Simple-Windows-Posix-Semaphore/semaphore.h index 124d9b6..b84e535 100644 --- a/thirdparty/Simple-Windows-Posix-Semaphore/semaphore.h +++ b/thirdparty/Simple-Windows-Posix-Semaphore/semaphore.h @@ -27,7 +27,9 @@ #define _SEMAPHORE_H_ 1 #ifdef WIN32 -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include <WinSock2.h> #include <WS2tcpip.h> #include <Windows.h>
