mirror of https://github.com/oxen-io/lokinet
Merge pull request #1597 from majestrate/lokinet-bootstrap-native-2021-04-15
Lokinet bootstrap native binary
This commit is contained in:
commit
6e05f7ad13
|
@ -1,4 +1,4 @@
|
|||
local default_deps_base='libsystemd-dev python3-dev libuv1-dev libunbound-dev nettle-dev libssl-dev libevent-dev libsqlite3-dev';
|
||||
local default_deps_base='libsystemd-dev python3-dev libuv1-dev libunbound-dev nettle-dev libssl-dev libevent-dev libsqlite3-dev libcurl4-openssl-dev';
|
||||
local default_deps_nocxx='libsodium-dev ' + default_deps_base; // libsodium-dev needs to be >= 1.0.18
|
||||
local default_deps='g++ ' + default_deps_nocxx; // g++ sometimes needs replacement
|
||||
local default_windows_deps='mingw-w64 zip nsis';
|
||||
|
|
|
@ -29,3 +29,6 @@
|
|||
[submodule "external/uvw"]
|
||||
path = external/uvw
|
||||
url = https://github.com/jagerman/uvw.git
|
||||
[submodule "external/cpr"]
|
||||
path = external/cpr
|
||||
url = https://github.com/whoshuu/cpr
|
||||
|
|
|
@ -59,6 +59,7 @@ if(BUILD_STATIC_DEPS AND NOT STATIC_LINK)
|
|||
message(FATAL_ERROR "Option BUILD_STATIC_DEPS requires STATIC_LINK to be enabled as well")
|
||||
endif()
|
||||
if(BUILD_STATIC_DEPS)
|
||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
|
||||
include(StaticBuild)
|
||||
endif()
|
||||
|
||||
|
@ -293,42 +294,7 @@ if(WITH_SYSTEMD AND (NOT ANDROID))
|
|||
target_compile_definitions(base_libs INTERFACE WITH_SYSTEMD)
|
||||
endif()
|
||||
|
||||
option(SUBMODULE_CHECK "Enables checking that vendored library submodules are up to date" ON)
|
||||
if(SUBMODULE_CHECK)
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
function(check_submodule relative_path)
|
||||
execute_process(COMMAND git rev-parse "HEAD" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${relative_path} OUTPUT_VARIABLE localHead)
|
||||
execute_process(COMMAND git rev-parse "HEAD:${relative_path}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE checkedHead)
|
||||
string(COMPARE EQUAL "${localHead}" "${checkedHead}" upToDate)
|
||||
if (upToDate)
|
||||
message(STATUS "Submodule '${relative_path}' is up-to-date")
|
||||
else()
|
||||
message(FATAL_ERROR "Submodule '${relative_path}' is not up-to-date. Please update with\ngit submodule update --init --recursive\nor run cmake with -DSUBMODULE_CHECK=OFF")
|
||||
endif()
|
||||
endfunction ()
|
||||
|
||||
message(STATUS "Checking submodules")
|
||||
check_submodule(external/nlohmann)
|
||||
check_submodule(external/cxxopts)
|
||||
check_submodule(external/ghc-filesystem)
|
||||
check_submodule(external/date)
|
||||
check_submodule(external/pybind11)
|
||||
check_submodule(external/sqlite_orm)
|
||||
check_submodule(external/oxen-mq)
|
||||
check_submodule(external/uvw)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_HIVE)
|
||||
add_subdirectory(external/pybind11 EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||
add_subdirectory(external/nlohmann EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(external/cxxopts EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(external/date EXCLUDE_FROM_ALL)
|
||||
|
||||
add_subdirectory(external)
|
||||
include_directories(SYSTEM external/sqlite_orm/include)
|
||||
|
||||
if(ANDROID)
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
set(LOCAL_MIRROR "" CACHE STRING "local mirror path/URL for lib downloads")
|
||||
|
||||
set(OPENSSL_VERSION 1.1.1g CACHE STRING "openssl version")
|
||||
set(OPENSSL_VERSION 1.1.1k CACHE STRING "openssl version")
|
||||
set(OPENSSL_MIRROR ${LOCAL_MIRROR} https://www.openssl.org/source CACHE STRING "openssl download mirror(s)")
|
||||
set(OPENSSL_SOURCE openssl-${OPENSSL_VERSION}.tar.gz)
|
||||
set(OPENSSL_HASH SHA256=ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46
|
||||
set(OPENSSL_HASH SHA256=892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
|
||||
CACHE STRING "openssl source hash")
|
||||
|
||||
set(EXPAT_VERSION 2.2.9 CACHE STRING "expat version")
|
||||
|
@ -55,6 +55,20 @@ set(LIBUV_SOURCE libuv-v${LIBUV_VERSION}.tar.gz)
|
|||
set(LIBUV_HASH SHA256=61a90db95bac00adec1cc5ddc767ebbcaabc70242bd1134a7a6b1fb1d498a194
|
||||
CACHE STRING "libuv source hash")
|
||||
|
||||
set(ZLIB_VERSION 1.2.11 CACHE STRING "zlib version")
|
||||
set(ZLIB_MIRROR ${LOCAL_MIRROR} https://zlib.net
|
||||
CACHE STRING "zlib mirror(s)")
|
||||
set(ZLIB_SOURCE zlib-${ZLIB_VERSION}.tar.gz)
|
||||
set(ZLIB_HASH SHA512=73fd3fff4adeccd4894084c15ddac89890cd10ef105dd5e1835e1e9bbb6a49ff229713bd197d203edfa17c2727700fce65a2a235f07568212d820dca88b528ae
|
||||
CACHE STRING "zlib source hash")
|
||||
|
||||
set(CURL_VERSION 7.74.0 CACHE STRING "curl version")
|
||||
set(CURL_MIRROR ${LOCAL_MIRROR} https://curl.haxx.se/download https://curl.askapache.com
|
||||
CACHE STRING "curl mirror(s)")
|
||||
set(CURL_SOURCE curl-${CURL_VERSION}.tar.xz)
|
||||
set(CURL_HASH SHA256=999d5f2c403cf6e25d58319fdd596611e455dd195208746bc6e6d197a77e878b
|
||||
CACHE STRING "curl source hash")
|
||||
|
||||
|
||||
|
||||
include(ExternalProject)
|
||||
|
@ -205,7 +219,13 @@ add_static_target(libuv libuv_external libuv.a)
|
|||
target_link_libraries(libuv INTERFACE ${CMAKE_DL_LIBS})
|
||||
|
||||
|
||||
|
||||
build_external(zlib
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS} -fPIC" ${cross_extra} ./configure --prefix=${DEPS_DESTDIR} --static
|
||||
BUILD_BYPRODUCTS
|
||||
${DEPS_DESTDIR}/lib/libz.a
|
||||
${DEPS_DESTDIR}/include/zlib.h
|
||||
)
|
||||
add_static_target(zlib zlib_external libz.a)
|
||||
|
||||
|
||||
set(openssl_system_env "")
|
||||
|
@ -239,9 +259,9 @@ if(WIN32)
|
|||
endif()
|
||||
|
||||
set(OPENSSL_INCLUDE_DIR ${DEPS_DESTDIR}/include)
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${DEPS_DESTDIR}/lib/libcrypto.a ${DEPS_DESTDIR}/lib/libssl.a)
|
||||
set(OPENSSL_VERSION 1.1.1)
|
||||
|
||||
|
||||
set(OPENSSL_ROOT_DIR ${DEPS_DESTDIR})
|
||||
|
||||
build_external(expat
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} --prefix=${DEPS_DESTDIR} --enable-static
|
||||
|
@ -308,3 +328,91 @@ endif()
|
|||
set_target_properties(libzmq PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${libzmq_link_libs}"
|
||||
INTERFACE_COMPILE_DEFINITIONS "ZMQ_STATIC")
|
||||
|
||||
set(curl_extra)
|
||||
if(WIN32)
|
||||
set(curl_ssl_opts --without-ssl --with-schannel)
|
||||
elseif(APPLE)
|
||||
set(curl_ssl_opts --without-ssl --with-secure-transport)
|
||||
if(IOS)
|
||||
# This CPP crap shouldn't be necessary but is because Apple's toolchain is trash
|
||||
set(curl_extra "LDFLAGS=-L${DEPS_DESTDIR}/lib -isysroot ${CMAKE_OSX_SYSROOT}" CPP=cpp)
|
||||
endif()
|
||||
else()
|
||||
set(curl_ssl_opts --with-ssl=${DEPS_DESTDIR})
|
||||
set(curl_extra "LIBS=-pthread")
|
||||
endif()
|
||||
|
||||
set(curl_arches default)
|
||||
set(curl_lib_outputs)
|
||||
if(IOS)
|
||||
# On iOS things get a little messy: curl won't build a multi-arch library (with `clang -arch arch1
|
||||
# -arch arch2`) so we have to build them separately then glue them together if we're building
|
||||
# multiple.
|
||||
set(curl_arches ${CMAKE_OSX_ARCHITECTURES})
|
||||
list(GET curl_arches 0 curl_arch0)
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES num_arches)
|
||||
endif()
|
||||
|
||||
foreach(curl_arch ${curl_arches})
|
||||
set(curl_target_suffix "")
|
||||
set(curl_prefix "${DEPS_DESTDIR}")
|
||||
if(curl_arch STREQUAL "default")
|
||||
set(curl_cflags_extra "")
|
||||
elseif(IOS)
|
||||
set(cflags_extra " -arch ${curl_arch}")
|
||||
if(num_arches GREATER 1)
|
||||
set(curl_target_suffix "-${curl_arch}")
|
||||
set(curl_prefix "${DEPS_DESTDIR}/tmp/${curl_arch}")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "unexpected curl_arch=${curl_arch}")
|
||||
endif()
|
||||
|
||||
build_external(curl
|
||||
TARGET_SUFFIX ${curl_target_suffix}
|
||||
DEPENDS openssl_external zlib_external
|
||||
CONFIGURE_COMMAND ./configure ${cross_host} ${cross_extra} --prefix=${curl_prefix} --disable-shared
|
||||
--enable-static --disable-ares --disable-ftp --disable-ldap --disable-laps --disable-rtsp
|
||||
--disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb
|
||||
--disable-smtp --disable-gopher --disable-manual --disable-libcurl-option --enable-http
|
||||
--enable-ipv6 --disable-threaded-resolver --disable-pthreads --disable-verbose --disable-sspi
|
||||
--enable-crypto-auth --disable-ntlm-wb --disable-tls-srp --disable-unix-sockets --disable-cookies
|
||||
--enable-http-auth --enable-doh --disable-mime --enable-dateparse --disable-netrc --without-libidn2
|
||||
--disable-progress-meter --without-brotli --with-zlib=${DEPS_DESTDIR} ${curl_ssl_opts}
|
||||
--without-libmetalink --without-librtmp --disable-versioned-symbols --enable-hidden-symbols
|
||||
--without-zsh-functions-dir --without-fish-functions-dir
|
||||
"CC=${deps_cc}" "CFLAGS=${deps_noarch_CFLAGS}${cflags_extra}" ${curl_extra}
|
||||
BUILD_COMMAND true
|
||||
INSTALL_COMMAND make -C lib install && make -C include install
|
||||
BUILD_BYPRODUCTS
|
||||
${curl_prefix}/lib/libcurl.a
|
||||
${curl_prefix}/include/curl/curl.h
|
||||
)
|
||||
list(APPEND curl_lib_targets curl${curl_target_suffix}_external)
|
||||
list(APPEND curl_lib_outputs ${curl_prefix}/lib/libcurl.a)
|
||||
endforeach()
|
||||
|
||||
message(STATUS "TARGETS: ${curl_lib_targets}")
|
||||
|
||||
if(IOS AND num_arches GREATER 1)
|
||||
# We are building multiple architectures for different iOS devices, so we need to glue the
|
||||
# separate libraries into one. (Normally multiple -arch values passed to clang does this for us,
|
||||
# but curl refuses to build that way).
|
||||
add_custom_target(curl_external
|
||||
COMMAND lipo ${curl_lib_outputs} -create -output ${DEPS_DESTDIR}/libcurl.a
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPS_DESTDIR}/tmp/${curl_arch0}/include/curl ${DEPS_DESTDIR}/include/curl
|
||||
BYPRODUCTS ${DEPS_DESTDIR}/lib/libcurl.a ${DEPS_DESTDIR}/include/curl/curl.h
|
||||
DEPENDS ${curl_lib_targets})
|
||||
endif()
|
||||
|
||||
add_static_target(CURL::libcurl curl_external libcurl.a)
|
||||
set(libcurl_link_libs zlib)
|
||||
if(CMAKE_CROSSCOMPILING AND ARCH_TRIPLET MATCHES mingw)
|
||||
list(APPEND libcurl_link_libs crypt32)
|
||||
elseif(APPLE)
|
||||
list(APPEND libcurl_link_libs "-framework Security")
|
||||
endif()
|
||||
set_target_properties(CURL::libcurl PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${libcurl_link_libs}"
|
||||
INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||
|
|
|
@ -32,7 +32,7 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "Lokinet")
|
|||
set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/win32-setup/lokinet.ico")
|
||||
set(CPACK_NSIS_DEFINES "RequestExecutionLevel admin")
|
||||
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
|
||||
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '$INSTDIR\\\\bin\\\\tuntap-install.exe /S'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe --install'\\nExecWait 'sc failure lokinet reset= 60 actions= restart/1000'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe -g C:\\\\ProgramData\\\\lokinet\\\\lokinet.ini'\\nCopyFiles '$INSTDIR\\\\share\\\\bootstrap.signed' C:\\\\ProgramData\\\\lokinet\\\\bootstrap.signed")
|
||||
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '$INSTDIR\\\\bin\\\\tuntap-install.exe /S'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe --install'\\nExecWait 'sc failure lokinet reset= 60 actions= restart/1000'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe -g C:\\\\ProgramData\\\\lokinet\\\\lokinet.ini'\\nCopyFiles '$INSTDIR\\\\share\\\\bootstrap.signed' C:\\\\ProgramData\\\\lokinet\\\\bootstrap.signed\\nExecWait '$INSTDIR\\\\bin\\\\lokinet-bootstrap.exe'")
|
||||
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "ExecWait 'net stop lokinet'\\nExecWait 'taskkill /f /t /im lokinet-gui.exe'\\nExecWait '$INSTDIR\\\\bin\\\\lokinet.exe --remove'\\nRMDir /r /REBOOTOK C:\\\\ProgramData\\\\lokinet")
|
||||
set(CPACK_NSIS_CREATE_ICONS_EXTRA
|
||||
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Lokinet.lnk' '$INSTDIR\\\\share\\\\gui\\\\lokinet-gui.exe'"
|
||||
|
|
|
@ -3,5 +3,22 @@ set -e
|
|||
set +x
|
||||
mkdir -p build-windows
|
||||
cd build-windows
|
||||
cmake -G Ninja -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_LIBLOKINET=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DWITH_TESTS=OFF -DNATIVE_BUILD=OFF -DSTATIC_LINK=ON -DWITH_SYSTEMD=OFF -DFORCE_OXENMQ_SUBMODULE=ON -DSUBMODULE_CHECK=OFF -DWITH_LTO=OFF -DCMAKE_BUILD_TYPE=Release $@ ..
|
||||
cmake \
|
||||
-G Ninja \
|
||||
-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 \
|
||||
-DWITH_TESTS=OFF \
|
||||
-DNATIVE_BUILD=OFF \
|
||||
-DSTATIC_LINK=ON \
|
||||
-DWITH_SYSTEMD=OFF \
|
||||
-DFORCE_OXENMQ_SUBMODULE=ON \
|
||||
-DSUBMODULE_CHECK=OFF \
|
||||
-DWITH_LTO=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
$@ ..
|
||||
ninja package
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
add_executable(lokinet main.cpp)
|
||||
add_executable(lokinet lokinet.cpp)
|
||||
add_executable(lokinet-vpn lokinet-vpn.cpp)
|
||||
enable_lto(lokinet lokinet-vpn)
|
||||
add_executable(lokinet-bootstrap lokinet-bootstrap.cpp)
|
||||
enable_lto(lokinet lokinet-vpn lokinet-bootstrap)
|
||||
|
||||
if(TRACY_ROOT)
|
||||
target_sources(lokinet PRIVATE ${TRACY_ROOT}/TracyClient.cpp)
|
||||
|
@ -22,7 +23,9 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|||
endif()
|
||||
endif()
|
||||
|
||||
foreach(exe lokinet lokinet-vpn)
|
||||
target_link_libraries(lokinet-bootstrap PUBLIC cpr::cpr)
|
||||
|
||||
foreach(exe lokinet lokinet-vpn lokinet-bootstrap)
|
||||
if(WIN32 AND NOT MSVC_VERSION)
|
||||
target_sources(${exe} PRIVATE ../llarp/win32/version.rc)
|
||||
target_link_libraries(${exe} PRIVATE ws2_32 iphlpapi)
|
||||
|
@ -43,9 +46,3 @@ endforeach()
|
|||
if(SETCAP)
|
||||
install(CODE "execute_process(COMMAND ${SETCAP} cap_net_admin,cap_net_bind_service=+eip ${CMAKE_INSTALL_PREFIX}/bin/lokinet)")
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
if(should_install)
|
||||
install(PROGRAMS ${CMAKE_SOURCE_DIR}/lokinet-bootstrap DESTINATION bin COMPONENT lokinet)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#include <cpr/cpr.h>
|
||||
#include <llarp/constants/files.hpp>
|
||||
#include <llarp/constants/version.hpp>
|
||||
#include <llarp/util/buffer.hpp>
|
||||
#include <llarp/util/fs.hpp>
|
||||
#include <llarp/router_contact.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <openssl/x509.h>
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
int
|
||||
exit_with_message(std::string msg, int exitcode)
|
||||
{
|
||||
std::cout << msg << std::endl;
|
||||
return exitcode;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
std::string bootstrap_url{"https://seed.lokinet.org/lokinet.signed"};
|
||||
if (argc > 1)
|
||||
{
|
||||
bootstrap_url = argv[1];
|
||||
}
|
||||
cpr::Response resp =
|
||||
#ifdef _WIN32
|
||||
cpr::Get(
|
||||
cpr::Url{bootstrap_url}, cpr::Header{{"User-Agent", std::string{llarp::VERSION_FULL}}});
|
||||
#else
|
||||
cpr::Get(
|
||||
cpr::Url{bootstrap_url},
|
||||
cpr::Header{{"User-Agent", std::string{llarp::VERSION_FULL}}},
|
||||
cpr::Ssl(cpr::ssl::CaPath{X509_get_default_cert_dir()}));
|
||||
#endif
|
||||
if (resp.status_code != 200)
|
||||
{
|
||||
return exit_with_message(
|
||||
"failed to fetch '" + bootstrap_url + "' HTTP " + std::to_string(resp.status_code), 1);
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << resp.text;
|
||||
|
||||
std::string data{ss.str()};
|
||||
llarp_buffer_t buf{&data[0], data.size()};
|
||||
|
||||
llarp::RouterContact rc;
|
||||
if (not rc.BDecode(&buf))
|
||||
return exit_with_message("invalid bootstrap data was fetched", 1);
|
||||
|
||||
const auto path = llarp::GetDefaultBootstrap();
|
||||
if (not rc.Write(path))
|
||||
return exit_with_message("failed to write bootstrap file to " + path.string(), 1);
|
||||
|
||||
const llarp::RouterID router{rc.pubkey};
|
||||
return exit_with_message("fetched bootstrap file for " + router.ToString(), 0);
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
option(SUBMODULE_CHECK "Enables checking that vendored library submodules are up to date" ON)
|
||||
if(SUBMODULE_CHECK)
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
function(check_submodule relative_path)
|
||||
execute_process(COMMAND git rev-parse "HEAD" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${relative_path} OUTPUT_VARIABLE localHead)
|
||||
execute_process(COMMAND git rev-parse "HEAD:external/${relative_path}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE checkedHead)
|
||||
string(COMPARE EQUAL "${localHead}" "${checkedHead}" upToDate)
|
||||
if (upToDate)
|
||||
message(STATUS "Submodule 'external/${relative_path}' is up-to-date")
|
||||
else()
|
||||
message(FATAL_ERROR "Submodule 'external/${relative_path}' is not up-to-date. Please update with\ngit submodule update --init --recursive\nor run cmake with -DSUBMODULE_CHECK=OFF")
|
||||
endif()
|
||||
endfunction ()
|
||||
|
||||
message(STATUS "Checking submodules")
|
||||
check_submodule(nlohmann)
|
||||
check_submodule(cxxopts)
|
||||
check_submodule(ghc-filesystem)
|
||||
check_submodule(date)
|
||||
check_submodule(pybind11)
|
||||
check_submodule(sqlite_orm)
|
||||
check_submodule(oxen-mq)
|
||||
check_submodule(uvw)
|
||||
check_submodule(cpr)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_HIVE)
|
||||
add_subdirectory(pybind11 EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||
add_subdirectory(nlohmann EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(cxxopts EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(date EXCLUDE_FROM_ALL)
|
||||
|
||||
add_library(sqlite_orm INTERFACE)
|
||||
target_include_directories(sqlite_orm SYSTEM INTERFACE sqlite_orm/include)
|
||||
if(NOT TARGET sqlite3)
|
||||
add_library(sqlite3 INTERFACE)
|
||||
pkg_check_modules(SQLITE3 REQUIRED IMPORTED_TARGET sqlite3)
|
||||
target_link_libraries(sqlite3 INTERFACE PkgConfig::SQLITE3)
|
||||
endif()
|
||||
target_link_libraries(sqlite_orm INTERFACE sqlite3)
|
||||
|
||||
add_library(uvw INTERFACE)
|
||||
target_include_directories(uvw INTERFACE uvw/src)
|
||||
target_link_libraries(uvw INTERFACE libuv)
|
||||
|
||||
# cpr configuration. Ideally we'd just do this via add_subdirectory, but cpr's cmake requires
|
||||
# 3.15+, and we target lower than that (and this is fairly simple to build).
|
||||
|
||||
if(NOT BUILD_STATIC_DEPS)
|
||||
find_package(CURL REQUIRED COMPONENTS HTTP HTTPS SSL)
|
||||
|
||||
# CURL::libcurl wasn't added to FindCURL until cmake 3.12, so add it if necessary
|
||||
if (CMAKE_VERSION VERSION_LESS 3.12 AND NOT TARGET CURL::libcurl)
|
||||
add_library(libcurl UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(libcurl PROPERTIES
|
||||
IMPORTED_LOCATION ${CURL_LIBRARIES}
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}")
|
||||
add_library(CURL_libcurl INTERFACE)
|
||||
target_link_libraries(CURL_libcurl INTERFACE libcurl)
|
||||
add_library(CURL::libcurl ALIAS CURL_libcurl)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(GLOB cpr_sources ${conf_depends} cpr/cpr/*.cpp)
|
||||
|
||||
add_library(cpr STATIC EXCLUDE_FROM_ALL ${cpr_sources})
|
||||
target_link_libraries(cpr PUBLIC CURL::libcurl)
|
||||
target_include_directories(cpr PUBLIC cpr/include)
|
||||
target_compile_definitions(cpr PUBLIC CPR_CURL_NOSIGNAL)
|
||||
add_library(cpr::cpr ALIAS cpr)
|
|
@ -0,0 +1 @@
|
|||
Subproject commit aac5058a15e9ad5ad393973dc6fe44d7614a7f55
|
|
@ -46,10 +46,6 @@ if(ANDROID)
|
|||
target_link_libraries(lokinet-util PUBLIC log)
|
||||
endif()
|
||||
|
||||
add_library(uvw INTERFACE)
|
||||
target_include_directories(uvw INTERFACE ${PROJECT_SOURCE_DIR}/external/uvw/src)
|
||||
target_link_libraries(uvw INTERFACE libuv)
|
||||
|
||||
add_library(lokinet-platform
|
||||
# for networking
|
||||
ev/ev.cpp
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
|
@ -21,23 +22,18 @@ namespace llarp
|
|||
GetDefaultDataDir()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const fs::path homedir = getenv("APPDATA");
|
||||
return homedir / "lokinet";
|
||||
return "C:/programdata/lokinet";
|
||||
#else
|
||||
fs::path homedir;
|
||||
fs::path datadir{"/var/lib/lokinet"};
|
||||
|
||||
auto pw = getpwuid(getuid());
|
||||
if ((pw and pw->pw_uid) and pw->pw_dir)
|
||||
if (auto uid = ::geteuid())
|
||||
{
|
||||
homedir = pw->pw_dir;
|
||||
if (auto* pw = getpwuid(uid))
|
||||
{
|
||||
datadir = fs::path{pw->pw_dir} / ".lokinet";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no home dir specified yea idk
|
||||
homedir = "/var/lib/lokinet";
|
||||
return homedir;
|
||||
}
|
||||
return homedir / ".lokinet";
|
||||
return datadir;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -53,4 +49,10 @@ namespace llarp
|
|||
return GetDefaultDataDir() / GetDefaultConfigFilename();
|
||||
}
|
||||
|
||||
inline fs::path
|
||||
GetDefaultBootstrap()
|
||||
{
|
||||
return GetDefaultDataDir() / "bootstrap.signed";
|
||||
}
|
||||
|
||||
} // namespace llarp
|
||||
|
|
|
@ -21,6 +21,7 @@ Build requirements:
|
|||
* C++ 17 capable C++ compiler
|
||||
* libuv >= 1.27.0
|
||||
* libsodium >= 1.0.18
|
||||
* libcurl (for lokinet-bootstrap)
|
||||
* libunbound
|
||||
* libzmq
|
||||
* sqlite3
|
||||
|
@ -39,7 +40,7 @@ You can install these using:
|
|||
|
||||
if you want to build a dev build you can do the following:
|
||||
|
||||
$ sudo apt install build-essential cmake git libcap-dev curl libuv1-dev libsodium-dev pkg-config
|
||||
$ sudo apt install build-essential cmake git libcap-dev libcurl4-openssl-dev libuv1-dev libsodium-dev pkg-config
|
||||
$ git clone --recursive https://github.com/loki-project/loki-network
|
||||
$ cd loki-network
|
||||
$ mkdir build
|
||||
|
|
Loading…
Reference in New Issue