Skip to content

[stubs] Update CMake to use TARGET_SDKS (NFC) #5002

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
Sep 29, 2016
Merged
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
56 changes: 32 additions & 24 deletions stdlib/public/stubs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
set(swift_stubs_objc_sources)
set(swift_stubs_unicode_normalization_sources)
set(swift_stubs_sources
Copy link
Contributor

@gottesmm gottesmm Sep 25, 2016

Choose a reason for hiding this comment

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

Can you add comments for each group of these sources. Maybe saying something like:

// Platform Independent Sources
set(swift_stubs_platform_independent_sources ...)

// Darwin Only ObjC Sources. This consists of objective-c related stubs.
...

// Sources for Android, Cygwin, FreeBSD, Linux. This consists currently of just ICU sources. [[INSERT EXPLANATION OF WHY WE DO NOT DO THIS ON DARWIN]].
...

I forgot the story with ICU on Darwin, but IIRC @aschwaighofer knows. Arnold, do you remember.

Copy link
Contributor

Choose a reason for hiding this comment

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

On Darwin we don't use ICU for String functions (hashing, comparison) but call to Foundation's NSString/CFString functions. On non-darwin platforms we call to ICU for this functionality.
The stubs for calling to ICU are in UnicodeNormalization.cpp.

Assert.cpp
CommandLine.cpp
GlobalObjects.cpp
LibcShims.cpp
Stubs.cpp
UnicodeExtendedGraphemeClusters.cpp.gyb)
set(swift_stubs_objc_sources
Availability.mm
DispatchShims.mm
FoundationHelpers.mm
OptionalBridgingHelper.mm
Reflection.mm
SwiftNativeNSXXXBase.mm.gyb)
set(swift_stubs_unicode_normalization_sources
UnicodeNormalization.cpp)
set(LLVM_OPTIONAL_SOURCES
Copy link
Contributor

@gottesmm gottesmm Sep 25, 2016

Choose a reason for hiding this comment

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

Isn't LLVM_OPTIONAL_SOURCES dead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing this results in a CMake error, so I don't think so.

${swift_stubs_objc_sources}
${swift_stubs_unicode_normalization_sources})

if(SWIFT_HOST_VARIANT MATCHES "${SWIFT_DARWIN_VARIANTS}")
set(swift_stubs_objc_sources
Availability.mm
DispatchShims.mm
FoundationHelpers.mm
OptionalBridgingHelper.mm
Reflection.mm
SwiftNativeNSXXXBase.mm.gyb)
set(LLVM_OPTIONAL_SOURCES
UnicodeNormalization.cpp)
else()
find_package(ICU REQUIRED COMPONENTS uc i18n)
set(swift_stubs_unicode_normalization_sources
UnicodeNormalization.cpp)
endif()
set(swift_stubs_c_compile_flags ${SWIFT_RUNTIME_CORE_CXX_FLAGS})
list(APPEND swift_stubs_c_compile_flags -DswiftCore_EXPORTS)

add_swift_library(swiftStdlibStubs OBJECT_LIBRARY TARGET_LIBRARY
Assert.cpp
CommandLine.cpp
GlobalObjects.cpp
LibcShims.cpp
Stubs.cpp
UnicodeExtendedGraphemeClusters.cpp.gyb
${swift_stubs_sources}
${swift_stubs_objc_sources}
C_COMPILE_FLAGS ${swift_stubs_c_compile_flags}
LINK_FLAGS ${SWIFT_RUNTIME_CORE_LINK_FLAGS}
TARGET_SDKS ALL_APPLE_PLATFORMS
INSTALL_IN_COMPONENT stdlib)

add_swift_library(swiftStdlibStubs OBJECT_LIBRARY TARGET_LIBRARY
${swift_stubs_sources}
${swift_stubs_unicode_normalization_sources}
C_COMPILE_FLAGS ${SWIFT_RUNTIME_CORE_CXX_FLAGS} -DswiftCore_EXPORTS
C_COMPILE_FLAGS ${swift_stubs_c_compile_flags}
LINK_FLAGS ${SWIFT_RUNTIME_CORE_LINK_FLAGS}
LINK_LIBRARIES ${ICU_UC_LIBRARY} ${ICU_I18N_LIBRARY}
TARGET_SDKS ANDROID CYGWIN FREEBSD LINUX
INSTALL_IN_COMPONENT stdlib)