blob: dc8585a82d7906b2ea453139ebcc254d88b6dc45 [file] [log] [blame]
#!/bin/bash
# This script extracts updated native libraries form the prebuilt file.
# Our build machines tend to have old native libraries, hence we cannot
# run KMP native compiler on them. This script uses the KMP prebuilts which
# have the versions KMP compiler requires.
#
# The mapping of kotlin version to tar archieve is kept in linux-prebuilts.properties
# file which is created by the KonanPrebuiltsDownloader script (importMaven)
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
function usage {
echo "Error: $1"
echo "Usage: ./copy-linux-sysroot.sh --kotlin-version <kotlin-version> --target-dir <out-libs-dir>
Arguments:
--kotlin-version: The kotlin version to use.
--target-dir: The directory into which the native libraries will be exported.
"
exit 1
}
SET_LIBRARY_PATH=false
while [ $# -gt 0 ]; do
case $1 in
-h|"-?")
usage "Help:"
;;
--kotlin-version)
KOTLIN_VERSION=$2
shift
;;
--target-dir)
SYSROOT_LIBS_TARGET=$2
shift
;;
*)
usage "Unexpected parameter $1"
esac
shift
done
if [ -z "$KOTLIN_VERSION" ]
then
usage "Missing kotlin-version argument"
else
echo "kotlin version: $KOTLIN_VERSION"
fi
if [ -z "$SYSROOT_LIBS_TARGET" ]
then
usage "missing target-dir argument"
else
echo "unzip dir: $SYSROOT_LIBS_TARGET"
fi
# linux-prebuilts.properties includes the mappings from kotlin version to the konan
# prebuilt that includes the native libraries for the linux X86_64 host.
PREBUILTS_FILE=$(grep "$KOTLIN_VERSION=" $SCRIPT_DIR/linux-prebuilts.properties | cut -d "=" -f2)
if [ -z "$PREBUILTS_FILE" ]
then
usage "Cannot find prebuilts file for $KOTLIN_VERSION"
fi
SYSROOT_PATH="$PREBUILTS_FILE/x86_64-unknown-linux-gnu/sysroot/lib"
echo "Prebuilts file: $PREBUILTS_FILE"
TMP_DIR="$SYSROOT_LIBS_TARGET-extract"
mkdir -p $TMP_DIR
mkdir -p $SYSROOT_LIBS_TARGET
tar -xf $SCRIPT_DIR/$PREBUILTS_FILE.tar.gz --directory $TMP_DIR $SYSROOT_PATH
# move sysroot from the extracted files
cp -R $TMP_DIR/$SYSROOT_PATH/* $SYSROOT_LIBS_TARGET/.
rm -rf $TMP_DIR
echo "Unzipped sysroot libs into ${SYSROOT_LIBS_TARGET}"