From d93238edd63e94d4cff169659142398fcf2551aa Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Tue, 11 Aug 2020 10:39:20 -0700 Subject: [PATCH] Update dump_toolchains to support home dir (#471) Before: ``` swift-DEVELOPMENT-SNAPSHOT-2020-01-29-a.xctoolchain -> org.swift.50202001291a swift-TEST-SNAPSHOT-2020-01-23-a.xctoolchain -> org.swift.50202001231a swift-latest.xctoolchain -> org.swift.50202001291a ``` After: ``` /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-01-29-a.xctoolchain -> org.swift.50202001291a /Library/Developer/Toolchains/swift-TEST-SNAPSHOT-2020-01-23-a.xctoolchain -> org.swift.50202001231a /Library/Developer/Toolchains/swift-latest.xctoolchain -> org.swift.50202001291a /Users/ksmiley/Library/Developer/Toolchains/swift-5.2-DEVELOPMENT-SNAPSHOT-2020-04-28-a.xctoolchain -> org.swift.52202004281a /Users/ksmiley/Library/Developer/Toolchains/swift-latest.xctoolchain -> org.swift.52202004281a ``` --- tools/dump_toolchains/dump_toolchains.sh | 29 ++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tools/dump_toolchains/dump_toolchains.sh b/tools/dump_toolchains/dump_toolchains.sh index 18f008211..9a97fc793 100755 --- a/tools/dump_toolchains/dump_toolchains.sh +++ b/tools/dump_toolchains/dump_toolchains.sh @@ -21,22 +21,23 @@ if [[ "$(uname)" != Darwin ]]; then exit 1 fi -toolchain_directory=/Library/Developer/Toolchains -if [[ ! -d "$toolchain_directory" ]]; then - echo "error: '$toolchain_directory' doesn't exist" - exit 1 -fi +readonly toolchain_directories=( + /Library/Developer/Toolchains + ~/Library/Developer/Toolchains +) -for toolchain in "$toolchain_directory"/*.xctoolchain +for toolchain_directory in "${toolchain_directories[@]}" do - plist_path="$toolchain/Info.plist" + for toolchain in "$toolchain_directory"/*.xctoolchain + do + plist_path="$toolchain/Info.plist" - if [[ ! -f "$plist_path" ]]; then - echo "error: '$toolchain' is missing Info.plist" - exit 1 - fi + if [[ ! -f "$plist_path" ]]; then + echo "error: '$toolchain' is missing Info.plist" + exit 1 + fi - bundle_id=$(/usr/libexec/PlistBuddy -c "print :CFBundleIdentifier" "$plist_path") - toolchain_name=$(basename "$toolchain") - echo "$toolchain_name -> $bundle_id" + bundle_id=$(/usr/libexec/PlistBuddy -c "print :CFBundleIdentifier" "$plist_path") + echo "$toolchain -> $bundle_id" + done done