Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit 0919630

Browse files
author
TeleGhost Dev
committed
Fix Android i2pd build: patch Boost headers for libc++ compatibility
1 parent 255f4dd commit 0919630

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

‎scripts/build_i2pd_android.sh‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ ARCHS=("arm64-v8a" "armeabi-v7a" "x86_64" "x86")
2727
# ABI names for CMake
2828
ABIS=("arm64-v8a" "armeabi-v7a" "x86_64" "x86")
2929

30+
# Patch Boost once for NDK 26 compatibility (std::unary_function removal in C++17)
31+
if [ ! -f "$BUILD_DIR/.boost_patched" ]; then
32+
echo "Patching Boost headers for NDK 26 compatibility..."
33+
# Find headers (version.hpp)
34+
TEMP_INCLUDE=$(find "$BOOST_ROOT" -name "version.hpp" | grep "boost/version.hpp" | head -n 1 | sed 's|/boost/version.hpp||')
35+
if [ -n "$TEMP_INCLUDE" ]; then
36+
echo " Found Boost include at $TEMP_INCLUDE. Patching..."
37+
# Replacing std::unary_function and std::binary_function with __ equivalents provided by libc++ for compatibility
38+
find "$TEMP_INCLUDE/boost" -type f -name "*.hpp" -exec sed -i 's/std::unary_function/std::__unary_function/g' {} +
39+
find "$TEMP_INCLUDE/boost" -type f -name "*.hpp" -exec sed -i 's/std::binary_function/std::__binary_function/g' {} +
40+
touch "$BUILD_DIR/.boost_patched"
41+
else
42+
echo " Warning: Could not find Boost headers to patch"
43+
fi
44+
fi
45+
3046
# Loop over architectures
3147
for i in "${!ARCHS[@]}"; do
3248
ARCH=${ARCHS[$i]}
@@ -35,7 +51,7 @@ for i in "${!ARCHS[@]}"; do
3551
echo ">>> Building for $ARCH ($ABI)..."
3652

3753
ARCH_BUILD_DIR="$BUILD_DIR/$ARCH"
38-
mkdir -p $ARCH_BUILD_DIR
54+
mkdir -p "$ARCH_BUILD_DIR"
3955

4056
# Locate OpenSSL for this Arch
4157
echo "--- OpenSSL Discovery for $ARCH ---"
@@ -64,7 +80,7 @@ for i in "${!ARCHS[@]}"; do
6480
# Locate Boost for this Arch
6581
echo "--- Boost Discovery for $ARCH ---"
6682

67-
# Find headers (version.hpp)
83+
# Find headers (already found above but let's re-verify per arch paths if needed)
6884
BOOST_INCLUDE_PATH=$(find "$BOOST_ROOT" -name "version.hpp" | grep "boost/version.hpp" | head -n 1 | sed 's|/boost/version.hpp||')
6985
if [ -z "$BOOST_INCLUDE_PATH" ]; then
7086
echo "Warning: find could not locate version.hpp, using fallback paths"
@@ -102,7 +118,6 @@ for i in "${!ARCHS[@]}"; do
102118
-DANDROID_ABI="$ABI" \
103119
-DANDROID_PLATFORM=android-21 \
104120
-DWITH_UPNP=NO \
105-
-DWITH_AESNI=NO \
106121
-DBUILD_SHARED_LIBS=OFF \
107122
-DWITH_LIBRARY=ON \
108123
-DWITH_BINARY=OFF \

0 commit comments

Comments
 (0)