Skip to content

Commit 7e0d31b

Browse files
fgerlitsszaszm
authored andcommitted
MINIFICPP-2807 Fix Conan build
Updated dependency versions and added small fixes. A few extensions still don't build with Conan, these are disabled in conanfile.py. TODO (in upcoming PRs): * enable the remaining extensions * use Conan in CI * integrate Conan into bootstrap. Closes #2181 Signed-off-by: Marton Szasz <szaszm@apache.org>
1 parent 970ff9b commit 7e0d31b

14 files changed

Lines changed: 146 additions & 69 deletions

File tree

CONAN.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,36 @@ source, it uses CMake to install the third party external libraries that are ena
3636

3737
## Build MiNiFi C++ with Conan
3838

39-
To build MiNiFi using conan, first we install conan version 2, then we create a **default** conan profile that will later be ignored for our custom conan profile, create a MINIFI_HOME environment variable, then we install prebuilt conan packages representing the MiNiFi external libraries and finally we compile MiNiFi.
39+
### Install Conan
4040

4141
~~~bash
42-
sudo pip install --force-reinstall -v "conan==2.0.17"
42+
sudo pip install --force-reinstall -v "conan==2.28.1"
4343

4444
# create a "default" conan profile, so conan has it on record in ~/.conan2/, before using your own custom profile.
4545
conan profile detect
46+
~~~
47+
48+
### Create Custom RocksDB Conan Package
49+
The default RocksDB conan package is built with -fno-rtti, which makes it incompatible with MiNiFi. So we need to create a custom RocksDB conan package that is built with -frtti.
50+
51+
~~~bash
52+
cd $HOME/nifi-minifi-cpp/thirdparty/rocksdb/all
53+
54+
conan create . --user=minifi --channel=develop --test-folder="" --version=11.1.1 --profile=../../../etc/conan/profiles/release-linux
55+
~~~
56+
57+
### Build MiNiFi
4658

59+
~~~bash
4760
# conanfile.py is in root dir of MiNiFi C++ project
4861
cd $HOME/nifi-minifi-cpp
4962

50-
# create MINIFI_HOME env variable for binary executable minifi
51-
export MINIFI_HOME=$(pwd)
52-
5363
# install conan packages for MiNiFi C++ using conanfile.py invoking Conan
5464
# since we created default profile earlier, we can override it with our own minifi profile
55-
conan install . --build=missing --output-folder=build_conan -pr=etc/conan/profiles/release-linux
65+
conan install . --build=missing --output-folder=build_conan --profile=etc/conan/profiles/release-linux
5666

5767
# build MiNiFi C++ using conanfile.py invoking Conan & CMake
58-
conan build . --output-folder=build_conan -pr=etc/conan/profiles/release-linux
68+
conan build . --output-folder=build_conan --profile=etc/conan/profiles/release-linux
5969
~~~
6070

6171
- **NOTE**: After building MiNiFi, we must have the MINIFI_HOME environment variable created in order to successfully run the minifi binary executable.
@@ -76,6 +86,10 @@ popd # build_conan/
7686

7787
~~~bash
7888
# verify we can run minifi binary executable
89+
cd $HOME/nifi-minifi-cpp
90+
91+
export MINIFI_HOME=$(pwd)
92+
7993
./build_conan/bin/minifi
8094
~~~
8195

@@ -85,7 +99,7 @@ To create a MiNiFi package, we will follow the similar steps we took to build Mi
8599

86100
~~~bash
87101
# make sure to install conan2 for your environment
88-
sudo pip install --force-reinstall -v "conan==2.0.17"
102+
sudo pip install --force-reinstall -v "conan==2.28.1"
89103

90104
# create a "default" conan profile, so conan has it on record, before using your own custom profile. Gets created in ~/.conan2/
91105
conan profile detect
@@ -99,10 +113,10 @@ export MINIFI_HOME=$(pwd)
99113
# install conan packages for MiNiFi C++ using conanfile.py invoking Conan
100114
# since we created default profile earlier, we can override it with our own minifi profile
101115
# make sure path is correct
102-
conan install . --build=missing --output-folder=build_conan -pr=etc/conan/profiles/release-linux
116+
conan install . --build=missing --output-folder=build_conan --profile=etc/conan/profiles/release-linux
103117

104118
# create MiNiFi C++ conan package using conanfile.py invoking Conan & CMake
105-
conan create . --user=minifi --channel=develop -pr=etc/conan/profiles/release-linux
119+
conan create . --user=minifi --channel=develop --profile=etc/conan/profiles/release-linux
106120
~~~
107121

108122
- **NOTE**: When we tell conan to create the MiNiFi conan package, conan first installs prebuilt conan packages, then it compiles MiNiFi from source inside `~/.conan2/p/b/minif<UUID>/b`, and then it copies over MiNiFi's libraries and its binary executables into the conan package folder `~/.conan2/p/b/minif<UUID>/p`. Once we have the MiNiFi conan package, we can integrate it into other C++ infrastructure using CMake.
@@ -123,15 +137,3 @@ To have a more consistent quick build process for MiNiFi, we can use conan versi
123137
There are multiple benefits of having MiNiFi prebuilt conan packages. We can upload these MiNiFi conan packages to a conan repository like jfrog for version management. We can easily integrate MiNiFi's edge data pipeline features into other C++ software infrastructure using conan's CMake support. We can still use MiNiFi for edge data collection from the IoT devices embedded on robotic systems. We can integrate MiNiFi into self-driving cars (sensor examples: cameras, lidar, radar, inertial measurement unit (IMU), electronic speed controller (ESC), steering servo, etc), into medical imaging robots (sensor examples: depth cameras, ultrasound, gamma detector, force/torque sensor, joint position sensor, etc) or some other real-time robotic system.
124138

125139
By leveraging MiNiFi as a conan package, we can leverage MiNiFi that comes with the best practices of building data pipelines from NiFi and bring them into existing C++ real-time robotics infrastructure. Some teams across companies typically have their own custom edge data pipelines that process data for the different events to eventually perform actions on that data. As an alternative to all these companies and their teams having their own custom edge data pipeline libraries, MiNiFi C++, which is like a headless NiFi, can provide a more consistent standard approach for team's to build edge pipelines. Through all stages of the edge data pipelines, MiNiFi can still provide telemetry to NiFi instances running in the cloud.
126-
127-
## Appendix
128-
129-
### Create Custom RocksDB Conan Package
130-
131-
~~~bash
132-
pushd nifi-minifi-cpp/thirdparty/rocksdb/all
133-
134-
conan create . --user=minifi --channel=develop --version=8.10.2 -pr=../../../etc/conan/profiles/release-linux
135-
136-
popd
137-
~~~

cmake/BundledRocksDB.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function(use_bundled_rocksdb SOURCE_DIR BINARY_DIR)
1919
message("Using bundled RocksDB")
2020

2121
if (NOT WIN32)
22-
include(Zstd)
23-
include(LZ4)
22+
include(GetZstd)
23+
include(GetLZ4)
2424
endif()
2525

2626
set(PATCH_FILE "${SOURCE_DIR}/thirdparty/rocksdb/all/patches/dboptions_equality_operator.patch")

cmake/Couchbase.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
include(FetchContent)
1919

20-
include(fmt)
21-
include(Spdlog)
20+
include(GetFmt)
21+
include(GetSpdlog)
2222
include(Asio)
2323

2424
set(COUCHBASE_CXX_CLIENT_BUILD_STATIC ON CACHE BOOL "" FORCE)

cmake/Fetchlibrdkafka.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# under the License.
1717

1818
include(FetchContent)
19-
include(Zstd)
2019

21-
include(LZ4)
20+
include(GetZstd)
21+
include(GetLZ4)
2222

2323
set(WITH_SSL "ON" CACHE STRING "" FORCE)
2424
set(WITH_SASL "OFF" CACHE STRING "" FORCE)
@@ -46,7 +46,10 @@ FetchContent_Declare(libkafka
4646
FetchContent_MakeAvailable(libkafka)
4747

4848
get_target_property(ZSTD_INCLUDE_DIRS zstd::zstd INTERFACE_INCLUDE_DIRECTORIES)
49-
get_target_property(LZ4_INCLUDE_DIRS lz4::lz4 INCLUDE_DIRECTORIES)
49+
50+
if(NOT DEFINED LZ4_INCLUDE_DIRS)
51+
get_target_property(LZ4_INCLUDE_DIRS lz4::lz4 INCLUDE_DIRECTORIES)
52+
endif()
5053

5154
target_include_directories(rdkafka SYSTEM PRIVATE ${ZSTD_INCLUDE_DIRS})
5255
target_include_directories(rdkafka SYSTEM PRIVATE ${LZ4_INCLUDE_DIRS})

cmake/GetLZ4.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
if(MINIFI_LZ4_SOURCE STREQUAL "CONAN")
19+
message("Using Conan to install lz4")
20+
find_package(lz4 REQUIRED)
21+
if(NOT TARGET lz4::lz4)
22+
add_library(lz4::lz4 ALIAS LZ4::liblz4_static)
23+
endif()
24+
if(NOT TARGET LZ4::LZ4)
25+
add_library(LZ4::LZ4 ALIAS lz4::lz4)
26+
endif()
27+
set(LZ4_LIBRARIES "${lz4_LIBRARIES}" CACHE STRING "" FORCE)
28+
set(LZ4_INCLUDE_DIRS "${lz4_INCLUDE_DIRS}" CACHE STRING "" FORCE)
29+
elseif(MINIFI_LZ4_SOURCE STREQUAL "BUILD")
30+
message("Using CMake to build lz4 from source")
31+
include(LZ4)
32+
endif()

cmake/GetLibArchive.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
if(MINIFI_LIBARCHIVE_SOURCE STREQUAL "CONAN")
19+
message("Using Conan to install LibArchive")
20+
find_package(LibArchive REQUIRED)
21+
elseif(MINIFI_LIBARCHIVE_SOURCE STREQUAL "BUILD")
22+
message("Using CMake to build LibArchive from source")
23+
include(BundledLibArchive)
24+
use_bundled_libarchive(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
25+
endif()

cmake/GetZstd.cmake

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
function(get_zstd)
19-
if(MINIFI_ZSTD_SOURCE STREQUAL "CONAN")
20-
message("Using Conan to install zstd")
21-
find_package(zstd REQUIRED)
18+
if(MINIFI_ZSTD_SOURCE STREQUAL "CONAN")
19+
message("Using Conan to install zstd")
20+
find_package(zstd REQUIRED)
21+
if(NOT TARGET zstd::zstd)
2222
add_library(zstd::zstd ALIAS zstd::libzstd_static)
23-
elseif(MINIFI_ZSTD_SOURCE STREQUAL "BUILD")
24-
message("Using CMake to build zstd from source")
25-
include(Zstd)
2623
endif()
27-
endfunction(get_zstd)
24+
set(ZSTD_LIBRARIES "${zstd_LIBRARIES}" CACHE STRING "" FORCE)
25+
set(ZSTD_INCLUDE_DIRS "${zstd_INCLUDE_DIRS}" CACHE STRING "" FORCE)
26+
elseif(MINIFI_ZSTD_SOURCE STREQUAL "BUILD")
27+
message("Using CMake to build zstd from source")
28+
include(Zstd)
29+
endif()

cmake/MiNiFiOptions.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ set(STRICT_GSL_CHECKS "DEBUG_ONLY" CACHE STRING "Contract checking and assertion
135135
list(APPEND STRICT_GSL_CHECKS_Values AUDIT ON DEBUG_ONLY OFF)
136136
set_property(CACHE STRICT_GSL_CHECKS PROPERTY STRINGS ${STRICT_GSL_CHECKS_Values})
137137

138+
add_minifi_multi_option(MINIFI_PACKAGING_TYPE "Selects the packaging format for the final artifact." "TGZ;RPM" "TGZ")
139+
138140
# BUILD: Fetch and build from source using CMake FetchContent or ExternalProject
139141
# SYSTEM: Use find_package to use the system version
140142
# CONAN: Use Conan packages
141-
add_minifi_multi_option(MINIFI_PACKAGING_TYPE "Selects the packaging format for the final artifact." "TGZ;RPM" "TGZ")
143+
add_minifi_multi_option(MINIFI_LZ4_SOURCE "Retrieves lz4 from provided source" "BUILD;SYSTEM;CONAN" "BUILD")
142144
add_minifi_multi_option(MINIFI_LIBCURL_SOURCE "Retrieves LibCURL from provided source" "BUILD;SYSTEM;CONAN" "BUILD")
143145
add_minifi_multi_option(MINIFI_OPENSSL_SOURCE "Retrieves OpenSSL from provided source" "BUILD;SYSTEM;CONAN" "BUILD")
144146
add_minifi_multi_option(MINIFI_ZLIB_SOURCE "Retrieves ZLib from provided source" "BUILD;SYSTEM;CONAN" "BUILD")
@@ -150,6 +152,7 @@ add_minifi_multi_option(MINIFI_LIBXML2_SOURCE "Retrieves LibXml2 from provided s
150152
add_minifi_multi_option(MINIFI_FMT_SOURCE "Retrieves Fmt from provided source" "BUILD;SYSTEM;CONAN" "BUILD")
151153
add_minifi_multi_option(MINIFI_SPDLOG_SOURCE "Retrieves Spdlog from provided source" "BUILD;SYSTEM;CONAN" "BUILD")
152154
add_minifi_multi_option(MINIFI_CATCH2_SOURCE "Retrieves Catch2 from provided source" "BUILD;SYSTEM;CONAN" "BUILD")
155+
add_minifi_multi_option(MINIFI_LIBARCHIVE_SOURCE "Retrieves libarchive from provided source" "BUILD;SYSTEM;CONAN" "BUILD")
153156

154157
# Docker options
155158

conanfile.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77

88
required_conan_version = ">=2.0"
99

10-
shared_requires = ("openssl/3.2.1", "libcurl/8.4.0", "civetweb/1.16", "libxml2/2.12.6", "fmt/10.2.1", "spdlog/1.14.0", "catch2/3.5.4", "zlib/1.2.11", "zstd/1.5.2", "bzip2/1.0.8", "rocksdb/8.10.2@minifi/develop")
10+
shared_requires = ("lz4/1.10.0", "openssl/3.6.2", "libcurl/8.20.0", "civetweb/1.16", "libxml2/2.15.3", "fmt/12.1.0", "spdlog/1.17.0", "catch2/3.14.0", "zlib/1.3.2", "zstd/1.5.7",
11+
"bzip2/1.0.8", "rocksdb/11.1.1@minifi/develop", "libarchive/3.8.7")
1112

12-
shared_sources = ("CMakeLists.txt", "libminifi/*", "extensions/*", "minifi_main/*", "nanofi/*", "bin/*", "bootstrap/*", "cmake/*", "conf/*", "controller/*", "encrypt-config/*", "etc/*", "examples/*", "packaging/msi/*", "thirdparty/*", "docker/*", "LICENSE", "NOTICE", "README.md", "C2.md", "CONFIGURE.md", "CONTRIBUTING.md", "CONTROLLERS.md", "EXPRESSIONS.md", "Extensions.md", "JNI.md", "METRICS.md", "OPS.md", "PROCESSORS.md", "ThirdParties.md", "Windows.md", "CPPLINT.cfg", "generateVersion.sh", "run_clang_tidy.sh", "run_clang_tidy.sh", "run_flake8.sh", "run_shellcheck.sh", "versioninfo.rc.in")
13+
shared_sources = ("CMakeLists.txt", "libminifi/*", "extensions/*", "minifi_main/*", "behave_framework/*", "bin/*", "bootstrap/*", "cmake/*", "conf/*", "controller/*", "core-framework/*",
14+
"docs/*", "encrypt-config/*", "etc/*", "examples/*", "extension-framework/*", "fips/*", "minifi-api/*", "packaging/*", "thirdparty/*", "docker/*", "LICENSE", "NOTICE",
15+
"README.md", "C2.md", "CONAN.md", "CONFIGURE.md", "CONTRIBUTING.md", "CONTROLLERS.md", "EXPRESSIONS.md", "Extensions.md", "METRICS.md", "OPS.md", "PARAMETER_PROVIDERS.md",
16+
"PROCESSORS.md", "SITE_TO_SITE.md", "ThirdParties.md", "Windows.md", "CPPLINT.cfg", "generateVersion.bat", "generateVersion.sh", "run_clang_tidy.sh", "run_flake8.sh",
17+
"run_shellcheck.sh", "versioninfo.rc.in")
1318

1419

1520
class MiNiFiCppMain(ConanFile):
@@ -28,6 +33,7 @@ class MiNiFiCppMain(ConanFile):
2833
def generate(self):
2934
tc = CMakeToolchain(self)
3035

36+
tc.variables["MINIFI_LZ4_SOURCE"] = "CONAN"
3137
tc.variables["MINIFI_LIBCURL_SOURCE"] = "CONAN"
3238
tc.variables["MINIFI_OPENSSL_SOURCE"] = "CONAN"
3339
tc.variables["MINIFI_ZLIB_SOURCE"] = "CONAN"
@@ -39,13 +45,10 @@ def generate(self):
3945
tc.variables["MINIFI_FMT_SOURCE"] = "CONAN"
4046
tc.variables["MINIFI_SPDLOG_SOURCE"] = "CONAN"
4147
tc.variables["MINIFI_CATCH2_SOURCE"] = "CONAN"
48+
tc.variables["MINIFI_LIBARCHIVE_SOURCE"] = "CONAN"
4249

43-
tc.variables["SKIP_TESTS"] = "OFF"
44-
tc.variables["ENABLE_CIVET"] = "ON"
45-
tc.variables["ENABLE_LIBARCHIVE"] = "OFF"
4650
tc.variables["ENABLE_AWS"] = "OFF"
47-
tc.variables["ENABLE_SQL"] = "OFF"
48-
tc.variables["ENABLE_GCP"] = "OFF"
51+
tc.variables["ENABLE_LLAMACPP"] = "OFF"
4952
tc.variables["ENABLE_LUA_SCRIPTING"] = "OFF"
5053

5154
tc.generate()

etc/conan/profiles/release-linux

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ os=Linux
33
arch=x86_64
44
build_type=Release
55
compiler=gcc
6-
compiler.cppstd=20
6+
compiler.cppstd=23
77
compiler.libcxx=libstdc++11
8-
compiler.version=11
8+
compiler.version=13
99
[conf]
1010
tools.system.package_manager:mode=install
1111
tools.system.package_manager:sudo=True
12+
tools.cmake.cmaketoolchain:generator=Ninja
1213
[options]

0 commit comments

Comments
 (0)