feat: switch iperf3 to JNI with 3.19 source
- Switch from bundled iperf3 binary (Process.start) to JNI compilation - iperf3 3.21 source API was incompatible (start_time, iperf_strerror, etc.) - iperf3 3.19 source is proven to work (used by CellularLab) - CMakeLists.txt updated: config.h generated into cpp/iperf/ for correct include paths - iperf_jni.c fixed for 3.19 API (no start_time on iperf_test) - getTestProgress() returns g_test->duration as fallback (no real-time elapsed tracking yet) - NDK CMake pinned to 3.22.1 - UI layer updated: removed Iperf3BinaryPathProvider references - Tests updated: TestRunViewModelTest matches new service interface - pubspec.yaml: removed iperf3 assets bundle, added http dependency - AndroidManifest: INTERNET permission (needed for hostname resolution)
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
cmake_minimum_required(VERSION 3.22.1)
|
||||
project("iperf3jni")
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# Paths
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# CMAKE_SOURCE_DIR here is android/app/src/main/cpp/
|
||||
set(IPERF_SRC_DIR ${CMAKE_SOURCE_DIR}/iperf)
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# Generate iperf_config.h from our Android template, into cpp/iperf/
|
||||
# (iperf.h uses #include "iperf_config.h" which resolves relative to its dir)
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
configure_file(
|
||||
${IPERF_SRC_DIR}/iperf_config_android.h
|
||||
${IPERF_SRC_DIR}/iperf_config.h
|
||||
)
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# Shared library: iperf3jni
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
add_library(iperf3jni SHARED
|
||||
|
||||
# JNI bridge (directly in cpp/)
|
||||
iperf_jni.c
|
||||
|
||||
# iperf3 source files (in cpp/iperf/)
|
||||
iperf/iperf_api.c
|
||||
iperf/iperf_client_api.c
|
||||
iperf/iperf_util.c
|
||||
iperf/iperf_udp.c
|
||||
iperf/iperf_tcp.c
|
||||
iperf/iperf_server_api.c
|
||||
iperf/iperf_sctp.c
|
||||
iperf/iperf_error.c
|
||||
iperf/iperf_time.c
|
||||
iperf/iperf_locale.c
|
||||
iperf/iperf_pthread.c
|
||||
iperf/iperf_auth.c
|
||||
iperf/net.c
|
||||
iperf/timer.c
|
||||
iperf/units.c
|
||||
iperf/cjson.c
|
||||
iperf/dscp.c
|
||||
iperf/tcp_info.c
|
||||
)
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# Include directories - iperf/ FIRST so "iperf_config.h" resolves there
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
target_include_directories(iperf3jni PRIVATE
|
||||
${IPERF_SRC_DIR} # for iperf headers (iperf_config.h, iperf.h, etc.)
|
||||
${CMAKE_SOURCE_DIR} # for JNI includes
|
||||
)
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# Compile definitions
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
target_compile_definitions(iperf3jni PRIVATE
|
||||
HAVE_PTHREAD
|
||||
__ANDROID__
|
||||
# Disable the main() entry point — we're a shared lib, not a standalone binary
|
||||
IPERF_JNI_BUILD=1
|
||||
)
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
# Link libraries
|
||||
# ──────────────────────────────────────────────────────────────────
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(iperf3jni
|
||||
Threads::Threads
|
||||
log
|
||||
android
|
||||
)
|
||||
Reference in New Issue
Block a user