Snap for 9512875 from 7311845d640df27c1b3d4fc1cef0ce55004228ca to androidx-arch-core-release

Change-Id: I0b7e40e7c65d2a0bdf81c295b11a3409f6cd4d37
diff --git a/README.md b/README.md
index c9970f7..759bc2e 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,13 @@
 This folder contains pre-downloaded dependencies for Kotlin
-native builds.  They have been downloaded by the script
-./download.sh, from the same default location that the Kotlin
-native compiler downloads the files by default.
+native builds.
 
-IMPORTANT: As agreed offline and signed off in b/200289211, we will use these
-downloaded dependencies for CI only, and will replace with verified
+They are downloaded by running `./gradlew updateKonanPrebuilts` in
+`frameworks/support`. If you need to update prebuilts, please
+re-run that task and commit the result.
+
+This repository is provided to the Kotlin Multiplatform Build as
+the remote server where it can find the dependencies.
+
+IMPORTANT: As agreed offline and signed off in b/200289211, we will use
+these downloaded dependencies for CI only, and will replace with verified
 self-built libraries before building anything for release.
diff --git a/aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2.tar.gz b/aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2.tar.gz
new file mode 100644
index 0000000..c00dbe3
--- /dev/null
+++ b/aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2.tar.gz
Binary files differ
diff --git a/apple-llvm-20200714-macos-aarch64-essentials.tar.gz b/apple-llvm-20200714-macos-aarch64-essentials.tar.gz
new file mode 100644
index 0000000..8607df1
--- /dev/null
+++ b/apple-llvm-20200714-macos-aarch64-essentials.tar.gz
Binary files differ
diff --git a/apple-llvm-20200714-macos-x64-essentials.tar.gz b/apple-llvm-20200714-macos-x64-essentials.tar.gz
new file mode 100644
index 0000000..20fea1e
--- /dev/null
+++ b/apple-llvm-20200714-macos-x64-essentials.tar.gz
Binary files differ
diff --git a/copy-linux-sysroot.sh b/copy-linux-sysroot.sh
new file mode 100755
index 0000000..dc8585a
--- /dev/null
+++ b/copy-linux-sysroot.sh
@@ -0,0 +1,74 @@
+#!/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}"
\ No newline at end of file
diff --git a/download-native-compiler-prebuilts.sh b/download-native-compiler-prebuilts.sh
new file mode 100755
index 0000000..78e0b66
--- /dev/null
+++ b/download-native-compiler-prebuilts.sh
@@ -0,0 +1,46 @@
+#!/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
\ No newline at end of file
diff --git a/download.sh b/download.sh
deleted file mode 100755
index 3b57023..0000000
--- a/download.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/bash
-
-echo "Downloading known-needed dependencies for kotlin-native 1.6.10..."
-
-BASE=https://download.jetbrains.com/kotlin/native
-
-download_if_missing() {
-    if [ ! -f $1 ]; then
-	wget $BASE/$1
-    else
-	echo "Already downloaded $1"
-    fi
-}
-
-download_if_missing x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2.tar.gz
-download_if_missing lldb-4-linux.tar.gz
-download_if_missing llvm-11.1.0-linux-x64-essentials.tar.gz
-download_if_missing libffi-3.2.1-2-linux-x86-64.tar.gz
diff --git a/libffi-3.2.1-3-darwin-macos.tar.gz b/libffi-3.2.1-3-darwin-macos.tar.gz
new file mode 100644
index 0000000..eba932a
--- /dev/null
+++ b/libffi-3.2.1-3-darwin-macos.tar.gz
Binary files differ
diff --git a/libffi-3.3-1-macos-arm64.tar.gz b/libffi-3.3-1-macos-arm64.tar.gz
new file mode 100644
index 0000000..fbae396
--- /dev/null
+++ b/libffi-3.3-1-macos-arm64.tar.gz
Binary files differ
diff --git a/linux-prebuilts.properties b/linux-prebuilts.properties
new file mode 100644
index 0000000..4c9caeb
--- /dev/null
+++ b/linux-prebuilts.properties
@@ -0,0 +1 @@
+1.8.0=x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2
diff --git a/lldb-4-macos.tar.gz b/lldb-4-macos.tar.gz
new file mode 100644
index 0000000..7f058e9
--- /dev/null
+++ b/lldb-4-macos.tar.gz
Binary files differ
diff --git a/msys2-mingw-w64-i686-1.tar.gz b/msys2-mingw-w64-i686-1.tar.gz
new file mode 100644
index 0000000..ef8dd13
--- /dev/null
+++ b/msys2-mingw-w64-i686-1.tar.gz
Binary files differ
diff --git a/msys2-mingw-w64-i686-2.tar.gz b/msys2-mingw-w64-i686-2.tar.gz
new file mode 100644
index 0000000..49e5da0
--- /dev/null
+++ b/msys2-mingw-w64-i686-2.tar.gz
Binary files differ
diff --git a/msys2-mingw-w64-x86_64-1.tar.gz b/msys2-mingw-w64-x86_64-1.tar.gz
new file mode 100644
index 0000000..809f066
--- /dev/null
+++ b/msys2-mingw-w64-x86_64-1.tar.gz
Binary files differ
diff --git a/msys2-mingw-w64-x86_64-2.tar.gz b/msys2-mingw-w64-x86_64-2.tar.gz
new file mode 100644
index 0000000..b21f5e8
--- /dev/null
+++ b/msys2-mingw-w64-x86_64-2.tar.gz
Binary files differ
diff --git a/nativeCompilerPrebuilts/releases/1.8.0/linux-x86_64/kotlin-native-prebuilt-linux-x86_64-1.8.0.tar.gz b/nativeCompilerPrebuilts/releases/1.8.0/linux-x86_64/kotlin-native-prebuilt-linux-x86_64-1.8.0.tar.gz
new file mode 100644
index 0000000..90af8f8
--- /dev/null
+++ b/nativeCompilerPrebuilts/releases/1.8.0/linux-x86_64/kotlin-native-prebuilt-linux-x86_64-1.8.0.tar.gz
Binary files differ
diff --git a/nativeCompilerPrebuilts/releases/1.8.0/macos-aarch64/kotlin-native-prebuilt-macos-aarch64-1.8.0.tar.gz b/nativeCompilerPrebuilts/releases/1.8.0/macos-aarch64/kotlin-native-prebuilt-macos-aarch64-1.8.0.tar.gz
new file mode 100644
index 0000000..6655865
--- /dev/null
+++ b/nativeCompilerPrebuilts/releases/1.8.0/macos-aarch64/kotlin-native-prebuilt-macos-aarch64-1.8.0.tar.gz
Binary files differ
diff --git a/nativeCompilerPrebuilts/releases/1.8.0/macos-x86_64/kotlin-native-prebuilt-macos-x86_64-1.8.0.tar.gz b/nativeCompilerPrebuilts/releases/1.8.0/macos-x86_64/kotlin-native-prebuilt-macos-x86_64-1.8.0.tar.gz
new file mode 100644
index 0000000..c9a7959
--- /dev/null
+++ b/nativeCompilerPrebuilts/releases/1.8.0/macos-x86_64/kotlin-native-prebuilt-macos-x86_64-1.8.0.tar.gz
Binary files differ