Skip to content

Commit 7792d4c

Browse files
committed
[utils] find-overlay-dependencies: reduce noise
- Don’t special-case Foundation. - Don’t update files if the only change is in the ordering. - Match for a space after CMAKE_DEPENDS_NAME.
1 parent 1f2d044 commit 7792d4c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

utils/find-overlay-dependencies.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ for sdk in $SDKS_ORDERED; do
7474
# Clear the cmake file of this unsupported platform and loop
7575
echo "unsupported"
7676
# Disable the unsupported platform and leave a note
77-
sed -i "" -E -e "s/^([ \t]*)($CMAKE_DEPENDS_NAME[$sdk]).*$/\1# \2 # unsupported platform/" "$CMAKE_PATH"
77+
sed -i "" -E -e "s/^([ \t]*)($CMAKE_DEPENDS_NAME[$sdk]) .*$/\1# \2 # unsupported platform/" "$CMAKE_PATH"
7878
continue
7979
fi
8080

@@ -93,16 +93,17 @@ for sdk in $SDKS_ORDERED; do
9393
DEPENDS_ON=("${(@)DEPENDS_ON:#XPC}")
9494
fi
9595

96-
# Foundation depends on CoreGraphics in the .swift code.
97-
# Hardcode the dependency.
98-
if [[ "$1" == "Foundation" ]]; then
99-
DEPENDS_ON+="CoreGraphics"
100-
fi
101-
102-
10396
echo "$DEPENDS_ON"
10497
if [[ $UPDATE_CMAKE == 1 ]]; then
105-
sed -i "" -E -e "s/^([ \t]*$CMAKE_DEPENDS_NAME[$sdk]).*$/\1 $DEPENDS_ON # auto-updated/" "$CMAKE_PATH"
98+
# Get existing list; only update if there is a difference.
99+
orig="$(sed -E -n -e "s/^([ \t]*$CMAKE_DEPENDS_NAME[$sdk]) ([^#]*)(#.*)?$/\2/p" "$CMAKE_PATH" | sed 's/ *$//')"
100+
if [ -z "$orig" ]; then
101+
echo "\twarning: Cannot find $CMAKE_DEPENDS_NAME[$sdk] declaration"
102+
fi
103+
diff="$(echo "$orig" "$DEPENDS_ON" | tr ' ' '\n' | sort | uniq -u)"
104+
if [ -n "$diff" ]; then
105+
sed -i "" -E -e "s/^([ \t]*$CMAKE_DEPENDS_NAME[$sdk]) .*$/\1 $DEPENDS_ON # auto-updated/" "$CMAKE_PATH"
106+
fi
106107
fi
107108
done
108109
echo # newline

0 commit comments

Comments
 (0)