Skip to content

Commit bb57ece

Browse files
authored
Integrate Sparkle Updater (#1053)
* feat: add Sparkle framework support for app updater on macOS * feat: set up Sparkle skeletal implementation. * feat: implement updater platform/product support with factory function. * chore: add SPDX identifiers to plugin source files. * fix: set correct rpath for embedded frameworks. * feat: enhance updater functionality and improve plugin integration * feat: conditionally include TestUpdater class for enhanced updater testing * feat: update CMake configuration for Sparkle integration and enhance plist generation * actions: tidy up workflow names
1 parent e50fe21 commit bb57ece

File tree

17 files changed

+277
-18
lines changed

17 files changed

+277
-18
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Test
1+
name: Build
22

33
on:
44
push:

.github/workflows/ldoc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Generate Lua Documentation
1+
name: LDoc
22

33
on:
44
push:

.github/workflows/reuse.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# SPDX-FileCopyrightText: Kushview, LLC
22
# SPDX-License-Identifier: CC0-1.0
33
name: REUSE compliance check
4-
on: [ push, pull_request ]
4+
on:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
59

610
jobs:
711
test:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ docs/_build/
6262

6363
Cardinal
6464
.meson-subproject*.txt
65+
.cache/

CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ set(PROJECT_VERSION_SUFFIX "b2")
77
set(PROJECT_VERSION_FULL "${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX}")
88

99
include(cmake/Element.cmake)
10+
if(APPLE AND ELEMENT_ENABLE_UPDATER)
11+
include(cmake/FindSparkle.cmake)
12+
endif()
1013
include(cmake/FindJack.cmake)
1114

1215
add_subdirectory(deps/sol2 EXCLUDE_FROM_ALL)
@@ -65,6 +68,8 @@ juce_add_gui_app(element_app
6568

6669
BUNDLE_ID "net.kushview.Element"
6770
MICROPHONE_PERMISSION_ENABLED TRUE
71+
72+
PLIST_TO_MERGE "${ELEMENT_APP_PLIST_TO_MERGE}"
6873
)
6974

7075
target_sources(element_app PRIVATE src/main.cc)
@@ -73,6 +78,22 @@ target_link_libraries(element_app PRIVATE kv::element)
7378
if(NOT APPLE)
7479
install(TARGETS element_app DESTINATION ${CMAKE_INSTALL_BINDIR})
7580
else()
81+
if(ELEMENT_ENABLE_UPDATER)
82+
target_compile_options(element_app PRIVATE "-F${sparkle_SOURCE_DIR}")
83+
target_link_options(element_app PRIVATE "-F${sparkle_SOURCE_DIR}" -framework Sparkle)
84+
target_sources(element_app PRIVATE src/sparkle.mm)
85+
add_custom_command(TARGET element_app POST_BUILD
86+
COMMAND ${CMAKE_COMMAND} -E rm -rf
87+
"$<TARGET_BUNDLE_CONTENT_DIR:element_app>/Frameworks/Sparkle.framework"
88+
COMMAND /usr/bin/ditto
89+
"${SPARKLE_FRAMEWORK}"
90+
"$<TARGET_BUNDLE_CONTENT_DIR:element_app>/Frameworks/Sparkle.framework")
91+
# Set rpath to find Sparkle.framework in app bundle
92+
set_target_properties(element_app PROPERTIES
93+
BUILD_RPATH "@executable_path/../Frameworks"
94+
INSTALL_RPATH "@executable_path/../Frameworks"
95+
)
96+
endif()
7697
install(TARGETS element_app
7798
BUNDLE DESTINATION "Applications"
7899
COMPONENT "Standalone")

cmake/Element.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ option(ELEMENT_ENABLE_VST2 "Build with VST2 support" OFF)
77
option(ELEMENT_ENABLE_LTO "Build with Link Time Optimization" OFF)
88
option(ELEMENT_ENABLE_UPDATER "Build with updater support" OFF)
99

10+
set(ELEMENT_APP_PLIST_TO_MERGE "")
11+
1012
if(APPLE)
1113
enable_language(OBJC)
1214
enable_language(OBJCXX)

cmake/FindSparkle.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
set(SPARKLE_VERSION "2.8.1" CACHE STRING "Sparkle version to download")
2+
3+
set(SPARKLE_FEED_URL "http://localhost:8000/appcast.xml"
4+
CACHE STRING "The Sparkle feed url to use")
5+
set(SPARKLE_PUBLIC_KEY "+3pPKr274O3KL4lTWaEs/ukVk3Ayvnc7BkdS45zOnE4="
6+
CACHE STRING "The Sparkle eDSA public key to use")
7+
8+
FetchContent_Declare(
9+
sparkle
10+
URL https://github.com/Sparkle-project/Sparkle/releases/download/${SPARKLE_VERSION}/Sparkle-${SPARKLE_VERSION}.tar.xz
11+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
12+
)
13+
14+
FetchContent_MakeAvailable(sparkle)
15+
message(STATUS "Searching for Sparkle in: ${sparkle_SOURCE_DIR}")
16+
find_library(SPARKLE_FRAMEWORK Sparkle HINTS ${sparkle_SOURCE_DIR})
17+
18+
if(SPARKLE_FRAMEWORK)
19+
message(STATUS "Found Sparkle: ${SPARKLE_FRAMEWORK}")
20+
else()
21+
message(FATAL_ERROR "Sparkle framework not found")
22+
endif()
23+
24+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE
25+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
26+
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
27+
<plist version=\"1.0\">
28+
<dict>
29+
")
30+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE "<key>SUFeedURL</key>")
31+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE "<string>${SPARKLE_FEED_URL}</string>")
32+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE "<key>SUPublicEDKey</key>")
33+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE "<string>${SPARKLE_PUBLIC_KEY}</string>")
34+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE "</dict></plist>")
35+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE "<key>SUEnableAutomaticChecks</key>")
36+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE "<false/>")
37+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE "<key>SUScheduledCheckInterval</key>")
38+
string(APPEND ELEMENT_APP_PLIST_TO_MERGE "<integer>0</integer>")

include/element/ui/updater.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ struct UpdatePackage {
4242
/** Updater helper for checking available updates */
4343
class Updater {
4444
public:
45-
Updater();
46-
Updater (const std::string& package, const std::string& version, const std::string& url);
47-
~Updater();
45+
static std::unique_ptr<Updater> create();
46+
47+
virtual ~Updater();
4848

4949
//==========================================================================
5050
/** Triggered when updates are found. Only fired when checking async. */
@@ -54,7 +54,7 @@ class Updater {
5454
void clear();
5555

5656
/** Check for updates now or later. */
57-
void check (bool async);
57+
virtual void check (bool async);
5858

5959
/** Returns all package updates listed in the repo. */
6060
std::vector<UpdatePackage> packages() const noexcept;
@@ -86,6 +86,10 @@ class Updater {
8686
*/
8787
void setUpdatesXml (const std::string& xml);
8888

89+
protected:
90+
Updater();
91+
Updater (const std::string& package, const std::string& version, const std::string& url);
92+
8993
private:
9094
class Updates;
9195
std::unique_ptr<Updates> updates;

src/pluginprocessor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
#include <element/engine.hpp>
55
#include <element/ui.hpp>
6+
#include <element/plugins.hpp>
7+
#include <element/settings.hpp>
8+
69
#include "services/sessionservice.hpp"
710
#include "services/mappingservice.hpp"
811
#include "services/deviceservice.hpp"
912
#include "engine/internalformat.hpp"
10-
#include <element/plugins.hpp>
11-
#include "ElementApp.h"
12-
#include <element/settings.hpp>
1313

1414
#include "pluginprocessor.hpp"
1515
#include "plugineditor.hpp"

src/plugins/effect.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
88
return new element::PluginProcessor (
99
element::PluginProcessor::Effect, 16);
1010
}
11+
12+
#if ELEMENT_UPDATER
13+
#include "./pluginupdater.cc"
14+
#endif

0 commit comments

Comments
 (0)