clean up build helper scripts:

* cleanup of android build shims
* cleanup of windows build shims
pull/1930/head
Jeff 2 years ago
parent 68148e098f
commit b819ed21d2
No known key found for this signature in database
GPG Key ID: 025C02EE3A092F2D

@ -1,17 +1,18 @@
#!/bin/bash #!/bin/bash
set -e set -e
set +x
default_abis="armeabi-v7a arm64-v8a x86_64" default_abis="armeabi-v7a arm64-v8a x86_64"
build_abis=${ABIS:-$default_abis} build_abis=${ABIS:-$default_abis}
test x$NDK = x && echo "NDK env var not set" test x$NDK = x && test -e /usr/lib/android-ndk && export NDK=/usr/lib/android-ndk
test x$NDK = x && exit 1 test x$NDK = x && exit 1
echo "building abis: $build_abis" echo "building abis: $build_abis"
root="$(readlink -f $(dirname $0)/../)" root=$(readlink -f "$1")
build=$root/build-android shift
build=$(readlink -f "$1")
shift
mkdir -p $build mkdir -p $build
cd $build cd $build
@ -19,6 +20,7 @@ for abi in $build_abis; do
mkdir -p build-$abi mkdir -p build-$abi
cd build-$abi cd build-$abi
cmake \ cmake \
-S "$root" -B . \
-G 'Unix Makefiles' \ -G 'Unix Makefiles' \
-DANDROID=ON \ -DANDROID=ON \
-DANDROID_ABI=$abi \ -DANDROID_ABI=$abi \
@ -37,12 +39,13 @@ for abi in $build_abis; do
-DWITH_SYSTEMD=OFF \ -DWITH_SYSTEMD=OFF \
-DFORCE_OXENMQ_SUBMODULE=ON \ -DFORCE_OXENMQ_SUBMODULE=ON \
-DFORCE_OXENC_SUBMODULE=ON \ -DFORCE_OXENC_SUBMODULE=ON \
-DFORCE_LOGGING_SUBMODULE=ON \ -DFORCE_FMT_SUBMODULE=ON \
-DFORCE_SPDLOG_SUBMODULE=ON \
-DFORCE_NLOHMANN_SUBMODULE=ON \ -DFORCE_NLOHMANN_SUBMODULE=ON \
-DSUBMODULE_CHECK=OFF \ -DSUBMODULE_CHECK=OFF \
-DWITH_LTO=OFF \ -DWITH_LTO=OFF \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
$@ $root $@
cd - cd -
done done
rm -f $build/Makefile rm -f $build/Makefile
@ -53,4 +56,11 @@ for abi in $build_abis; do
echo -ne '$(MAKE) -C ' >> $build/Makefile echo -ne '$(MAKE) -C ' >> $build/Makefile
echo "build-$abi lokinet-android" >> $build/Makefile echo "build-$abi lokinet-android" >> $build/Makefile
echo -ne "\tmkdir -p out/$abi && cp build-$abi/jni/liblokinet-android.so out/$abi/liblokinet-android.so\n\n" >> $build/Makefile echo -ne "\tmkdir -p out/$abi && cp build-$abi/jni/liblokinet-android.so out/$abi/liblokinet-android.so\n\n" >> $build/Makefile
echo -ne "clean-$abi:\n\t" >> $build/Makefile
echo -ne '$(MAKE) -C ' >> $build/Makefile
echo "build-$abi clean" >> $build/Makefile
done done
echo -ne "clean:" >> $build/Makefile
for targ in $build_abis ; do echo -ne " clean-$targ" >> $build/Makefile ; done
echo "" >> $build/Makefile

@ -2,9 +2,7 @@
set -e set -e
set +x set +x
test x$NDK = x && echo "NDK env var not set"
test x$NDK = x && exit 1
root="$(readlink -f $(dirname $0)/../)" root="$(readlink -f $(dirname $0)/../)"
cd "$root" cd "$root"
./contrib/android-configure.sh $@ ./contrib/android-configure.sh . build-android $@
make -C build-android -j ${JOBS:-$(nproc)} make -C build-android -j ${JOBS:-$(nproc)}

@ -0,0 +1,33 @@
#!/bin/bash
set -e
set -x
root=$(readlink -f "$1")
shift
mkdir -p "$1"
build=$(readlink -f "$1")
shift
cd "$build"
cmake \
-S "$root" -B "$build" \
-G 'Unix Makefiles' \
-DCMAKE_EXE_LINKER_FLAGS=-fstack-protector \
-DCMAKE_CXX_FLAGS=-fdiagnostics-color=always \
-DCMAKE_TOOLCHAIN_FILE="$root/contrib/cross/mingw64.cmake" \
-DBUILD_STATIC_DEPS=ON \
-DBUILD_PACKAGE=ON \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_LIBLOKINET=OFF \
-DWITH_TESTS=OFF \
-DNATIVE_BUILD=OFF \
-DSTATIC_LINK=ON \
-DWITH_SYSTEMD=OFF \
-DFORCE_OXENMQ_SUBMODULE=ON \
-DFORCE_OXENC_SUBMODULE=ON \
-DFORCE_FMT_SUBMODULE=ON \
-DFORCE_SPDLOG_SUBMODULE=ON \
-DFORCE_NLOHMANN_SUBMODULE=ON \
-DSUBMODULE_CHECK=OFF \
-DWITH_LTO=OFF \
$@

@ -6,28 +6,9 @@
set -e set -e
set +x set +x
mkdir -p build-windows
cd build-windows
cmake \ root="$(readlink -f $(dirname $0)/../)"
-G 'Unix Makefiles' \ cd "$root"
-DCMAKE_EXE_LINKER_FLAGS=-fstack-protector \ ./contrib/windows-configure.sh . build-windows $@
-DCMAKE_CXX_FLAGS=-fdiagnostics-color=always\ make package -j${JOBS:-$(nproc)} -C build-windows
-DCMAKE_TOOLCHAIN_FILE=../contrib/cross/mingw64.cmake\
-DBUILD_STATIC_DEPS=ON \
-DBUILD_PACKAGE=ON \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_LIBLOKINET=OFF \
-DWITH_TESTS=OFF \
-DNATIVE_BUILD=OFF \
-DSTATIC_LINK=ON \
-DWITH_SYSTEMD=OFF \
-DFORCE_OXENMQ_SUBMODULE=ON \
-DFORCE_OXENC_SUBMODULE=ON \
-DFORCE_LOGGING_SUBMODULE=ON \
-DFORCE_NLOHMANN_SUBMODULE=ON \
-DSUBMODULE_CHECK=OFF \
-DWITH_LTO=OFF \
-DCMAKE_BUILD_TYPE=Release \
$@ ..
make package -j${JOBS:-$(nproc)}

@ -100,14 +100,8 @@ namespace llarp
virtual std::shared_ptr<llarp::vpn::Platform> virtual std::shared_ptr<llarp::vpn::Platform>
makeVPNPlatform(); makeVPNPlatform();
#ifdef ANDROID
int androidFD = -1; int androidFD = -1;
int
GetUDPSocket();
#endif
protected: protected:
std::shared_ptr<Config> config = nullptr; std::shared_ptr<Config> config = nullptr;

@ -77,24 +77,24 @@ extern "C"
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_network_loki_lokinet_LokinetDaemon_InjectVPNFD(JNIEnv* env, jobject self) Java_network_loki_lokinet_LokinetDaemon_InjectVPNFD(JNIEnv* env, jobject self)
{ {
auto ptr = GetImpl<llarp::Context>(env, self); if (auto ptr = GetImpl<llarp::Context>(env, self))
ptr->androidFD = GetObjectMemberAsInt<int>(env, self, "m_FD");
ptr->androidFD = GetObjectMemberAsInt<int>(env, self, "m_FD");
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_network_loki_lokinet_LokinetDaemon_GetUDPSocket(JNIEnv* env, jobject self) Java_network_loki_lokinet_LokinetDaemon_GetUDPSocket(JNIEnv* env, jobject self)
{ {
auto ptr = GetImpl<llarp::Context>(env, self); auto ptr = GetImpl<llarp::Context>(env, self);
if (const auto& router = ptr->router; ptr and ptr->router)
return ptr->router.m_OutboundUDPSocket; return router->OutboundUDPSocket();
return -1;
} }
JNIEXPORT jstring JNICALL JNIEXPORT jstring JNICALL
Java_network_loki_lokinet_LokinetDaemon_DetectFreeRange(JNIEnv* env, jclass) Java_network_loki_lokinet_LokinetDaemon_DetectFreeRange(JNIEnv* env, jclass)
{ {
std::string rangestr{}; std::string rangestr{};
if (auto maybe = llarp::net::Platform::Default().FindFreeRange()) if (auto maybe = llarp::net::Platform::Default_ptr()->FindFreeRange())
{ {
rangestr = maybe->ToString(); rangestr = maybe->ToString();
} }

@ -54,7 +54,7 @@ llarp_apple_init(llarp_apple_config* appleconf)
auto& range = config->network.m_ifaddr; auto& range = config->network.m_ifaddr;
if (!range.addr.h) if (!range.addr.h)
{ {
if (auto maybe = llarp::net::Platform::Default().FindFreeRange()) if (auto maybe = llarp::net::Platform::Default_ptr()->FindFreeRange())
range = *maybe; range = *maybe;
else else
throw std::runtime_error{"Could not find any free IP range"}; throw std::runtime_error{"Could not find any free IP range"};

@ -211,12 +211,4 @@ namespace llarp
loop.reset(); loop.reset();
} }
#if defined(ANDROID)
int
Context::GetUDPSocket()
{
return router->GetOutboundUDPSocket();
}
#endif
} // namespace llarp } // namespace llarp

@ -354,10 +354,8 @@ namespace llarp
HandleRouterEvent(std::move(event)); HandleRouterEvent(std::move(event));
} }
#if defined(ANDROID)
virtual int virtual int
GetOutboundUDPSocket() const = 0; OutboundUDPSocket() const = 0;
#endif
protected: protected:
/// Virtual function to handle RouterEvent. HiveRouter overrides this in /// Virtual function to handle RouterEvent. HiveRouter overrides this in

@ -1190,6 +1190,12 @@ namespace llarp
return true; return true;
} }
int
Router::OutboundUDPSocket() const
{
return m_OutboundUDPSocket;
}
bool bool
Router::Run() Router::Run()
{ {

@ -211,6 +211,9 @@ namespace llarp
bool bool
ShouldTestOtherRouters() const; ShouldTestOtherRouters() const;
int
OutboundUDPSocket() const override;
std::optional<SockAddr> _ourAddress; std::optional<SockAddr> _ourAddress;
EventLoop_ptr _loop; EventLoop_ptr _loop;

Loading…
Cancel
Save