Skip to content

build: introduce and switch to GYB_SOURCES #23201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ function(_add_swift_library_single target name)
FILE_DEPENDS
FRAMEWORK_DEPENDS
FRAMEWORK_DEPENDS_WEAK
GYB_SOURCES
INCORPORATE_OBJECT_LIBRARIES
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
INTERFACE_LINK_LIBRARIES
Expand Down Expand Up @@ -810,10 +811,14 @@ function(_add_swift_library_single target name)
"Either SHARED, STATIC, or OBJECT_LIBRARY must be specified")
endif()

handle_gyb_sources(
gyb_dependency_targets
SWIFTLIB_SINGLE_SOURCES
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
if(SWIFTLIB_SINGLE_GYB_SOURCES)
handle_gyb_sources(
gyb_dependency_targets
SWIFTLIB_SINGLE_GYB_SOURCES
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
set(SWIFTLIB_SINGLE_SOURCES ${SWIFTLIB_SINGLE_SOURCES}
${SWIFTLIB_SINGLE_GYB_SOURCES})
endif()

# Remove the "swift" prefix from the name to determine the module name.
if(SWIFTLIB_IS_STDLIB_CORE)
Expand Down Expand Up @@ -1620,6 +1625,7 @@ function(add_swift_target_library name)
FRAMEWORK_DEPENDS_IOS_TVOS
FRAMEWORK_DEPENDS_OSX
FRAMEWORK_DEPENDS_WEAK
GYB_SOURCES
INCORPORATE_OBJECT_LIBRARIES
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
INTERFACE_LINK_LIBRARIES
Expand Down Expand Up @@ -1914,6 +1920,7 @@ function(add_swift_target_library name)
DEPLOYMENT_VERSION_IOS "${SWIFTLIB_DEPLOYMENT_VERSION_IOS}"
DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS}"
DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}"
GYB_SOURCES ${SWIFTLIB_GYB_SOURCES}
)

if(NOT SWIFTLIB_OBJECT_LIBRARY)
Expand Down
48 changes: 22 additions & 26 deletions cmake/modules/SwiftHandleGybSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,31 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
"${SWIFT_SOURCE_DIR}/utils/gyb_sourcekit_support/UIDs.py")

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

# On Windows (using Visual Studio), the generated project files assume that the
# generated GYB files will be in the source, not binary directory.
# We can work around this by modifying the root directory when generating VS projects.
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
else()
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
endif()

if (arch)
set(dir "${dir_root}/${ptr_size}")
else()
set(dir "${dir_root}")
endif()
set(output_file_name "${dir}/${src_sans_gyb}")
list(APPEND de_gybbed_sources "${output_file_name}")
handle_gyb_source_single(dependency_target
SOURCE "${src}"
OUTPUT "${output_file_name}"
FLAGS ${extra_gyb_flags}
DEPENDS "${gyb_extra_sources}"
COMMENT "with ptr size = ${ptr_size}")
list(APPEND dependency_targets "${dependency_target}")
if (arch)
set(dir "${dir_root}/${ptr_size}")
else()
set(dir "${dir_root}")
endif()
# get_filename_component(src_sans_gyb ${src} NAME_WLE)
string(REGEX REPLACE "\.gyb$" "" src_sans_gyb ${src})
set(output_file_name "${dir}/${src_sans_gyb}")
list(APPEND de_gybbed_sources "${output_file_name}")
handle_gyb_source_single(dependency_target
SOURCE "${src}"
OUTPUT "${output_file_name}"
FLAGS ${extra_gyb_flags}
DEPENDS "${gyb_extra_sources}"
COMMENT "with ptr size = ${ptr_size}")
list(APPEND dependency_targets "${dependency_target}")
endforeach()
set("${dependency_out_var_name}" "${dependency_targets}" PARENT_SCOPE)
set("${sources_var_name}" "${de_gybbed_sources}" PARENT_SCOPE)
Expand Down
3 changes: 2 additions & 1 deletion lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ add_swift_host_library(swiftBasic STATIC
# Platform-agnostic fallback TaskQueue implementation
Default/TaskQueue.inc

UnicodeExtendedGraphemeClusters.cpp.gyb
GYB_SOURCES
UnicodeExtendedGraphemeClusters.cpp.gyb

C_COMPILE_FLAGS ${UUID_INCLUDE}
LLVM_COMPONENT_DEPENDS support)
Expand Down
10 changes: 6 additions & 4 deletions lib/Parse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ add_swift_host_library(swiftParse STATIC
ParseDecl.cpp
ParsedRawSyntaxNode.cpp
ParsedRawSyntaxRecorder.cpp
ParsedSyntaxBuilders.cpp.gyb
ParsedSyntaxNodes.cpp.gyb
ParsedSyntaxRecorder.cpp.gyb
ParsedTrivia.cpp
ParseExpr.cpp
ParseGeneric.cpp
Expand All @@ -24,7 +21,12 @@ add_swift_host_library(swiftParse STATIC
PersistentParserState.cpp
Scope.cpp
SyntaxParsingCache.cpp
SyntaxParsingContext.cpp)
SyntaxParsingContext.cpp

GYB_SOURCES
ParsedSyntaxBuilders.cpp.gyb
ParsedSyntaxNodes.cpp.gyb
ParsedSyntaxRecorder.cpp.gyb)
target_link_libraries(swiftParse PRIVATE
swiftAST
swiftSyntax)
Expand Down
18 changes: 10 additions & 8 deletions lib/Syntax/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ else()
endif()

add_swift_host_library(swiftSyntax STATIC
SyntaxNodes.cpp.gyb
SyntaxBuilders.cpp.gyb
SyntaxKind.cpp.gyb
SyntaxFactory.cpp.gyb
SyntaxVisitor.cpp.gyb
Trivia.cpp.gyb
RawSyntax.cpp
Syntax.cpp
SyntaxData.cpp
SyntaxSerialization.cpp.gyb
UnknownSyntax.cpp)
UnknownSyntax.cpp

GYB_SOURCES
SyntaxNodes.cpp.gyb
SyntaxBuilders.cpp.gyb
SyntaxKind.cpp.gyb
SyntaxFactory.cpp.gyb
SyntaxVisitor.cpp.gyb
Trivia.cpp.gyb
SyntaxSerialization.cpp.gyb)
4 changes: 3 additions & 1 deletion stdlib/private/SwiftPrivate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ add_swift_target_library(swiftSwiftPrivate ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
# filename.
SwiftPrivate.swift

AtomicInt.swift.gyb
IO.swift
ShardedAtomicCounter.swift

GYB_SOURCES
AtomicInt.swift.gyb

SWIFT_MODULE_DEPENDS_WINDOWS MSVCRT WinSDK
SWIFT_COMPILE_FLAGS ${swift_swiftprivate_compile_flags}
INSTALL_IN_COMPONENT stdlib-experimental)
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/AVFoundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ add_swift_target_library(swiftAVFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYP
AVCaptureVideoDataOutput.swift
AVError.swift
AVMetadataObject.swift
NSValue.swift.gyb

GYB_SOURCES
NSValue.swift.gyb

TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/Accelerate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.4.3)
include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftAccelerate ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
BNNS.swift.gyb

GYB_SOURCES
BNNS.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/CoreGraphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftCoreGraphics ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
CoreGraphics.swift
CGFloat.swift.gyb
Private.swift

GYB_SOURCES
CGFloat.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
SWIFT_MODULE_DEPENDS_OSX Darwin CoreFoundation Dispatch IOKit ObjectiveC # auto-updated
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/CoreLocation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftCoreLocation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
CLError.swift
NSValue.swift.gyb

GYB_SOURCES
NSValue.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/Foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ add_swift_target_library(swiftFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES
NSTextCheckingResult.swift
NSUndoManager.swift
NSURL.swift
NSValue.swift.gyb
PersonNameComponents.swift
PlistEncoder.swift
Progress.swift
Expand All @@ -64,6 +63,9 @@ add_swift_target_library(swiftFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES
UUID.swift
CheckClass.mm

GYB_SOURCES
NSValue.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}" "-Xllvm" "-sil-inline-generics" "-Xllvm" "-sil-partial-specialization" "-swift-version" "5"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"

Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/GLKit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.4.3)
include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftGLKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
GLKMath.swift.gyb

GYB_SOURCES
GLKMath.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/MapKit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.4.3)
include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftMapKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
NSValue.swift.gyb

GYB_SOURCES
NSValue.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/QuartzCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.4.3)
include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftQuartzCore ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
NSValue.swift.gyb

GYB_SOURCES
NSValue.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/SceneKit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.4.3)
include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftSceneKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
SceneKit.swift.gyb

GYB_SOURCES
SceneKit.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/SpriteKit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftSpriteKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
SpriteKit.swift
SpriteKitQuickLooks.swift.gyb

GYB_SOURCES
SpriteKitQuickLooks.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
4 changes: 3 additions & 1 deletion stdlib/public/Darwin/UIKit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ include("../../../../cmake/modules/StandaloneOverlay.cmake")
add_swift_target_library(swiftUIKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
DesignatedInitializers.mm
UIKit.swift
UIKit_FoundationExtensions.swift.gyb

GYB_SOURCES
UIKit_FoundationExtensions.swift.gyb

SWIFT_COMPILE_FLAGS ${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS} -swift-version 4.2
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
6 changes: 4 additions & 2 deletions stdlib/public/Darwin/simd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ cmake_minimum_required(VERSION 3.4.3)
include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftsimd ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
simd.swift.gyb
Quaternion.swift.gyb

GYB_SOURCES
simd.swift.gyb
Quaternion.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
Expand Down
16 changes: 13 additions & 3 deletions stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
set(swift_platform_sources
Platform.swift
TiocConstants.swift
TiocConstants.swift)
set(swift_platform_gyb_sources
tgmath.swift.gyb)

add_swift_target_library(swiftDarwin ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
Darwin.swift.gyb
${swift_platform_sources}
POSIXError.swift
MachError.swift

GYB_SOURCES
${swift_platform_gyb_sources}
Darwin.swift.gyb

SWIFT_COMPILE_FLAGS -Xfrontend -disable-objc-attr-requires-foundation-module "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
TARGET_SDKS ALL_APPLE_PLATFORMS
Expand All @@ -18,9 +22,12 @@ add_swift_target_library(swiftDarwin ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_
DEPENDS copy_apinotes)

add_swift_target_library(swiftGlibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
Glibc.swift.gyb
${swift_platform_sources}

GYB_SOURCES
${swift_platform_gyb_sources}
Glibc.swift.gyb

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
TARGET_SDKS ANDROID CYGWIN FREEBSD LINUX HAIKU
Expand All @@ -30,6 +37,9 @@ add_swift_target_library(swiftMSVCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_
msvcrt.swift
${swift_platform_sources}

GYB_SOURCES
${swift_platform_gyb_sources}

SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
TARGET_SDKS WINDOWS)
Expand Down
Loading