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/
0 commit comments