kubbebrowser/tools/vendor/bootstrap.sh

106 lines
4.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
vendor_root="${project_root}/vendor"
cache_root="${vendor_root}/cache"
source_root="${vendor_root}/source"
tool_root="${vendor_root}/tools"
work_root="${vendor_root}/work"
toolchain_root="${project_root}/.toolchains"
mkdir -p "${cache_root}" "${source_root}" "${tool_root}" "${work_root}" "${toolchain_root}"
download() {
local url="$1"
local output="$2"
if [[ ! -f "${output}" ]]; then
printf 'Downloading %s\n' "${url}"
curl --fail --location --retry 5 --retry-delay 2 --continue-at - --output "${output}" "${url}"
fi
}
verify_sha256() {
local expected="$1"
local file="$2"
printf '%s %s\n' "${expected}" "${file}" | sha256sum --check --status
}
extract_archive() {
local archive="$1"
local destination="$2"
if [[ -d "${destination}" ]]; then
printf 'Source already present: %s\n' "${destination}"
return
fi
mkdir -p "$(dirname "${destination}")"
local temporary
temporary="$(mktemp -d "${work_root}/extract.XXXXXX")"
tar -xf "${archive}" --strip-components=1 -C "${temporary}"
mv "${temporary}" "${destination}"
}
fetch_snapshot() {
local name="$1"
local url="$2"
local revision="$3"
local destination="$4"
if [[ -d "${destination}" ]]; then
printf 'Source already present: %s\n' "${destination}"
return
fi
local temporary
temporary="$(mktemp -d "${work_root}/${name}.XXXXXX")"
git -C "${temporary}" init --quiet
git -C "${temporary}" remote add origin "${url}"
git -C "${temporary}" fetch --quiet --depth 1 origin "${revision}"
git -C "${temporary}" checkout --quiet --detach FETCH_HEAD
mv "${temporary}" "${destination}"
}
sdl_archive="${cache_root}/SDL3-3.4.12.tar.gz"
download "https://github.com/libsdl-org/SDL/releases/download/release-3.4.12/SDL3-3.4.12.tar.gz" "${sdl_archive}"
verify_sha256 "f07b958a9ac5020fb7a44cadb957f658b2149c3c8abb4f63145fac9303249db7" "${sdl_archive}"
extract_archive "${sdl_archive}" "${source_root}/sdl"
ccache_archive="${cache_root}/ccache-4.13.6.tar.xz"
download "https://github.com/ccache/ccache/releases/download/v4.13.6/ccache-4.13.6.tar.xz" "${ccache_archive}"
verify_sha256 "a7de667ca08cf67c3c8af9f213f6aa701a1188a2b3163fb74483858ce5e79fbb" "${ccache_archive}"
extract_archive "${ccache_archive}" "${source_root}/ccache"
ccache_binary_archive="${cache_root}/ccache-4.13.6-linux-x86_64-glibc.tar.xz"
download "https://github.com/ccache/ccache/releases/download/v4.13.6/ccache-4.13.6-linux-x86_64-glibc.tar.xz" "${ccache_binary_archive}"
verify_sha256 "508b2a1217dc6e04a23e967c7b95a0fb45d8a7e16fde9e180919698f2e2be060" "${ccache_binary_archive}"
extract_archive "${ccache_binary_archive}" "${toolchain_root}/ccache/4.13.6"
mkdir -p "${toolchain_root}/ccache/current"
ln -sfn "${toolchain_root}/ccache/4.13.6/ccache" "${toolchain_root}/ccache/current/ccache"
valgrind_archive="${cache_root}/valgrind-3.27.1.tar.bz2"
download "https://ftp.funet.fi/pub/mirrors/sourceware.org/pub/valgrind/valgrind-3.27.1.tar.bz2" "${valgrind_archive}"
verify_sha256 "5d589152eb8071c02feab8ce6ab719e431a1fbc3e2b1700f5432632a8b9264dc" "${valgrind_archive}"
extract_archive "${valgrind_archive}" "${source_root}/valgrind"
googletest_archive="${cache_root}/googletest-1.17.0.tar.gz"
download "https://github.com/google/googletest/archive/refs/tags/v1.17.0.tar.gz" "${googletest_archive}"
verify_sha256 "65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c" "${googletest_archive}"
extract_archive "${googletest_archive}" "${source_root}/googletest"
mkdir -p "${source_root}/vulkan"
fetch_snapshot "vulkan-headers" "https://github.com/KhronosGroup/Vulkan-Headers.git" "8864cdc896bbc2a9b6eb36b3218fc9ef57908d77" "${source_root}/vulkan/headers"
fetch_snapshot "vulkan-loader" "https://github.com/KhronosGroup/Vulkan-Loader.git" "a9e72c66d5cb79911eb9a9063bf4016dd0a3a123" "${source_root}/vulkan/loader"
fetch_snapshot "vulkan-utility-libraries" "https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git" "a96bd4933c6adfc21329d15e9999791a0153bbf3" "${source_root}/vulkan/utility-libraries"
fetch_snapshot "spirv-headers" "https://github.com/KhronosGroup/SPIRV-Headers.git" "ad9184e76a66b1001c29db9b0a3e87f646c64de0" "${source_root}/vulkan/spirv-headers"
fetch_snapshot "spirv-tools" "https://github.com/KhronosGroup/SPIRV-Tools.git" "0539c81f69a3daeb706fd3477dca61435b475156" "${source_root}/vulkan/spirv-tools"
fetch_snapshot "glslang" "https://github.com/KhronosGroup/glslang.git" "275822a6261ee689aadb1da5f09a0ec2f058685c" "${source_root}/vulkan/glslang"
fetch_snapshot "validation-layers" "https://github.com/KhronosGroup/Vulkan-ValidationLayers.git" "b9d4f9ead8d97c1bb0d174ea07d8aed8273818a5" "${source_root}/vulkan/validation-layers"
"${project_root}/tools/vendor/sync-skia.sh"
"${project_root}/tools/vendor/sync-v8.sh"
"${project_root}/tools/vendor/strip-vcs.sh"
printf 'Vendor bootstrap complete.\n'