Skip to content

Commit 56b14ea

Browse files
Add BAZEL_SIMCTL_LAUNCH_FLAGS and BAZEL_DEVICECTL_LAUNCH_FLAGS env variable options (#2770)
Setting these allows you to adjust the launch flags for `bazel run` of simulator and device applications respectively, e.g. setting `--wait-for-debugger`. They default to `--console-pty` and `--console` to keep existing behavior. Signed-off-by: Brentley Jones <github@brentleyjones.com>
1 parent 00c64f5 commit 56b14ea

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

apple/internal/templates/apple_device.template.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import pathlib
4040
import platform
4141
import plistlib
42+
import shlex
4243
import shutil
4344
import subprocess
4445
import sys
@@ -407,6 +408,13 @@ def run_app(
407408
check=True
408409
)
409410
app_bundle_id = bundle_id(app_path)
411+
launch_args = shlex.split(
412+
os.environ.get(
413+
"BAZEL_DEVICECTL_LAUNCH_FLAGS",
414+
# Attaches the application to the console and waits for it to exit.
415+
"--console",
416+
),
417+
)
410418
logger.info(
411419
"Launching app %s on %s", app_bundle_id, device_identifier
412420
)
@@ -415,7 +423,7 @@ def run_app(
415423
"device",
416424
"process",
417425
"launch",
418-
"--console", # Attaches the application to the console and waits for it to exit.
426+
*launch_args,
419427
"--device",
420428
device_identifier,
421429
app_bundle_id,

apple/internal/templates/apple_simulator.template.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import pathlib
5353
import platform
5454
import plistlib
55+
import shlex
5556
import shutil
5657
import subprocess
5758
import sys
@@ -681,13 +682,20 @@ def run_app_in_simulator(
681682
[simctl_path, "install", simulator_udid, app_path], check=True
682683
)
683684
app_bundle_id = bundle_id(app_path)
685+
launch_args = shlex.split(
686+
os.environ.get(
687+
"BAZEL_SIMCTL_LAUNCH_FLAGS",
688+
# Attaches the application to the console and waits for it to exit.
689+
"--console-pty",
690+
),
691+
)
684692
logger.info(
685693
"Launching app %s in simulator %s", app_bundle_id, simulator_udid
686694
)
687695
args = [
688696
simctl_path,
689697
"launch",
690-
"--console-pty",
698+
*launch_args,
691699
simulator_udid,
692700
app_bundle_id,
693701
]

0 commit comments

Comments
 (0)