From c8aa53a4567a512db1c659fa255b3558e6ea1b05 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 26 Oct 2022 13:22:33 -0300 Subject: [PATCH 1/4] Use rsvg instead of imagemagick to make windows .ico imagemagick is messing up the conversion, so just avoid it entirely and use rsvg-convert directly to do it instead. --- .drone.jsonnet | 2 +- contrib/make-ico.sh | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index d41e7797b..74a4fbcd6 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -147,7 +147,7 @@ local windows_cross_pipeline(name, 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections', apt_get_quiet + ' update', apt_get_quiet + ' install -y eatmydata', - 'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y p7zip-full build-essential cmake git pkg-config ccache g++-mingw-w64-x86-64-posix nsis zip icoutils automake libtool', + 'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y p7zip-full build-essential cmake git pkg-config ccache g++-mingw-w64-x86-64-posix nsis zip icoutils automake libtool librsvg2-bin', 'update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix', 'update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix', 'JOBS=' + jobs + ' VERBOSE=1 ./contrib/windows.sh -DSTRIP_SYMBOLS=ON ' + diff --git a/contrib/make-ico.sh b/contrib/make-ico.sh index 9a0413a67..cdc74183d 100755 --- a/contrib/make-ico.sh +++ b/contrib/make-ico.sh @@ -14,13 +14,16 @@ mkdir -p "${outdir}" for size in "${sizes[@]}"; do outf="${outdir}/${size}x${size}.png" if [ $size -lt 32 ]; then - # For 16x16 and 24x24 we crop the image to 3/4 of its regular size before resizing and make - # it all white (instead of transparent) which effectively zooms in on it a bit because if we - # resize the full icon it ends up a fuzzy mess, while the crop and resize lets us retain - # some detail of the logo. - convert -background white -resize 512x512 "$svg" -gravity Center -extent 320x320 -resize ${size}x${size} -strip "png32:$outf" + # For 16x16 and 24x24 we crop the image to 2/3 of its regular size make it all white + # (instead of transparent) to zoom in on it a bit because if we resize the full icon to the + # target size it ends up a fuzzy mess, while the crop and resize lets us retain some detail + # of the logo. + rsvg-convert -b white \ + --page-height $size --page-width $size \ + -w $(($size*3/2)) -h $(($size*3/2)) --left " -$(($size/4))" --top " -$(($size/4))" \ + "$svg" >"$outf" else - convert -background transparent -resize ${size}x${size} "$svg" -strip "png32:$outf" + rsvg-convert -b transparent -w $size -h $size "$svg" >"$outf" fi outs="-r $outf $outs" done From 11e052cb39a1eb2af22249ad652f1bcd012f2e22 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 26 Oct 2022 13:44:53 -0300 Subject: [PATCH 2/4] Add rsvg-convert dep to windows readme --- docs/install.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/install.md b/docs/install.md index 2061ea990..b13284684 100644 --- a/docs/install.md +++ b/docs/install.md @@ -127,6 +127,7 @@ additional build requirements: * nsis * cpack +* rsvg-convert (`librsvg2-bin` package on Debian/Ubuntu) setup: From caf97b1861fb7b7839a419baf74bbd0c4b29a737 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 26 Oct 2022 14:13:40 -0300 Subject: [PATCH 3/4] Split windows into gui/main builds, main now builds on bookworm The options we need in rsvg-convert are apparently too new for bullseye, so split the build so that we do the gui separately (in the nodejs-lts container) and then build lokinet in bookworm. --- .drone.jsonnet | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 74a4fbcd6..10405784e 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -119,13 +119,13 @@ local apk_builder(name, image, extra_cmds=[], allow_fail=false, jobs=6) = { // windows cross compile on debian local windows_cross_pipeline(name, image, + gui_image=docker_base + 'nodejs-lts', arch='amd64', build_type='Release', lto=false, werror=false, cmake_extra='', local_mirror=true, - gui_zip_url='', extra_cmds=[], jobs=6, allow_fail=false) = { @@ -136,6 +136,22 @@ local windows_cross_pipeline(name, trigger: { branch: { exclude: ['debian/*', 'ubuntu/*'] } }, steps: [ submodules, + { + name: 'GUI', + image: gui_image, + pull: 'always', + [if allow_fail then 'failure']: 'ignore', + commands: [ + 'echo "Building on ${DRONE_STAGE_MACHINE}"', + 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections', + apt_get_quiet + ' update', + apt_get_quiet + ' install -y eatmydata', + 'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y p7zip-full wine', + 'cd gui', + 'yarn install --frozen-lockfile', + 'USE_SYSTEM_7ZA=true DISPLAY= WINEDEBUG=-all yarn win32', + ], + }, { name: 'build', image: image, @@ -147,11 +163,10 @@ local windows_cross_pipeline(name, 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections', apt_get_quiet + ' update', apt_get_quiet + ' install -y eatmydata', - 'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y p7zip-full build-essential cmake git pkg-config ccache g++-mingw-w64-x86-64-posix nsis zip icoutils automake libtool librsvg2-bin', + 'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y build-essential cmake git pkg-config ccache g++-mingw-w64-x86-64-posix nsis zip icoutils automake libtool librsvg2-bin', 'update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix', 'update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix', - 'JOBS=' + jobs + ' VERBOSE=1 ./contrib/windows.sh -DSTRIP_SYMBOLS=ON ' + - (if std.length(gui_zip_url) > 0 then '-DBUILD_GUI=OFF -DGUI_ZIP_URL=' + gui_zip_url else '') + + 'JOBS=' + jobs + ' VERBOSE=1 ./contrib/windows.sh -DSTRIP_SYMBOLS=ON -DGUI_EXE=$${DRONE_WORKSPACE}/gui/release/Lokinet-GUI_portable.exe' + ci_dep_mirror(local_mirror), ] + extra_cmds, }, @@ -378,7 +393,7 @@ local docs_pipeline(name, image, extra_cmds=[], allow_fail=false) = { // Windows builds (x64) windows_cross_pipeline('Windows (amd64)', - docker_base + 'nodejs-lts', + docker_base + 'debian-bookworm', extra_cmds=[ './contrib/ci/drone-static-upload.sh', ]), From 491f452dd7c043d1a252cdbc39b88b99ca8428ca Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 26 Oct 2022 15:06:06 -0300 Subject: [PATCH 4/4] Windows prebuilt gui fixes Currently you can't use GUI_EXE without BUILD_GUI, but BUILD_GUI also requires the yarn command (even though it will never use it when GUI_EXE is set). This commit fixes it: - Make `GUI_EXE` a windows-only top-level project options, rather than being guarded by `BUILD_GUI`. - Make `BUILD_GUI` control *building* the GUI instead of bundling it. - GUI_EXE and BUILD_GUI are now mutually exclusive. --- cmake/gui-option.cmake | 11 +++++++ cmake/gui.cmake | 52 +++++++++++++------------------- cmake/win32_installer_deps.cmake | 19 ------------ 3 files changed, 32 insertions(+), 50 deletions(-) diff --git a/cmake/gui-option.cmake b/cmake/gui-option.cmake index 323f201fa..1ec141ea2 100644 --- a/cmake/gui-option.cmake +++ b/cmake/gui-option.cmake @@ -3,4 +3,15 @@ if(APPLE OR WIN32) set(default_build_gui ON) endif() +if(WIN32) + set(GUI_EXE "" CACHE FILEPATH "path to a pre-built Windows GUI .exe to use (implies -DBUILD_GUI=OFF)") + if(GUI_EXE) + set(default_build_gui OFF) + endif() +endif() + option(BUILD_GUI "build electron gui from 'gui' submodule source" ${default_build_gui}) + +if(BUILD_GUI AND GUI_EXE) + message(FATAL_ERROR "-DGUI_EXE=... and -DBUILD_GUI=ON are mutually exclusive") +endif() diff --git a/cmake/gui.cmake b/cmake/gui.cmake index 7bf8cc27b..6b74ab9ed 100644 --- a/cmake/gui.cmake +++ b/cmake/gui.cmake @@ -1,24 +1,26 @@ -set(default_gui_target pack) -if(APPLE) - set(default_gui_target macos:raw) -elseif(WIN32) - set(default_gui_target win32) - set(GUI_EXE "" CACHE FILEPATH "path to an externally built lokinet gui.exe") -endif() +if(WIN32 AND GUI_EXE) + message(STATUS "using pre-built lokinet gui executable: ${GUI_EXE}") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${GUI_EXE}" "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe") +elseif(BUILD_GUI) + message(STATUS "Building lokinet-gui from source") + + set(default_gui_target pack) + if(APPLE) + set(default_gui_target macos:raw) + elseif(WIN32) + set(default_gui_target win32) + endif() -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") + 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") # allow manually specifying yarn with -DYARN= if(NOT YARN) find_program(YARN NAMES yarnpkg yarn REQUIRED) endif() message(STATUS "Building lokinet-gui with yarn ${YARN}, target ${GUI_YARN_TARGET}") - if(NOT WIN32) add_custom_target(lokinet-gui COMMAND ${YARN} install --frozen-lockfile && @@ -45,25 +47,13 @@ if (BUILD_GUI) ) elseif(WIN32) file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/gui") - 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}) - add_custom_target("${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe" COMMAND "true") - elseif(GUI_EXE) - message(STATUS "using custom lokinet gui executable: ${GUI_EXE}") - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${GUI_EXE}" "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe") - add_custom_target("${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe" COMMAND "true") - else() - add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe" - COMMAND ${YARN} install --frozen-lockfile && - USE_SYSTEM_7ZA=true DISPLAY= WINEDEBUG=-all WINEPREFIX="${PROJECT_BINARY_DIR}/wineprefix" ${YARN} ${GUI_YARN_EXTRA_OPTS} ${GUI_YARN_TARGET} - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${PROJECT_SOURCE_DIR}/gui/release/Lokinet-GUI_portable.exe" - "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe" - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/gui") - endif() + add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe" + COMMAND ${YARN} install --frozen-lockfile && + USE_SYSTEM_7ZA=true DISPLAY= WINEDEBUG=-all WINEPREFIX="${PROJECT_BINARY_DIR}/wineprefix" ${YARN} ${GUI_YARN_EXTRA_OPTS} ${GUI_YARN_TARGET} + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${PROJECT_SOURCE_DIR}/gui/release/Lokinet-GUI_portable.exe" + "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe" + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/gui") add_custom_target(assemble_gui ALL COMMAND "true" DEPENDS "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe") else() message(FATAL_ERROR "Building/bundling the GUI from this repository is not supported on this platform") diff --git a/cmake/win32_installer_deps.cmake b/cmake/win32_installer_deps.cmake index e0591466e..8099e9a00 100644 --- a/cmake/win32_installer_deps.cmake +++ b/cmake/win32_installer_deps.cmake @@ -1,22 +1,3 @@ -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}) - - # 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) if(WITH_WINDOWS_32)