-
-
Save asenchenkov/04a1e7584306a0436ff16488c9444530 to your computer and use it in GitHub Desktop.
Скрипт загрузки Carthage зависимостей (кэша)
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
#!/bin/sh | |
set -e | |
# Считываем опциональные параметры (флаги) | |
while [[ $# -gt 0 ]]; do | |
case $1 in | |
-c|--clean) | |
clean="$2" | |
shift # past argument | |
shift # past value | |
;; | |
-*|--*) | |
echo "Unknown option $1" | |
exit 1 | |
;; | |
*) | |
esac | |
done | |
# Get cache_prefix - получаем префикс для нашего кэша (чтобы хранить кэш для нужного xcode и toolchain) | |
echo 'Create prefix' | |
version=$(./carthage_cache_prefix.sh) | |
cache_prefix="$version" | |
[ $? -eq 0 ] && echo "Success generate prefix" || exit 1 | |
# Download cache with rome - качаем кэш для Carthage (выше мы сделали checkout), чтобы не пересобирать зависимости, которые уже итак есть. | |
echo 'Download cache with rome' | |
./rome download --concurrently --use-xcframeworks --cache-prefix $cache_prefix | |
[ $? -eq 0 ] && echo "Success download rome cache" || exit 1 | |
# Если передали флаг - чистим кэш (используется CI для чистых сборок) | |
if [[ "$clean" == "all" ]] || [[ "$clean" == "before" ]]; then | |
echo "Clean cache before build" | |
rm -rf ~/Library/Developer/Xcode/DerivedData/ | |
rm -rf ~/Library/Caches/org.carthage.CarthageKit/DerivedData | |
else | |
echo "No clean before build" | |
fi | |
# Валидируем скачиваемый кэш | |
echo 'Start validate carthage downloaded cache' | |
cache_validator=$(./carthage-cache-validator.swift) | |
if [[ $cache_validator == *"true"* ]]; then | |
echo "Downloaded cache is valid" | |
else | |
echo "Downloaded cache is not valid. Checkout carthage" | |
./tools/Carthage/carthagebin checkout # Если кэш не валиден, то делаем checkout, чтобы ниже build смог пересобрать зависимости | |
fi | |
# Build missing frameworks - теперь собираем наш carthage c учетом скачанного кэша | |
echo 'Build missing framework' | |
./tools/Carthage/carthagebin build --platform iOS --cache-builds --no-use-binaries --verbose --use-xcframeworks | |
[ $? -eq 0 ] && echo "Success build" || exit 1 | |
# Generate romefile - генерируем новый Romefile, если были изменения в Cartfile, то Romefile перестроится | |
echo 'Generate romefile' | |
./romefile-builder.swift | |
[ $? -eq 0 ] && echo "Success build Romefile" || exit 1 | |
# Generate carthage config если дошли до сюда, значит все закачалось и можно обновить конфиг файл (вдруг делали rebase и были изменения) | |
echo 'Create carthage cache config' | |
./carthage-cache-config-builder.swift | |
[ $? -eq 0 ] && echo "Success build carthage cache config" || exit 1 | |
if [[ "$clean" == "all" ]] || [[ "$clean" == "after" ]]; then | |
echo "Clean cache after build" | |
rm -rf ~/Library/Developer/Xcode/DerivedData/ | |
rm -rf ~/Library/Caches/org.carthage.CarthageKit/DerivedData | |
else | |
echo "No clean after build" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment