Ryan Savitski | d197a7a | 2022-03-21 18:22:20 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright (C) 2022 The Android Open Source 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 | set -eu |
| 17 | |
| 18 | # For perfetto maintainers. Pulls out demangling-related sources out of |
| 19 | # llvm-project and repackages them as a single tar archive. This works around |
| 20 | # the fact that gitiles, when generating an on-demand archive, uses a current |
| 21 | # timestamp, so the hash of the archive is different every time you fetch. |
| 22 | |
| 23 | # Usage example: |
| 24 | # sh tools/repackage_llvm_demangler.sh 3b4c59c156919902c785ce3cbae0eee2ee53064d |
| 25 | # |
| 26 | # Then upload the tar with "gsutil cp -n -a public-read ... gs://perfetto/...", |
| 27 | # and update install-build-deps. |
| 28 | |
| 29 | GIT_REF=$1 |
| 30 | |
| 31 | WORK_DIR=$(mktemp -d) |
| 32 | pushd . && cd "${WORK_DIR}" |
| 33 | |
| 34 | CC_DIR="llvm-project/llvm/lib/Demangle" |
| 35 | H_DIR="llvm-project/llvm/include/llvm/Demangle" |
| 36 | |
| 37 | CC_TGZ="Demangle_lib.tgz" |
| 38 | H_TGZ="Demangle_include.tgz" |
| 39 | |
| 40 | curl -f -L -# "https://llvm.googlesource.com/llvm-project/+archive/${GIT_REF}/llvm/lib/Demangle.tar.gz" -o "${CC_TGZ}" |
| 41 | curl -f -L -# "https://llvm.googlesource.com/llvm-project/+archive/${GIT_REF}/llvm/include/llvm/Demangle.tar.gz" -o "${H_TGZ}" |
| 42 | |
| 43 | mkdir -p "${CC_DIR}" |
| 44 | mkdir -p "${H_DIR}" |
| 45 | |
| 46 | tar xf "${CC_TGZ}" -C "${CC_DIR}" |
| 47 | tar xf "${H_TGZ}" -C "${H_DIR}" |
| 48 | |
| 49 | TAR_NAME="llvm-project-${GIT_REF}.tgz" |
| 50 | tar czf "${TAR_NAME}" --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2019-01-01' llvm-project |
| 51 | |
| 52 | TAR_SHA=$(sha256sum "${TAR_NAME}") |
| 53 | |
| 54 | echo "output file: ${WORK_DIR}/${TAR_NAME}" |
| 55 | echo "contents sha256: ${TAR_SHA}" |
| 56 | |
| 57 | popd |