Skip to content

build: port to new Swift support #2304

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

Closed
wants to merge 1 commit into from
Closed
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
597 changes: 27 additions & 570 deletions CMakeLists.txt

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions CoreFoundation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

cmake_minimum_required(VERSION 3.4.3)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()

project(CoreFoundation
VERSION
Expand Down Expand Up @@ -422,6 +426,9 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
PRIVATE
${LIBXML2_INCLUDE_DIR})
find_package(CURL REQUIRED)
target_include_directories(CoreFoundation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoreFoundation is not supposed to import or link with libcurl.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is based on an older state of the tree. I will have to redo the work, this was to demonstrate what the build would look like.

PRIVATE
${CURL_INCLUDE_DIRS})
target_include_directories(CFURLSessionInterface
PRIVATE
${CURL_INCLUDE_DIRS})
Expand Down Expand Up @@ -586,7 +593,7 @@ endif()

install(TARGETS
CoreFoundation
CFURLSessionInterface
CFURLSessionInterface
DESTINATION
"${CMAKE_INSTALL_FULL_LIBDIR}")
install(DIRECTORY
Expand Down
263 changes: 263 additions & 0 deletions Foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@

# FIXME(compnerd) workaround linker flag munging
set(CMAKE_SHARED_LINKER_FLAGS "")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "")
# FIXME(compnerd) workaround the library search path flag
set(CMAKE_LIBRARY_PATH_FLAG -L)
set(CMAKE_LINK_LIBRARY_FLAG "-l")

add_library(Foundation
AffineTransform.swift
Array.swift
Boxing.swift
Bridging.swift
Bundle.swift
ByteCountFormatter.swift
Calendar.swift
CGFloat.swift
CharacterSet.swift
Codable.swift
Collections+DataProtocol.swift
ContiguousBytes.swift
Data.swift
DataProtocol.swift
Date.swift
DateComponents.swift
DateComponentsFormatter.swift
DateFormatter.swift
DateInterval.swift
DateIntervalFormatter.swift
Decimal.swift
Dictionary.swift
DispatchData+DataProtocol.swift
EnergyFormatter.swift
ExtraStringAPIs.swift
FileHandle.swift
FileManager.swift
FileManager+POSIX.swift
FileManager+Win32.swift
FileManager_XDG.swift
Formatter.swift
FoundationErrors.swift
Host.swift
IndexPath.swift
IndexSet.swift
ISO8601DateFormatter.swift
JSONEncoder.swift
JSONSerialization.swift
LengthFormatter.swift
Locale.swift
MassFormatter.swift
Measurement.swift
MeasurementFormatter.swift
Notification.swift
NotificationQueue.swift
NSArray.swift
NSAttributedString.swift
NSCache.swift
NSCalendar.swift
NSCFArray.swift
NSCFBoolean.swift
NSCFCharacterSet.swift
NSCFDictionary.swift
NSCFSet.swift
NSCFString.swift
NSCharacterSet.swift
NSCoder.swift
NSComparisonPredicate.swift
NSCompoundPredicate.swift
NSConcreteValue.swift
NSData+DataProtocol.swift
NSData.swift
NSDate.swift
NSDecimalNumber.swift
NSDictionary.swift
NSEnumerator.swift
NSError.swift
NSExpression.swift
NSGeometry.swift
NSIndexPath.swift
NSIndexSet.swift
NSKeyedArchiver.swift
NSKeyedArchiverHelpers.swift
NSKeyedCoderOldStyleArray.swift
NSKeyedUnarchiver.swift
NSLocale.swift
NSLock.swift
NSLog.swift
NSMeasurement.swift
NSNotification.swift
NSNull.swift
NSNumber.swift
NSObjCRuntime.swift
NSObject.swift
NSOrderedSet.swift
NSPathUtilities.swift
NSPersonNameComponents.swift
NSPlatform.swift
NSPredicate.swift
NSRange.swift
NSRegularExpression.swift
NSSet.swift
NSSortDescriptor.swift
NSSpecialValue.swift
NSString.swift
NSStringAPI.swift
NSSwiftRuntime.swift
NSTextCheckingResult.swift
NSTimeZone.swift
NSURL.swift
NSURLError.swift
NSUUID.swift
NSValue.swift
NumberFormatter.swift
Operation.swift
PersonNameComponents.swift
PersonNameComponentsFormatter.swift
Pointers+DataProtocol.swift
Port.swift
PortMessage.swift
Process.swift
ProcessInfo.swift
Progress.swift
ProgressFraction.swift
PropertyListEncoder.swift
PropertyListSerialization.swift
ReferenceConvertible.swift
RunLoop.swift
Scanner.swift
ScannerAPI.swift
Set.swift
Stream.swift
String.swift
StringEncodings.swift
Thread.swift
Timer.swift
TimeZone.swift
Unit.swift
URL.swift
URLComponents.swift
UserDefaults.swift
UUID.swift
XMLDocument.swift
XMLDTD.swift
XMLDTDNode.swift
XMLElement.swift
XMLNode.swift
XMLParser.swift)

target_compile_definitions(Foundation PRIVATE
DEPLOYMENT_RUNTIME_SWIFT)

target_compile_options(Foundation PRIVATE
$<$<BOOL:ENABLE_TESTING>:-enable-testing>)
target_compile_options(Foundation PUBLIC
"SHELL:-Xcc -F${CMAKE_BINARY_DIR}")

set_target_properties(Foundation PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}
INTERFACE_LINK_DIRECTORIES $<TARGET_LINKER_FILE_DIR:Foundation>)

if(FOUNDATION_ENABLE_LIBDISPATCH)
target_compile_definitions(Foundation PRIVATE
DEPLOYMENT_ENABLE_LIBDISPATCH)

# FIXME(compnerd) these three can go away with export targets
target_compile_options(Foundation PUBLIC
"SHELL:-Xcc -fblocks"
"SHELL:-Xcc -I${FOUNDATION_PATH_TO_LIBDISPATCH_SOURCE}")
target_include_directories(Foundation PUBLIC
${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/swift)
target_link_directories(Foundation PUBLIC
${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src
${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src/BlocksRuntime
${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src/swift)

target_link_libraries(Foundation PRIVATE
swiftDispatch)
endif()

target_link_libraries(Foundation PRIVATE
uuid CoreFoundation)
target_link_libraries(Foundation PRIVATE
${ICU_UC_LIBRARY} ${ICU_I18N_LIBRARY})
target_link_libraries(Foundation PRIVATE
${LIBXML2_LIBRARIES})
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
target_link_libraries(Foundation PRIVATE
DbgHelp Ole32 ShLwApi Shell32 WS2_32 iphlpapi pathcch)
target_link_libraries(Foundation PRIVATE
CoreFoundationResources)

# FIXME(compnerd) SR-9138
target_link_options(Foundation PRIVATE
"LINKER:-ignore:4217")
endif()

add_library(FoundationNetworking
Boxing.swift
NSURLRequest.swift
HTTPCookie.swift
HTTPCookieStorage.swift
URLAuthenticationChallenge.swift
URLCache.swift
URLCredential.swift
URLCredentialStorage.swift
URLProtectionSpace.swift
URLProtocol.swift
URLRequest.swift
URLResponse.swift
URLSession/BodySource.swift
URLSession/Configuration.swift
URLSession/http/HTTPMessage.swift
URLSession/http/HTTPURLProtocol.swift
URLSession/libcurl/EasyHandle.swift
URLSession/libcurl/libcurlHelpers.swift
URLSession/libcurl/MultiHandle.swift
URLSession/Message.swift
URLSession/NativeProtocol.swift
URLSession/NetworkingSpecific.swift
URLSession/ftp/FTPURLProtocol.swift
URLSession/TaskRegistry.swift
URLSession/TransferState.swift
URLSession/URLSession.swift
URLSession/URLSessionConfiguration.swift
URLSession/URLSessionDelegate.swift
URLSession/URLSessionTask.swift)

target_compile_definitions(FoundationNetworking PRIVATE
DEPLOYMENT_RUNTIME_SWIFT
NS_BUILDING_FOUNDATION_NETWORKING)

target_compile_options(FoundationNetworking PRIVATE
$<$<BOOL:ENABLE_TESTING>:-enable-testing>)

target_link_libraries(FoundationNetworking PRIVATE
Foundation
CFURLSessionInterface)

if(CMAKE_SYSTEM_NAME STREQUAL Windows)
# FIXME(compnerd) SR-9138
target_link_options(FoundationNetworking PRIVATE
"LINKER:-ignore:4217")
endif()

set_target_properties(FoundationNetworking PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}
INTERFACE_LINK_DIRECTORIES $<TARGET_LINKER_FILE_DIR:FoundationNetworking>)


install(FILES
${CMAKE_Swift_MODULE_DIRECTORY}/Foundation.swiftdoc
${CMAKE_Swift_MODULE_DIRECTORY}/Foundation.swiftmodule
${CMAKE_Swift_MODULE_DIRECTORY}/FoundationNetworking.swiftdoc
${CMAKE_Swift_MODULE_DIRECTORY}/FoundationNetworking.swiftmodule
DESTINATION
lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>/${swift_arch})
install(TARGETS
Foundation
FoundationNetworking
ARCHIVE DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>/${swift_arch}
LIBRARY DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>/${swift_arch}
RUNTIME DESTINATION bin)

Loading