Skip to content

Commit

Permalink
Flag to disable blink build client
Browse files Browse the repository at this point in the history
  • Loading branch information
yury authored and Carlos Cabanero committed May 11, 2023
1 parent ac37277 commit d599b46
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
16 changes: 12 additions & 4 deletions Blink.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@
D276AB0D28D1D36200950728 /* NewSecurityKeyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D276AB0C28D1D36200950728 /* NewSecurityKeyView.swift */; };
D277150D287F0C2200D31F4E /* build.m in Sources */ = {isa = PBXBuildFile; fileRef = D277150A287F0C2100D31F4E /* build.m */; };
D277150E287F0C2200D31F4E /* TokioSignals.m in Sources */ = {isa = PBXBuildFile; fileRef = D277150C287F0C2200D31F4E /* TokioSignals.m */; };
D2771511287F0EA200D31F4E /* libbuild_cli.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2771510287F0EA200D31F4E /* libbuild_cli.a */; };
D27AD9BC222FDD3D00379872 /* xcall.m in Sources */ = {isa = PBXBuildFile; fileRef = D27AD9BB222FDD3D00379872 /* xcall.m */; };
D27BBA1C20529FFF00AEA303 /* TermStream.m in Sources */ = {isa = PBXBuildFile; fileRef = D27BBA1B20529FFF00AEA303 /* TermStream.m */; };
D27C4DA42987F124008427F2 /* BuildHelp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27C4DA32987F124008427F2 /* BuildHelp.swift */; };
Expand Down Expand Up @@ -1238,7 +1237,6 @@
BDB72CB227A9C08500DCC446 /* StoreKit.framework in Frameworks */,
D2DC5D4B295DB43D007E2B9D /* RevenueCat in Frameworks */,
D2A9B2F7272E6F26009FCBDE /* BlinkCode.framework in Frameworks */,
D2771511287F0EA200D31F4E /* libbuild_cli.a in Frameworks */,
D2334EF225C1C28F00385378 /* files.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -4428,7 +4426,12 @@
"$(PROJECT_DIR)/Frameworks",
);
MARKETING_VERSION = 16.1.8;
OTHER_LDFLAGS = "-ObjC";
NEW_SETTING = "";
OTHER_CFLAGS = "$(BLINK_OTHER_CFLAGS)";
OTHER_LDFLAGS = (
"-ObjC",
"$(BLINK_OTHER_LDFLAGS)",
);
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID)";
PRODUCT_NAME = Blink;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -4468,7 +4471,12 @@
"$(PROJECT_DIR)/Frameworks",
);
MARKETING_VERSION = 16.1.8;
OTHER_LDFLAGS = "-ObjC";
NEW_SETTING = "";
OTHER_CFLAGS = "$(BLINK_OTHER_CFLAGS)";
OTHER_LDFLAGS = (
"-ObjC",
"$(BLINK_OTHER_LDFLAGS)",
);
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID)";
PRODUCT_NAME = Blink;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
6 changes: 6 additions & 0 deletions Blink/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
#include "xcall.h"
#include "Blink-Swift.h"

#ifdef BLINK_BUILD_ENABLED
extern void build_auto_start_wg_ports(void);
extern void rebind_ports(void);
#endif


@import CloudKit;
Expand Down Expand Up @@ -134,7 +136,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

[PurchasesUserModelObjc preparePurchasesUserModel];

#ifdef BLINK_BUILD_ENABLED
build_auto_start_wg_ports();
#endif

return YES;
}
Expand Down Expand Up @@ -272,7 +276,9 @@ - (void)_cancelApplicationSuspend {
// We can't resume if we don't have access to protected data
if (UIApplication.sharedApplication.isProtectedDataAvailable) {
if (_suspendedMode) {
#ifdef BLINK_BUILD_ENABLED
rebind_ports();
#endif
}

_suspendedMode = NO;
Expand Down
14 changes: 12 additions & 2 deletions Blink/Commands/TokioSignals.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#import "TokioSignals.h"



#ifdef BLINK_BUILD_ENABLED
extern void signal_release(void * signals);
extern void signal_send(void * signals, int signal);

Expand All @@ -48,6 +48,7 @@ extern void build_call_service(
BOOL auth, void * ctx,
build_service_callback callback,
void ** signals);
#endif

@implementation TokioSignals {
}
Expand All @@ -59,7 +60,7 @@ + (instancetype) requestService:
callback: (build_service_callback) callback
{
TokioSignals *signals = [TokioSignals new];
#ifdef BLINK_BUILD_ENABLED
build_call_service(
request.URL.absoluteString.UTF8String,
request.HTTPMethod.UTF8String,
Expand All @@ -68,11 +69,13 @@ + (instancetype) requestService:
[request valueForHTTPHeaderField:@"Content-Type"].UTF8String,
auth,
ctx, callback, &signals->_signals);
#endif

return signals;
}

+ (nullable NSString *)getBuildId {
#ifdef BLINK_BUILD_ENABLED
char *ptr = build_get_build_id();
if (ptr) {
return [[NSString alloc] initWithBytesNoCopy:ptr
Expand All @@ -82,18 +85,25 @@ + (nullable NSString *)getBuildId {
} else {
return nil;
}
#else
return nil;
#endif
}


- (void) signalCtrlC {
if (_signals) {
#ifdef BLINK_BUILD_ENABLED
signal_send(_signals, 0);
#endif
}
}

- (void)dealloc {
if (_signals) {
#ifdef BLINK_BUILD_ENABLED
signal_release(_signals);
#endif
_signals = NULL;
}
}
Expand Down
12 changes: 11 additions & 1 deletion Blink/Commands/build.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@
void * start_mosh_fn;
};




void tokio_open_url(char *url) {
#ifdef BLINK_BUILD_ENABLED
NSString * str = @(url);
blink_openurl([NSURL URLWithString:str]);
#endif
}

void tokio_start_mosh(char * key, char * host, char * port) {
#ifdef BLINK_BUILD_ENABLED
MCPSession *session = (__bridge MCPSession *)thread_context;
if (!session) {
return;
Expand All @@ -63,13 +69,14 @@ void tokio_start_mosh(char * key, char * host, char * port) {
dispatch_async(session.cmdQueue, ^{
[session enqueueCommand:cmd skipHistoryRecord:YES];
});
//
#endif
}

extern int blink_build_cmd(int argc, char *argv[], struct IOSEnv * env, void ** signals);

__attribute__ ((visibility("default")))
int build_main(int argc, char *argv[]) {
#ifdef BLINK_BUILD_ENABLED
MCPSession *session = (__bridge MCPSession *)thread_context;
if (!session) {
return -1;
Expand All @@ -92,4 +99,7 @@ int build_main(int argc, char *argv[]) {
session.tokioSignals = nil;

return res;
#else
return 0;
#endif
}

0 comments on commit d599b46

Please sign in to comment.