Skip to content

Commit 39019f2

Browse files
committed
[CMake] Add 'parser-lib' install component and install the relevant files
The files go into 'lib/swift' so that SwiftSyntax can import the library without needing custom search paths to be added to the swiftpm invocation.
1 parent d8c30d8 commit 39019f2

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

cmake/modules/SwiftComponents.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
# * toolchain-dev-tools -- install development tools useful in a shared toolchain
6666
# * dev -- headers and libraries required to use Swift compiler as a library.
6767
set(_SWIFT_DEFINED_COMPONENTS
68-
"autolink-driver;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;sdk-overlay;editor-integration;tools;testsuite-tools;toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers")
68+
"autolink-driver;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;sdk-overlay;parser-lib;editor-integration;tools;testsuite-tools;toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers")
6969

7070
macro(swift_configure_components)
7171
# Set the SWIFT_INSTALL_COMPONENTS variable to the default value if it is not passed in via -D

tools/libSwiftSyntaxParser/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Use an 'internal' name, this is primarily intended for SwiftSyntax to import.
2+
set(SYNTAX_PARSER_LIB_NAME "_InternalSwiftSyntaxParser")
3+
14
set(LLVM_EXPORTED_SYMBOL_FILE
25
${CMAKE_CURRENT_SOURCE_DIR}/libSwiftSyntaxParser.exports)
36

@@ -10,7 +13,7 @@ add_swift_host_library(libSwiftSyntaxParser SHARED
1013
)
1114
set_target_properties(libSwiftSyntaxParser
1215
PROPERTIES
13-
OUTPUT_NAME _InternalSwiftSyntaxParser)
16+
OUTPUT_NAME ${SYNTAX_PARSER_LIB_NAME})
1417

1518
add_llvm_symbol_exports(libSwiftSyntaxParser ${LLVM_EXPORTED_SYMBOL_FILE})
1619

@@ -22,3 +25,10 @@ set_property(TARGET libSwiftSyntaxParser APPEND_STRING PROPERTY
2225
if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
2326
target_link_libraries(libSwiftSyntaxParser PRIVATE BlocksRuntime)
2427
endif()
28+
29+
swift_install_in_component(parser-lib
30+
FILES "${SWIFT_LIBRARY_OUTPUT_INTDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${SYNTAX_PARSER_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}"
31+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
32+
swift_install_in_component(parser-lib
33+
DIRECTORY "${SWIFT_MAIN_INCLUDE_DIR}/swift-c/SyntaxParser/"
34+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${SYNTAX_PARSER_LIB_NAME}")

utils/build-presets.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[preset: mixin_buildbot_install_components]
1717
dash-dash
1818

19-
swift-install-components=compiler;clang-builtin-headers;stdlib;sdk-overlay;editor-integration;tools;testsuite-tools;sourcekit-xpc-service;swift-remote-mirror;swift-remote-mirror-headers;
19+
swift-install-components=compiler;clang-builtin-headers;stdlib;sdk-overlay;parser-lib;editor-integration;tools;testsuite-tools;sourcekit-xpc-service;swift-remote-mirror;swift-remote-mirror-headers;
2020

2121

2222
[preset: mixin_buildbot_trunk_base]
@@ -728,7 +728,7 @@ install-swiftpm
728728
install-xctest
729729
install-libicu
730730
install-prefix=/usr
731-
swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc
731+
swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;parser-lib;license;sourcekit-inproc
732732
llvm-install-components=llvm-cov;llvm-profdata;IndexStore
733733
build-swift-static-stdlib
734734
build-swift-static-sdk-overlay
@@ -1078,7 +1078,7 @@ test-installable-package
10781078
# If someone uses this for incremental builds, force reconfiguration.
10791079
reconfigure
10801080

1081-
swift-install-components=compiler;clang-builtin-headers;stdlib;sdk-overlay;license;sourcekit-xpc-service;swift-remote-mirror;swift-remote-mirror-headers
1081+
swift-install-components=compiler;clang-builtin-headers;stdlib;sdk-overlay;parser-lib;license;sourcekit-xpc-service;swift-remote-mirror;swift-remote-mirror-headers
10821082
llvm-install-components=llvm-cov;llvm-profdata;IndexStore
10831083

10841084
# Path to the .tar.gz package we would create.

0 commit comments

Comments
 (0)