From e981c9f89983a12cc75d691fc439366703d5bfff Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 16 Aug 2022 15:49:08 -0400 Subject: [PATCH] tweaks for wine and yarn for gui * allow specifying a custom yarn binary for building the gui using -DYARN= cmake option * unset DISPLAY when calling wine because i hate popups * do not rebuild gui when building for windows * by setting the magical undocumented env var USE_SYSTEM_7ZA to 'true' we can have the pile of npm bullshit code use our system's local 7z binary instead of the probably not backdoored binary from npm, yes for real. i hate nodejs so god damn much you have no fucking idea * allow providing a custom gui from a zip file via -DGUI_ZIP_FILE cmake option --- CMakeLists.txt | 3 +-- cmake/gui.cmake | 30 +++++++++++++++++++----------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f726a720..8498e480e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,7 +317,6 @@ if(NOT TARGET uninstall) COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) endif() - -if(BUILD_PACKAGE AND NOT APPLE) +if(BUILD_PACKAGE) include(cmake/installer.cmake) endif() diff --git a/cmake/gui.cmake b/cmake/gui.cmake index 32dc93116..be27a9688 100644 --- a/cmake/gui.cmake +++ b/cmake/gui.cmake @@ -1,4 +1,3 @@ - set(default_build_gui OFF) set(default_gui_target pack) if(APPLE) @@ -15,12 +14,13 @@ set(GUI_YARN_EXTRA_OPTS "" CACHE STRING "extra options to pass into the yarn bui if (BUILD_GUI) message(STATUS "Building lokinet-gui") - - find_program(YARN NAMES yarn yarnpkg REQUIRED) + if(NOT YARN) + find_program(YARN NAMES yarn yarnpkg REQUIRED) + endif() message(STATUS "Building lokinet-gui with yarn ${YARN}, target ${GUI_YARN_TARGET}") set(wine_env) if(WIN32) - set(wine_env WINEDEBUG=-all "WINEPREFIX=${PROJECT_BINARY_DIR}/wineprefix") + set(wine_env USE_SYSTEM_7ZA=true DISPLAY= WINEDEBUG=-all "WINEPREFIX=${PROJECT_BINARY_DIR}/wineprefix") endif() add_custom_target(lokinet-gui @@ -48,17 +48,25 @@ if (BUILD_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 + option(GUI_ZIP_FILE "custom lokinet gui for windows from zip file" OFF) + if(GUI_ZIP_FILE) + message(STATUS "using custom lokinet gui from ${GUI_ZIP_FILE}") + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${GUI_ZIP_FILE} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) + else() + add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe" + 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" - ) + ) + add_custom_target(assemble_gui ALL + DEPENDS ${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe) + endif() 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") + message(STATUS "not building gui") endif()