Skip to content

Commit b4529a6

Browse files
add build-stdlib-docs flag that generates stdlib symbol graphs
1 parent b66bc17 commit b4529a6

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ option(SWIFT_STDLIB_ENABLE_SIB_TARGETS
463463
"Should we generate sib targets for the stdlib or not?"
464464
FALSE)
465465

466+
option(SWIFT_STDLIB_BUILD_SYMBOL_GRAPHS
467+
"Whether to build symbol graphs for the stdlib, for use in documentation."
468+
FALSE)
469+
466470

467471
set(SWIFT_DARWIN_SUPPORTED_ARCHS "" CACHE STRING
468472
"Semicolon-separated list of architectures to configure on Darwin platforms. \

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,13 @@ function(add_swift_target_library_single target name)
937937
set(SWIFTLIB_SINGLE_SOURCES ${SWIFTLIB_SINGLE_SOURCES} ${SWIFTLIB_SINGLE_HEADERS} ${SWIFTLIB_SINGLE_TDS})
938938
endif()
939939

940+
# FIXME: swiftDarwin currently trips an assertion in SymbolGraphGen
941+
if (SWIFTLIB_IS_STDLIB AND SWIFT_STDLIB_BUILD_SYMBOL_GRAPHS AND NOT ${name} STREQUAL "swiftDarwin")
942+
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-Xfrontend;-emit-symbol-graph")
943+
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS
944+
"-Xfrontend;-emit-symbol-graph-dir;-Xfrontend;${out_lib_dir}/symbol-graph/${VARIANT_NAME}")
945+
endif()
946+
940947
if(MODULE)
941948
set(libkind MODULE)
942949
elseif(SWIFTLIB_SINGLE_OBJECT_LIBRARY)
@@ -2233,7 +2240,6 @@ function(add_swift_target_library name)
22332240
endif()
22342241
endif()
22352242

2236-
22372243
# Collect architecture agnostic SDK linker flags
22382244
set(swiftlib_link_flags_all ${SWIFTLIB_LINK_FLAGS})
22392245
if(sdk STREQUAL "IOS_SIMULATOR" AND name STREQUAL "swiftMediaPlayer")

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,11 @@ def create_argument_parser():
11601160
help='Include Unicode data in the standard library.'
11611161
'Note: required for full String functionality')
11621162

1163+
option('--build-stdlib-docs', toggle_true,
1164+
default=False,
1165+
help='Build documentation for the standard library.'
1166+
'Note: this builds SwiftDocC to perform the docs build.')
1167+
11631168
option('--build-swift-clang-overlays', toggle_true,
11641169
default=True,
11651170
help='Build Swift overlays for the clang builtin modules')

utils/swift_build_support/swift_build_support/products/swift.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ def __init__(self, args, toolchain, source_dir, build_dir):
8989

9090
self.cmake_options.extend(self._enable_embedded_stdlib_cross_compiling)
9191

92+
self.cmake_options.extend(self._enable_stdlib_symbol_graphs)
93+
9294
self.cmake_options.extend(
9395
self._swift_tools_ld64_lto_codegen_only_for_supporting_targets)
9496

@@ -271,6 +273,11 @@ def _enable_embedded_stdlib_cross_compiling(self):
271273
return [('SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING',
272274
self.args.build_embedded_stdlib_cross_compiling)]
273275

276+
@property
277+
def _enable_stdlib_symbol_graphs(self):
278+
return [('SWIFT_STDLIB_BUILD_SYMBOL_GRAPHS',
279+
self.args.build_stdlib_docs)]
280+
274281
def _handle_swift_debuginfo_non_lto_args(self):
275282
if ('swift_debuginfo_non_lto_args' not in self.args
276283
or self.args.swift_debuginfo_non_lto_args is None):

0 commit comments

Comments
 (0)