Skip to content

Commit 85b30c3

Browse files
committed
Add --print-build-dir option to build-script
If passed, build-script doesn’t build anything; it just prints the full path to the directory the invocation would have built its products in. This is intended to allow you to build tools which take build-script options like --debug and --xcode and use them to determine the build directory you’re currently using.
1 parent 26c7f5c commit 85b30c3

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

utils/build-script

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,11 @@ def main_preset():
10921092
parser.add_argument(
10931093
"--build-dir",
10941094
help="specify the directory where build artifact should be stored")
1095+
parser.add_argument(
1096+
"--print-build-dir",
1097+
help="Print the build directory and exit without building",
1098+
action="store_true",
1099+
default=False)
10951100
args = parser.parse_args()
10961101
if len(args.preset_file_names) == 0:
10971102
args.preset_file_names = [
@@ -1141,6 +1146,8 @@ def main_preset():
11411146
build_script_args = [sys.argv[0]]
11421147
if args.dry_run:
11431148
build_script_args += ["--dry-run"]
1149+
if args.print_build_dir:
1150+
build_script_args += ["--print-build-dir"]
11441151

11451152
build_script_args += preset_args
11461153
if args.distcc:
@@ -1226,6 +1233,10 @@ def main_normal():
12261233
if args.show_sdks:
12271234
debug.print_xcodebuild_versions()
12281235

1236+
if args.print_build_dir:
1237+
print(invocation.workspace.build_root)
1238+
return 0
1239+
12291240
# Clean build directory if requested.
12301241
if args.clean:
12311242
clean_delay()

utils/build_swift/driver_arguments.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ def create_argument_parser():
333333
metavar='PATH',
334334
help='name of the directory under $SWIFT_BUILD_ROOT where the '
335335
'build products will be placed')
336+
option('--print-build-dir', toggle_true,
337+
help='print the build directory and exit without building')
336338
option('--install-prefix', store_path,
337339
default=targets.install_prefix(),
338340
help='The installation prefix. This is where built Swift products '

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
'tsan_libdispatch_test': False,
162162
'long_test': False,
163163
'lto_type': None,
164+
'print_build_dir': False,
164165
'show_sdks': False,
165166
'skip_build': False,
166167
'stdlib_deployment_targets': None,
@@ -402,6 +403,7 @@ class IgnoreOption(_BaseOption):
402403
SetTrueOption('--benchmark'),
403404
SetTrueOption('--clean'),
404405
SetTrueOption('--dry-run'),
406+
SetTrueOption('--print-build-dir'),
405407
SetTrueOption('--disable-guaranteed-normal-arguments'),
406408
SetTrueOption('--enable-stdlibcore-exclusivity-checking'),
407409
SetTrueOption('--force-optimized-typechecker'),

0 commit comments

Comments
 (0)