Skip to content

Commit

Permalink
add swift version bullshit file and additional bullshittery
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff authored and majestrate committed Sep 2, 2021
1 parent 0708a0d commit 5edd045
Show file tree
Hide file tree
Showing 22 changed files with 358 additions and 238 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.4.2
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if(RELEASE_MOTTO AND CMAKE_BUILD_TYPE MATCHES "[Rr][Ee][Ll][Ee][Aa][Ss][Ee]")
add_definitions(-DLLARP_RELEASE_MOTTO="${RELEASE_MOTTO}")
endif()

set(LOKINET_VERSION "${lokinet_VERSION_MAJOR}.${lokinet_VERSION_MINOR}.${lokinet_VERSION_PATCH}")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

Expand Down
4 changes: 2 additions & 2 deletions contrib/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ fi

cd "$(dirname $0)/../"
if [ "$1" = "verify" ] ; then
if [ $($binary --output-replacements-xml $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$' | grep -v '\#') | grep '</replacement>' | wc -l) -ne 0 ] ; then
if [ $($binary --output-replacements-xml $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|mm)$' | grep -v '\#') | grep '</replacement>' | wc -l) -ne 0 ] ; then
exit 1
fi
else
$binary -i $(find jni daemon llarp include pybind | grep -E '\.[hc](pp)?$' | grep -v '\#') &> /dev/null
$binary -i $(find jni daemon llarp include pybind | grep -E '\.([hc](pp)?|mm)$' | grep -v '\#') &> /dev/null
fi

swift_format=$(which swiftformat 2>/dev/null)
Expand Down
2 changes: 1 addition & 1 deletion contrib/macos/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>MacOS/lokinet</string>
<key>CFBundleIdentifier</key>
<string>org.lokinet.Daemon</string>
<string>com.loki-project.lokinet</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
31 changes: 0 additions & 31 deletions contrib/macos/LokinetExtension.Info.plist

This file was deleted.

40 changes: 40 additions & 0 deletions contrib/macos/LokinetExtension.Info.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>Lokinet</string>

<key>CFBundleExecutable</key>
<string>lokinet-extension</string>

<key>CFBundleIdentifier</key>
<string>com.loki-project.lokinet.network-extension</string>

<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>

<key>CFBundlePackageType</key>
<string>XPC!</string>

<key>CFBundleName</key>
<string>lokinet</string>

<key>CFBundleVersion</key>
<string>${LOKINET_VERSION}</string>

<key>ITSAppUsesNonExemptEncryption</key>
<false/>

<key>LSMinimumSystemVersion</key>
<string>11.0</string>

<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.networkextension.packet-tunnel</string>
<key>NSExtensionPrincipalClass</key>
<string>LLARPPacketTunnel</string>
</dict>
</dict>
</plist>
25 changes: 25 additions & 0 deletions contrib/macos/lokinet-extension.entitlements.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.networking.networkextension</key>
<array>
<string>packet-tunnel-provider</string>
</array>
<!--
<key>com.apple.developer.networking.vpn.api</key>
<array>
<string>allow-vpn</string>
</array>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>${CODESIGN_TEAM_ID}.com.loki-project.lokinet.network-extension</string>
</array>
-->
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
10 changes: 0 additions & 10 deletions contrib/macos/lokinet.entitlements.plist

This file was deleted.

24 changes: 24 additions & 0 deletions contrib/macos/lokinet.entitlements.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.networking.networkextension</key>
<array>
<string>packet-tunnel-provider</string>
</array>
<!--
<key>com.apple.developer.networking.vpn.api</key>
<array>
<string>allow-vpn</string>
</array>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>${CODESIGN_TEAM_ID}.com.loki-project.lokinet</string>
</array>
-->
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
8 changes: 3 additions & 5 deletions contrib/macos/sign.sh.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -x
set -e
for file in "${SIGN_TARGET}/Contents/Frameworks/lokinet-extension.framework" "${SIGN_TARGET}/Contents/MacOS/Lokinet" "${SIGN_TARGET}" ; do
codesign -vvvv --force -s "${CODESIGN_KEY}" --entitlements "${SIGN_ENTITLEMENTS}" --deep --timestamp --options=runtime "$file"
codesign --verbose=4 --force -s "${CODESIGN_KEY}" --entitlements "${NETEXT_ENTITLEMENTS}" --deep --timestamp --options=runtime "${SIGN_TARGET}/Contents/Frameworks/lokinet-extension.framework"
for file in "${SIGN_TARGET}/Contents/MacOS/Lokinet" "${SIGN_TARGET}" ; do
codesign --verbose=4 --force -s "${CODESIGN_KEY}" --entitlements "${LOKINET_ENTITLEMENTS}" --deep --timestamp --options=runtime "$file"
done

codesign --verify "${SIGN_TARGET}"
58 changes: 32 additions & 26 deletions daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
if(APPLE)
option(WITH_SWIFT "use swift" ON)
if(WITH_SWIFT)
add_executable(lokinet lokinet.swift)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Lokinet.modulemap.in ${CMAKE_CURRENT_BINARY_DIR}/swift/LokinetExtension/module.modulemap ESCAPE_QUOTES @ONLY)
target_include_directories(lokinet PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/swift)
else()
add_executable(lokinet lokinet.mm)
endif()
set(LOKINET_SWIFT_SOURCES lokinet.swift)
add_executable(lokinet ${LOKINET_SWIFT_SOURCES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Lokinet.modulemap.in ${CMAKE_CURRENT_BINARY_DIR}/swift/LokinetExtension/module.modulemap ESCAPE_QUOTES @ONLY)
target_include_directories(lokinet PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/swift)
target_link_libraries(lokinet PUBLIC lokinet-extension)
add_executable(lokinet-old lokinet.cpp)
enable_lto(lokinet-old)
else()
add_executable(lokinet lokinet.cpp)
add_executable(lokinet-vpn lokinet-vpn.cpp)
add_executable(lokinet-bootstrap lokinet-bootstrap.cpp)
enable_lto(lokinet lokinet-vpn lokinet-bootstrap)
endif()
add_executable(lokinet-vpn lokinet-vpn.cpp)
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)
Expand All @@ -35,16 +33,19 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
endif()
endif()

target_link_libraries(lokinet-bootstrap PUBLIC cpr::cpr)
if(NOT WIN32)
find_package(OpenSSL REQUIRED)
# because debian sid's curl doesn't link against openssl for some godawful cursed reason
target_link_libraries(lokinet-bootstrap PUBLIC OpenSSL::SSL OpenSSL::Crypto)
if(NOT APPLE)
target_link_libraries(lokinet-bootstrap PUBLIC cpr::cpr)
if(NOT WIN32)
find_package(OpenSSL REQUIRED)
# because debian sid's curl doesn't link against openssl for some godawful cursed reason
target_link_libraries(lokinet-bootstrap PUBLIC OpenSSL::SSL OpenSSL::Crypto)
endif()
endif()

set(exetargets lokinet-vpn lokinet-bootstrap)
if(NOT APPLE)
set(exetargets lokinet ${exes})
if(APPLE)
set(exetargets lokinet-old lokinet)
else()
set(exetargets lokinet lokinet-vpn lokinet-bootstrap)
endif()

foreach(exe ${exetargets})
Expand All @@ -55,11 +56,11 @@ foreach(exe ${exetargets})
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
target_link_directories(${exe} PRIVATE /usr/local/lib)
endif()
target_link_libraries(${exe} PRIVATE liblokinet)
target_link_libraries(${exe} PUBLIC liblokinet)
if(WITH_JEMALLOC)
target_link_libraries(${exe} PUBLIC jemalloc)
endif()
target_include_directories(${exe} PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories(${exe} PUBLIC "${PROJECT_SOURCE_DIR}")
target_compile_definitions(${exe} PRIVATE -DVERSIONTAG=${GIT_VERSION_REAL})
add_log_tag(${exe})
if(should_install)
Expand Down Expand Up @@ -87,18 +88,23 @@ if(APPLE)
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_STRING "Lokinet IP Packet Onion Router"
MACOSX_BUNDLE_BUNDLE_NAME "Lokinet"
MACOSX_BUNDLE_BUNDLE_VERSION "${lokinet_VERSION_MAJOR}.${lokinet_VERSION_MINOR}.${lokinet_VERSION_PATCH}"
MACOSX_BUNDLE_BUNDLE_VERSION "${LOKINET_VERSION}"
MACOSX_BUNDLE_LONG_VERSION_STRING "${lokinet_VERSION}.$lokinet_VERSION_MINOR}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${lokinet_VERSION_MAJOR}.${lokinet_VERSION_MINOR}"
MACOSX_BUNDLE_GUI_IDENTIFIER "org.lokinet.lokinet"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.loki-project.lokinet"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/contrib/macos/Info.plist"
MACOSX_BUNDLE_ICON_FILE "${CMAKE_CURRENT_BINARY_DIR}/lokinet.icns"
MACOSX_BUNDLE_COPYRIGHT "© 2021, The Loki Project")
option(CODESIGN_KEY "codesign all the shit with this key" OFF)
if (CODESIGN_KEY)
if (CODESIGN_KEY AND CODESIGN_TEAM_ID)
message(STATUS "codesigning with ${CODESIGN_KEY}")
set(SIGN_TARGET "${CMAKE_CURRENT_BINARY_DIR}/Lokinet.app")
set(SIGN_ENTITLEMENTS "${CMAKE_SOURCE_DIR}/contrib/macos/lokinet.entitlements.plist")
set(SIGN_TARGET "${CMAKE_CURRENT_BINARY_DIR}/Lokinet.app")
configure_file("${CMAKE_SOURCE_DIR}/contrib/macos/lokinet.entitlements.plist.in"
"${CMAKE_BINARY_DIR}/lokinet.entitlements.plist")
configure_file("${CMAKE_SOURCE_DIR}/contrib/macos/lokinet-extension.entitlements.plist.in"
"${CMAKE_BINARY_DIR}/lokinet-extension.entitlements.plist")
set(LOKINET_ENTITLEMENTS "${CMAKE_BINARY_DIR}/lokinet.entitlements.plist")
set(NETEXT_ENTITLEMENTS "${CMAKE_BINARY_DIR}/lokinet-extension.entitlements.plist")
configure_file(
"${PROJECT_SOURCE_DIR}/contrib/macos/sign.sh.in"
"${CMAKE_BINARY_DIR}/sign.sh")
Expand Down
8 changes: 8 additions & 0 deletions daemon/lokinet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <dbghelp.h>
#endif

#ifdef __APPLE__
#include <llarp/util/logging/apple_logger.hpp>
#endif

#include <csignal>

#include <cxxopts.hpp>
Expand Down Expand Up @@ -396,6 +400,10 @@ lokinet_main(int argc, char* argv[])
{
return result;
}
#ifdef __APPLE__
llarp::LogContext::Instance().logStream.reset(new llarp::NSLogStream{});
#endif

llarp::RuntimeOptions opts;

#ifdef _WIN32
Expand Down
9 changes: 0 additions & 9 deletions daemon/lokinet.mm

This file was deleted.

Loading

0 comments on commit 5edd045

Please sign in to comment.