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 16set -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 29GIT_REF=$1 30 31WORK_DIR=$(mktemp -d) 32pushd . && cd "${WORK_DIR}" 33 34CC_DIR="llvm-project/llvm/lib/Demangle" 35H_DIR="llvm-project/llvm/include/llvm/Demangle" 36 37CC_TGZ="Demangle_lib.tgz" 38H_TGZ="Demangle_include.tgz" 39 40curl -f -L -# "https://llvm.googlesource.com/llvm-project/+archive/${GIT_REF}/llvm/lib/Demangle.tar.gz" -o "${CC_TGZ}" 41curl -f -L -# "https://llvm.googlesource.com/llvm-project/+archive/${GIT_REF}/llvm/include/llvm/Demangle.tar.gz" -o "${H_TGZ}" 42 43mkdir -p "${CC_DIR}" 44mkdir -p "${H_DIR}" 45 46tar xf "${CC_TGZ}" -C "${CC_DIR}" 47tar xf "${H_TGZ}" -C "${H_DIR}" 48 49TAR_NAME="llvm-project-${GIT_REF}.tgz" 50tar czf "${TAR_NAME}" --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2019-01-01' llvm-project 51 52TAR_SHA=$(sha256sum "${TAR_NAME}") 53 54echo "output file: ${WORK_DIR}/${TAR_NAME}" 55echo "contents sha256: ${TAR_SHA}" 56 57popd 58