11cb0ef41Sopenharmony_ci#!/usr/bin/env bash 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci# Copyright 2019 the V8 project authors. All rights reserved. 41cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 51cb0ef41Sopenharmony_ci# found in the LICENSE file. 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci# This script will package a built gcmole plugin together with the 81cb0ef41Sopenharmony_ci# corresponding clang binary into an archive which can be used on the 91cb0ef41Sopenharmony_ci# buildbot infrastructure to be run against V8 checkouts. 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciTHIS_DIR="$(readlink -f "$(dirname "${0}")")" 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciPACKAGE_DIR="${THIS_DIR}/gcmole-tools" 141cb0ef41Sopenharmony_ciPACKAGE_FILE="${THIS_DIR}/gcmole-tools.tar.gz" 151cb0ef41Sopenharmony_ciPACKAGE_SUM="${THIS_DIR}/gcmole-tools.tar.gz.sha1" 161cb0ef41Sopenharmony_ciBUILD_DIR="${THIS_DIR}/bootstrap/build" 171cb0ef41Sopenharmony_ciV8_ROOT_DIR= `realpath "${THIS_DIR}/../.."` 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci# Echo all commands 201cb0ef41Sopenharmony_ciset -x 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci# Clean out any old files 231cb0ef41Sopenharmony_ciif [ -e "${PACKAGE_DIR:?}/bin" ] ; then 241cb0ef41Sopenharmony_ci rm -rf "${PACKAGE_DIR:?}/bin" 251cb0ef41Sopenharmony_cifi 261cb0ef41Sopenharmony_ciif [ -e "${PACKAGE_DIR:?}/lib" ] ; then 271cb0ef41Sopenharmony_ci rm -rf "${PACKAGE_DIR:?}/lib" 281cb0ef41Sopenharmony_cifi 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci# Copy all required files 311cb0ef41Sopenharmony_cimkdir -p "${PACKAGE_DIR}/bin" 321cb0ef41Sopenharmony_cicp "${BUILD_DIR}/bin/clang++" "${PACKAGE_DIR}/bin" 331cb0ef41Sopenharmony_cimkdir -p "${PACKAGE_DIR}/lib" 341cb0ef41Sopenharmony_cicp -r "${BUILD_DIR}/lib/clang" "${PACKAGE_DIR}/lib" 351cb0ef41Sopenharmony_cicp "${THIS_DIR}/libgcmole.so" "${PACKAGE_DIR}" 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci# Generate the archive. Set some flags on tar to make the output more 381cb0ef41Sopenharmony_ci# deterministic (e.g. not dependent on timestamps by using the timestamp of 391cb0ef41Sopenharmony_ci# gcmole.cc for all files) 401cb0ef41Sopenharmony_cicd "$(dirname "${PACKAGE_DIR}")" 411cb0ef41Sopenharmony_citar \ 421cb0ef41Sopenharmony_ci --sort=name \ 431cb0ef41Sopenharmony_ci --owner=root:0 \ 441cb0ef41Sopenharmony_ci --group=root:0 \ 451cb0ef41Sopenharmony_ci --mtime="${THIS_DIR}/gcmole.cc" \ 461cb0ef41Sopenharmony_ci --create \ 471cb0ef41Sopenharmony_ci "$(basename "${PACKAGE_DIR}")" | gzip --no-name >"${PACKAGE_FILE}" 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci# Generate checksum 501cb0ef41Sopenharmony_cisha1sum "${PACKAGE_FILE}" | awk '{print $1}' > "${PACKAGE_SUM}" 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ciset +x 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ciecho 551cb0ef41Sopenharmony_ciecho You can find a packaged version of gcmole here: 561cb0ef41Sopenharmony_ciecho 571cb0ef41Sopenharmony_ciecho $(readlink -f "${PACKAGE_FILE}") 581cb0ef41Sopenharmony_ciecho 591cb0ef41Sopenharmony_ciecho Upload the update package to the chrome infra: 601cb0ef41Sopenharmony_ciecho 611cb0ef41Sopenharmony_ciecho 'gsutil.py cp tools/gcmole/gcmole-tools.tar.gz gs://chrome-v8-gcmole/$(cat tools/gcmole/gcmole-tools.tar.gz.sha1)' 621cb0ef41Sopenharmony_ciecho 631cb0ef41Sopenharmony_ciecho Run bootstrap.sh in chroot if glibc versions mismatch with bots: 641cb0ef41Sopenharmony_ciecho '# Create chroot' 651cb0ef41Sopenharmony_ciecho 'mkdir -p $CHROOT_DIR' 661cb0ef41Sopenharmony_ciecho 'sudo debootstrap $DEBIAN_VERSION $CHROOT_DIR' 671cb0ef41Sopenharmony_ciecho 'sudo chroot $CHROOT_DIR apt install g++ cmake python git' 681cb0ef41Sopenharmony_ciecho '# Mount ./depot_tools and ./v8 dirs in the chroot:' 691cb0ef41Sopenharmony_ciecho 'sudo chroot $CHROOT_DIR mkdir /docs' 701cb0ef41Sopenharmony_ciecho 'sudo mount --bind /path/to/workspace /docs' 711cb0ef41Sopenharmony_ciecho '# Build gcmole' 721cb0ef41Sopenharmony_ciecho "sudo chroot \$CHROOT_DIR bash -c 'PATH=/docs/depot_tools:\$PATH; /docs/v8/v8/tools/gcmole/bootstrap.sh'" 731cb0ef41Sopenharmony_ciecho 741cb0ef41Sopenharmony_ciecho You can now run gcmole using this command: 751cb0ef41Sopenharmony_ciecho 761cb0ef41Sopenharmony_ciecho 'tools/gcmole/gcmole.py \' 771cb0ef41Sopenharmony_ciecho ' --clang-bin-dir="tools/gcmole/gcmole-tools/bin" \' 781cb0ef41Sopenharmony_ciecho ' --clang-plugins-dir="tools/gcmole/gcmole-tools" \' 791cb0ef41Sopenharmony_ciecho ' --v8-target-cpu=$CPU' 801cb0ef41Sopenharmony_ciecho 81