blob: 78e0b66016446b1cafb8dffc7e8dab60bbfe62ce [file] [log] [blame] [edit]
#!/bin/bash
# Script to download kotlin native compiler prebuilts. It builds the URLs
# same as the NativeCompilerDownloader class in the Kotlin repository.
#
# ./download-native-compiler-prebuilts.sh <kotlinVersion>"
#
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
function usage {
echo "$1"
echo "Usage: ./download-native-compiler-prebuilts.sh <kotlinVersion>"
exit 1
}
KOTLIN_VERSION=$1
if [ -z $KOTLIN_VERSION ]; then
usage "Must pass kotlin version as the first argument"
fi
META_VERSION="releases"
BASE_URL="https://download.jetbrains.com/kotlin/native/builds/${META_VERSION}"
LOCAL_PATH="${SCRIPT_DIR}/nativeCompilerPrebuilts/${META_VERSION}"
function downloadPrebuilt {
local platformName=$1
local fileName="kotlin-native-prebuilt-${platformName}-${KOTLIN_VERSION}.tar.gz"
local path="${KOTLIN_VERSION}/${platformName}"
local remoteUrl="${BASE_URL}/${path}/${fileName}"
local targetFolder="${LOCAL_PATH}/${path}"
local targetFile="${targetFolder}/${fileName}"
if test -f "$targetFile"; then
echo "File exists, skipping download for $targetFile"
else
echo "Will download $remoteUrl into $targetFile"
(mkdir -p $targetFolder && cd $targetFolder && curl -OL $remoteUrl)
fi
}
# these are the host platforms where we support building KMP
for PLATFORM_NAME in "linux-x86_64" "macos-aarch64" "macos-x86_64"
do
downloadPrebuilt $PLATFORM_NAME
done