@@ -156,18 +156,36 @@ RNBRunLoopMode RNBRunLoopGetStartModeFromRemote(RNBRemote *remote) {
156
156
return eRNBRunLoopModeExit;
157
157
}
158
158
159
- // Check the name to see if it ends with .app
160
- static bool is_dot_app (const char *app_name) {
161
- size_t len = strlen (app_name);
162
- if (len < 4 )
159
+ static nub_launch_flavor_t default_launch_flavor (const char *app_name) {
160
+ #if defined(WITH_FBS) || defined(WITH_BKS) || defined(WITH_SPRINGBOARD)
161
+ // Check the name to see if it ends with .app
162
+ auto is_dot_app = [](const char *app_name) {
163
+ size_t len = strlen (app_name);
164
+ if (len < 4 )
165
+ return false ;
166
+
167
+ if (app_name[len - 4 ] == ' .' && app_name[len - 3 ] == ' a' &&
168
+ app_name[len - 2 ] == ' p' && app_name[len - 1 ] == ' p' )
169
+ return true ;
163
170
return false ;
164
-
165
- if (app_name[len - 4 ] == ' .' &&
166
- app_name[len - 3 ] == ' a' &&
167
- app_name[len - 2 ] == ' p' &&
168
- app_name[len - 1 ] == ' p' )
169
- return true ;
170
- return false ;
171
+ };
172
+
173
+ if (is_dot_app (app_name)) {
174
+ #if defined WITH_FBS
175
+ // Check if we have an app bundle, if so launch using FrontBoard Services.
176
+ return eLaunchFlavorFBS;
177
+ #elif defined WITH_BKS
178
+ // Check if we have an app bundle, if so launch using BackBoard Services.
179
+ return eLaunchFlavorBKS;
180
+ #elif defined WITH_SPRINGBOARD
181
+ // Check if we have an app bundle, if so launch using SpringBoard.
182
+ return eLaunchFlavorSpringBoard;
183
+ #endif
184
+ }
185
+ #endif
186
+
187
+ // Our default launch method is posix spawn
188
+ return eLaunchFlavorPosixSpawn;
171
189
}
172
190
173
191
// This run loop mode will wait for the process to launch and hit its
@@ -208,29 +226,8 @@ RNBRunLoopMode RNBRunLoopLaunchInferior(RNBRemote *remote,
208
226
// figure our how we are going to launch automatically.
209
227
210
228
nub_launch_flavor_t launch_flavor = g_launch_flavor;
211
- if (launch_flavor == eLaunchFlavorDefault) {
212
- // Our default launch method is posix spawn
213
- launch_flavor = eLaunchFlavorPosixSpawn;
214
-
215
- const bool dot_app = is_dot_app (inferior_argv[0 ]);
216
- (void )dot_app;
217
- #if defined WITH_FBS
218
- // Check if we have an app bundle, if so launch using BackBoard Services.
219
- if (dot_app) {
220
- launch_flavor = eLaunchFlavorFBS;
221
- }
222
- #elif defined WITH_BKS
223
- // Check if we have an app bundle, if so launch using BackBoard Services.
224
- if (dot_app) {
225
- launch_flavor = eLaunchFlavorBKS;
226
- }
227
- #elif defined WITH_SPRINGBOARD
228
- // Check if we have an app bundle, if so launch using SpringBoard.
229
- if (dot_app) {
230
- launch_flavor = eLaunchFlavorSpringBoard;
231
- }
232
- #endif
233
- }
229
+ if (launch_flavor == eLaunchFlavorDefault)
230
+ launch_flavor = default_launch_flavor (inferior_argv[0 ]);
234
231
235
232
ctx.SetLaunchFlavor (launch_flavor);
236
233
char resolved_path[PATH_MAX];
@@ -1509,27 +1506,8 @@ int main(int argc, char *argv[]) {
1509
1506
timeout_ptr = &attach_timeout_abstime;
1510
1507
}
1511
1508
nub_launch_flavor_t launch_flavor = g_launch_flavor;
1512
- if (launch_flavor == eLaunchFlavorDefault) {
1513
- // Our default launch method is posix spawn
1514
- launch_flavor = eLaunchFlavorPosixSpawn;
1515
-
1516
- #if defined WITH_FBS
1517
- // Check if we have an app bundle, if so launch using SpringBoard.
1518
- if (is_dot_app (waitfor_pid_name.c_str ())) {
1519
- launch_flavor = eLaunchFlavorFBS;
1520
- }
1521
- #elif defined WITH_BKS
1522
- // Check if we have an app bundle, if so launch using SpringBoard.
1523
- if (is_dot_app (waitfor_pid_name.c_str ())) {
1524
- launch_flavor = eLaunchFlavorBKS;
1525
- }
1526
- #elif defined WITH_SPRINGBOARD
1527
- // Check if we have an app bundle, if so launch using SpringBoard.
1528
- if (is_dot_app (waitfor_pid_name.c_str ())) {
1529
- launch_flavor = eLaunchFlavorSpringBoard;
1530
- }
1531
- #endif
1532
- }
1509
+ if (launch_flavor == eLaunchFlavorDefault)
1510
+ launch_flavor = default_launch_flavor (waitfor_pid_name.c_str ());
1533
1511
1534
1512
ctx.SetLaunchFlavor (launch_flavor);
1535
1513
bool ignore_existing = false ;
0 commit comments