clean up build helper scripts:

* cleanup of android build shims
* cleanup of windows build shims
dev
Jeff 3 months ago
parent 68148e098f
commit b819ed21d2
Signed by: jeff
GPG Key ID: 025C02EE3A092F2D
  1. 22
      contrib/android-configure.sh
  2. 4
      contrib/android.sh
  3. 33
      contrib/windows-configure.sh
  4. 31
      contrib/windows.sh
  5. 6
      include/llarp.hpp
  6. 12
      jni/lokinet_daemon.cpp
  7. 2
      llarp/apple/context_wrapper.cpp
  8. 8
      llarp/context.cpp
  9. 4
      llarp/router/abstractrouter.hpp
  10. 6
      llarp/router/router.cpp
  11. 3
      llarp/router/router.hpp

@ -1,17 +1,18 @@
#!/bin/bash
set -e
set +x
default_abis="armeabi-v7a arm64-v8a x86_64"
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
echo "building abis: $build_abis"
root="$(readlink -f $(dirname $0)/../)"
build=$root/build-android
root=$(readlink -f "$1")
shift
build=$(readlink -f "$1")
shift
mkdir -p $build
cd $build
@ -19,6 +20,7 @@ for abi in $build_abis; do
mkdir -p build-$abi
cd build-$abi
cmake \
-S "$root" -B . \
-G 'Unix Makefiles' \
-DANDROID=ON \
-DANDROID_ABI=$abi \
@ -37,12 +39,13 @@ for abi in $build_abis; do
-DWITH_SYSTEMD=OFF \
-DFORCE_OXENMQ_SUBMODULE=ON \
-DFORCE_OXENC_SUBMODULE=ON \
-DFORCE_LOGGING_SUBMODULE=ON \
-DFORCE_FMT_SUBMODULE=ON \
-DFORCE_SPDLOG_SUBMODULE=ON \
-DFORCE_NLOHMANN_SUBMODULE=ON \
-DSUBMODULE_CHECK=OFF \
-DWITH_LTO=OFF \
-DCMAKE_BUILD_TYPE=Release \
$@ $root
$@
cd -
done
rm -f $build/Makefile
@ -53,4 +56,11 @@ for abi in $build_abis; do
echo -ne '$(MAKE) -C ' >> $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 "clean-$abi:\n\t" >> $build/Makefile
echo -ne '$(MAKE) -C ' >> $build/Makefile
echo "build-$abi clean" >> $build/Makefile
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 +x
test x$NDK = x && echo "NDK env var not set"
test x$NDK = x && exit 1
root="$(readlink -f $(dirname $0)/../)"
cd "$root"
./contrib/android-configure.sh $@
./contrib/android-configure.sh . build-android $@
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 +x
mkdir -p build-windows
cd build-windows
cmake \
-G 'Unix Makefiles' \
-DCMAKE_EXE_LINKER_FLAGS=-fstack-protector \
-DCMAKE_CXX_FLAGS=-fdiagnostics-color=always\
-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)}
root="$(readlink -f $(dirname $0)/../)"
cd "$root"
./contrib/windows-configure.sh . build-windows $@
make package -j${JOBS:-$(nproc)} -C build-windows

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

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

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

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

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

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

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

Loading…
Cancel
Save