diff --git a/kotlin-native/tools/toolchain_builder/Dockerfile b/kotlin-native/tools/toolchain_builder/Dockerfile index 5eeee43e176..8bb3e5c2030 100644 --- a/kotlin-native/tools/toolchain_builder/Dockerfile +++ b/kotlin-native/tools/toolchain_builder/Dockerfile @@ -40,7 +40,8 @@ RUN mkdir src ENV TARGET=x86_64-unknown-linux-gnu ENV VERSION=gcc-8.3.0-glibc-2.19-kernel-4.9 +ENV TOOLCHAIN_VERSION_SUFFIX="" # Add entry point. COPY build_toolchain.sh . -ENTRYPOINT "/bin/bash" "build_toolchain.sh" ${TARGET} ${VERSION} \ No newline at end of file +ENTRYPOINT "/bin/bash" "build_toolchain.sh" ${TARGET} ${VERSION} ${TOOLCHAIN_VERSION_SUFFIX} \ No newline at end of file diff --git a/kotlin-native/tools/toolchain_builder/README.md b/kotlin-native/tools/toolchain_builder/README.md index 5c91bdc9e94..eb73a569196 100644 --- a/kotlin-native/tools/toolchain_builder/README.md +++ b/kotlin-native/tools/toolchain_builder/README.md @@ -8,8 +8,9 @@ This directory contains a set of scripts and configuration files that allow one ### Usage 1. First, you need to build a Docker image with crosstool-ng inside. Use `create_image.sh` for it. 2. Now you can build an actual toolchain. To pick one, take a look inside `toolchains` folder. -It is organized as `$TARGET/$VERSION`. Then run `./run_container.sh $TARGET $VERSION`. Building a toolchain might take a while (~17 minutes on Ryzen 5 3600). +It is organized as `$TARGET/$VERSION`. Then run `./run_container.sh $TARGET $VERSION $TOOLCHAIN_VERSION_SUFFIX`. Building a toolchain might take a while (~17 minutes on Ryzen 5 3600). Once ready, an archive will be placed in `artifacts` folder. +`$TOOLCHAIN_VERSION_SUFFIX` is an optional argument that adds suffix to the end of toolchain name. ### Example ```bash diff --git a/kotlin-native/tools/toolchain_builder/build_toolchain.sh b/kotlin-native/tools/toolchain_builder/build_toolchain.sh index cf6f9674ec2..f744edfea51 100644 --- a/kotlin-native/tools/toolchain_builder/build_toolchain.sh +++ b/kotlin-native/tools/toolchain_builder/build_toolchain.sh @@ -4,6 +4,7 @@ set -eou pipefail TARGET=$1 VERSION=$2 +TOOLCHAIN_VERSION_SUFFIX=$3 HOME=/home/ct ZLIB_VERSION=1.2.11 @@ -33,7 +34,12 @@ build_zlib() { build_archive() { cd $HOME/x-tools - FULL_NAME=$TARGET-$VERSION + 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" diff --git a/kotlin-native/tools/toolchain_builder/run_container.sh b/kotlin-native/tools/toolchain_builder/run_container.sh index e81765fc715..d51a00bc363 100755 --- a/kotlin-native/tools/toolchain_builder/run_container.sh +++ b/kotlin-native/tools/toolchain_builder/run_container.sh @@ -5,11 +5,16 @@ CONTAINER_NAME=kotlin-toolchain-builder IMAGE_NAME=kotlin-toolchain-builder TARGET=$1 VERSION=$2 +TOOLCHAIN_VERSION_SUFFIX="${3:-""}" docker ps -a | grep $CONTAINER_NAME > /dev/null \ && docker stop $CONTAINER_NAME > /dev/null \ && docker rm $CONTAINER_NAME > /dev/null echo "Running build script in container..." -docker run -it -v "$PWD"/artifacts:/artifacts --env TARGET="$TARGET" --env VERSION="$VERSION" --name=$CONTAINER_NAME $IMAGE_NAME +docker run -it -v "$PWD"/artifacts:/artifacts \ + --env TARGET="$TARGET" \ + --env VERSION="$VERSION" \ + --env TOOLCHAIN_VERSION_SUFFIX="$TOOLCHAIN_VERSION_SUFFIX" \ + --name=$CONTAINER_NAME $IMAGE_NAME echo "Done." \ No newline at end of file