Files
kotlin-fork/kotlin-native/tools/toolchain_builder/build_toolchain.sh
T
Svyatoslav Scherbina aecf18b842 Native: move copying of toolchain builder artifact from Docker to host
Don't make Docker container copy artifact to a host directory mounted
with -v, because this fails due to a file permission issue:
build is run by a regular user, but the volume directory inside the
container is owned by root.

Instead, make the host copy the artifact from the container.

Also, make the container print the artifact path before that.
Just in case, in order to easily copy file manually, should something
go wrong.

^KT-58864
2023-07-21 10:40:13 +00:00

55 lines
1.1 KiB
Bash

#!/bin/bash
set -eou pipefail
TARGET=$1
VERSION=$2
TOOLCHAIN_VERSION_SUFFIX=$3
HOME=/home/ct
ZLIB_VERSION=1.2.11
build_toolchain() {
mkdir $HOME/build-"$TARGET"
cd $HOME/build-"$TARGET"
cp $HOME/toolchains/"$TARGET"/"$VERSION".config .config
ct-ng build
cd ..
}
build_zlib() {
TOOLCHAINS_PATH=$HOME/x-tools
INSTALL_PATH=$TOOLCHAINS_PATH/$TARGET/$TARGET/sysroot/usr
TOOLCHAIN_BIN_PREFIX=$TOOLCHAINS_PATH/$TARGET/bin/$TARGET
cd $HOME/zlib-$ZLIB_VERSION
CHOST=$TARGET \
CC=$TOOLCHAIN_BIN_PREFIX-gcc \
AR=$TOOLCHAIN_BIN_PREFIX-ar \
RANLIB=$TOOLCHAIN_BIN_PREFIX-ranlib \
./configure \
--prefix="$INSTALL_PATH"
make && make install
}
build_archive() {
cd $HOME/x-tools
if [ -z "$TOOLCHAIN_VERSION_SUFFIX" ]
then
FULL_NAME="$TARGET-$VERSION"
else
FULL_NAME="$TARGET-$VERSION-$TOOLCHAIN_VERSION_SUFFIX"
fi
mv "$TARGET" "$FULL_NAME"
ARCHIVE_NAME="$FULL_NAME.tar.gz"
tar -czvf "$ARCHIVE_NAME" "$FULL_NAME"
echo "$PWD/$ARCHIVE_NAME"
mkdir -p ~/artifacts
cp "$ARCHIVE_NAME" ~/artifacts/"$ARCHIVE_NAME"
}
echo "building toolchain for $TARGET"
build_toolchain
build_zlib
build_archive