1#!/usr/bin/env bash 2 3# Copyright 2019 the V8 project authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7# This script will package a built gcmole plugin together with the 8# corresponding clang binary into an archive which can be used on the 9# buildbot infrastructure to be run against V8 checkouts. 10 11THIS_DIR="$(readlink -f "$(dirname "${0}")")" 12 13PACKAGE_DIR="${THIS_DIR}/gcmole-tools" 14PACKAGE_FILE="${THIS_DIR}/gcmole-tools.tar.gz" 15PACKAGE_SUM="${THIS_DIR}/gcmole-tools.tar.gz.sha1" 16BUILD_DIR="${THIS_DIR}/bootstrap/build" 17V8_ROOT_DIR= `realpath "${THIS_DIR}/../.."` 18 19# Echo all commands 20set -x 21 22# Clean out any old files 23if [ -e "${PACKAGE_DIR:?}/bin" ] ; then 24 rm -rf "${PACKAGE_DIR:?}/bin" 25fi 26if [ -e "${PACKAGE_DIR:?}/lib" ] ; then 27 rm -rf "${PACKAGE_DIR:?}/lib" 28fi 29 30# Copy all required files 31mkdir -p "${PACKAGE_DIR}/bin" 32cp "${BUILD_DIR}/bin/clang++" "${PACKAGE_DIR}/bin" 33mkdir -p "${PACKAGE_DIR}/lib" 34cp -r "${BUILD_DIR}/lib/clang" "${PACKAGE_DIR}/lib" 35cp "${THIS_DIR}/libgcmole.so" "${PACKAGE_DIR}" 36 37# Generate the archive. Set some flags on tar to make the output more 38# deterministic (e.g. not dependent on timestamps by using the timestamp of 39# gcmole.cc for all files) 40cd "$(dirname "${PACKAGE_DIR}")" 41tar \ 42 --sort=name \ 43 --owner=root:0 \ 44 --group=root:0 \ 45 --mtime="${THIS_DIR}/gcmole.cc" \ 46 --create \ 47 "$(basename "${PACKAGE_DIR}")" | gzip --no-name >"${PACKAGE_FILE}" 48 49# Generate checksum 50sha1sum "${PACKAGE_FILE}" | awk '{print $1}' > "${PACKAGE_SUM}" 51 52set +x 53 54echo 55echo You can find a packaged version of gcmole here: 56echo 57echo $(readlink -f "${PACKAGE_FILE}") 58echo 59echo Upload the update package to the chrome infra: 60echo 61echo 'gsutil.py cp tools/gcmole/gcmole-tools.tar.gz gs://chrome-v8-gcmole/$(cat tools/gcmole/gcmole-tools.tar.gz.sha1)' 62echo 63echo Run bootstrap.sh in chroot if glibc versions mismatch with bots: 64echo '# Create chroot' 65echo 'mkdir -p $CHROOT_DIR' 66echo 'sudo debootstrap $DEBIAN_VERSION $CHROOT_DIR' 67echo 'sudo chroot $CHROOT_DIR apt install g++ cmake python git' 68echo '# Mount ./depot_tools and ./v8 dirs in the chroot:' 69echo 'sudo chroot $CHROOT_DIR mkdir /docs' 70echo 'sudo mount --bind /path/to/workspace /docs' 71echo '# Build gcmole' 72echo "sudo chroot \$CHROOT_DIR bash -c 'PATH=/docs/depot_tools:\$PATH; /docs/v8/v8/tools/gcmole/bootstrap.sh'" 73echo 74echo You can now run gcmole using this command: 75echo 76echo 'tools/gcmole/gcmole.py \' 77echo ' --clang-bin-dir="tools/gcmole/gcmole-tools/bin" \' 78echo ' --clang-plugins-dir="tools/gcmole/gcmole-tools" \' 79echo ' --v8-target-cpu=$CPU' 80echo 81