-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Generate overlay dependencies with utils/find-overlay-dependencies.sh
#5017
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ add_swift_library(swiftCoreGraphics ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_ | |
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}" | ||
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" | ||
SWIFT_MODULE_DEPENDS ObjectiveC Dispatch Darwin | ||
SWIFT_MODULE_DEPENDS_OSX IOKit XPC | ||
SWIFT_MODULE_DEPENDS_OSX Dispatch IOKit ObjectiveC os | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one should probably have _IOS, _TVOS, _WATCHOS entries too. Maybe the script should complain if there's no entry for a particular SDK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am going off of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lack of TARGET_SDKS means all four Apple platforms (plus simulators). |
||
FRAMEWORK_DEPENDS CoreGraphics) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
SET(SWIFT_SCENEKIT_DEPENDENCIES_NON_WATCHOS | ||
Foundation | ||
GLKit | ||
simd | ||
CoreImage) | ||
|
||
add_swift_library(swiftSceneKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY | ||
SceneKit.swift.gyb | ||
Thunks.mm | ||
|
||
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}" | ||
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" | ||
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR | ||
SWIFT_MODULE_DEPENDS_OSX ${SWIFT_SCENEKIT_DEPENDENCIES_NON_WATCHOS} AppKit | ||
SWIFT_MODULE_DEPENDS_IOS ${SWIFT_SCENEKIT_DEPENDENCIES_NON_WATCHOS} UIKit | ||
SWIFT_MODULE_DEPENDS_TVOS ${SWIFT_SCENEKIT_DEPENDENCIES_NON_WATCHOS} UIKit | ||
SWIFT_MODULE_DEPENDS_OSX AppKit CoreData CoreGraphics CoreImage Dispatch Foundation GLKit IOKit ObjectiveC os QuartzCore simd XPC | ||
SWIFT_MODULE_DEPENDS_IOS CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC os QuartzCore simd UIKit | ||
SWIFT_MODULE_DEPENDS_TVOS CoreGraphics CoreImage Dispatch Foundation GLKit ObjectiveC os QuartzCore simd UIKit | ||
SWIFT_MODULE_DEPENDS_WATCHOS CoreGraphics Dispatch Foundation ObjectiveC os simd | ||
SWIFT_MODULE_DEPENDS Foundation simd | ||
FRAMEWORK_DEPENDS_WEAK SceneKit) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
#===--- find-overlay-dependencies-loop.sh - driver for find-overlay-dependency.sh---===# | ||
# | ||
## This source file is part of the Swift.org open source project | ||
## | ||
## Copyright (c) 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 | ||
# | ||
#===------------------------------------------------------------------------===# | ||
|
||
SCRIPT="$(dirname "$0")/find-overlay-dependencies.sh" | ||
|
||
# `update` edits the cmake file in-place; `print` just prints to console | ||
function usage() { | ||
echo 'usage:' $0 'update|print' >&2 | ||
exit 1 | ||
} | ||
|
||
case $# in | ||
1) if [[ $1 != 'update' && $1 != 'print' ]]; then | ||
usage | ||
fi ;; | ||
*) | ||
usage ;; | ||
esac | ||
|
||
# Don't update XCTest | ||
for overlay in $(find ./stdlib/public/SDK/ -depth 1 -type d ! -name XCTest -exec basename \{\} \;); do | ||
$SCRIPT $overlay $1 | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,39 +14,70 @@ | |
# 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 | ||
function usage() { | ||
echo 'usage:' $0 '<module-name> [update|print]' >&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
# `update` edits the cmake file in-place; `print` just prints to console | ||
UPDATE_CMAKE=0 | ||
case $# in | ||
1) ;; | ||
2) if [[ $2 == 'update' ]]; then | ||
UPDATE_CMAKE=1 | ||
elif [[ $2 != 'print' ]]; then | ||
usage | ||
fi ;; | ||
*) | ||
usage ;; | ||
esac | ||
|
||
OVERLAYS_PATH=$(dirname "$0")/../stdlib/public/SDK/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be consistent with the |
||
CMAKE_PATH=$OVERLAYS_PATH/$1/CMakeLists.txt | ||
|
||
# Add both directions to associative array | ||
typeset -A CUSTOM_NAMED_MODULES | ||
CUSTOM_NAMED_MODULES[ObjectiveC]=objc | ||
CUSTOM_NAMED_MODULES[objc]=ObjectiveC | ||
CUSTOM_NAMED_MODULES[Dispatch]=dispatch | ||
CUSTOM_NAMED_MODULES[dispatch]=Dispatch | ||
CUSTOM_NAMED_MODULES[XPC]=xpc | ||
CUSTOM_NAMED_MODULES[xpc]=XPC | ||
|
||
# Exclude XCTest/ and CMakeLists.txt | ||
ALL_OVERLAYS=() | ||
for overlay in $(ls "$OVERLAYS_PATH"); do | ||
for overlay in $(find "$OVERLAYS_PATH" -depth 1 -type d ! -name XCTest -exec basename \{\} \;); 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 | ||
SDKS[macosx]="x86_64" | ||
SDKS[iphoneos]="arm64" | ||
SDKS[appletvos]="arm64" | ||
SDKS[watchos]="armv7k" | ||
|
||
typeset -A CMAKE_DEPENDS_NAME | ||
CMAKE_DEPENDS_NAME[macosx]="SWIFT_MODULE_DEPENDS_OSX" | ||
CMAKE_DEPENDS_NAME[iphoneos]="SWIFT_MODULE_DEPENDS_IOS" | ||
CMAKE_DEPENDS_NAME[appletvos]="SWIFT_MODULE_DEPENDS_TVOS" | ||
CMAKE_DEPENDS_NAME[watchos]="SWIFT_MODULE_DEPENDS_WATCHOS" | ||
|
||
echo $1 | ||
for sdk in ${(k)SDKS}; do | ||
arch=$SDKS[$sdk] | ||
DEPENDS_ON=() | ||
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 | ||
DEPENDS_ON+=${CUSTOM_NAMED_MODULES[$overlay]-$overlay} | ||
done | ||
echo # newline | ||
echo " $DEPENDS_ON" | ||
if [[ $UPDATE_CMAKE == 1 ]]; then | ||
perl -pi -e "s/^ $CMAKE_DEPENDS_NAME[$sdk].*$/ $CMAKE_DEPENDS_NAME[$sdk] $DEPENDS_ON/" $CMAKE_PATH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: can you use sed instead of perl? One fewer dependency, even if Perl is installed on most systems by default now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was using http://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux
Basically it works but creates extra files like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to be portable to Linux for this; only Darwin platforms have a modularized SDK anyway. |
||
fi | ||
done | ||
echo # newline |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we drop the non-OS-specific lines now that it's explicit for every OS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could go either way on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is used all over in
stdlib/private
and I'm only changing thepublic
directory for now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the lines should either be autogenerated (and have a comment saying such) or should contain manual dependencies. Doing both is odd.