Skip to content

Commit

Permalink
Update Build Podspec & Dependencies Script with weissi's Updates (app…
Browse files Browse the repository at this point in the history
…le#189)

Co-authored-by: Jake Prickett <[email protected]>
  • Loading branch information
Jake-Prickett and jpricke1-ford authored Mar 3, 2020
1 parent 780e3a2 commit 0841f64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions scripts/build_podspec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ tmpdir=$(mktemp -d /tmp/.build_podspecsXXXXXX)

echo "Building podspec in $tmpdir"

# We only want to generate Podspec files for the two targets
targets=( "SwiftNIOHPACK" "SwiftNIOHTTP2" )
targets=( $("${here}/list_topsorted_dependencies.sh" -l -r | sed 's/^NIO/SwiftNIO/') )

for target in "${targets[@]}"; do

Expand Down
16 changes: 9 additions & 7 deletions scripts/list_topsorted_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function usage() {
echo "OPTIONS:"
echo " -l: Only dependencies of library targets"
echo " -r: Reverse the output"
echo " -d <PACKAGE>: Prints the dependencies of the given package"
echo " -d <PACKAGE>: Prints the dependencies of the given module"
}

function tac_compat() {
Expand All @@ -34,7 +34,7 @@ tmpfile=$(mktemp /tmp/.list_topsorted_dependencies_XXXXXX)

only_libs=false
do_reversed=false
package_dependency=""
module_dependency=""
while getopts "lrd:" opt; do
case $opt in
l)
Expand All @@ -44,7 +44,7 @@ while getopts "lrd:" opt; do
do_reversed=true
;;
d)
package_dependency="$OPTARG"
module_dependency="$OPTARG"
;;
\?)
usage
Expand All @@ -58,24 +58,26 @@ if $do_reversed; then
transform=tac_compat
fi

if [[ ! -z "$package_dependency" ]]; then
if [[ ! -z "$module_dependency" ]]; then
swift package dump-package | jq -r ".targets |
map(select(.name == \"$package_dependency\" and .type == \"regular\") | .dependencies | map(.byName | first)) | .[] | .[]"
map(select(.name == \"$module_dependency\" and .type == \"regular\") | .dependencies | map(.byName | first)) | .[] | .[]"
exit 0
fi

(
cd "$here/.."
if $only_libs; then
find Sources -name 'main.swift' | cut -d/ -f2 >> "$tmpfile"
swift package dump-package | jq '.products |
map(select(.type | has("library") | not)) |
map(.name) | .[]' | tr -d '"' \
>> "$tmpfile"
fi
swift package dump-package | jq '.targets |
map (.name) as $names |
map(.name as $name |
select(.name == $name and .type == "regular") |
{ "\($name)": .dependencies | map(.byName | first) } ) |
{ "\($name)": .dependencies | map(.byName | first) | map(. as $current | $names | map(select($current == .))) | flatten } ) |
map(to_entries[]) |
map("\(.key) \(.value | .[])") |
.[]' | \
Expand All @@ -87,4 +89,4 @@ swift package dump-package | jq '.targets |
done
)

rm "$tmpfile"
rm "$tmpfile"

0 comments on commit 0841f64

Please sign in to comment.