Skip to content

Commit 7e6d730

Browse files
committed
fix(runtime,cli): fix build for macos
1 parent fd50876 commit 7e6d730

File tree

24 files changed

+156
-131
lines changed

24 files changed

+156
-131
lines changed

bin/build-runtime-library.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ if [[ "$platform" = "android" ]]; then
157157
sources+=($(find "$root/src/platform/android"/*.cc))
158158
sources+=("$root/src/window/android.cc")
159159
elif [[ "$host" = "Darwin" ]]; then
160-
sources+=("$root/src/runtime/app/delegate.mm")
160+
sources+=("$root/src/runtime/app/apple.mm")
161161
sources+=("$root/src/runtime/window/apple.mm")
162162

163163
if (( TARGET_OS_IPHONE)); then

src/cli/main.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static Process::PID appPid = 0;
314314
static SharedPointer<Process> appProcess = nullptr;
315315
static std::atomic<int> appStatus = -1;
316316
static std::mutex appMutex;
317-
static uv_loop_t *loop = nullptr;
317+
static uv_loop_t *eventLoop = nullptr;
318318

319319
static uv_udp_t logsocket;
320320
static int lastLogSequence = 0;
@@ -326,10 +326,10 @@ unsigned short createLogSocket() {
326326
std::future<int> future = p.get_future();
327327
int port = 0;
328328

329-
auto t = std::thread([](std::promise<int>&& p) {
330-
loop = uv_default_loop();
329+
auto t = Thread([](std::promise<int>&& p) {
330+
eventLoop = uv_default_loop();
331331

332-
uv_udp_init(loop, &logsocket);
332+
uv_udp_init(eventLoop, &logsocket);
333333
struct sockaddr_in addr;
334334
int port;
335335

@@ -405,7 +405,7 @@ unsigned short createLogSocket() {
405405
p.set_value(port);
406406
}
407407

408-
uv_run(loop, UV_RUN_DEFAULT);
408+
uv_run(eventLoop, UV_RUN_DEFAULT);
409409
}, std::move(p));
410410

411411
port = future.get();

src/desktop/main.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,9 +904,10 @@ MAIN {
904904
}
905905

906906
#if SOCKET_RUNTIME_PLATFORM_APPLE
907-
if (app.wasLaunchedFromCli) {
907+
// launched from CLI
908+
if (app.launchSource == App::LaunchSource::Tool) {
908909
debug("__EXIT_SIGNAL__=%d", 0);
909-
CLI::notify();
910+
ssc::cli::notify();
910911
}
911912
#endif
912913

src/extension/extension.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ void sapi_log (const sapi_context_t* ctx, const char* message) {
586586
#endif
587587

588588
#if SOCKET_RUNTIME_PLATFORM_APPLE
589-
static auto userConfig = ssc::runtime::getUserConfig();
589+
static auto userConfig = ssc::runtime::config::getUserConfig();
590590
static auto bundleIdentifier = userConfig["meta_bundle_identifier"];
591591
static auto SOCKET_RUNTIME_OS_LOG_INFO = os_log_create(
592592
bundleIdentifier.c_str(),

src/extension/ipc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ const char* sapi_ipc_message_get_seq (const sapi_ipc_message_t* message) {
462462

463463
const char* sapi_ipc_message_get_uri (const sapi_ipc_message_t* message) {
464464
if (message->uri.size() == 0) return nullptr;
465-
return message->uri.c_str();
465+
return message->href.c_str();
466466
}
467467

468468
const char* sapi_ipc_message_get (

src/runtime/app/apple.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include "../app.hh"
22

3+
using namespace ssc::runtime;
4+
using ssc::runtime::config::getUserConfig;
5+
using ssc::runtime::string::parseStringList;
6+
using ssc::runtime::string::split;
7+
38
static dispatch_queue_attr_t qos = dispatch_queue_attr_make_with_qos_class(
49
DISPATCH_QUEUE_CONCURRENT,
510
QOS_CLASS_USER_INITIATED,

src/runtime/bluetooth/bluetooth.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using ssc::runtime::crypto::rand64;
1212

1313
#if SOCKET_RUNTIME_PLATFORM_APPLE
1414
@interface SSCBluetoothController ()
15-
@property (nonatomic) Bluetooth* bluetooth;
15+
@property (nonatomic) ssc::runtime::bluetooth::Bluetooth* bluetooth;
1616
@end
1717

1818
@implementation SSCBluetoothController
@@ -379,7 +379,7 @@ using ssc::runtime::crypto::rand64;
379379
queuedResponse.headers = headers;
380380

381381
if (bytes != nullptr && length > 0) {
382-
queuedResponse.body = std::make_shared<char[]>(length);
382+
queuedResponse.body = std::make_shared<unsigned char[]>(length);
383383
queuedResponse.length = length;
384384
memcpy(queuedResponse.body.get(), bytes, length);
385385
}

src/runtime/core/services/geolocation.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace ssc::runtime::core::services {
4747
@property (atomic, retain) NSMutableArray* activationCompletions;
4848
@property (atomic, retain) NSMutableArray* locationRequestCompletions;
4949
@property (atomic, retain) NSMutableArray* locationWatchers;
50-
W@property (nonatomic) ssc::runtime::core::services::Geolocation* geolocation;
50+
@property (nonatomic) ssc::runtime::core::services::Geolocation* geolocation;
5151
@property (atomic, assign) BOOL isAuthorized;
5252
- (BOOL) attemptActivation;
5353
- (BOOL) attemptActivationWithCompletion: (void (^)(BOOL)) completion;

src/runtime/core/services/notifications.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ namespace ssc::runtime::core::services {
256256
const auto path = filesystem::Resource::getResourcePath(url.pathname);
257257
iconURL = [NSURL fileURLWithPath: @(path.string().c_str())];
258258
} else {
259-
iconURL = [NSURL fileURLWithPath: @(url.href.c_str())];
259+
iconURL = [NSURL fileURLWithPath: @(url.href().c_str())];
260260
}
261261

262262
const auto types = [UTType
@@ -341,7 +341,7 @@ namespace ssc::runtime::core::services {
341341
const auto path = filesystem::Resource::getResourcePath(url.pathname);
342342
imageURL = [NSURL fileURLWithPath: @(path.string().c_str())];
343343
} else {
344-
imageURL = [NSURL fileURLWithPath: @(url.href.c_str())];
344+
imageURL = [NSURL fileURLWithPath: @(url.href().c_str())];
345345
}
346346

347347
const auto types = [UTType

src/runtime/core/services/permissions.cc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#include "../services.hh"
77
#include "permissions.hh"
88

9-
using ssc::runtime::config::getUserConfig;
10-
using ssc::runtime::string::replace;
11-
129
namespace ssc::runtime::core::services {
1310
bool Permissions::hasRuntimePermission (const String& permission) const {
1411
return this->context.getRuntime()->hasPermission(permission);
@@ -263,16 +260,16 @@ namespace ssc::runtime::core::services {
263260
}
264261

265262
if (name == "geolocation") {
266-
JSON::Object json;
263+
__block JSON::Object json;
267264

268265
#if SOCKET_RUNTIME_PLATFORM_APPLE
269-
const auto performedActivation = [this->core->geolocation.locationObserver attemptActivationWithCompletion: ^(BOOL isAuthorized) {
266+
const auto performedActivation = [this->services.geolocation.locationObserver attemptActivationWithCompletion: ^(BOOL isAuthorized) {
270267
if (!isAuthorized) {
271268
auto reason = @("Location observer could not be activated");
272269

273-
if (!this->core->geolocation.locationObserver.locationManager) {
270+
if (!this->services.geolocation.locationObserver.locationManager) {
274271
reason = @("Location observer manager is not initialized");
275-
} else if (!this->core->geolocation.locationObserver.locationManager.location) {
272+
} else if (!this->services.geolocation.locationObserver.locationManager.location) {
276273
reason = @("Location observer manager could not provide location");
277274
}
278275

@@ -281,7 +278,7 @@ namespace ssc::runtime::core::services {
281278

282279
if (isAuthorized) {
283280
json["data"] = JSON::Object::Entries {{"state", "granted"}};
284-
} else if (this->core->geolocation.locationObserver.locationManager.authorizationStatus == kCLAuthorizationStatusNotDetermined) {
281+
} else if (this->services.geolocation.locationObserver.locationManager.authorizationStatus == kCLAuthorizationStatusNotDetermined) {
285282
json["data"] = JSON::Object::Entries {{"state", "prompt"}};
286283
} else {
287284
json["data"] = JSON::Object::Entries {{"state", "denied"}};

0 commit comments

Comments
 (0)