Forked from wakinchan/generate-target-dependencies.sh
Created
January 25, 2024 15:53
-
-
Save tahirmt/3d15a86b07ee125f1ce99072ca1f3240 to your computer and use it in GitHub Desktop.
Generate Target Dependencies for Package.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# usage: sh ./generate-target-dependencies.sh | dot -Tsvg -o target-graph.svg | |
packages=`swift package describe --type json` | |
targets=`echo $packages | jq '.targets'` | |
target_names=`echo $targets | jq -r '.[] | .name'` | |
body="" | |
template=`cat <<EOF | |
digraph DependenciesGraph { | |
node [shape = box] | |
%BODY% | |
} | |
` | |
for target_name in `echo $target_names`; do | |
label='"'$target_name'" [label="'$target_name'"]' | |
body+="$label\n" | |
target_dependencies=`echo $targets | jq -r '.[] | select(.name == "'$target_name'") | select(.target_dependencies != null) | .target_dependencies | .[]'` | |
for target_dependency in `echo $target_dependencies`; do | |
target='"'$target_name'" -> "'$target_dependency'"' | |
body+="$target\n" | |
done | |
done | |
echo "$template" | sed -e 's/%BODY%/'"$body"'/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment