Skip to content

Commit 7ad53d6

Browse files
Respect --output_base set on command-line (#1917)
Signed-off-by: Brentley Jones <[email protected]>
1 parent b3deedb commit 7ad53d6

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

buildbuddy.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ x_templates:
4747

4848
commands:
4949
- &set_release_archive_override "--output_base=setup-bazel-output-base run --config=workflows @rules_xcodeproj//tools:set_release_archive_override"
50-
- &validate_integration "run --config=workflows --config=fixtures //test/fixtures:validate"
51-
- &build_all "build --config=workflows --noexperimental_enable_bzlmod //..."
52-
- &test_all "test --config=workflows --noexperimental_enable_bzlmod //..."
53-
- &bzlmod_generate_integration "run --config=workflows --config=fixtures //test/fixtures:update"
54-
- &bzlmod_build_all "build --config=workflows //..."
55-
- &bzlmod_test_all "test --config=workflows //test/..."
50+
- &validate_integration "--output_base=bazel-output-base run --config=workflows --config=fixtures //test/fixtures:validate"
51+
- &build_all "--output_base=bazel-output-base build --config=workflows --noexperimental_enable_bzlmod //..."
52+
- &test_all "--output_base=bazel-output-base test --config=workflows --noexperimental_enable_bzlmod //..."
53+
- &bzlmod_generate_integration "--output_base=bazel-output-base run --config=workflows --config=fixtures //test/fixtures:update"
54+
- &bzlmod_build_all "--output_base=bazel-output-base build --config=workflows //..."
55+
- &bzlmod_test_all "--output_base=bazel-output-base test --config=workflows //test/..."
5656

5757
actions:
5858
- name: Buildifier Lint

xcodeproj/internal/runner.template.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fail() {
1818

1919
# Process Args
2020

21+
readonly execution_root_file="$PWD/%execution_root_file%"
2122
readonly extra_flags_bazelrc="$PWD/%extra_flags_bazelrc%"
2223
readonly generator_build_file="$PWD/%generator_build_file%"
2324
readonly generator_defs_bzl="$PWD/%generator_defs_bzl%"
@@ -101,11 +102,7 @@ fi
101102

102103
installer_flags+=(--bazel_path "$bazel_path")
103104

104-
if [[ %is_fixture% -eq 1 ]]; then
105-
execution_root=$("$bazel_path" info --config=fixtures execution_root)
106-
else
107-
execution_root=$("$bazel_path" info execution_root)
108-
fi
105+
execution_root=$(<"$execution_root_file")
109106
installer_flags+=(--execution_root "$execution_root")
110107

111108
readonly output_base="${execution_root%/*/*}"

xcodeproj/internal/xcodeproj_runner.bzl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
112137
def _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

Comments
 (0)