Skip to content

Commit da4cf4a

Browse files
committed
build(android): remove stale nat traversal artifacts
1 parent c6631c4 commit da4cf4a

6 files changed

Lines changed: 14 additions & 47 deletions

File tree

.github/workflows/mobile_android.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ jobs:
5454
test -f "$out/lib/liblibp2p.so"
5555
test -f "$out/lib/liblibp2p.a"
5656
test -f "$out/lib/libc++_shared.so"
57-
test -f "$out/lib/libminiupnpc.a"
58-
test -f "$out/lib/libnatpmp.a"
5957
test -f "$out/include/libp2p.h"
6058
test -f "$out/include/nim_ffi_cbor.h"
6159
test -f "$out/include/nim_ffi_prelude.h"

.pinned

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ stew;https://github.com/status-im/nim-stew@#b66168735d6f3841c5239c3169d3fe5fe98b
1515
websock;https://github.com/status-im/nim-websock@#387a8eb7e961e8fdd3b1a717d36bc53b55e4dc5d
1616
zlib;https://github.com/status-im/nim-zlib@#e680f269fb01af2c34a2ba879ff281795a5258fe
1717
protobuf_serialization;https://github.com/status-im/nim-protobuf-serialization@#8406e7287196661614ce6a8e8be20f755376af7f
18-
nat_traversal;https://github.com/status-im/nim-nat-traversal@#860e18c37667b5dd005b94c63264560c35d88004
18+
libplum;https://github.com/logos-storage/nim-libplum@#acefbe424cf9d1f05f2d93533790c9ac4e034df8
1919
npeg;https://github.com/zevv/npeg@#409f6796d0e880b3f0222c964d1da7de6e450811

docs/mobile_android.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ toolchain from Nix:
1414
| `x86_64` | `amd64` | `x86_64-linux-android23-clang` |
1515

1616
The Nix derivation currently pins Android NDK `27.2.12479018` through
17-
`androidenv.composeAndroidPackages` and rebuilds the vendored `nat_traversal` C
18-
libraries with the same Android clang used for Nim-generated C code.
17+
`androidenv.composeAndroidPackages` and uses the same Android clang for
18+
Nim-generated C code and the C check harness.
1919

2020
## Build Commands
2121

@@ -53,8 +53,6 @@ result/
5353
lib/liblibp2p.so
5454
lib/liblibp2p.a
5555
lib/libc++_shared.so
56-
lib/libminiupnpc.a
57-
lib/libnatpmp.a
5856
nix-support/android-target
5957
```
6058

@@ -86,14 +84,7 @@ library.
8684
For shared-library linking, package the matching ABI's `lib/liblibp2p.so` and
8785
`lib/libc++_shared.so` with the Android application and load them through the
8886
normal Android native library path. For static linking, link `lib/liblibp2p.a`
89-
together with `lib/libminiupnpc.a`, `lib/libnatpmp.a`, and the Android C++
90-
runtime selected by your application.
91-
92-
## Dependency Notes
93-
94-
The Android derivation uses a writable copy of `nat_traversal` so its vendored
95-
`miniupnpc` and `libnatpmp` archives can be rebuilt with the selected Android
96-
clang.
87+
together with the Android C++ runtime selected by your application.
9788

9889
## Android Check Harness
9990

libp2p.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ requires "nim >= 2.2.4",
1313
"chronos >= 4.2.2", "metrics >= 0.2.2", "secp256k1", "stew >= 0.4.2", "results",
1414
"serialization", "lsquic >= 0.5.5", "protobuf_serialization >= 0.5.3",
1515
"https://github.com/status-im/nim-websock >= 0.4.0",
16-
"https://github.com/status-im/nim-nat-traversal >= 0.0.1"
16+
"https://github.com/logos-storage/nim-libplum#acefbe424cf9d1f05f2d93533790c9ac4e034df8"
1717

1818
import os, sequtils, strutils
1919

nix/cbind-ffi-android.nix

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ let
1010
deps = import ./deps.nix { inherit pkgs; };
1111
cbindDeps = import ./cbind-deps.nix { inherit pkgs; };
1212

13-
# nat_traversal is copied into the build directory because its vendored C
14-
# archives need to be rebuilt with the Android toolchain.
15-
depsWithoutWritable = builtins.removeAttrs deps [ "nat_traversal" ];
16-
1713
pathArgs =
1814
builtins.concatStringsSep " "
19-
(map (p: "--path:${p}") (builtins.attrValues depsWithoutWritable));
15+
(map (p: "--path:${p}") (builtins.attrValues deps));
2016

2117
cbindPathArgs =
2218
builtins.concatStringsSep " "
@@ -98,31 +94,16 @@ pkgs.stdenv.mkDerivation {
9894
fi
9995
10096
mkdir -p build $NIMCACHE
101-
102-
echo "== Preparing writable dependency copies for Android ${abi} =="
103-
NAT_PKG=$TMPDIR/nat_traversal
104-
cp -r ${deps.nat_traversal} $NAT_PKG
105-
chmod -R +w $NAT_PKG
106-
107-
echo "== Building nat_traversal vendored C libs for Android ${abi} =="
108-
make -C "$NAT_PKG/vendor/miniupnp/miniupnpc" \
109-
CC="$ANDROID_CC" AR="$ANDROID_AR" RANLIB="$ANDROID_RANLIB" \
110-
CFLAGS="-Os -fPIC -DANDROID" \
111-
build/libminiupnpc.a
112-
113-
make -C "$NAT_PKG/vendor/libnatpmp-upstream" \
114-
CC="$ANDROID_CC" AR="$ANDROID_AR" RANLIB="$ANDROID_RANLIB" \
115-
CFLAGS="-Wall -Os -fPIC -DENABLE_STRNATPMPERR -DNATPMP_MAX_RETRIES=4" \
116-
libnatpmp.a
97+
echo 'INPUT(-lc)' > build/libpthread.so
11798
11899
# ffiThreadExitTimeoutMs: bound the FFI thread's graceful-shutdown wait; the
119100
# 1500ms default is too tight for libp2pDestroy's switch.stop() over many conns.
120-
commonArgs="--noNimblePath ${cbindPathArgs} ${pathArgs} --path:$NAT_PKG \
101+
commonArgs="--noNimblePath ${cbindPathArgs} ${pathArgs} \
121102
--os:android --cpu:${nimCpu} --cc:clang \
122103
--clang.path:$ANDROID_TOOLCHAIN/bin \
123104
--clang.exe:${androidCcName} --clang.linkerexe:${androidCxxName} \
124105
--passC:-DANDROID --passC:-fPIC \
125-
--passL:-lc++_shared --passL:-llog --passL:-ldl --passL:-lm \
106+
--passL:-L$PWD/build --passL:-lc++_shared --passL:-llog --passL:-ldl --passL:-lm \
126107
--threads:on --opt:size --noMain --mm:refc --d:metrics \
127108
-d:ffiThreadExitTimeoutMs=5000 \
128109
--nimMainPrefix:liblibp2p --nimcache:$NIMCACHE"
@@ -156,7 +137,7 @@ pkgs.stdenv.mkDerivation {
156137
obj=build/check-objects/$(basename "$src" .c).o
157138
"$ANDROID_CC" -std=c11 -fPIE -I cbind/c_bindings/tinycbor -c "$src" -o "$obj"
158139
done
159-
"$ANDROID_CXX" -fPIE -pie -pthread \
140+
"$ANDROID_CXX" -L build -fPIE -pie -pthread \
160141
build/check-objects/*.o build/liblibp2p.so \
161142
-lc++_shared -ldl -lm -llog \
162143
-o build/libp2p_ffi_android_check
@@ -172,9 +153,6 @@ pkgs.stdenv.mkDerivation {
172153
cp build/liblibp2p.so $out/lib/
173154
cp build/liblibp2p.a $out/lib/
174155
cp "$ANDROID_CXX_STDLIB" $out/lib/
175-
cp $NAT_PKG/vendor/miniupnp/miniupnpc/build/libminiupnpc.a $out/lib/
176-
cp $NAT_PKG/vendor/libnatpmp-upstream/libnatpmp.a $out/lib/
177-
178156
cp cbind/c_bindings/*.h $out/include/
179157
cp -r cbind/c_bindings/tinycbor $out/include/
180158
cp -r cbind/cddl_bindings $out/include/

nix/deps.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
fetchSubmodules = true;
3232
};
3333

34-
nat_traversal = pkgs.fetchgit {
35-
url = "https://github.com/status-im/nim-nat-traversal";
36-
rev = "860e18c37667b5dd005b94c63264560c35d88004";
37-
sha256 = "0319k5bbl468phwfnvlrh7725sc80rnf7m9gyj0i3cb5hb9q78bs";
34+
libplum = pkgs.fetchgit {
35+
url = "https://github.com/logos-storage/nim-libplum";
36+
rev = "acefbe424cf9d1f05f2d93533790c9ac4e034df8";
37+
sha256 = "0j6rc96cznsh90pvs27i1qgpby3ib04a2xqihps3jwlnlng2nrkb";
3838
fetchSubmodules = true;
3939
};
4040

0 commit comments

Comments
 (0)