Skip to content

Commit 40244c8

Browse files
authored
Merge pull request #2289 from millenomi/foundationnetworking
2 parents 9858f1b + db36644 commit 40244c8

Some content is hidden

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

48 files changed

+1253
-177
lines changed

CMakeLists.txt

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ endif()
117117
# be able to remove this and just use
118118
# `target_link_libraries(Foundation PRIVATE CoreFoundation)`.
119119
set(CoreFoundation_LIBRARIES $<TARGET_FILE:CoreFoundation>)
120+
set(CFURLSessionInterface_LIBRARIES $<TARGET_FILE:CFURLSessionInterface>)
120121
get_target_property(CoreFoundation_LINK_LIBRARIES CoreFoundation LINK_LIBRARIES)
121122
foreach(library ${CoreFoundation_LINK_LIBRARIES})
122123
if(NOT library STREQUAL Threads::Threads)
123124
list(APPEND CoreFoundation_LIBRARIES -l${library})
125+
list(APPEND CFURLSessionInterface_LIBRARIES -l${library})
124126
endif()
125127
endforeach()
126128

@@ -165,8 +167,6 @@ add_swift_library(Foundation
165167
Foundation/Formatter.swift
166168
Foundation/FoundationErrors.swift
167169
Foundation/Host.swift
168-
Foundation/HTTPCookie.swift
169-
Foundation/HTTPCookieStorage.swift
170170
Foundation/IndexPath.swift
171171
Foundation/IndexSet.swift
172172
Foundation/ISO8601DateFormatter.swift
@@ -235,7 +235,6 @@ add_swift_library(Foundation
235235
Foundation/NSTimeZone.swift
236236
Foundation/NSURL.swift
237237
Foundation/NSURLError.swift
238-
Foundation/NSURLRequest.swift
239238
Foundation/NSUUID.swift
240239
Foundation/NSValue.swift
241240
Foundation/NumberFormatter.swift
@@ -264,31 +263,7 @@ add_swift_library(Foundation
264263
Foundation/TimeZone.swift
265264
Foundation/Unit.swift
266265
Foundation/URL.swift
267-
Foundation/URLAuthenticationChallenge.swift
268-
Foundation/URLCache.swift
269266
Foundation/URLComponents.swift
270-
Foundation/URLCredential.swift
271-
Foundation/URLCredentialStorage.swift
272-
Foundation/URLProtectionSpace.swift
273-
Foundation/URLProtocol.swift
274-
Foundation/URLRequest.swift
275-
Foundation/URLResponse.swift
276-
Foundation/URLSession/BodySource.swift
277-
Foundation/URLSession/Configuration.swift
278-
Foundation/URLSession/http/HTTPMessage.swift
279-
Foundation/URLSession/http/HTTPURLProtocol.swift
280-
Foundation/URLSession/libcurl/EasyHandle.swift
281-
Foundation/URLSession/libcurl/libcurlHelpers.swift
282-
Foundation/URLSession/libcurl/MultiHandle.swift
283-
Foundation/URLSession/Message.swift
284-
Foundation/URLSession/NativeProtocol.swift
285-
Foundation/URLSession/ftp/FTPURLProtocol.swift
286-
Foundation/URLSession/TaskRegistry.swift
287-
Foundation/URLSession/TransferState.swift
288-
Foundation/URLSession/URLSession.swift
289-
Foundation/URLSession/URLSessionConfiguration.swift
290-
Foundation/URLSession/URLSessionDelegate.swift
291-
Foundation/URLSession/URLSessionTask.swift
292267
Foundation/UserDefaults.swift
293268
Foundation/UUID.swift
294269
Foundation/XMLDocument.swift
@@ -303,7 +278,6 @@ add_swift_library(Foundation
303278
-F${CMAKE_CURRENT_BINARY_DIR}
304279
LINK_FLAGS
305280
${CoreFoundation_LIBRARIES}
306-
${CURL_LIBRARIES}
307281
${ICU_UC_LIBRARY} ${ICU_I18N_LIBRARY}
308282
${LIBXML2_LIBRARIES}
309283
${libdispatch_ldflags}
@@ -331,6 +305,75 @@ add_swift_library(Foundation
331305
CoreFoundation
332306
$<$<PLATFORM_ID:Windows>:CoreFoundationResources>)
333307

308+
add_swift_library(FoundationNetworking
309+
MODULE_NAME
310+
FoundationNetworking
311+
MODULE_LINK_NAME
312+
FoundationNetworking
313+
MODULE_PATH
314+
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationNetworking.swiftmodule
315+
SOURCES
316+
Foundation/Boxing.swift
317+
Foundation/NSURLRequest.swift
318+
Foundation/HTTPCookie.swift
319+
Foundation/HTTPCookieStorage.swift
320+
Foundation/URLAuthenticationChallenge.swift
321+
Foundation/URLCache.swift
322+
Foundation/URLCredential.swift
323+
Foundation/URLCredentialStorage.swift
324+
Foundation/URLProtectionSpace.swift
325+
Foundation/URLProtocol.swift
326+
Foundation/URLRequest.swift
327+
Foundation/URLResponse.swift
328+
Foundation/URLSession/BodySource.swift
329+
Foundation/URLSession/Configuration.swift
330+
Foundation/URLSession/http/HTTPMessage.swift
331+
Foundation/URLSession/http/HTTPURLProtocol.swift
332+
Foundation/URLSession/libcurl/EasyHandle.swift
333+
Foundation/URLSession/libcurl/libcurlHelpers.swift
334+
Foundation/URLSession/libcurl/MultiHandle.swift
335+
Foundation/URLSession/Message.swift
336+
Foundation/URLSession/NativeProtocol.swift
337+
Foundation/URLSession/NetworkingSpecific.swift
338+
Foundation/URLSession/ftp/FTPURLProtocol.swift
339+
Foundation/URLSession/TaskRegistry.swift
340+
Foundation/URLSession/TransferState.swift
341+
Foundation/URLSession/URLSession.swift
342+
Foundation/URLSession/URLSessionConfiguration.swift
343+
Foundation/URLSession/URLSessionDelegate.swift
344+
Foundation/URLSession/URLSessionTask.swift
345+
TARGET
346+
${CMAKE_C_COMPILER_TARGET}
347+
CFLAGS
348+
${MSVCRT_C_FLAGS}
349+
-F${CMAKE_CURRENT_BINARY_DIR}
350+
LINK_FLAGS
351+
${MSVCRT_LINK_FLAGS}
352+
-L${CMAKE_CURRENT_BINARY_DIR}
353+
${libdispatch_ldflags}
354+
-lFoundation
355+
${Foundation_INTERFACE_LIBRARIES}
356+
${CFURLSessionInterface_LIBRARIES}
357+
${CURL_LIBRARIES}
358+
${Foundation_RPATH}
359+
${WORKAROUND_SR9138}
360+
${WORKAROUND_SR9995}
361+
SWIFT_FLAGS
362+
-DDEPLOYMENT_RUNTIME_SWIFT
363+
-DNS_BUILDING_FOUNDATION_NETWORKING
364+
${deployment_enable_libdispatch}
365+
-I;${CMAKE_CURRENT_BINARY_DIR}/swift
366+
${libdispatch_cflags}
367+
${swift_enable_testing}
368+
${swift_optimization_flags}
369+
DEPENDS
370+
uuid
371+
CoreFoundation
372+
$<$<PLATFORM_ID:Windows>:CoreFoundationResources>
373+
Foundation)
374+
375+
376+
334377
if(NOT BUILD_SHARED_LIBS)
335378
set(Foundation_INTERFACE_LIBRARIES
336379
-L${install_dir}/usr/lib

CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <CoreFoundation/CFXMLInterface.h>
2525
#include <CoreFoundation/CFRegularExpression.h>
2626
#include <CoreFoundation/CFLogUtilities.h>
27-
#include <CoreFoundation/CFURLSessionInterface.h>
2827
#include <CoreFoundation/CFDateIntervalFormatter.h>
2928
#include <CoreFoundation/ForFoundationOnly.h>
3029
#include <CoreFoundation/CFCharacterSetPriv.h>

CoreFoundation/CMakeLists.txt

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,21 @@ add_framework(CoreFoundation
316316
URL.subproj/CFURLComponents.c
317317
URL.subproj/CFURLComponents_URIParser.c
318318
URL.subproj/CFURLSessionInterface.c)
319+
320+
add_framework(CFURLSessionInterface
321+
${FRAMEWORK_LIBRARY_TYPE}
322+
FRAMEWORK_DIRECTORY
323+
CoreFoundation_FRAMEWORK_DIRECTORY
324+
MODULE_MAP
325+
URL.subproj/module.modulemap
326+
PRIVATE_HEADERS
327+
URL.subproj/CFURLSessionInterface.h
328+
PUBLIC_HEADERS
329+
URL.subproj/CFURLSessionInterface.h
330+
SOURCES
331+
URL.subproj/CFURLSessionInterface.c)
332+
add_dependencies(CFURLSessionInterface CoreFoundation)
333+
319334
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
320335
add_library(CoreFoundationResources OBJECT
321336
CoreFoundation.rc)
@@ -337,38 +352,63 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android)
337352
target_compile_definitions(CoreFoundation
338353
PRIVATE
339354
-D_GNU_SOURCE)
355+
target_compile_definitions(CFURLSessionInterface
356+
PRIVATE
357+
-D_GNU_SOURCE)
340358
if(HAVE_SCHED_GETAFFINITY)
341359
target_compile_definitions(CoreFoundation
342360
PRIVATE
343361
-DHAVE_SCHED_GETAFFINITY)
362+
target_compile_definitions(CFURLSessionInterface
363+
PRIVATE
364+
-DHAVE_SCHED_GETAFFINITY)
344365
endif()
345366
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
346367
# NOTE(compnerd) we only support building with the dynamic CRT as using the
347368
# static CRT causes problems for users of the library.
348369
target_compile_definitions(CoreFoundation
349370
PRIVATE
350371
-D_DLL)
372+
target_compile_definitions(CFURLSessionInterface
373+
PRIVATE
374+
-D_DLL)
351375
if(BUILD_SHARED_LIBS)
352376
target_compile_definitions(CoreFoundation
353377
PRIVATE
354378
-D_WINDLL)
379+
target_compile_definitions(CFURLSessionInterface
380+
PRIVATE
381+
-D_WINDLL)
355382
endif()
356383
target_compile_definitions(CoreFoundation
357384
PRIVATE
358385
-DCURL_STATICLIB)
386+
target_compile_definitions(CFURLSessionInterface
387+
PRIVATE
388+
-DCURL_STATICLIB)
359389
endif()
360390
target_compile_definitions(CoreFoundation
361391
PRIVATE
362392
-DU_SHOW_DRAFT_API
363393
-DCF_BUILDING_CF)
394+
target_compile_definitions(CFURLSessionInterface
395+
PRIVATE
396+
-DU_SHOW_DRAFT_API
397+
-DCF_BUILDING_CF)
364398
if(CF_DEPLOYMENT_SWIFT)
365399
target_compile_definitions(CoreFoundation
366400
PRIVATE
367401
-DDEPLOYMENT_RUNTIME_SWIFT)
402+
target_compile_definitions(CFURLSessionInterface
403+
PRIVATE
404+
-DDEPLOYMENT_RUNTIME_SWIFT)
368405
else()
369406
target_compile_definitions(CoreFoundation
370407
PRIVATE
371408
-DDEPLOYMENT_RUNTIME_C)
409+
target_compile_definitions(CFURLSessionInterface
410+
PRIVATE
411+
-DDEPLOYMENT_RUNTIME_C)
372412
endif()
373413
target_compile_definitions(CoreFoundation
374414
PRIVATE
@@ -386,7 +426,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
386426
PRIVATE
387427
${LIBXML2_INCLUDE_DIR})
388428
find_package(CURL REQUIRED)
389-
target_include_directories(CoreFoundation
429+
target_include_directories(CFURLSessionInterface
390430
PRIVATE
391431
${CURL_INCLUDE_DIRS})
392432
find_package(ICU COMPONENTS uc i18n REQUIRED)
@@ -398,27 +438,44 @@ target_include_directories(CoreFoundation
398438
PRIVATE
399439
${CF_PATH_TO_LIBDISPATCH_SOURCE}
400440
${CF_PATH_TO_LIBDISPATCH_BUILD}/tests)
441+
target_include_directories(CFURLSessionInterface
442+
PRIVATE
443+
${CF_PATH_TO_LIBDISPATCH_SOURCE}
444+
${CF_PATH_TO_LIBDISPATCH_BUILD}/tests)
401445
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
402446
target_include_directories(CoreFoundation
403447
SYSTEM PRIVATE
404448
${CF_PATH_TO_LIBDISPATCH_SOURCE}/src/BlocksRuntime)
449+
target_include_directories(CFURLSessionInterface
450+
SYSTEM PRIVATE
451+
${CF_PATH_TO_LIBDISPATCH_SOURCE}/src/BlocksRuntime)
405452
endif()
406453

407454
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
408455
target_compile_options(CoreFoundation
409456
PRIVATE
410457
$<$<COMPILE_LANGUAGE:C>:/FI${PROJECT_SOURCE_DIR}/Base.subproj/CoreFoundation_Prefix.h>)
458+
target_compile_options(CFURLSessionInterface
459+
PRIVATE
460+
$<$<COMPILE_LANGUAGE:C>:/FI${PROJECT_SOURCE_DIR}/Base.subproj/CoreFoundation_Prefix.h>)
411461
else()
412462
target_compile_options(CoreFoundation
413463
PRIVATE
414464
$<$<COMPILE_LANGUAGE:C>:-include;${PROJECT_SOURCE_DIR}/Base.subproj/CoreFoundation_Prefix.h>)
465+
target_compile_options(CFURLSessionInterface
466+
PRIVATE
467+
$<$<COMPILE_LANGUAGE:C>:-include;${PROJECT_SOURCE_DIR}/Base.subproj/CoreFoundation_Prefix.h>)
415468
endif()
416469

417470
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
418471
target_compile_options(CoreFoundation
419472
PRIVATE
420473
-fblocks
421474
/EHsc)
475+
target_compile_options(CFURLSessionInterface
476+
PRIVATE
477+
-fblocks
478+
/EHsc)
422479
else()
423480
target_compile_options(CoreFoundation
424481
PRIVATE
@@ -427,16 +484,29 @@ else()
427484
-fdollars-in-identifiers
428485
-fexceptions
429486
-fno-common)
487+
target_compile_options(CFURLSessionInterface
488+
PRIVATE
489+
-fblocks
490+
-fconstant-cfstrings
491+
-fdollars-in-identifiers
492+
-fexceptions
493+
-fno-common)
430494
endif()
431495
if(CF_DEPLOYMENT_SWIFT)
432496
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
433497
target_compile_options(CoreFoundation
434498
PRIVATE
435499
/clang:-fcf-runtime-abi=swift)
500+
target_compile_options(CFURLSessionInterface
501+
PRIVATE
502+
/clang:-fcf-runtime-abi=swift)
436503
else()
437504
target_compile_options(CoreFoundation
438505
PRIVATE
439506
-fcf-runtime-abi=swift)
507+
target_compile_options(CFURLSessionInterface
508+
PRIVATE
509+
-fcf-runtime-abi=swift)
440510
endif()
441511
endif()
442512

@@ -450,12 +520,24 @@ target_compile_options(CoreFoundation
450520
-Wno-int-conversion
451521
-Wno-unused-function
452522
-Wno-microsoft-enum-forward-reference)
523+
target_compile_options(CFURLSessionInterface
524+
PRIVATE
525+
-Wno-shorten-64-to-32
526+
-Wno-deprecated-declarations
527+
-Wno-unreachable-code
528+
-Wno-conditional-uninitialized
529+
-Wno-unused-variable
530+
-Wno-int-conversion
531+
-Wno-unused-function
532+
-Wno-microsoft-enum-forward-reference)
453533

454534
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
455535
target_link_libraries(CoreFoundation
456536
PRIVATE
457-
${CURL_LIBRARIES}
458537
${LIBXML2_LIBRARIES})
538+
target_link_libraries(CFURLSessionInterface
539+
PRIVATE
540+
${CURL_LIBRARIES})
459541
endif()
460542
if(CMAKE_SYSTEM_NAME STREQUAL Android)
461543
target_link_libraries(CoreFoundation
@@ -473,26 +555,42 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
473555
Secur32
474556
User32
475557
mincore)
558+
target_link_libraries(CFURLSessionInterface
559+
PRIVATE
560+
AdvAPI32
561+
Secur32
562+
User32
563+
mincore)
476564
endif()
477565
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
478566
target_link_libraries(CoreFoundation
479567
PRIVATE
480568
m)
569+
target_link_libraries(CFURLSessionInterface
570+
PRIVATE
571+
m)
481572
endif()
482573
target_link_libraries(CoreFoundation
483574
PRIVATE
484575
dispatch)
576+
target_link_libraries(CFURLSessionInterface
577+
PRIVATE
578+
dispatch)
485579
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
486580
target_link_libraries(CoreFoundation
487581
PRIVATE
488582
icucore)
583+
target_link_libraries(CFURLSessionInterface
584+
PRIVATE
585+
icucore)
489586
set_target_properties(CoreFoundation
490587
PROPERTIES LINK_FLAGS
491588
-Xlinker;-alias_list;-Xlinker;Base.subproj/DarwinSymbolAliases;-twolevel_namespace;-sectcreate;__UNICODE;__csbitmaps;CharacterSets/CFCharacterSetBitmaps.bitmap;-sectcreate;__UNICODE;__properties;CharacterSets/CFUniCharPropertyDatabase.data;-sectcreate;__UNICODE;__data;CharacterSets/CFUnicodeData-L.mapping;-segprot;__UNICODE;r;r)
492589
endif()
493590

494591
install(TARGETS
495592
CoreFoundation
593+
CFURLSessionInterface
496594
DESTINATION
497595
"${CMAKE_INSTALL_FULL_LIBDIR}")
498596
install(DIRECTORY

0 commit comments

Comments
 (0)