Skip to content

Commit 384882d

Browse files
authored
Merge pull request swiftlang#23201 from compnerd/patience-is-not-always-a-virtue
build: introduce and switch to GYB_SOURCES
2 parents 71b012e + 8ed5c1a commit 384882d

File tree

24 files changed

+160
-101
lines changed

24 files changed

+160
-101
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ function(_add_swift_library_single target name)
721721
FILE_DEPENDS
722722
FRAMEWORK_DEPENDS
723723
FRAMEWORK_DEPENDS_WEAK
724+
GYB_SOURCES
724725
INCORPORATE_OBJECT_LIBRARIES
725726
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
726727
INTERFACE_LINK_LIBRARIES
@@ -810,10 +811,14 @@ function(_add_swift_library_single target name)
810811
"Either SHARED, STATIC, or OBJECT_LIBRARY must be specified")
811812
endif()
812813

813-
handle_gyb_sources(
814-
gyb_dependency_targets
815-
SWIFTLIB_SINGLE_SOURCES
816-
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
814+
if(SWIFTLIB_SINGLE_GYB_SOURCES)
815+
handle_gyb_sources(
816+
gyb_dependency_targets
817+
SWIFTLIB_SINGLE_GYB_SOURCES
818+
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
819+
set(SWIFTLIB_SINGLE_SOURCES ${SWIFTLIB_SINGLE_SOURCES}
820+
${SWIFTLIB_SINGLE_GYB_SOURCES})
821+
endif()
817822

818823
# Remove the "swift" prefix from the name to determine the module name.
819824
if(SWIFTLIB_IS_STDLIB_CORE)
@@ -1620,6 +1625,7 @@ function(add_swift_target_library name)
16201625
FRAMEWORK_DEPENDS_IOS_TVOS
16211626
FRAMEWORK_DEPENDS_OSX
16221627
FRAMEWORK_DEPENDS_WEAK
1628+
GYB_SOURCES
16231629
INCORPORATE_OBJECT_LIBRARIES
16241630
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
16251631
INTERFACE_LINK_LIBRARIES
@@ -1914,6 +1920,7 @@ function(add_swift_target_library name)
19141920
DEPLOYMENT_VERSION_IOS "${SWIFTLIB_DEPLOYMENT_VERSION_IOS}"
19151921
DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS}"
19161922
DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}"
1923+
GYB_SOURCES ${SWIFTLIB_GYB_SOURCES}
19171924
)
19181925

19191926
if(NOT SWIFTLIB_OBJECT_LIBRARY)

cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,35 +131,31 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
131131
"${SWIFT_SOURCE_DIR}/utils/gyb_sourcekit_support/UIDs.py")
132132

133133
foreach (src ${${sources_var_name}})
134-
string(REGEX REPLACE "[.]gyb$" "" src_sans_gyb "${src}")
135-
if(src STREQUAL src_sans_gyb)
136-
list(APPEND de_gybbed_sources "${src}")
134+
# On Windows (using Visual Studio), the generated project files assume that the
135+
# generated GYB files will be in the source, not binary directory.
136+
# We can work around this by modifying the root directory when generating VS projects.
137+
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
138+
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
137139
else()
140+
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
141+
endif()
138142

139-
# On Windows (using Visual Studio), the generated project files assume that the
140-
# generated GYB files will be in the source, not binary directory.
141-
# We can work around this by modifying the root directory when generating VS projects.
142-
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
143-
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
144-
else()
145-
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
146-
endif()
147-
148-
if (arch)
149-
set(dir "${dir_root}/${ptr_size}")
150-
else()
151-
set(dir "${dir_root}")
152-
endif()
153-
set(output_file_name "${dir}/${src_sans_gyb}")
154-
list(APPEND de_gybbed_sources "${output_file_name}")
155-
handle_gyb_source_single(dependency_target
156-
SOURCE "${src}"
157-
OUTPUT "${output_file_name}"
158-
FLAGS ${extra_gyb_flags}
159-
DEPENDS "${gyb_extra_sources}"
160-
COMMENT "with ptr size = ${ptr_size}")
161-
list(APPEND dependency_targets "${dependency_target}")
143+
if (arch)
144+
set(dir "${dir_root}/${ptr_size}")
145+
else()
146+
set(dir "${dir_root}")
162147
endif()
148+
# get_filename_component(src_sans_gyb ${src} NAME_WLE)
149+
string(REGEX REPLACE "\.gyb$" "" src_sans_gyb ${src})
150+
set(output_file_name "${dir}/${src_sans_gyb}")
151+
list(APPEND de_gybbed_sources "${output_file_name}")
152+
handle_gyb_source_single(dependency_target
153+
SOURCE "${src}"
154+
OUTPUT "${output_file_name}"
155+
FLAGS ${extra_gyb_flags}
156+
DEPENDS "${gyb_extra_sources}"
157+
COMMENT "with ptr size = ${ptr_size}")
158+
list(APPEND dependency_targets "${dependency_target}")
163159
endforeach()
164160
set("${dependency_out_var_name}" "${dependency_targets}" PARENT_SCOPE)
165161
set("${sources_var_name}" "${de_gybbed_sources}" PARENT_SCOPE)

lib/Basic/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ add_swift_host_library(swiftBasic STATIC
102102
# Platform-agnostic fallback TaskQueue implementation
103103
Default/TaskQueue.inc
104104

105-
UnicodeExtendedGraphemeClusters.cpp.gyb
105+
GYB_SOURCES
106+
UnicodeExtendedGraphemeClusters.cpp.gyb
106107

107108
C_COMPILE_FLAGS ${UUID_INCLUDE}
108109
LLVM_COMPONENT_DEPENDS support)

lib/Parse/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ add_swift_host_library(swiftParse STATIC
1010
ParseDecl.cpp
1111
ParsedRawSyntaxNode.cpp
1212
ParsedRawSyntaxRecorder.cpp
13-
ParsedSyntaxBuilders.cpp.gyb
14-
ParsedSyntaxNodes.cpp.gyb
15-
ParsedSyntaxRecorder.cpp.gyb
1613
ParsedTrivia.cpp
1714
ParseExpr.cpp
1815
ParseGeneric.cpp
@@ -24,7 +21,12 @@ add_swift_host_library(swiftParse STATIC
2421
PersistentParserState.cpp
2522
Scope.cpp
2623
SyntaxParsingCache.cpp
27-
SyntaxParsingContext.cpp)
24+
SyntaxParsingContext.cpp
25+
26+
GYB_SOURCES
27+
ParsedSyntaxBuilders.cpp.gyb
28+
ParsedSyntaxNodes.cpp.gyb
29+
ParsedSyntaxRecorder.cpp.gyb)
2830
target_link_libraries(swiftParse PRIVATE
2931
swiftAST
3032
swiftSyntax)

lib/Syntax/CMakeLists.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ else()
55
endif()
66

77
add_swift_host_library(swiftSyntax STATIC
8-
SyntaxNodes.cpp.gyb
9-
SyntaxBuilders.cpp.gyb
10-
SyntaxKind.cpp.gyb
11-
SyntaxFactory.cpp.gyb
12-
SyntaxVisitor.cpp.gyb
13-
Trivia.cpp.gyb
148
RawSyntax.cpp
159
Syntax.cpp
1610
SyntaxData.cpp
17-
SyntaxSerialization.cpp.gyb
18-
UnknownSyntax.cpp)
11+
UnknownSyntax.cpp
12+
13+
GYB_SOURCES
14+
SyntaxNodes.cpp.gyb
15+
SyntaxBuilders.cpp.gyb
16+
SyntaxKind.cpp.gyb
17+
SyntaxFactory.cpp.gyb
18+
SyntaxVisitor.cpp.gyb
19+
Trivia.cpp.gyb
20+
SyntaxSerialization.cpp.gyb)

stdlib/private/SwiftPrivate/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ add_swift_target_library(swiftSwiftPrivate ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
77
# filename.
88
SwiftPrivate.swift
99

10-
AtomicInt.swift.gyb
1110
IO.swift
1211
ShardedAtomicCounter.swift
1312

13+
GYB_SOURCES
14+
AtomicInt.swift.gyb
15+
1416
SWIFT_MODULE_DEPENDS_WINDOWS MSVCRT WinSDK
1517
SWIFT_COMPILE_FLAGS ${swift_swiftprivate_compile_flags}
1618
INSTALL_IN_COMPONENT stdlib-experimental)

stdlib/public/Darwin/AVFoundation/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ add_swift_target_library(swiftAVFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYP
88
AVCaptureVideoDataOutput.swift
99
AVError.swift
1010
AVMetadataObject.swift
11-
NSValue.swift.gyb
11+
12+
GYB_SOURCES
13+
NSValue.swift.gyb
1214

1315
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
1416
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"

stdlib/public/Darwin/Accelerate/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.4.3)
22
include("../../../../cmake/modules/StandaloneOverlay.cmake")
33

44
add_swift_target_library(swiftAccelerate ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
5-
BNNS.swift.gyb
5+
6+
GYB_SOURCES
7+
BNNS.swift.gyb
68

79
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
810
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"

stdlib/public/Darwin/CoreGraphics/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ include("../../../../cmake/modules/StandaloneOverlay.cmake")
33

44
add_swift_target_library(swiftCoreGraphics ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
55
CoreGraphics.swift
6-
CGFloat.swift.gyb
76
Private.swift
87

8+
GYB_SOURCES
9+
CGFloat.swift.gyb
10+
911
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
1012
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
1113
SWIFT_MODULE_DEPENDS_OSX Darwin CoreFoundation Dispatch IOKit ObjectiveC # auto-updated

stdlib/public/Darwin/CoreLocation/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ include("../../../../cmake/modules/StandaloneOverlay.cmake")
33

44
add_swift_target_library(swiftCoreLocation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
55
CLError.swift
6-
NSValue.swift.gyb
6+
7+
GYB_SOURCES
8+
NSValue.swift.gyb
79

810
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
911
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"

0 commit comments

Comments
 (0)