프로젝트 소스 공개
This commit is contained in:
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/zsh
|
||||
set -euo pipefail
|
||||
|
||||
script_dir=${0:A:h}
|
||||
project_root=${script_dir:h:h}
|
||||
sparkle_root="$project_root/ThirdParty/Sparkle/2.9.4"
|
||||
source_file="$script_dir/project_quint_updater.mm"
|
||||
bundle_root="$project_root/Assets/ProjectQuint/Plugins/macOS/ProjectQuintUpdater.bundle"
|
||||
output_file="$bundle_root/Contents/MacOS/ProjectQuintUpdater"
|
||||
|
||||
mkdir -p "${output_file:h}"
|
||||
/usr/bin/xcrun --sdk macosx clang++ \
|
||||
-std=c++17 \
|
||||
-O2 \
|
||||
-DNDEBUG \
|
||||
-fobjc-arc \
|
||||
-fvisibility=hidden \
|
||||
-mmacosx-version-min=12.0 \
|
||||
-arch arm64 \
|
||||
-arch x86_64 \
|
||||
-dynamiclib \
|
||||
-install_name '@rpath/ProjectQuintUpdater' \
|
||||
-Wl,-rpath,'@loader_path/../../../../Frameworks' \
|
||||
-F "$sparkle_root" \
|
||||
-framework AppKit \
|
||||
-framework Foundation \
|
||||
-framework Sparkle \
|
||||
"$source_file" \
|
||||
-o "$output_file"
|
||||
|
||||
/usr/bin/lipo "$output_file" -verify_arch arm64 x86_64
|
||||
/usr/bin/otool -L "$output_file" | /usr/bin/grep -Fq "@rpath/Sparkle.framework/Versions/B/Sparkle"
|
||||
/usr/bin/otool -l "$output_file" | /usr/bin/grep -Fq "@loader_path/../../../../Frameworks"
|
||||
/usr/bin/codesign --force --sign - "$bundle_root"
|
||||
/usr/bin/codesign --verify --strict "$bundle_root"
|
||||
echo "Built Universal ProjectQuintUpdater: $output_file"
|
||||
@@ -0,0 +1,110 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Sparkle/Sparkle.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define PQ_EXPORT extern "C" __attribute__((visibility("default")))
|
||||
#else
|
||||
#define PQ_EXPORT extern "C"
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
SPUStandardUpdaterController *s_updaterController = nil;
|
||||
std::string s_lastError;
|
||||
|
||||
void SetError(NSString *message)
|
||||
{
|
||||
s_lastError = message == nil ? std::string() : std::string(message.UTF8String);
|
||||
}
|
||||
|
||||
bool RequireMainThread()
|
||||
{
|
||||
if ([NSThread isMainThread])
|
||||
return true;
|
||||
SetError(@"Sparkle updater calls must run on the macOS main thread.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PQ_EXPORT bool PQUpdaterInitialize()
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
if (!RequireMainThread())
|
||||
return false;
|
||||
if (s_updaterController != nil)
|
||||
return true;
|
||||
|
||||
@try
|
||||
{
|
||||
s_updaterController = [[SPUStandardUpdaterController alloc]
|
||||
initWithStartingUpdater:YES
|
||||
updaterDelegate:nil
|
||||
userDriverDelegate:nil];
|
||||
if (s_updaterController == nil)
|
||||
{
|
||||
SetError(@"Sparkle updater controller could not be created.");
|
||||
return false;
|
||||
}
|
||||
s_lastError.clear();
|
||||
return true;
|
||||
}
|
||||
@catch (NSException *exception)
|
||||
{
|
||||
SetError(exception.reason ?: exception.name);
|
||||
s_updaterController = nil;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PQ_EXPORT bool PQUpdaterCanCheckForUpdates()
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
if (!RequireMainThread() || s_updaterController == nil)
|
||||
return false;
|
||||
return s_updaterController.updater.canCheckForUpdates;
|
||||
}
|
||||
}
|
||||
|
||||
PQ_EXPORT bool PQUpdaterCheckForUpdates()
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
if (!RequireMainThread())
|
||||
return false;
|
||||
if (s_updaterController == nil)
|
||||
{
|
||||
SetError(@"Sparkle updater has not been initialized.");
|
||||
return false;
|
||||
}
|
||||
if (!s_updaterController.updater.canCheckForUpdates)
|
||||
{
|
||||
SetError(@"Sparkle is already checking for an update.");
|
||||
return false;
|
||||
}
|
||||
|
||||
[s_updaterController checkForUpdates:nil];
|
||||
s_lastError.clear();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
PQ_EXPORT void PQUpdaterShutdown()
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
if (!RequireMainThread())
|
||||
return;
|
||||
s_updaterController = nil;
|
||||
s_lastError.clear();
|
||||
}
|
||||
}
|
||||
|
||||
PQ_EXPORT const char *PQUpdaterGetLastError()
|
||||
{
|
||||
return s_lastError.c_str();
|
||||
}
|
||||
Reference in New Issue
Block a user