Skip to content

Commit c71d822

Browse files
committed
MINIFICPP-2740 Rust bindings based on stable C API
1 parent a50d591 commit c71d822

128 files changed

Lines changed: 8348 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ concurrency:
1111
env:
1212
DOCKER_CMAKE_FLAGS: -DDOCKER_VERIFY_THREAD=3 -DUSE_SHARED_LIBS= -DSTRICT_GSL_CHECKS=AUDIT -DCI_BUILD=ON -DENABLE_AWS=ON -DENABLE_KAFKA=ON -DENABLE_MQTT=ON -DENABLE_AZURE=ON -DENABLE_SQL=ON \
1313
-DENABLE_SPLUNK=ON -DENABLE_GCP=ON -DENABLE_OPC=ON -DENABLE_PYTHON_SCRIPTING=ON -DENABLE_LUA_SCRIPTING=ON -DENABLE_KUBERNETES=ON -DENABLE_TEST_PROCESSORS=ON -DENABLE_PROMETHEUS=ON \
14-
-DENABLE_ELASTICSEARCH=ON -DENABLE_GRAFANA_LOKI=ON -DENABLE_COUCHBASE=ON -DENABLE_LLAMACPP=ON -DDOCKER_BUILD_ONLY=ON -DMINIFI_PERFORMANCE_TESTS=ON
14+
-DENABLE_ELASTICSEARCH=ON -DENABLE_GRAFANA_LOKI=ON -DENABLE_COUCHBASE=ON -DENABLE_LLAMACPP=ON -DDOCKER_BUILD_ONLY=ON -DMINIFI_PERFORMANCE_TESTS=ON -DMINIFI_RUST=OFF
1515
CCACHE_DIR: ${{ GITHUB.WORKSPACE }}/.ccache
1616
jobs:
1717
macos_xcode:
@@ -552,8 +552,55 @@ jobs:
552552
with:
553553
name: behavex_output_modular
554554
path: build/behavex_output_modular
555+
rusty_docker_tests:
556+
name: "Rusty Docker integration tests (x86_64)"
557+
needs: docker_build
558+
runs-on: ubuntu-24.04
559+
timeout-minutes: 20
560+
steps:
561+
- id: checkout
562+
uses: actions/checkout@v6
563+
- id: run_cmake
564+
name: Run CMake
565+
run: |
566+
mkdir build
567+
cd build
568+
cmake ${DOCKER_CMAKE_FLAGS} ..
569+
- name: Download artifact
570+
uses: actions/download-artifact@v8
571+
with:
572+
name: minifi_docker
573+
path: build
574+
- name: Load Docker image
575+
run: |
576+
docker load --input ./build/minifi_docker.tar && docker tag apacheminificpp:1.0.0 apacheminificpp:behave
577+
- id: install_deps
578+
name: Install dependencies for Docker Verify
579+
run: |
580+
sudo apt update
581+
sudo apt install -y python3-virtualenv
582+
- id: test
583+
name: Docker Verify
584+
working-directory: ./minifi_rust
585+
run: cargo behave-alpine
586+
- name: Test Reporter
587+
if: always()
588+
uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3
589+
with:
590+
name: Docker integration tests
591+
path: minifi_rust/minifi_rs_behave/output/behave/*.xml
592+
reporter: java-junit
593+
only-summary: 'true'
594+
list-tests: 'failed'
595+
list-suites: 'failed'
596+
- name: Upload artifact
597+
if: failure()
598+
uses: actions/upload-artifact@v7
599+
with:
600+
name: minifi_rs_behave
601+
path: minifi_rust/minifi_rs_behave/output
555602
linters:
556-
name: "C++ lint + Shellcheck + Flake8"
603+
name: "C++ lint + Shellcheck + Flake8 + Cargo check"
557604
runs-on: ubuntu-22.04-arm
558605
timeout-minutes: 15
559606
steps:
@@ -578,8 +625,14 @@ jobs:
578625
continue-on-error: true
579626
run: ./run_flake8.sh .
580627

628+
- id: cargo_check
629+
name: Cargo check
630+
continue-on-error: true
631+
run: cargo fmt --check
632+
working-directory: minifi_rust
633+
581634
- name: Check Linter Statuses
582-
if: steps.cpp_lint.outcome == 'failure' || steps.shellcheck.outcome == 'failure' || steps.flake8_check.outcome == 'failure'
635+
if: steps.cpp_lint.outcome == 'failure' || steps.shellcheck.outcome == 'failure' || steps.flake8_check.outcome == 'failure' || steps.cargo_check.outcome == 'failure'
583636
run: |
584637
echo "One or more linters failed. Failing the workflow."
585638
exit 1

.github/workflows/create-release-artifacts.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ jobs:
4343
with:
4444
name: ${{ matrix.platform.rpm-artifact }}
4545
path: build/nifi-minifi-cpp-*.rpm
46+
47+
- id: cargo
48+
working-directory: minifi_rust
49+
run: |
50+
cargo build --release
51+
52+
- uses: actions/upload-artifact@v7
53+
with:
54+
name: minifi_rust_extensions
55+
path: minifi_rust/target/release/*.so
4656
windows_VS2022:
4757
name: "Windows Server 2025 x86_64"
4858
runs-on: windows-2025

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,3 +851,5 @@ if (MINIFI_ADVANCED_CODE_COVERAGE)
851851
endif()
852852

853853
add_subdirectory(packaging)
854+
855+
add_subdirectory(minifi_rust)

cmake/MiNiFiOptions.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ add_minifi_option(ENABLE_EXECUTE_PROCESS "Enable ExecuteProcess processor" OFF)
116116
add_minifi_option(ENABLE_CONTROLLER "Enables the build of MiNiFi controller binary." ON)
117117
add_minifi_option(ENABLE_LLAMACPP "Enables llama.cpp support." ON)
118118
add_minifi_option(ENABLE_OPC "Instructs the build system to enable the OPC extension" ON)
119+
add_minifi_option(MINIFI_RUST "Enables the build of rust based extension." ON)
119120

120121
set_minifi_cache_variable(CUSTOM_MALLOC OFF "Overwrite malloc implementation.")
121122
set_property(CACHE CUSTOM_MALLOC PROPERTY STRINGS "jemalloc" "mimalloc" "rpmalloc" OFF)

docker/rockylinux/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ COPY . ${MINIFI_BASE_DIR}
4242
# Install the system dependencies needed for a build
4343
# ccache is in EPEL
4444
RUN dnf -y install epel-release && dnf -y install gcc-toolset-14 gcc-toolset-14-libatomic-devel sudo git which make libarchive ccache ca-certificates perl patch bison flex libtool cmake rpmdevtools && \
45+
if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_ALL=ON\|MINIFI_RUST=ON"; then dnf -y install rust cargo clang; fi && \
4546
if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_ALL=ON\|ENABLE_PYTHON_SCRIPTING=ON\|ENABLE_OPC=ON"; then dnf -y --enablerepo=devel install python3-devel; fi && \
4647
if echo "$MINIFI_OPTIONS" | grep -q "ENABLE_SFTP=ON" && [ "${DOCKER_SKIP_TESTS}" == "OFF" ]; then dnf -y install java-1.8.0-openjdk maven; fi
4748

4849
RUN cd $MINIFI_BASE_DIR && \
49-
ln -s /usr/bin/ccache /usr/lib64/ccache/c++
50+
ln -sfn /usr/bin/ccache /usr/lib64/ccache/c++
5051

5152
# Setup minificpp user
5253
RUN groupadd -g ${GID} ${USER} && useradd -g ${GID} ${USER} && \

minifi_rust/.cargo/config.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[target.aarch64-unknown-linux-musl]
2+
rustflags = ["-C", "target-feature=-crt-static"]
3+
4+
[target.x86_64-unknown-linux-musl]
5+
rustflags = ["-C", "target-feature=-crt-static"]
6+
7+
[target.aarch64-apple-darwin]
8+
rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]
9+
10+
[target.x86_64-apple-darwin]
11+
rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]
12+
13+
[alias]
14+
behave = ["run", "--release", "--bin", "minifi_rs_behave"]
15+
behave-alpine = ["run", "--release", "--bin", "minifi_rs_behave", "--", "--alpine"]
16+
behave-debian = ["run", "--release", "--bin", "minifi_rs_behave", "--", "--debian"]
17+
18+
[env]
19+
MINIFI_SDK_PATH="../"

minifi_rust/.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.git
2+
.vscode
3+
.gitmodules
4+
.idea
5+
output
6+
features
7+
target/debug
8+
target/release/build
9+
target/release/deps
10+
target/release/.fingerprint
11+
target/release/examples
12+
target/release/incremental

minifi_rust/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea
2+
output
3+
venv
4+
.venv
5+
target
6+
.DS_Store
7+
Cargo.lock

minifi_rust/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
#
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
if (NOT (ENABLE_ALL OR MINIFI_RUST))
21+
return()
22+
endif()
23+
24+
include(FetchContent)
25+
26+
# Corrosion is a tool for integrating Rust into an existing CMake project
27+
FetchContent_Declare(Corrosion
28+
URL https://github.com/corrosion-rs/corrosion/archive/refs/tags/v0.6.1.tar.gz
29+
URL_HASH SHA256=e9e95b1ee2bad52681f347993fb1a5af5cce458c5ce8a2636c9e476e4babf8e3
30+
SYSTEM)
31+
32+
FetchContent_MakeAvailable(Corrosion)
33+
34+
corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml)
35+
36+
include(CTest)
37+
38+
add_test(
39+
NAME cargo_tests
40+
COMMAND cargo test
41+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
42+
)

minifi_rust/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[workspace]
2+
resolver = "3"
3+
members = ["minifi_native_sys", "minifi_native", "minifi_native_macros", "minifi_rs_behave", "extensions/*"]
4+
5+
[profile.release]
6+
panic = "abort"
7+
8+
[profile.dev]
9+
panic = "abort"

0 commit comments

Comments
 (0)