@@ -109,6 +109,31 @@ def _write_extra_flags_bazelrc(name, actions, attr, config):
109109
110110 return output
111111
112+ def _write_execution_root_file (* , ctx ):
113+ output = ctx .actions .declare_file ("{}_execution_root_file" .format (ctx .attr .name ))
114+
115+ ctx .actions .run_shell (
116+ outputs = [output ],
117+ command = """\
118+ bin_dir_full_path="$(perl -MCwd -e 'print Cwd::abs_path shift' "{bin_dir_full}";)"
119+ execution_root="${{bin_dir_full_path%/{bin_dir_full}}}"
120+
121+ echo "$execution_root" > "{out_full}"
122+ """ .format (
123+ bin_dir_full = ctx .bin_dir .path ,
124+ out_full = output .path ,
125+ ),
126+ mnemonic = "CalculateXcodeProjExecutionRoot" ,
127+ # This has to run locally
128+ execution_requirements = {
129+ "local" : "1" ,
130+ "no-remote" : "1" ,
131+ "no-sandbox" : "1" ,
132+ },
133+ )
134+
135+ return output
136+
112137def _write_schemes_json (* , actions , name , schemes_json ):
113138 output = actions .declare_file (
114139 "{}-custom_xcode_schemes.json" .format (name ),
@@ -267,6 +292,7 @@ def _write_runner(
267292 actions ,
268293 bazel_path ,
269294 config ,
295+ execution_root_file ,
270296 extra_flags_bazelrc ,
271297 extra_generator_flags ,
272298 generator_build_file ,
@@ -289,6 +315,7 @@ def _write_runner(
289315 substitutions = {
290316 "%bazel_path%" : bazel_path ,
291317 "%config%" : config ,
318+ "%execution_root_file%" : execution_root_file .short_path ,
292319 "%extra_flags_bazelrc%" : extra_flags_bazelrc .short_path ,
293320 "%extra_generator_flags%" : extra_generator_flags ,
294321 "%generator_label%" : (
@@ -336,6 +363,7 @@ def _xcodeproj_runner_impl(ctx):
336363 config = config ,
337364 name = name ,
338365 )
366+ execution_root_file = _write_execution_root_file (ctx = ctx )
339367 schemes_json = _write_schemes_json (
340368 actions = actions ,
341369 name = name ,
@@ -363,6 +391,7 @@ def _xcodeproj_runner_impl(ctx):
363391 actions = actions ,
364392 bazel_path = ctx .attr .bazel_path ,
365393 config = config ,
394+ execution_root_file = execution_root_file ,
366395 extra_flags_bazelrc = extra_flags_bazelrc ,
367396 extra_generator_flags = (
368397 ctx .attr ._extra_generator_flags [BuildSettingInfo ].value
@@ -383,6 +412,7 @@ def _xcodeproj_runner_impl(ctx):
383412 executable = runner ,
384413 runfiles = ctx .runfiles (
385414 files = [
415+ execution_root_file ,
386416 extra_flags_bazelrc ,
387417 generator_build_file ,
388418 generator_defs_bzl ,
0 commit comments