Skip to content

Commit b6b3a1b

Browse files
committed
[CMake] Generate swiftinterface files next to the stdlib swiftmodules
We're not using them for anything yet, but this will exercise -emit-interface while we're working on it and make sure that it doesn't crash when processing complex code like the standard library.
1 parent 845e8be commit b6b3a1b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ function(_compile_swift_files
317317
set(sibopt_file "${module_base}.O.sib")
318318
set(sibgen_file "${module_base}.sibgen")
319319
set(module_doc_file "${module_base}.swiftdoc")
320+
set(interface_file "${module_base}.swiftinterface")
320321

321322
list(APPEND command_create_dirs
322323
COMMAND "${CMAKE_COMMAND}" -E make_directory "${module_dir}")
@@ -395,7 +396,7 @@ function(_compile_swift_files
395396

396397
set(standard_outputs ${SWIFTFILE_OUTPUT})
397398
set(apinotes_outputs ${apinote_files})
398-
set(module_outputs "${module_file}" "${module_doc_file}")
399+
set(module_outputs "${module_file}" "${module_doc_file}" "${interface_file}")
399400
set(sib_outputs "${sib_file}")
400401
set(sibopt_outputs "${sibopt_file}")
401402
set(sibgen_outputs "${sibgen_file}")
@@ -483,13 +484,14 @@ function(_compile_swift_files
483484
#
484485
# 1. *.swiftmodule
485486
# 2. *.swiftdoc
486-
# 3. *.Onone.sib
487-
# 4. *.O.sib
488-
# 5. *.sibgen
487+
# 3. *.swiftinterface
488+
# 4. *.Onone.sib
489+
# 5. *.O.sib
490+
# 6. *.sibgen
489491
#
490-
# Only 1,2 are built by default. 3,4,5 are utility targets for use by engineers
491-
# and thus even though the targets are generated, the targets are not built by
492-
# default.
492+
# Only 1,2,3 are built by default. 4,5,6 are utility targets for use by
493+
# engineers and thus even though the targets are generated, the targets are
494+
# not built by default.
493495
#
494496
# We only build these when we are not producing a main file. We could do this
495497
# with sib/sibgen, but it is useful for looking at the stdlib.
@@ -500,10 +502,12 @@ function(_compile_swift_files
500502
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${module_file}"
501503
COMMAND
502504
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${module_doc_file}"
505+
COMMAND
506+
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${interface_file}"
503507
COMMAND
504508
"${PYTHON_EXECUTABLE}" "${line_directive_tool}" "@${file_path}" --
505-
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}" ${swift_flags}
506-
"@${file_path}"
509+
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}"
510+
"-experimental-emit-interface" ${swift_flags} "@${file_path}"
507511
${command_touch_module_outputs}
508512
OUTPUT ${module_outputs}
509513
DEPENDS

0 commit comments

Comments
 (0)