summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt18
-rw-r--r--Depends.cmake21
-rw-r--r--res/MacOSXBundleInfo.plist.in4
-rw-r--r--src/macos.m22
-rw-r--r--src/updater.c76
5 files changed, 93 insertions, 48 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b0d8f70c..21cf1c7d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,9 +52,10 @@ option (ENABLE_MPG123 "Use mpg123 for decoding MPEG audio" ON)
52option (ENABLE_POPUP_MENUS "Use popup windows for context menus (if OFF, menus are confined inside main window)" ON) 52option (ENABLE_POPUP_MENUS "Use popup windows for context menus (if OFF, menus are confined inside main window)" ON)
53option (ENABLE_RELATIVE_EMBED "Resources should always be found via relative path" OFF) 53option (ENABLE_RELATIVE_EMBED "Resources should always be found via relative path" OFF)
54option (ENABLE_RESIZE_DRAW "Force window to redraw during resizing" ${DEFAULT_RESIZE_DRAW}) 54option (ENABLE_RESIZE_DRAW "Force window to redraw during resizing" ${DEFAULT_RESIZE_DRAW})
55option (ENABLE_SPARKLE "Use Sparkle for automatic updates (macOS)" OFF)
55option (ENABLE_WEBP "Use libwebp to decode .webp images (via pkg-config)" ON) 56option (ENABLE_WEBP "Use libwebp to decode .webp images (via pkg-config)" ON)
56option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF) 57option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF)
57option (ENABLE_WINSPARKLE "Use WinSparkle for automatic updates" OFF) 58option (ENABLE_WINSPARKLE "Use WinSparkle for automatic updates (Windows)" OFF)
58option (ENABLE_X11_SWRENDER "Use software rendering (X11)" OFF) 59option (ENABLE_X11_SWRENDER "Use software rendering (X11)" OFF)
59 60
60include (BuildType.cmake) 61include (BuildType.cmake)
@@ -98,9 +99,8 @@ list (APPEND RESOURCES ${FONTS})
98if ((UNIX AND NOT APPLE) OR MSYS) 99if ((UNIX AND NOT APPLE) OR MSYS)
99 list (APPEND RESOURCES res/lagrange-64.png) 100 list (APPEND RESOURCES res/lagrange-64.png)
100endif () 101endif ()
101make_resources (${CMAKE_CURRENT_BINARY_DIR}/resources.lgr ${RESOURCES})
102
103set (EMB_BIN ${CMAKE_CURRENT_BINARY_DIR}/resources.lgr) 102set (EMB_BIN ${CMAKE_CURRENT_BINARY_DIR}/resources.lgr)
103make_resources (${EMB_BIN} ${RESOURCES})
104set_source_files_properties (${EMB_BIN} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) 104set_source_files_properties (${EMB_BIN} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
105 105
106# Source files. 106# Source files.
@@ -150,7 +150,6 @@ set (SOURCES
150 src/stb_image.h 150 src/stb_image.h
151 src/stb_image_resize.h 151 src/stb_image_resize.h
152 src/stb_truetype.h 152 src/stb_truetype.h
153 src/updater.c
154 src/updater.h 153 src/updater.h
155 src/visited.c 154 src/visited.c
156 src/visited.h 155 src/visited.h
@@ -222,8 +221,11 @@ set (SOURCES
222 res/about/lagrange.gmi 221 res/about/lagrange.gmi
223 res/about/license.gmi 222 res/about/license.gmi
224 res/about/version.gmi 223 res/about/version.gmi
225 ${CMAKE_CURRENT_BINARY_DIR}/resources.lgr 224 ${EMB_BIN}
226) 225)
226if (NOT APPLE) # macos.m has Sparkle updater
227 list (APPEND SOURCES src/updater.c)
228endif ()
227if (ENABLE_IPC) 229if (ENABLE_IPC)
228 list (APPEND SOURCES 230 list (APPEND SOURCES
229 src/ipc.c 231 src/ipc.c
@@ -363,6 +365,9 @@ if (APPLE)
363 else () 365 else ()
364 target_link_libraries (app PUBLIC "-framework AppKit") 366 target_link_libraries (app PUBLIC "-framework AppKit")
365 endif () 367 endif ()
368 if (ENABLE_SPARKLE)
369 target_link_libraries (app PUBLIC sparkle)
370 endif ()
366 if (CMAKE_OSX_DEPLOYMENT_TARGET AND NOT IOS) 371 if (CMAKE_OSX_DEPLOYMENT_TARGET AND NOT IOS)
367 target_compile_options (app PUBLIC -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}) 372 target_compile_options (app PUBLIC -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
368 target_link_options (app PUBLIC -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}) 373 target_link_options (app PUBLIC -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
@@ -407,8 +412,7 @@ endif ()
407if (MSYS) 412if (MSYS)
408 target_link_libraries (app PUBLIC d2d1 uuid dwmapi) # querying DPI 413 target_link_libraries (app PUBLIC d2d1 uuid dwmapi) # querying DPI
409 if (ENABLE_WINSPARKLE) 414 if (ENABLE_WINSPARKLE)
410 target_link_libraries (app PUBLIC winsparkle) 415 target_link_libraries (app PUBLIC winsparkle)
411 target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_WINSPARKLE=1)
412 endif () 416 endif ()
413endif () 417endif ()
414if (UNIX) 418if (UNIX)
diff --git a/Depends.cmake b/Depends.cmake
index 3faeca75..c6e4495f 100644
--- a/Depends.cmake
+++ b/Depends.cmake
@@ -146,15 +146,30 @@ else ()
146 endif () 146 endif ()
147endif () 147endif ()
148 148
149if (ENABLE_SPARKLE)
150 # macOS only.
151 add_library (sparkle INTERFACE)
152 set (SPARKLE_FRAMEWORK ${SPARKLE_DIR}/Sparkle.framework)
153 target_link_libraries (sparkle INTERFACE ${SPARKLE_FRAMEWORK})
154 target_compile_definitions (sparkle INTERFACE LAGRANGE_ENABLE_SPARKLE=1)
155 message (STATUS "Using Sparkle: ${SPARKLE_FRAMEWORK}")
156 if (NOT SPARKLE_ARCH)
157 message (FATAL_ERROR "Set SPARKLE_ARCH to a CPU architecture ID (e.g., arm64)")
158 endif ()
159endif ()
160
149if (ENABLE_WINSPARKLE) 161if (ENABLE_WINSPARKLE)
150 # We're assuming this is Windows. 162 # Windows only.
151 add_library (winsparkle INTERFACE) 163 add_library (winsparkle INTERFACE)
152 target_include_directories (winsparkle INTERFACE ${WINSPARKLE_DIR}/include) 164 target_include_directories (winsparkle INTERFACE ${WINSPARKLE_DIR}/include)
153 target_link_libraries (winsparkle INTERFACE ${WINSPARKLE_DIR}/x64/Release/WinSparkle.dll) 165 set (WINSPARKLE_DLL ${WINSPARKLE_DIR}/x64/Release/WinSparkle.dll)
166 target_link_libraries (winsparkle INTERFACE ${WINSPARKLE_DLL})
167 target_compile_definitions (winsparkle INTERFACE LAGRANGE_ENABLE_WINSPARKLE=1)
154 install ( 168 install (
155 PROGRAMS ${WINSPARKLE_DIR}/x64/Release/WinSparkle.dll 169 PROGRAMS ${WINSPARKLE_DLL}
156 DESTINATION . 170 DESTINATION .
157 ) 171 )
172 message (STATUS "Using WinSparkle: ${WINSPARKLE_DLL}")
158endif () 173endif ()
159 174
160find_package (PkgConfig REQUIRED) 175find_package (PkgConfig REQUIRED)
diff --git a/res/MacOSXBundleInfo.plist.in b/res/MacOSXBundleInfo.plist.in
index a17831ad..08907283 100644
--- a/res/MacOSXBundleInfo.plist.in
+++ b/res/MacOSXBundleInfo.plist.in
@@ -104,5 +104,9 @@
104 </array> 104 </array>
105 </dict> 105 </dict>
106 </array> 106 </array>
107 <key>SUFeedURL</key>
108 <string>https://etc.skyjake.fi/lagrange/appcast-${SPARKLE_ARCH}.xml</string>
109 <key>SUPublicEDKey</key>
110 <string>NK3VR3l8lypjm05VS4+Ry8A95rhmRzX+ftgQpzqYAy4=</string>
107</dict> 111</dict>
108</plist> 112</plist>
diff --git a/src/macos.m b/src/macos.m
index 35594b7b..cfbca488 100644
--- a/src/macos.m
+++ b/src/macos.m
@@ -709,3 +709,25 @@ iColor systemAccent_Color(void) {
709#endif 709#endif
710 return (iColor){ 255, 255, 255, 255 }; 710 return (iColor){ 255, 255, 255, 255 };
711} 711}
712
713#if defined (LAGRANGE_ENABLE_SPARKLE)
714#import <Sparkle/Sparkle.h>
715
716void init_Updater(void) {
717 SUUpdater *updater = [SUUpdater sharedUpdater];
718 /* Add it to the menu. */
719 NSMenu *appMenu = [[[NSApp mainMenu] itemAtIndex:0] submenu];
720 NSMenuItem *item = [appMenu insertItemWithTitle:@"Check for Updates…"
721 action:@selector(checkForUpdates:)
722 keyEquivalent:@""
723 atIndex:3];
724 item.target = updater;
725}
726
727#else
728/* dummy as a fallback */
729void init_Updater(void) {}
730#endif
731
732void deinit_Updater(void) {}
733void checkNow_Updater(void) {}
diff --git a/src/updater.c b/src/updater.c
index 6c5d6eae..706de31d 100644
--- a/src/updater.c
+++ b/src/updater.c
@@ -22,48 +22,48 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
22 22
23#include "updater.h" 23#include "updater.h"
24 24
25static const char *signaturePublicKeyPem_ =
26"-----BEGIN PUBLIC KEY-----\n"
27"MIIGRjCCBDkGByqGSM44BAEwggQsAoICAQC0jSisyaT6q6qqjmlWFfFDOs66EfC7\n"
28"78ATFlhl63otIed7oeyg2Q0BFB2bdGMpJbivu/jFjaZglz7YpKLhLHiUb3Fn10lz\n"
29"V3WwaXXmbdwSuYH1zceIptho6crWgkZcSwGer+/I3twDxIe0XhGEG7quh7ukJsh/\n"
30"hh9LgeIgNsVDdKRyJEs24ZQD44rQwb3hY19JCEzdd/S4FZwLbNeXwrPBPdzUO7JT\n"
31"KmhMJJbQbhb1iNyqClCl5VQM0w5cI3L+k3fcBcUgsEh2kJHsH8ezATDH8Ltmvkmz\n"
32"L8bhVLLHlGl0jvHfKHjINz9p/Ur+ifcFmwCWTmd61ZhEKcBpK0jEkE5ZwXzIZ3pJ\n"
33"AAen0Nr0Y6x7rK5AU630wkQbD7M6W5QOys+9FPuIGW/q0nk80TKFR4ElVc0CVF0t\n"
34"nOGa6lu6uaIkgKN+ePXUwSUFvYNOC/3ILURq9JnAPPGXwgIsOUTPtzPcBOfH24sy\n"
35"HhImEaAZPdsx2eTiJv2zFwF0k5H/kPHQgyr+5dPaYSt+9yeObF4zQ7S/raqCRE/d\n"
36"eT29MkwkGugXnljbSi0cjn1MCw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WGiZwq+Rr3v\n"
52"Q5vI8T8lsnYuplCPGnoWJzq1niCPobVydog1lmZ396ARErGrPZxzM7ab8EY2BNSj\n"
53"pcA1wYwuGGJIvCRLDxqaUlTbIdTP/QzIKQAHoFCtJetOmS5ovCyz9Zr+4fC/SFtq\n"
54"G1BjTodIhQFrreGMwl3VtIOnrCUI430BxEPMsDWgZzgx5JgMwmgIVFul47MoulVE\n"
55"gcz6sNKVuRXYhRTq8V6hZOamOT1VqZQb+dqQqDZ5p265VOgz71z1CgTF9FnRV04z\n"
56"qhlWHHnxMEaQYZWlvw8zlXRNBqjHQyOHhOE9nsrNpTsFqnImBpO0s9UJxTRWNnf/\n"
57"hLrzuOBQoDlOcE4yBR1mRymJQ9xHFzEI4yxP9Vg7RTEkMhhk1vlqPWvuIyv4gCCm\n"
58"7btKMnYNL99cMAjhgyDyh7mAOfOWv5rAgzDIMViRO+U7EZ+ZRR+ovnuWMMn1OZAA\n"
59"aXDKDVffI0NSO+Aw3EDAL4LfZsOBkDS2N/2ESR+EoBtYqoI7YJ3iu1iEHp8WxCyA\n"
60"4YdR7KTyioKNHjvC5EG2bvHtYfw6ng6zSOY=\n"
61"-----END PUBLIC KEY-----";
62
63#if defined (LAGRANGE_ENABLE_WINSPARKLE) 25#if defined (LAGRANGE_ENABLE_WINSPARKLE)
64#include <time.h> 26#include <time.h>
65#include <winsparkle.h> 27#include <winsparkle.h>
66 28
29static const char *signaturePublicKeyPem_ =
30 "-----BEGIN PUBLIC KEY-----\n"
31 "MIIGRjCCBDkGByqGSM44BAEwggQsAoICAQC0jSisyaT6q6qqjmlWFfFDOs66EfC7\n"
32 "78ATFlhl63otIed7oeyg2Q0BFB2bdGMpJbivu/jFjaZglz7YpKLhLHiUb3Fn10lz\n"
33 "V3WwaXXmbdwSuYH1zceIptho6crWgkZcSwGer+/I3twDxIe0XhGEG7quh7ukJsh/\n"
34 "hh9LgeIgNsVDdKRyJEs24ZQD44rQwb3hY19JCEzdd/S4FZwLbNeXwrP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C KEY-----";
66
67void init_Updater(void) { 67void init_Updater(void) {
68 win_sparkle_set_appcast_url("https://etc.skyjake.fi/lagrange/appcast-windows.xml"); 68 win_sparkle_set_appcast_url("https://etc.skyjake.fi/lagrange/appcast-windows.xml");
69 win_sparkle_set_dsa_pub_pem(signaturePublicKeyPem_); 69 win_sparkle_set_dsa_pub_pem(signaturePublicKeyPem_);