Skip to content

Commit a9f737c

Browse files
committed
[swift_build_support] Always emit a compilation_db.
There is no reason not to do this (and it is really cheap) and I want to make some scripts use it with various clang tooling techniques like clang-tidy to improve code quality. This will ensure that by default people can just use these scripts without knowing about how things are working under the hood.
1 parent 50fa0d3 commit a9f737c

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

utils/build-script

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,10 +2048,6 @@ iterations with -O",
20482048
parser.add_argument("--enable-sil-ownership",
20492049
help="Enable the SIL ownership model",
20502050
action='store_true')
2051-
parser.add_argument('--compilation-db',
2052-
help='When configuring, have cmake emit a compilation '
2053-
'database in $BUILD_DIR/compilation_commands.json',
2054-
action='store_true')
20552051

20562052
parser.add_argument(
20572053
# Explicitly unavailable options here.

utils/swift_build_support/swift_build_support/products/swift.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,4 @@ def _sil_ownership_flags(self):
107107

108108
@property
109109
def _compile_db_flags(self):
110-
if not self.args.compilation_db:
111-
return []
112110
return ['-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE']

utils/swift_build_support/tests/products/test_swift.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def setUp(self):
5555
benchmark=False,
5656
benchmark_num_onone_iterations=3,
5757
benchmark_num_o_iterations=3,
58-
enable_sil_ownership=False,
59-
compilation_db=False)
58+
enable_sil_ownership=False)
6059

6160
# Setup shell
6261
shell.dry_run = True
@@ -83,7 +82,7 @@ def test_by_default_no_cmake_options(self):
8382
toolchain=self.toolchain,
8483
source_dir='/path/to/src',
8584
build_dir='/path/to/build')
86-
self.assertEqual(swift.cmake_options, [])
85+
self.assertEqual(swift.cmake_options, ['-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE'])
8786

8887
def test_swift_runtime_tsan(self):
8988
self.args.enable_tsan_runtime = True
@@ -93,7 +92,8 @@ def test_swift_runtime_tsan(self):
9392
source_dir='/path/to/src',
9493
build_dir='/path/to/build')
9594
self.assertEqual(swift.cmake_options,
96-
['-DSWIFT_RUNTIME_USE_SANITIZERS=Thread'])
95+
['-DSWIFT_RUNTIME_USE_SANITIZERS=Thread',
96+
'-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE'])
9797

9898
def test_swift_compiler_vendor_flags(self):
9999
self.args.compiler_vendor = "none"
@@ -229,7 +229,7 @@ def test_benchmark_flags(self):
229229
self.assertEqual(
230230
['-DSWIFT_BENCHMARK_NUM_ONONE_ITERATIONS=3',
231231
'-DSWIFT_BENCHMARK_NUM_O_ITERATIONS=3'],
232-
swift.cmake_options)
232+
[x for x in swift.cmake_options if 'SWIFT_BENCHMARK_NUM' in x])
233233

234234
self.args.benchmark_num_onone_iterations = 20
235235
swift = Swift(
@@ -240,7 +240,7 @@ def test_benchmark_flags(self):
240240
self.assertEqual(
241241
['-DSWIFT_BENCHMARK_NUM_ONONE_ITERATIONS=20',
242242
'-DSWIFT_BENCHMARK_NUM_O_ITERATIONS=3'],
243-
swift.cmake_options)
243+
[x for x in swift.cmake_options if 'SWIFT_BENCHMARK_NUM' in x])
244244
self.args.benchmark_num_onone_iterations = 3
245245

246246
self.args.benchmark_num_o_iterations = 30
@@ -252,7 +252,7 @@ def test_benchmark_flags(self):
252252
self.assertEqual(
253253
['-DSWIFT_BENCHMARK_NUM_ONONE_ITERATIONS=3',
254254
'-DSWIFT_BENCHMARK_NUM_O_ITERATIONS=30'],
255-
swift.cmake_options)
255+
[x for x in swift.cmake_options if 'SWIFT_BENCHMARK_NUM' in x])
256256
self.args.benchmark_num_onone_iterations = 3
257257

258258
self.args.benchmark_num_onone_iterations = 10
@@ -265,7 +265,7 @@ def test_benchmark_flags(self):
265265
self.assertEqual(
266266
['-DSWIFT_BENCHMARK_NUM_ONONE_ITERATIONS=10',
267267
'-DSWIFT_BENCHMARK_NUM_O_ITERATIONS=25'],
268-
swift.cmake_options)
268+
[x for x in swift.cmake_options if 'SWIFT_BENCHMARK_NUM' in x])
269269

270270
def test_sil_ownership_flags(self):
271271
self.args.enable_sil_ownership = True
@@ -276,15 +276,4 @@ def test_sil_ownership_flags(self):
276276
build_dir='/path/to/build')
277277
self.assertEqual(
278278
['-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=TRUE'],
279-
swift.cmake_options)
280-
281-
def test_compilation_db_flags(self):
282-
self.args.compilation_db = True
283-
swift = Swift(
284-
args=self.args,
285-
toolchain=self.toolchain,
286-
source_dir='/path/to/src',
287-
build_dir='/path/to/build')
288-
self.assertEqual(
289-
['-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE'],
290-
swift.cmake_options)
279+
[x for x in swift.cmake_options if 'SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP' in x])

0 commit comments

Comments
 (0)