mirror of https://github.com/oxen-io/lokinet
build gui and assemble app bundles into one singular app bundle
This commit is contained in:
parent
279b5710cc
commit
b8896740de
|
@ -25,7 +25,7 @@ cmake \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
"$@" \
|
"$@" \
|
||||||
..
|
..
|
||||||
ninja sign
|
ninja sign -j1
|
||||||
|
|
||||||
echo -e "Build complete, your app is here:\n"
|
echo -e "Build complete, your app is here:\n"
|
||||||
ls -lad $(pwd)/Lokinet.app
|
ls -lad $(pwd)/Lokinet.app
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<string>Lokinet</string>
|
<string>Lokinet</string>
|
||||||
|
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>Lokinet</string>
|
<string>lokinet-gui</string>
|
||||||
|
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>org.lokinet</string>
|
<string>org.lokinet</string>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
set(exetargets lokinet)
|
set(exetargets lokinet)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
@ -56,7 +55,6 @@ foreach(exe ${exetargets})
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(${exe} PUBLIC liblokinet)
|
target_link_libraries(${exe} PUBLIC liblokinet)
|
||||||
target_include_directories(${exe} PUBLIC "${PROJECT_SOURCE_DIR}")
|
target_include_directories(${exe} PUBLIC "${PROJECT_SOURCE_DIR}")
|
||||||
add_log_tag(${exe})
|
|
||||||
if(should_install)
|
if(should_install)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
install(TARGETS ${exe}
|
install(TARGETS ${exe}
|
||||||
|
@ -69,6 +67,36 @@ foreach(exe ${exetargets})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
set(default_with_gui OFF)
|
||||||
|
if(APPLE)
|
||||||
|
set(default_with_gui ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(WITH_GUI "build electron gui from source" ${default_with_gui})
|
||||||
|
|
||||||
|
if (WITH_GUI)
|
||||||
|
find_program(YARN yarn REQUIRED)
|
||||||
|
message(STATUS "Found yarn: ${YARN}")
|
||||||
|
if(NOT GUI_GIT_REPO)
|
||||||
|
set(GUI_GIT_REPO "https://github.com/oxen-io/lokinet-gui")
|
||||||
|
endif()
|
||||||
|
if(NOT GUI_GIT_BRANCH)
|
||||||
|
set(GUI_GIT_BRANCH "stable")
|
||||||
|
endif()
|
||||||
|
if(NOT YARN_TARGET)
|
||||||
|
set(YARN_TARGET pack:raw)
|
||||||
|
if(APPLE)
|
||||||
|
set(YARN_TARGET macos:raw)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
message(STATUS "will build gui: ${GUI_GIT_REPO} (branch: ${GUI_GIT_BRANCH}) using ${YARN} ${YARN_TARGET}")
|
||||||
|
add_custom_target(lokinet-gui
|
||||||
|
COMMAND rm -rf "${PROJECT_BINARY_DIR}/lokinet-gui" && git clone "${GUI_GIT_REPO}" -b ${GUI_GIT_BRANCH} "${PROJECT_BINARY_DIR}/lokinet-gui" && cd "${PROJECT_BINARY_DIR}/lokinet-gui" && ${YARN} install --frozen-lockfile && ${YARN} ${YARN_TARGET})
|
||||||
|
else()
|
||||||
|
message(STATUS "not building gui")
|
||||||
|
add_custom_target(lokinet-gui COMMAND "true")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
option(MACOS_SYSTEM_EXTENSION
|
option(MACOS_SYSTEM_EXTENSION
|
||||||
"Build the network extension as a system extension rather than a plugin. This must be ON for non-app store release builds, and must be OFF for dev builds and Mac App Store distribution builds"
|
"Build the network extension as a system extension rather than a plugin. This must be ON for non-app store release builds, and must be OFF for dev builds and Mac App Store distribution builds"
|
||||||
|
@ -154,18 +182,9 @@ if(APPLE)
|
||||||
$<TARGET_BUNDLE_DIR:lokinet>/Contents/embedded.provisionprofile)
|
$<TARGET_BUNDLE_DIR:lokinet>/Contents/embedded.provisionprofile)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_custom_command(TARGET lokinet
|
|
||||||
POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/contrib/bootstrap/mainnet.signed
|
|
||||||
$<TARGET_BUNDLE_DIR:lokinet-extension>/Contents/Resources/bootstrap.signed
|
|
||||||
COMMAND mkdir -p $<TARGET_BUNDLE_DIR:lokinet>/${lokinet_ext_dir}
|
|
||||||
COMMAND cp -a $<TARGET_BUNDLE_DIR:lokinet-extension> $<TARGET_BUNDLE_DIR:lokinet>/${lokinet_ext_dir}
|
|
||||||
${post_build_pp}
|
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties(lokinet
|
set_target_properties(lokinet
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
OUTPUT_NAME Lokinet
|
OUTPUT_NAME Lokinet
|
||||||
MACOSX_BUNDLE TRUE
|
MACOSX_BUNDLE TRUE
|
||||||
MACOSX_BUNDLE_INFO_STRING "Lokinet IP Packet Onion Router"
|
MACOSX_BUNDLE_INFO_STRING "Lokinet IP Packet Onion Router"
|
||||||
MACOSX_BUNDLE_BUNDLE_NAME "Lokinet"
|
MACOSX_BUNDLE_BUNDLE_NAME "Lokinet"
|
||||||
|
@ -178,15 +197,29 @@ if(APPLE)
|
||||||
MACOSX_BUNDLE_COPYRIGHT "© 2022, The Oxen Project"
|
MACOSX_BUNDLE_COPYRIGHT "© 2022, The Oxen Project"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}"
|
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}"
|
||||||
)
|
)
|
||||||
|
set(copy_gui)
|
||||||
|
if(BUILD_GUI)
|
||||||
|
set(copy_gui COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_BINARY_DIR}/lokinet-gui/release/mac/lokinet-gui.app $<TARGET_BUNDLE_DIR:lokinet>)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_target(assemble
|
||||||
|
DEPENDS lokinet lokinet-extension lokinet-gui
|
||||||
|
${copy_gui}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/contrib/bootstrap/mainnet.signed
|
||||||
|
$<TARGET_BUNDLE_DIR:lokinet-extension>/Contents/Resources/bootstrap.signed
|
||||||
|
COMMAND mkdir -p $<TARGET_BUNDLE_DIR:lokinet>/${lokinet_ext_dir}
|
||||||
|
COMMAND cp -a $<TARGET_BUNDLE_DIR:lokinet-extension> $<TARGET_BUNDLE_DIR:lokinet>/${lokinet_ext_dir}
|
||||||
|
${post_build_pp})
|
||||||
|
|
||||||
if(NOT CODESIGN)
|
if(NOT CODESIGN)
|
||||||
message(STATUS "codesigning disabled")
|
message(STATUS "codesigning disabled")
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
sign
|
sign
|
||||||
DEPENDS lokinet lokinet-extension
|
DEPENDS assemble
|
||||||
COMMAND "true")
|
COMMAND "true")
|
||||||
|
|
||||||
elseif(CODESIGN)
|
elseif(CODESIGN)
|
||||||
set(SIGN_TARGET "${PROJECT_BINARY_DIR}/lokinet.app")
|
set(SIGN_TARGET "${PROJECT_BINARY_DIR}/Lokinet.app")
|
||||||
if(MACOS_SYSTEM_EXTENSION)
|
if(MACOS_SYSTEM_EXTENSION)
|
||||||
set(LOKINET_ENTITLEMENTS_TYPE sysext)
|
set(LOKINET_ENTITLEMENTS_TYPE sysext)
|
||||||
else()
|
else()
|
||||||
|
@ -198,7 +231,7 @@ if(APPLE)
|
||||||
@ONLY)
|
@ONLY)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
sign
|
sign
|
||||||
DEPENDS "${PROJECT_BINARY_DIR}/sign.sh" lokinet lokinet-extension
|
DEPENDS "${PROJECT_BINARY_DIR}/sign.sh" assemble
|
||||||
COMMAND "${PROJECT_BINARY_DIR}/sign.sh"
|
COMMAND "${PROJECT_BINARY_DIR}/sign.sh"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,13 @@ class LokinetMain: NSObject, NSApplicationDelegate {
|
||||||
let netextBundleId = "org.lokinet.network-extension"
|
let netextBundleId = "org.lokinet.network-extension"
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_: Notification) {
|
func applicationDidFinishLaunching(_: Notification) {
|
||||||
if self.mode == START {
|
if mode == START {
|
||||||
startNetworkExtension()
|
startNetworkExtension()
|
||||||
} else if self.mode == STOP {
|
} else if mode == STOP {
|
||||||
tearDownVPNTunnel()
|
tearDownVPNTunnel()
|
||||||
} else {
|
} else {
|
||||||
self.result(msg: HELP_STRING)
|
result(msg: HELP_STRING)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func bail() {
|
func bail() {
|
||||||
|
@ -33,7 +32,7 @@ class LokinetMain: NSObject, NSApplicationDelegate {
|
||||||
func result(msg: String) {
|
func result(msg: String) {
|
||||||
NSLog(msg)
|
NSLog(msg)
|
||||||
// TODO: does lokinet continue after this?
|
// TODO: does lokinet continue after this?
|
||||||
self.bail()
|
bail()
|
||||||
}
|
}
|
||||||
|
|
||||||
func tearDownVPNTunnel() {
|
func tearDownVPNTunnel() {
|
||||||
|
@ -58,19 +57,18 @@ class LokinetMain: NSObject, NSApplicationDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func startNetworkExtension() {
|
func startNetworkExtension() {
|
||||||
#if MACOS_SYSTEM_EXTENSION
|
#if MACOS_SYSTEM_EXTENSION
|
||||||
NSLog("Loading Lokinet network extension")
|
NSLog("Loading Lokinet network extension")
|
||||||
// Start by activating the system extension
|
// Start by activating the system extension
|
||||||
let activationRequest = OSSystemExtensionRequest.activationRequest(forExtensionWithIdentifier: netextBundleId, queue: .main)
|
let activationRequest = OSSystemExtensionRequest.activationRequest(forExtensionWithIdentifier: netextBundleId, queue: .main)
|
||||||
activationRequest.delegate = self
|
activationRequest.delegate = self
|
||||||
OSSystemExtensionManager.shared.submitRequest(activationRequest)
|
OSSystemExtensionManager.shared.submitRequest(activationRequest)
|
||||||
#else
|
#else
|
||||||
setupVPNTunnel()
|
setupVPNTunnel()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupVPNTunnel() {
|
func setupVPNTunnel() {
|
||||||
|
|
||||||
NSLog("Starting up Lokinet tunnel")
|
NSLog("Starting up Lokinet tunnel")
|
||||||
NETunnelProviderManager.loadAllFromPreferences { [self] (savedManagers: [NETunnelProviderManager]?, error: Error?) in
|
NETunnelProviderManager.loadAllFromPreferences { [self] (savedManagers: [NETunnelProviderManager]?, error: Error?) in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
|
@ -113,7 +111,7 @@ class LokinetMain: NSObject, NSApplicationDelegate {
|
||||||
self.initializeConnectionObserver()
|
self.initializeConnectionObserver()
|
||||||
try self.vpnManager.connection.startVPNTunnel()
|
try self.vpnManager.connection.startVPNTunnel()
|
||||||
} catch let error as NSError {
|
} catch let error as NSError {
|
||||||
self.result(msg: error.localizedDescription)
|
self.result(msg: error.localizedDescription)
|
||||||
} catch {
|
} catch {
|
||||||
self.result(msg: "There was a fatal error")
|
self.result(msg: "There was a fatal error")
|
||||||
}
|
}
|
||||||
|
@ -145,32 +143,32 @@ class LokinetMain: NSObject, NSApplicationDelegate {
|
||||||
|
|
||||||
#if MACOS_SYSTEM_EXTENSION
|
#if MACOS_SYSTEM_EXTENSION
|
||||||
|
|
||||||
extension LokinetMain: OSSystemExtensionRequestDelegate {
|
extension LokinetMain: OSSystemExtensionRequestDelegate {
|
||||||
|
func request(_: OSSystemExtensionRequest, didFinishWithResult result: OSSystemExtensionRequest.Result) {
|
||||||
func request(_ request: OSSystemExtensionRequest, didFinishWithResult result: OSSystemExtensionRequest.Result) {
|
guard result == .completed else {
|
||||||
guard result == .completed else {
|
NSLog("Unexpected result %d for system extension request", result.rawValue)
|
||||||
NSLog("Unexpected result %d for system extension request", result.rawValue)
|
return
|
||||||
return
|
}
|
||||||
|
NSLog("Lokinet system extension loaded")
|
||||||
|
setupVPNTunnel()
|
||||||
}
|
}
|
||||||
NSLog("Lokinet system extension loaded")
|
|
||||||
setupVPNTunnel()
|
|
||||||
}
|
|
||||||
|
|
||||||
func request(_ request: OSSystemExtensionRequest, didFailWithError error: Error) {
|
func request(_: OSSystemExtensionRequest, didFailWithError error: Error) {
|
||||||
NSLog("System extension request failed: %@", error.localizedDescription)
|
NSLog("System extension request failed: %@", error.localizedDescription)
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestNeedsUserApproval(_ request: OSSystemExtensionRequest) {
|
func requestNeedsUserApproval(_ request: OSSystemExtensionRequest) {
|
||||||
NSLog("Extension %@ requires user approval", request.identifier)
|
NSLog("Extension %@ requires user approval", request.identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
func request(_ request: OSSystemExtensionRequest,
|
func request(_ request: OSSystemExtensionRequest,
|
||||||
actionForReplacingExtension existing: OSSystemExtensionProperties,
|
actionForReplacingExtension existing: OSSystemExtensionProperties,
|
||||||
withExtension extension: OSSystemExtensionProperties) -> OSSystemExtensionRequest.ReplacementAction {
|
withExtension extension: OSSystemExtensionProperties) -> OSSystemExtensionRequest.ReplacementAction
|
||||||
NSLog("Replacing extension %@ version %@ with version %@", request.identifier, existing.bundleShortVersion, `extension`.bundleShortVersion)
|
{
|
||||||
return .replace
|
NSLog("Replacing extension %@ version %@ with version %@", request.identifier, existing.bundleShortVersion, `extension`.bundleShortVersion)
|
||||||
|
return .replace
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ static void del_default_route(void* ctx) {
|
||||||
NSString* dns_ip = [NSString stringWithUTF8String:conf.dns_bind_ip];
|
NSString* dns_ip = [NSString stringWithUTF8String:conf.dns_bind_ip];
|
||||||
#else
|
#else
|
||||||
// TODO: placeholder
|
// TODO: placeholder
|
||||||
NSString* dns_ip = @"127.0.0.1";
|
NSString* dns_ip = ip;
|
||||||
#endif
|
#endif
|
||||||
NSLog(@"setting dns to %@", dns_ip);
|
NSLog(@"setting dns to %@", dns_ip);
|
||||||
NEDNSSettings* dns = [[NEDNSSettings alloc] initWithServers:@[dns_ip]];
|
NEDNSSettings* dns = [[NEDNSSettings alloc] initWithServers:@[dns_ip]];
|
||||||
|
|
|
@ -93,9 +93,9 @@ build 1 or many cross targets:
|
||||||
|
|
||||||
### MacOS <span id="mac-install" />
|
### MacOS <span id="mac-install" />
|
||||||
|
|
||||||
Lokinet ~~is~~ will be available on the Apple App store.
|
Source code compilation of Lokinet by end users is not supported or permitted by apple on their platforms, see [this](contrib/macos/README.txt) for more information.
|
||||||
|
|
||||||
Source code compilation of Lokinet by end users is not supported or permitted by apple on their platforms, see [this](contrib/macos/README.txt) for more information. If you find this disagreeable consider using a platform that permits compiling from source.
|
If you find this disagreeable consider using a platform that permits compiling from source.
|
||||||
|
|
||||||
### Windows <span id="windows-install" />
|
### Windows <span id="windows-install" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue