jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # Copyright (c) the JPEG XL Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # This file downloads the dependencies needed to build JPEG XL into third_party. |
| 17 | # These dependencies are normally pulled by gtest. |
| 18 | |
| 19 | set -eu |
| 20 | |
| 21 | MYDIR=$(dirname $(realpath "$0")) |
| 22 | |
| 23 | # Git revisions we use for the given submodules. Update these whenever you |
jpegxl-bot | 945ad0c | 2021-01-21 20:27:02 +0100 | [diff] [blame] | 24 | # update a git submodule. |
jpegxl-bot | ab7c5e9 | 2021-04-21 19:22:38 +0200 | [diff] [blame] | 25 | THIRD_PARTY_HIGHWAY="ca1a57c342cd815053abfcffa29b44eaead4f20b" |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 26 | THIRD_PARTY_LODEPNG="48e5364ef48ec2408f44c727657ac1b6703185f8" |
| 27 | THIRD_PARTY_SKCMS="64374756e03700d649f897dbd98c95e78c30c7da" |
| 28 | THIRD_PARTY_SJPEG="868ab558fad70fcbe8863ba4e85179eeb81cc840" |
| 29 | |
| 30 | # Download the target revision from GitHub. |
| 31 | download_github() { |
| 32 | local path="$1" |
| 33 | local project="$2" |
| 34 | |
| 35 | local varname="${path^^}" |
| 36 | varname="${varname/\//_}" |
| 37 | local sha |
| 38 | eval "sha=\${${varname}}" |
| 39 | |
| 40 | local down_dir="${MYDIR}/downloads" |
| 41 | local local_fn="${down_dir}/${sha}.tar.gz" |
| 42 | if [[ -e "${local_fn}" && -d "${MYDIR}/${path}" ]]; then |
| 43 | echo "${path} already up to date." >&2 |
| 44 | return 0 |
| 45 | fi |
| 46 | |
| 47 | local url |
| 48 | local strip_components=0 |
| 49 | if [[ "${project:0:4}" == "http" ]]; then |
| 50 | # "project" is a googlesource.com base url. |
| 51 | url="${project}${sha}.tar.gz" |
| 52 | else |
| 53 | # GitHub files have a top-level directory |
| 54 | strip_components=1 |
| 55 | url="https://github.com/${project}/tarball/${sha}" |
| 56 | fi |
| 57 | |
| 58 | echo "Downloading ${path} version ${sha}..." >&2 |
| 59 | mkdir -p "${down_dir}" |
| 60 | curl -L --show-error -o "${local_fn}.tmp" "${url}" |
| 61 | mkdir -p "${MYDIR}/${path}" |
| 62 | tar -zxf "${local_fn}.tmp" -C "${MYDIR}/${path}" \ |
| 63 | --strip-components="${strip_components}" |
| 64 | mv "${local_fn}.tmp" "${local_fn}" |
| 65 | } |
| 66 | |
| 67 | |
| 68 | main() { |
| 69 | if git -C "${MYDIR}" rev-parse; then |
| 70 | cat >&2 <<EOF |
| 71 | Currenty directory is a git repository, downloading dependencies via git: |
| 72 | |
| 73 | git submodule update --init --recursive |
| 74 | |
| 75 | EOF |
| 76 | git -C "${MYDIR}" submodule update --init --recursive |
| 77 | return 0 |
| 78 | fi |
| 79 | |
| 80 | # Sources downloaded from a tarball. |
jpegxl-bot | d5ab3c6 | 2020-11-14 01:52:03 +0100 | [diff] [blame] | 81 | download_github third_party/highway google/highway |
| 82 | download_github third_party/lodepng lvandeve/lodepng |
| 83 | download_github third_party/sjpeg webmproject/sjpeg |
| 84 | download_github third_party/skcms \ |
| 85 | "https://skia.googlesource.com/skcms/+archive/" |
| 86 | echo "Done." |
| 87 | } |
| 88 | |
| 89 | main "$@" |