Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
18c3d8b
initial ios junk
Jun 13, 2022
cbdd54e
i hate apple
Jun 13, 2022
5cc6089
squash
Jun 13, 2022
4b54f72
Revert "squash"
Jun 13, 2022
76eeddc
squash
Jun 13, 2022
e56eef1
squash
Jun 14, 2022
0cad6e9
it actually start to build omg
Jun 14, 2022
1da239f
squash
Jun 14, 2022
2b9e2e7
remove submodule
Jun 14, 2022
17e5ed8
squash
Jun 14, 2022
5a7fa2a
tmp
Jun 14, 2022
e3aa9e8
OH MY FUCKING SWEET BABY JESUS SON OF THE VIRGIN MARY IT FUCKING COMP…
Jun 15, 2022
02d4f78
cleanups
Jun 15, 2022
a793057
add iphone to ci
Jun 15, 2022
e5496a1
all the stuff for the ci pipeline, probably
Jun 15, 2022
e343417
squashme
Jun 15, 2022
0c55630
squashme
Jun 15, 2022
aee7296
format
Jun 15, 2022
8d5ae38
WITH_ to USE_
Jun 15, 2022
9af52af
squashme
Jun 15, 2022
acf8a07
submodule
Jun 15, 2022
a770bd5
fix up cross.sh
Jun 15, 2022
075dc79
check libuv submodule
Jun 15, 2022
7ff9678
build ios first
Jun 15, 2022
239d0ec
only pack liblokinet-embedded.a in iphone ci pipeline
Jun 15, 2022
89b499d
use uv static build when using submodule
Jun 15, 2022
5051739
move logic out of ci into ios builder script
Jun 16, 2022
7c978cc
restructure build for iphone
Jun 16, 2022
e0b978e
fix typos
Jun 16, 2022
d00a60e
clean up static deps for cross targets
Jun 16, 2022
8b83137
fix up compiler flags and make shit smaller
Jul 6, 2022
65d3c0e
fall back to null vpn platform when we have no implementation for the…
majestrate Jun 22, 2022
8a905db
Updated the ios.sh to create fat libraries and generate a .xcframework
mpretty-cyro Jul 7, 2022
8585d53
Merge pull request #5 from mpretty-cyro/ios-ci-2022-06-13
Jul 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
OH MY FUCKING SWEET BABY JESUS SON OF THE VIRGIN MARY IT FUCKING COMP…
…ILES FOR IPHONE
  • Loading branch information
jeff committed Jul 6, 2022
commit e3aa9e83555e08d6f311cc2fbd0cacadf30251ae
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@
[submodule "external/oxen-encoding"]
path = external/oxen-encoding
url = https://github.com/oxen-io/oxen-encoding.git
[submodule "external/libuv"]
path = external/libuv
url = https://github.com/libuv/libuv
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ endif()


# Core options
option(USE_AVX2 "enable avx2 code" OFF)
option(USE_AVX2 "enable avx2 code" ON)
option(USE_NETNS "enable networking namespace support. Linux only" OFF)
option(NATIVE_BUILD "optimise for host system and FPU" ON)
option(EMBEDDED_CFG "optimise for older hardware or embedded systems" OFF)
option(BUILD_LIBLOKINET "build liblokinet.so" ON)
option(BUILD_LIBLOKINET "build liblokinet.so" OFF)
option(BUILD_EMBEDDED_LOKINET "build embedded lokinet" OFF)
option(XSAN "use sanitiser, if your system has it (requires -DCMAKE_BUILD_TYPE=Debug)" OFF)
option(USE_JEMALLOC "Link to jemalloc for memory allocations, if found" ON)
option(TESTNET "testnet build" OFF)
Expand All @@ -73,8 +74,10 @@ option(STATIC_LINK "link statically against dependencies" ${BUILD_STATIC_DEPS})
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(cmake/combine_archives.cmake)
include(StaticBuild)
endif()

Expand Down Expand Up @@ -140,6 +143,7 @@ find_package(PkgConfig REQUIRED)
if(NOT BUILD_STATIC_DEPS)
pkg_check_modules(LIBUV libuv>=1.18.0 IMPORTED_TARGET)
endif()

if(LIBUV_FOUND AND NOT BUILD_STATIC_DEPS)
add_library(libuv INTERFACE)
target_link_libraries(libuv INTERFACE PkgConfig::LIBUV)
Expand Down
57 changes: 33 additions & 24 deletions cmake/StaticBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ set(ZMQ_SOURCE zeromq-${ZMQ_VERSION}.tar.gz)
set(ZMQ_HASH SHA512=e198ef9f82d392754caadd547537666d4fba0afd7d027749b3adae450516bcf284d241d4616cad3cb4ad9af8c10373d456de92dc6d115b037941659f141e7c0e
CACHE STRING "libzmq source hash")

set(LIBUV_VERSION 1.44.1 CACHE STRING "libuv version")
set(LIBUV_MIRROR ${LOCAL_MIRROR} https://dist.libuv.org/dist/v${LIBUV_VERSION}
CACHE STRING "libuv mirror(s)")
set(LIBUV_SOURCE libuv-v${LIBUV_VERSION}.tar.gz)
set(LIBUV_HASH SHA512=b4f8944e2c79e3a6a31ded6cccbe4c0eeada50db6bc8a448d7015642795012a4b80ffeef7ca455bb093c59a8950d0e1430566c3c2fa87b73f82699098162d834
CACHE STRING "libuv source hash")

set(ZLIB_VERSION 1.2.12 CACHE STRING "zlib version")
set(ZLIB_MIRROR ${LOCAL_MIRROR} https://zlib.net
CACHE STRING "zlib mirror(s)")
Expand Down Expand Up @@ -224,16 +217,6 @@ function(build_external target)
BUILD_BYPRODUCTS ${arg_BUILD_BYPRODUCTS}
)
endfunction()

build_external(libuv
CONFIGURE_COMMAND ./autogen.sh && ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --with-pic --disable-shared --enable-static "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}"
BUILD_BYPRODUCTS
${DEPS_DESTDIR}/lib/libuv.a
${DEPS_DESTDIR}/include/uv.h
)
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
Expand Down Expand Up @@ -286,11 +269,35 @@ elseif(CMAKE_C_FLAGS MATCHES "-march=armv7")
endif()



set(openssl_configure ./config)
set(openssl_system_env "")
set(openssl_cc "${deps_cc}")
if(CMAKE_CROSSCOMPILING)
if(ARCH_TRIPLET STREQUAL x86_64-w64-mingw32)
set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER})
elseif(ARCH_TRIPLET STREQUAL i686-w64-mingw32)
set(openssl_system_env SYSTEM=MINGW64 RC=${CMAKE_RC_COMPILER})
elseif(ANDROID)
set(openssl_system_env SYSTEM=Linux MACHINE=${openssl_machine} ${cross_rc})
set(openssl_extra_opts no-asm)
elseif(IOS)
get_filename_component(apple_toolchain "${CMAKE_C_COMPILER}" DIRECTORY)
get_filename_component(apple_sdk "${CMAKE_OSX_SYSROOT}" NAME)
if(NOT ${apple_toolchain} MATCHES Xcode OR NOT ${apple_sdk} MATCHES "iPhone(OS|Simulator)")
message(FATAL_ERROR "didn't find your toolchain and sdk correctly from ${CMAKE_C_COMPILER}/${CMAKE_OSX_SYSROOT}: found toolchain=${apple_toolchain}, sdk=${apple_sdk}")
endif()
set(openssl_system_env CROSS_COMPILE=${apple_toolchain}/ CROSS_TOP=${CMAKE_DEVELOPER_ROOT} CROSS_SDK=${apple_sdk})
set(openssl_configure ./Configure iphoneos-cross)
set(openssl_cc "clang")
endif()
endif()

build_external(openssl
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CC=${deps_cc} ${openssl_system_env} ${openssl_configure_command}
--prefix=${DEPS_DESTDIR} ${openssl_extra_opts} no-shared no-capieng no-dso no-dtls1 no-ec_nistp_64_gcc_128 no-gost
no-heartbeats no-md2 no-rc5 no-rdrand no-rfc3779 no-sctp no-ssl-trace no-ssl2 no-ssl3
no-static-engine no-tests no-weak-ssl-ciphers no-zlib no-zlib-dynamic "CFLAGS=${deps_CFLAGS}"
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CC=${openssl_cc} ${openssl_system_env} ${openssl_configure}
--prefix=${DEPS_DESTDIR} ${openssl_extra_opts} no-shared no-capieng no-dso no-dtls1 no-ec_nistp_64_gcc_128 no-gost
no-heartbeats no-md2 no-rc5 no-rdrand no-rfc3779 no-sctp no-ssl-trace no-ssl2 no-ssl3 no-engine
no-static-engine no-tests no-weak-ssl-ciphers no-zlib-dynamic "CFLAGS=${deps_CFLAGS}"
INSTALL_COMMAND ${_make} install_sw
BUILD_BYPRODUCTS
${DEPS_DESTDIR}/lib/libssl.a ${DEPS_DESTDIR}/lib/libcrypto.a
Expand All @@ -301,7 +308,6 @@ add_static_target(OpenSSL::Crypto openssl_external libcrypto.a)
if(WIN32)
target_link_libraries(OpenSSL::Crypto INTERFACE "ws2_32;crypt32;iphlpapi")
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)
Expand All @@ -323,7 +329,7 @@ endif()
build_external(unbound
DEPENDS openssl_external expat_external
CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --disable-shared
--enable-static --with-libunbound-only --with-pic
--enable-static --with-libunbound-only --with-pic --disable-gost
--$<IF:$<BOOL:${WITH_LTO}>,enable,disable>-flto --with-ssl=${DEPS_DESTDIR}
--with-libexpat=${DEPS_DESTDIR}
"CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}" ${unbound_extra}
Expand All @@ -341,7 +347,10 @@ build_external(sodium CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --
--enable-static --with-pic "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}")
add_static_target(sodium sodium_external libsodium.a)

build_external(sqlite3)
build_external(sqlite3 CONFIGURE_COMMAND ./configure ${cross_host} ${cross_rc} --prefix=${DEPS_DESTDIR} --enable-static --disable-shared --disable-readline --with-pic "CC=${deps_cc}" "CFLAGS=${deps_CFLAGS}"
BUILD_COMMAND true
INSTALL_COMMAND make install-includeHEADERS install-libLTLIBRARIES)

add_static_target(sqlite3 sqlite3_external libsqlite3.a)


Expand Down
30 changes: 30 additions & 0 deletions cmake/combine_archives.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function(combine_archives output_archive)
set(FULL_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib${output_archive}.a)
set(output_archive_dummy_file ${CMAKE_CURRENT_BINARY_DIR}/${output_archive}.dummy.cpp)
add_custom_command(OUTPUT ${output_archive_dummy_file}
COMMAND touch ${output_archive_dummy_file}
DEPENDS ${ARGN})
add_library(${output_archive} STATIC EXCLUDE_FROM_ALL ${output_archive_dummy_file})

if(NOT APPLE)
set(mri_file ${CMAKE_CURRENT_BINARY_DIR}/${output_archive}.mri)
set(mri_content "create ${FULL_OUTPUT_PATH}\n")
foreach(in_archive ${ARGN})
string(APPEND mri_content "addlib $<TARGET_FILE:${in_archive}>\n")
endforeach()
string(APPEND mri_content "save\nend\n")
file(GENERATE OUTPUT ${mri_file} CONTENT "${mri_content}")

add_custom_command(TARGET ${output_archive}
POST_BUILD
COMMAND ar -M < ${mri_file})
else()
set(merge_libs)
foreach(in_archive ${ARGN})
list(APPEND merge_libs $<TARGET_FILE:${in_archive}>)
endforeach()
add_custom_command(TARGET ${output_archive}
POST_BUILD
COMMAND /usr/bin/libtool -static -o ${FULL_OUTPUT_PATH} ${merge_libs})
endif()
endfunction(combine_archives)
9 changes: 5 additions & 4 deletions contrib/ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ fi
mkdir -p build/iphone
cmake \
-G Ninja \
-DCMAKE_TOOLCHAIN_FILE=./contrib/cross/ios.toolchain.cmake -DPLATFORM=OS -DDEPLOYMENT_TARGET=13 -DENABLE_VISIBILITY=ON -DENABLE_BITCODE=OFF \
-DCMAKE_CXX_COMPILER_LAUNCHER= -DCMAKE_C_COMPILER_LAUNCHER= \
-DBUILD_STATIC_DEPS=ON \
-DBUILD_PACKAGE=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_LIBLOKINET=ON \
-DBUILD_EMBEDDED_LOKINET=ON \
-DWITH_TESTS=OFF \
-DNATIVE_BUILD=OFF \
-DSTATIC_LINK=ON \
Expand All @@ -26,10 +27,10 @@ cmake \
-DFORCE_OXENMQ_SUBMODULE=ON \
-DFORCE_OXENC_SUBMODULE=ON \
-DFORCE_NLOHMANN_SUBMODULE=ON \
-DFORCE_LIBUV_SUBMODULE=ON \
-DSUBMODULE_CHECK=ON \
-DWITH_LTO=OFF \
-S . -B build/iphone \
$@ \
-DCMAKE_TOOLCHAIN_FILE=contrib/cross/ios.toolchain.cmake
$@

cmake --build build/iphone --target lokinet-shared
cmake --build build/iphone --target lokinet-embedded
2 changes: 1 addition & 1 deletion crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ set(NTRU_AVX_SRC
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-mavx2 COMPILER_SUPPORTS_AVX2)
check_cxx_compiler_flag(-mfma COMPILER_SUPPORTS_FMA)
if(COMPILER_SUPPORTS_AVX2 AND COMPILER_SUPPORTS_FMA AND (NOT ANDROID))
if(COMPILER_SUPPORTS_AVX2 AND COMPILER_SUPPORTS_FMA AND WITH_AVX2)
target_sources(lokinet-cryptography PRIVATE ${NTRU_AVX_SRC})
set_property(SOURCE ${NTRU_AVX_SRC} APPEND PROPERTY COMPILE_FLAGS "-mavx2 -mfma")
message(STATUS "Building libntrup with runtime AVX2/FMA support")
Expand Down
3 changes: 2 additions & 1 deletion external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ system_or_submodule(OXENC oxenc liboxenc>=1.0.3 oxen-encoding)
system_or_submodule(OXENMQ oxenmq liboxenmq>=1.2.12 oxen-mq)
set(JSON_BuildTests OFF CACHE INTERNAL "")
system_or_submodule(NLOHMANN nlohmann_json nlohmann_json>=3.7.0 nlohmann)
system_or_submodule(LIBUV uv libuv libuv) # TODO: select better version


if(WITH_HIVE)
Expand All @@ -75,7 +76,7 @@ target_link_libraries(sqlite_orm INTERFACE sqlite3)

add_library(uvw INTERFACE)
target_include_directories(uvw INTERFACE uvw/src)
target_link_libraries(uvw INTERFACE libuv)
target_link_libraries(uvw INTERFACE uv::uv)

# ngtcp2 needs some massaging to build nicely:
include(ngtcp2_lib)
Expand Down
26 changes: 20 additions & 6 deletions llarp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,26 @@ if(BUILD_LIBLOKINET)
install(TARGETS lokinet-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT liblokinet)
endif()
add_log_tag(lokinet-shared)
if(CMAKE_GENERATOR MATCHES "Xcode")
option(CODE_SIGN_IDENT "for codesign magic on ios" "iPhone Developer")
option(DEV_TEAM_ID "for codesign magic on ios" "SUQ8J2PCT7")
set_property (TARGET lokinet-shared PROPERTY XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CODE_SIGN_IDENT})
set_property (TARGET lokinet-shared PROPERTY XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${DEV_TEAM_ID})
endif()
endif()

if(BUILD_EMBEDDED_LOKINET)
add_library(lokinet-embedded-api STATIC lokinet_shared.cpp)
target_link_libraries(lokinet-embedded-api PUBLIC liblokinet)
add_log_tag(lokinet-embedded-api)
combine_archives(lokinet-embedded
lokinet-embedded-api
lokinet-platform lokinet-util lokinet-cryptography sqlite3 ngtcp2_static
liblokinet
sodium
zlib
OpenSSL::SSL OpenSSL::Crypto
expat
libunbound
libzmq
oxenmq)
install(TARGETS
ARCHIVE DESTINATION ${lib_folder}
EXCLUDE_FROM_ALL)

endif()

Expand Down