Skip to content

Commit 5dd3ce9

Browse files
authored
Merge pull request #3020 from modocache/sr-1738-add-swift-library-shared-static-args
[SR-1738] add_swift_library takes SHARED/STATIC arg
2 parents 5dffe97 + 328de9e commit 5dd3ce9

File tree

75 files changed

+120
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+120
-83
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ endfunction()
361361
# target
362362
# name
363363
# [SHARED]
364+
# [STATIC]
364365
# [SDK sdk]
365366
# [ARCHITECTURE architecture]
366367
# [DEPENDS dep1 ...]
@@ -390,6 +391,9 @@ endfunction()
390391
# SHARED
391392
# Build a shared library.
392393
#
394+
# STATIC
395+
# Build a static library.
396+
#
393397
# SDK sdk
394398
# SDK to build for.
395399
#
@@ -448,7 +452,7 @@ endfunction()
448452
# Sources to add into this library
449453
function(_add_swift_library_single target name)
450454
set(SWIFTLIB_SINGLE_options
451-
SHARED OBJECT_LIBRARY IS_STDLIB IS_STDLIB_CORE IS_SDK_OVERLAY
455+
SHARED STATIC OBJECT_LIBRARY IS_STDLIB IS_STDLIB_CORE IS_SDK_OVERLAY
452456
TARGET_LIBRARY FORCE_BUILD_FOR_HOST_SDK
453457
API_NOTES_NON_OVERLAY DONT_EMBED_BITCODE)
454458
cmake_parse_arguments(SWIFTLIB_SINGLE
@@ -473,6 +477,13 @@ function(_add_swift_library_single target name)
473477
if("${SWIFTLIB_SINGLE_INSTALL_IN_COMPONENT}" STREQUAL "")
474478
message(FATAL_ERROR "INSTALL_IN_COMPONENT is required")
475479
endif()
480+
481+
if(NOT SWIFTLIB_SINGLE_SHARED AND
482+
NOT SWIFTLIB_SINGLE_STATIC AND
483+
NOT SWIFTLIB_SINGLE_OBJECT_LIBRARY)
484+
message(FATAL_ERROR
485+
"Either SHARED, STATIC, or OBJECT_LIBRARY must be specified")
486+
endif()
476487

477488
# Determine the subdirectory where this library will be installed.
478489
set(SWIFTLIB_SINGLE_SUBDIR
@@ -681,7 +692,7 @@ function(_add_swift_library_single target name)
681692
# Do these LAST.
682693

683694
set(target_static)
684-
if(SWIFTLIB_SINGLE_IS_STDLIB AND SWIFT_BUILD_STATIC_STDLIB)
695+
if(SWIFTLIB_SINGLE_IS_STDLIB AND SWIFTLIB_SINGLE_STATIC)
685696
set(target_static "${target}-static")
686697

687698
# We have already compiled Swift sources. Link everything into a static
@@ -920,6 +931,7 @@ endfunction()
920931
# Usage:
921932
# add_swift_library(name
922933
# [SHARED]
934+
# [STATIC]
923935
# [DEPENDS dep1 ...]
924936
# [LINK_LIBRARIES dep1 ...]
925937
# [INTERFACE_LINK_LIBRARIES dep1 ...]
@@ -949,6 +961,9 @@ endfunction()
949961
# SHARED
950962
# Build a shared library.
951963
#
964+
# STATIC
965+
# Build a static library.
966+
#
952967
# DEPENDS
953968
# Targets that this library depends on.
954969
#
@@ -1028,7 +1043,7 @@ endfunction()
10281043
# Sources to add into this library.
10291044
function(add_swift_library name)
10301045
set(SWIFTLIB_options
1031-
SHARED OBJECT_LIBRARY IS_STDLIB IS_STDLIB_CORE IS_SDK_OVERLAY
1046+
SHARED STATIC OBJECT_LIBRARY IS_STDLIB IS_STDLIB_CORE IS_SDK_OVERLAY
10321047
TARGET_LIBRARY FORCE_BUILD_FOR_HOST_SDK
10331048
API_NOTES_NON_OVERLAY DONT_EMBED_BITCODE HAS_SWIFT_CONTENT)
10341049
cmake_parse_arguments(SWIFTLIB
@@ -1042,7 +1057,6 @@ function(add_swift_library name)
10421057

10431058
if(SWIFTLIB_IS_SDK_OVERLAY)
10441059
set(SWIFTLIB_HAS_SWIFT_CONTENT TRUE)
1045-
set(SWIFTLIB_SHARED TRUE)
10461060
set(SWIFTLIB_IS_STDLIB TRUE)
10471061
set(SWIFTLIB_TARGET_LIBRARY TRUE)
10481062

@@ -1104,6 +1118,13 @@ function(add_swift_library name)
11041118
if("${SWIFTLIB_INSTALL_IN_COMPONENT}" STREQUAL "")
11051119
message(FATAL_ERROR "INSTALL_IN_COMPONENT is required")
11061120
endif()
1121+
1122+
if(NOT SWIFTLIB_SHARED AND
1123+
NOT SWIFTLIB_STATIC AND
1124+
NOT SWIFTLIB_OBJECT_LIBRARY)
1125+
message(FATAL_ERROR
1126+
"Either SHARED, STATIC, or OBJECT_LIBRARY must be specified")
1127+
endif()
11071128

11081129
if(SWIFTLIB_TARGET_LIBRARY)
11091130
# If we are building this library for targets, loop through the various
@@ -1196,6 +1217,7 @@ function(add_swift_library name)
11961217
${VARIANT_NAME}
11971218
${name}
11981219
${SWIFTLIB_SHARED_keyword}
1220+
${SWIFTLIB_STATIC_keyword}
11991221
${SWIFTLIB_OBJECT_LIBRARY_keyword}
12001222
${SWIFTLIB_SOURCES}
12011223
SDK ${sdk}
@@ -1231,7 +1253,7 @@ function(add_swift_library name)
12311253
endif()
12321254
endforeach()
12331255

1234-
if (SWIFT_BUILD_STATIC_STDLIB AND SWIFTLIB_IS_STDLIB)
1256+
if (SWIFTLIB_IS_STDLIB AND SWIFTLIB_STATIC)
12351257
# Add dependencies on the (not-yet-created) custom lipo target.
12361258
foreach(DEP ${SWIFTLIB_LINK_LIBRARIES})
12371259
if (NOT "${DEP}" STREQUAL "icucore")
@@ -1300,7 +1322,7 @@ function(add_swift_library name)
13001322
# If we built static variants of the library, create a lipo target for
13011323
# them.
13021324
set(lipo_target_static)
1303-
if (SWIFT_BUILD_STATIC_STDLIB AND SWIFTLIB_IS_STDLIB)
1325+
if (SWIFTLIB_IS_STDLIB AND SWIFTLIB_STATIC)
13041326
set(THIN_INPUT_TARGETS_STATIC)
13051327
foreach(TARGET ${THIN_INPUT_TARGETS})
13061328
list(APPEND THIN_INPUT_TARGETS_STATIC "${TARGET}-static")
@@ -1366,6 +1388,8 @@ function(add_swift_library name)
13661388
${name}
13671389
${name}
13681390
${SWIFTLIB_SHARED_keyword}
1391+
${SWIFTLIB_STATIC_keyword}
1392+
${SWIFTLIB_OBJECT_LIBRARY_keyword}
13691393
${SWIFTLIB_SOURCES}
13701394
SDK ${sdk}
13711395
ARCHITECTURE ${arch}

lib/AST/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_swift_library(swiftAST
1+
add_swift_library(swiftAST STATIC
22
ArchetypeBuilder.cpp
33
ASTContext.cpp
44
ASTDumper.cpp

lib/ASTSectionImporter/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_swift_library(swiftASTSectionImporter
1+
add_swift_library(swiftASTSectionImporter STATIC
22
ASTSectionImporter.cpp
33
LINK_LIBRARIES swiftBasic
44
COMPONENT_DEPENDS core)

lib/Basic/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ generate_revision_inc(swift_revision_inc Swift "${SWIFT_SOURCE_DIR}")
5858
set(version_inc_files
5959
${llvm_revision_inc} ${clang_revision_inc} ${swift_revision_inc})
6060

61-
add_swift_library(swiftBasic
61+
add_swift_library(swiftBasic STATIC
6262
Cache.cpp
6363
ClusteredBitVector.cpp
6464
Demangle.cpp

lib/ClangImporter/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ handle_gyb_sources(
88
generated_include_sources
99
"")
1010

11-
add_swift_library(swiftClangImporter
11+
add_swift_library(swiftClangImporter STATIC
1212
CFTypeInfo.cpp
1313
ClangDiagnosticConsumer.cpp
1414
ClangImporter.cpp

lib/Driver/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(swiftDriver_sources
1414

1515
set(swiftDriver_targetDefines)
1616

17-
add_swift_library(swiftDriver
17+
add_swift_library(swiftDriver STATIC
1818
${swiftDriver_sources}
1919
DEPENDS SwiftOptions
2020
LINK_LIBRARIES swiftAST swiftBasic swiftFrontend swiftOption)

lib/Frontend/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_swift_library(swiftFrontend
1+
add_swift_library(swiftFrontend STATIC
22
CompilerInvocation.cpp
33
DiagnosticVerifier.cpp
44
Frontend.cpp

lib/FrontendTool/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_swift_library(swiftFrontendTool
1+
add_swift_library(swiftFrontendTool STATIC
22
FrontendTool.cpp
33
DEPENDS SwiftOptions
44
LINK_LIBRARIES

lib/IDE/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_swift_library(swiftIDE
1+
add_swift_library(swiftIDE STATIC
22
CodeCompletion.cpp
33
CodeCompletionCache.cpp
44
CommentConversion.cpp

lib/IRGen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_swift_library(swiftIRGen
1+
add_swift_library(swiftIRGen STATIC
22
DebugTypeInfo.cpp
33
EnumPayload.cpp
44
ExtraInhabitants.cpp

0 commit comments

Comments
 (0)