Skip to content

[CMake] Add missing SDK overlay dependencies. #3799

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
Jul 27, 2016
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
1 change: 1 addition & 0 deletions stdlib/public/SDK/AVFoundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ add_swift_library(swiftAVFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_
AVFoundation.swift
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
SWIFT_MODULE_DEPENDS Foundation CoreMedia
SWIFT_MODULE_DEPENDS_OSX AppKit
FRAMEWORK_DEPENDS AVFoundation)
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Intents/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ add_swift_library(swiftIntents ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_O
INTemperature.swift

TARGET_SDKS OSX IOS IOS_SIMULATOR
SWIFT_MODULE_DEPENDS Foundation
SWIFT_MODULE_DEPENDS Foundation CoreLocation
SWIFT_MODULE_DEPENDS_OSX AppKit
SWIFT_MODULE_DEPENDS_IOS UIKit
FRAMEWORK_DEPENDS_WEAK Intents)
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Photos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ add_swift_library(swiftPhotos ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OV

TARGET_SDKS IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
SWIFT_MODULE_DEPENDS Foundation CoreLocation CoreImage CoreMedia
SWIFT_MODULE_DEPENDS_IOS UIKit
SWIFT_MODULE_DEPENDS_TVOS UIKit
SWIFT_MODULE_DEPENDS_IOS UIKit AVFoundation
SWIFT_MODULE_DEPENDS_TVOS UIKit AVFoundation
FRAMEWORK_DEPENDS Photos)

3 changes: 2 additions & 1 deletion stdlib/public/SDK/WatchKit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
add_swift_library(swiftWatchKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
WatchKit.swift
TARGET_SDKS IOS IOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR
SWIFT_MODULE_DEPENDS Foundation UIKit CoreGraphics SceneKit
SWIFT_MODULE_DEPENDS Foundation UIKit CoreGraphics
SWIFT_MODULE_DEPENDS_WATCHOS HomeKit SceneKit
FRAMEWORK_DEPENDS_WEAK WatchKit
SWIFT_COMPILE_FLAGS_WATCHOS -Xfrontend -disable-autolink-framework -Xfrontend CoreText
)
52 changes: 52 additions & 0 deletions utils/find-overlay-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env zsh
#===--- find-overlay-dependencies.sh - ...by looking at imported headers ---===#
#
## This source file is part of the Swift.org open source project
##
## Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
## Licensed under Apache License v2.0 with Runtime Library Exception
##
## See http://swift.org/LICENSE.txt for license information
## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
#===------------------------------------------------------------------------===#

# This script uses zsh for its associative array support, because it is only
# intended to be run on macOS and macOS bash is very old.

if [[ $# -ne 1 ]]; then
echo 'usage:' $0 '<module-name>' >&2
exit 1
fi

OVERLAYS_PATH=$(dirname "$0")/../stdlib/public/SDK/

typeset -A CUSTOM_NAMED_MODULES
CUSTOM_NAMED_MODULES[ObjectiveC]=objc
CUSTOM_NAMED_MODULES[Dispatch]=dispatch
CUSTOM_NAMED_MODULES[XPC]=xpc

ALL_OVERLAYS=()
for overlay in $(ls "$OVERLAYS_PATH"); do
ALL_OVERLAYS+=${CUSTOM_NAMED_MODULES[$overlay]-$overlay}
done

typeset -A SDKS
SDKS[macosx]=x86_64
SDKS[iphoneos]=arm64
SDKS[appletvos]=arm64
SDKS[watchos]=armv7k

for sdk in ${(k)SDKS}; do
arch=$SDKS[$sdk]
printf "%s:\n\t" "$sdk"
deps=$(echo "@import $1;" | xcrun -sdk $sdk clang -arch $arch -x objective-c - -M -fmodules 2>/dev/null)
for overlay in $ALL_OVERLAYS; do
(echo "$deps" |
egrep -v 'module.(module)?map' |
egrep -v "\b${CUSTOM_NAMED_MODULES[$1]-$1}\b" |
egrep -q "\b$overlay\b") &&
printf "%s " $overlay
done
echo # newline
done