Build apple/macos GUI from lokinet project
This adds the gui as a submodule, and consolidates the GUI handling a bit between the two platforms.stable
parent
7b2b114240
commit
181de210cd
|
@ -36,3 +36,6 @@
|
|||
[submodule "external/oxen-logging"]
|
||||
path = external/oxen-logging
|
||||
url = https://github.com/oxen-io/oxen-logging.git
|
||||
[submodule "gui"]
|
||||
path = gui
|
||||
url = https://github.com/oxen-io/lokinet-gui.git
|
||||
|
|
|
@ -299,6 +299,8 @@ endif()
|
|||
|
||||
add_subdirectory(docs)
|
||||
|
||||
include(cmake/gui.cmake)
|
||||
|
||||
# uninstall target
|
||||
if(NOT TARGET uninstall)
|
||||
configure_file(
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
set(default_build_gui OFF)
|
||||
set(default_gui_target pack)
|
||||
if(APPLE)
|
||||
set(default_build_gui ON)
|
||||
set(default_gui_target macos:raw)
|
||||
elseif(WIN32)
|
||||
set(default_build_gui ON)
|
||||
set(default_gui_target win32)
|
||||
endif()
|
||||
|
||||
option(BUILD_GUI "build electron gui from 'gui' submodule source" ${default_build_gui})
|
||||
set(GUI_YARN_TARGET "${default_gui_target}" CACHE STRING "yarn target for building the GUI")
|
||||
set(GUI_YARN_EXTRA_OPTS "" CACHE STRING "extra options to pass into the yarn build command")
|
||||
|
||||
if (BUILD_GUI)
|
||||
message(STATUS "Building lokinet-gui")
|
||||
|
||||
find_program(YARN NAMES yarn yarnpkg REQUIRED)
|
||||
message(STATUS "Building lokinet-gui with yarn ${YARN}, target ${GUI_YARN_TARGET}")
|
||||
add_custom_target(lokinet-gui
|
||||
COMMAND ${YARN} install --frozen-lockfile &&
|
||||
WINEDEBUG=-all "WINEPREFIX=${PROJECT_BINARY_DIR}/wineprefix" ${YARN} ${GUI_YARN_EXTRA_OPTS} ${GUI_YARN_TARGET}
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/gui")
|
||||
|
||||
if(APPLE)
|
||||
add_custom_target(copy_gui ALL
|
||||
DEPENDS lokinet lokinet-extension lokinet-gui
|
||||
# FIXME: we really shouldn't be building inside the source directory but this is npm...
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${PROJECT_SOURCE_DIR}/lokinet-gui/release/mac/lokinet-gui.app
|
||||
$<TARGET_BUNDLE_DIR:lokinet>
|
||||
)
|
||||
add_dependencies(assemble copy_gui)
|
||||
elseif(WIN32)
|
||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/gui")
|
||||
add_custom_target(copy_gui ALL
|
||||
DEPENDS lokinet lokinet-gui
|
||||
# FIXME: we really shouldn't be building inside the source directory but this is npm...
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/gui/release/Lokinet-GUI_portable.exe"
|
||||
"${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe"
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Building/bundling the GUI from this repository is not supported on this platform")
|
||||
endif()
|
||||
|
||||
else()
|
||||
message(STATUS "Not building lokinet-gui")
|
||||
endif()
|
|
@ -1,8 +1,3 @@
|
|||
if(NOT GUI_ZIP_URL)
|
||||
set(GUI_ZIP_URL "https://oxen.rocks/oxen-io/lokinet-gui/dev/lokinet-windows-x64-20220331T180338Z-569f90ad8.zip")
|
||||
set(GUI_ZIP_HASH_OPTS EXPECTED_HASH SHA256=316f10489f5907bfa9c74b21f8ef2fdd7b7c7e6a0f5bcedaed2ee5f4004eab52)
|
||||
endif()
|
||||
|
||||
set(TUNTAP_URL "https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe")
|
||||
set(TUNTAP_EXE "${CMAKE_BINARY_DIR}/tuntap-install.exe")
|
||||
set(BOOTSTRAP_FILE "${PROJECT_SOURCE_DIR}/contrib/bootstrap/mainnet.signed")
|
||||
|
@ -11,13 +6,25 @@ file(DOWNLOAD
|
|||
${TUNTAP_URL}
|
||||
${TUNTAP_EXE})
|
||||
|
||||
file(DOWNLOAD
|
||||
if(NOT BUILD_GUI)
|
||||
if(NOT GUI_ZIP_URL)
|
||||
set(GUI_ZIP_URL "https://oxen.rocks/oxen-io/lokinet-gui/dev/lokinet-windows-x64-20220331T180338Z-569f90ad8.zip")
|
||||
set(GUI_ZIP_HASH_OPTS EXPECTED_HASH SHA256=316f10489f5907bfa9c74b21f8ef2fdd7b7c7e6a0f5bcedaed2ee5f4004eab52)
|
||||
endif()
|
||||
|
||||
file(DOWNLOAD
|
||||
${GUI_ZIP_URL}
|
||||
${CMAKE_BINARY_DIR}/lokinet-gui.zip
|
||||
${GUI_ZIP_HASH_OPTS})
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_DIR}/lokinet-gui.zip
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
# We expect the produced .zip file above to extract to ./gui/lokinet-gui.exe
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_DIR}/lokinet-gui.zip
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/gui/lokinet-gui.exe)
|
||||
message(FATAL_ERROR "Downloaded gui archive from ${GUI_ZIP_URL} does not contain gui/lokinet-gui.exe!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/gui DESTINATION share COMPONENT gui)
|
||||
install(PROGRAMS ${TUNTAP_EXE} DESTINATION bin COMPONENT tuntap)
|
||||
|
|
|
@ -67,36 +67,6 @@ foreach(exe ${exetargets})
|
|||
endif()
|
||||
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)
|
||||
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"
|
||||
|
@ -197,20 +167,24 @@ if(APPLE)
|
|||
MACOSX_BUNDLE_COPYRIGHT "© 2022, The Oxen Project"
|
||||
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}
|
||||
DEPENDS lokinet lokinet-extension
|
||||
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(TARGET lokinet-gui)
|
||||
add_custom_target(copy_gui
|
||||
DEPENDS lokinet lokinet-extension lokinet-gui
|
||||
# FIXME: we really shouldn't be building inside the source directory but this is npm...
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/lokinet-gui/release/mac/lokinet-gui.app $<TARGET_BUNDLE_DIR:lokinet>
|
||||
)
|
||||
add_dependencies(assemble copy_gui)
|
||||
endif()
|
||||
|
||||
if(NOT CODESIGN)
|
||||
message(STATUS "codesigning disabled")
|
||||
add_custom_target(
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 4861da59c3f1251a002199e185cc8a638845e692
|
Loading…
Reference in New Issue