Skip to content

Commit 4b0b325

Browse files
authored
[CMake] Add missing SDK overlay dependencies. (#3799)
...plus the hacked-up tool I used to find them.
1 parent d050a21 commit 4b0b325

File tree

5 files changed

+58
-4
lines changed

5 files changed

+58
-4
lines changed

stdlib/public/SDK/AVFoundation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ add_swift_library(swiftAVFoundation ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_
22
AVFoundation.swift
33
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
44
SWIFT_MODULE_DEPENDS Foundation CoreMedia
5+
SWIFT_MODULE_DEPENDS_OSX AppKit
56
FRAMEWORK_DEPENDS AVFoundation)

stdlib/public/SDK/Intents/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ add_swift_library(swiftIntents ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_O
1717
INTemperature.swift
1818

1919
TARGET_SDKS OSX IOS IOS_SIMULATOR
20-
SWIFT_MODULE_DEPENDS Foundation
20+
SWIFT_MODULE_DEPENDS Foundation CoreLocation
2121
SWIFT_MODULE_DEPENDS_OSX AppKit
2222
SWIFT_MODULE_DEPENDS_IOS UIKit
2323
FRAMEWORK_DEPENDS_WEAK Intents)

stdlib/public/SDK/Photos/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ add_swift_library(swiftPhotos ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OV
33

44
TARGET_SDKS IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
55
SWIFT_MODULE_DEPENDS Foundation CoreLocation CoreImage CoreMedia
6-
SWIFT_MODULE_DEPENDS_IOS UIKit
7-
SWIFT_MODULE_DEPENDS_TVOS UIKit
6+
SWIFT_MODULE_DEPENDS_IOS UIKit AVFoundation
7+
SWIFT_MODULE_DEPENDS_TVOS UIKit AVFoundation
88
FRAMEWORK_DEPENDS Photos)
99

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
add_swift_library(swiftWatchKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
22
WatchKit.swift
33
TARGET_SDKS IOS IOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR
4-
SWIFT_MODULE_DEPENDS Foundation UIKit CoreGraphics SceneKit
4+
SWIFT_MODULE_DEPENDS Foundation UIKit CoreGraphics
5+
SWIFT_MODULE_DEPENDS_WATCHOS HomeKit SceneKit
56
FRAMEWORK_DEPENDS_WEAK WatchKit
67
SWIFT_COMPILE_FLAGS_WATCHOS -Xfrontend -disable-autolink-framework -Xfrontend CoreText
78
)

utils/find-overlay-dependencies.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env zsh
2+
#===--- find-overlay-dependencies.sh - ...by looking at imported headers ---===#
3+
#
4+
## This source file is part of the Swift.org open source project
5+
##
6+
## Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
7+
## Licensed under Apache License v2.0 with Runtime Library Exception
8+
##
9+
## See http://swift.org/LICENSE.txt for license information
10+
## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
11+
#
12+
#===------------------------------------------------------------------------===#
13+
14+
# This script uses zsh for its associative array support, because it is only
15+
# intended to be run on macOS and macOS bash is very old.
16+
17+
if [[ $# -ne 1 ]]; then
18+
echo 'usage:' $0 '<module-name>' >&2
19+
exit 1
20+
fi
21+
22+
OVERLAYS_PATH=$(dirname "$0")/../stdlib/public/SDK/
23+
24+
typeset -A CUSTOM_NAMED_MODULES
25+
CUSTOM_NAMED_MODULES[ObjectiveC]=objc
26+
CUSTOM_NAMED_MODULES[Dispatch]=dispatch
27+
CUSTOM_NAMED_MODULES[XPC]=xpc
28+
29+
ALL_OVERLAYS=()
30+
for overlay in $(ls "$OVERLAYS_PATH"); do
31+
ALL_OVERLAYS+=${CUSTOM_NAMED_MODULES[$overlay]-$overlay}
32+
done
33+
34+
typeset -A SDKS
35+
SDKS[macosx]=x86_64
36+
SDKS[iphoneos]=arm64
37+
SDKS[appletvos]=arm64
38+
SDKS[watchos]=armv7k
39+
40+
for sdk in ${(k)SDKS}; do
41+
arch=$SDKS[$sdk]
42+
printf "%s:\n\t" "$sdk"
43+
deps=$(echo "@import $1;" | xcrun -sdk $sdk clang -arch $arch -x objective-c - -M -fmodules 2>/dev/null)
44+
for overlay in $ALL_OVERLAYS; do
45+
(echo "$deps" |
46+
egrep -v 'module.(module)?map' |
47+
egrep -v "\b${CUSTOM_NAMED_MODULES[$1]-$1}\b" |
48+
egrep -q "\b$overlay\b") &&
49+
printf "%s " $overlay
50+
done
51+
echo # newline
52+
done

0 commit comments

Comments
 (0)