Skip to content

Commit ca09204

Browse files
authored
Merge pull request #61516 from ahoppen/ahoppen/swift-format-ci
Build swift-format as part of CI testing and install it into open source toolchains
2 parents e7eba7f + 4512cb0 commit ca09204

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

utils/build-presets.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ sourcekit-lsp
367367
# swift-inspect
368368
swiftsyntax
369369
swiftsyntax-verify-generated-files
370+
swiftformat
370371

371372
skstresstester
372373
swiftevolve
@@ -623,6 +624,7 @@ llbuild
623624
swiftpm
624625
swiftsyntax
625626
swiftsyntax-verify-generated-files
627+
swiftformat
626628
swift-driver
627629
indexstore-db
628630
sourcekit-lsp
@@ -824,6 +826,7 @@ install-xctest
824826
install-libicu
825827
install-prefix=/usr
826828
install-sourcekit-lsp
829+
install-swiftformat
827830
install-swiftdocc
828831
build-swift-static-stdlib
829832
build-swift-static-sdk-overlay
@@ -1118,6 +1121,7 @@ foundation
11181121
libdispatch
11191122
swiftsyntax
11201123
swiftsyntax-verify-generated-files
1124+
swiftformat
11211125
indexstore-db
11221126
sourcekit-lsp
11231127
install-llvm
@@ -1236,6 +1240,7 @@ swift-driver
12361240
# Failing to build in CI: rdar://78408440
12371241
# swift-inspect
12381242
swiftsyntax
1243+
swiftformat
12391244
playgroundsupport
12401245
libcxx
12411246
indexstore-db
@@ -1285,6 +1290,7 @@ install-swiftsyntax
12851290
install-playgroundsupport
12861291
install-libcxx
12871292
install-sourcekit-lsp
1293+
install-swiftformat
12881294
install-back-deploy-concurrency
12891295
install-swiftdocc
12901296

@@ -1393,6 +1399,7 @@ skip-test-lldb
13931399
skip-test-cmark
13941400
skip-test-playgroundsupport
13951401
skip-test-swiftsyntax
1402+
skip-test-swiftformat
13961403
skip-test-skstresstester
13971404
skip-test-swiftevolve
13981405
skip-test-swiftdocc
@@ -1432,6 +1439,7 @@ skip-test-lldb
14321439
skip-test-cmark
14331440
skip-test-playgroundsupport
14341441
skip-test-swiftsyntax
1442+
skip-test-swiftformat
14351443
skip-test-skstresstester
14361444
skip-test-swiftevolve
14371445
skip-test-swiftdocc
@@ -1576,6 +1584,7 @@ swiftpm
15761584
# swift-inspect
15771585
swift-driver
15781586
swiftsyntax
1587+
swiftformat
15791588
swiftdocc
15801589

15811590
# Don't generate the SwiftSyntax gyb files. Instead verify that up-to-date ones
@@ -1808,6 +1817,7 @@ release
18081817
assertions
18091818
swiftsyntax
18101819
swiftsyntax-verify-generated-files
1820+
swiftformat
18111821
skstresstester
18121822
swiftevolve
18131823
sourcekit-lsp
@@ -1820,6 +1830,7 @@ assertions
18201830
swiftsyntax
18211831
sourcekit-lsp
18221832
swiftsyntax-verify-generated-files
1833+
swiftformat
18231834

18241835
#===------------------------------------------------------------------------===#
18251836
# Test Swift Format

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ def create_argument_parser():
701701
'match the ones that would be generated from current main')
702702
option(['--install-sourcekit-lsp'], toggle_true('install_sourcekitlsp'),
703703
help='install SourceKitLSP')
704+
option(['--install-swiftformat'], toggle_true('install_swiftformat'),
705+
help='install SourceKitLSP')
704706
option(['--install-skstresstester'], toggle_true('install_skstresstester'),
705707
help='install the SourceKit stress tester')
706708
option(['--install-swift-driver'], toggle_true('install_swift_driver'),

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
'swiftsyntax_verify_generated_files': False,
109109
'install_playgroundsupport': False,
110110
'install_sourcekitlsp': False,
111+
'install_swiftformat': False,
111112
'install_skstresstester': False,
112113
'install_swiftevolve': False,
113114
'build_toolchainbenchmarks': False,
@@ -586,6 +587,7 @@ class BuildScriptImplOption(_BaseOption):
586587
EnableOption('--install-swiftpm', dest='install_swiftpm'),
587588
EnableOption('--install-swift-driver', dest='install_swift_driver'),
588589
EnableOption('--install-sourcekit-lsp', dest='install_sourcekitlsp'),
590+
EnableOption('--install-swiftformat', dest='install_swiftformat'),
589591
EnableOption('--install-skstresstester', dest='install_skstresstester'),
590592
EnableOption('--install-swiftevolve', dest='install_swiftevolve'),
591593
EnableOption('--install-swiftdocc', dest='install_swiftdocc'),

utils/swift_build_support/swift_build_support/products/swiftformat.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def run_build_script_helper(self, action, host_target, additional_params=[]):
5454
script_path = os.path.join(
5555
self.source_dir, 'build-script-helper.py')
5656

57+
install_destdir = self.host_install_destdir(host_target)
58+
5759
configuration = 'release' if self.is_release() else 'debug'
5860

5961
helper_cmd = [
@@ -68,6 +70,9 @@ def run_build_script_helper(self, action, host_target, additional_params=[]):
6870
# reset the dependencies to be local.
6971
'--update'
7072
]
73+
helper_cmd.extend([
74+
'--prefix', install_destdir + self.args.install_prefix
75+
])
7176
if self.args.verbose_build:
7277
helper_cmd.append('--verbose')
7378
helper_cmd.extend(additional_params)
@@ -87,7 +92,10 @@ def test(self, host_target):
8792
self.run_build_script_helper('test', host_target)
8893

8994
def should_install(self, host_target):
90-
return False
95+
return self.args.install_swiftformat
96+
97+
def install(self, host_target):
98+
self.run_build_script_helper('install', host_target)
9199

92100
@classmethod
93101
def get_dependencies(cls):

0 commit comments

Comments
 (0)