1#!/bin/bash 2 3# Copyright 2023 Google LLC 4# 5# Use of this source code is governed by a BSD-style license that can be 6# found in the LICENSE file. 7 8# Helper script to build skia with reclient. 9# This script does some setup and teardown for reclient build. 10# Use this like 11# $ ./tools/build_with_reclient.sh ninja -C out/Static -j 1000 12 13set -eux 14 15cd $(dirname $(dirname $0)) 16 17# download reclient binary. 18echo 'infra/rbe/client/${platform}' 're_client_version:0.116.1.9128bc4-gomaip' > /tmp/reclient.ensure 19cipd ensure --root ./out/reclient --ensure-file /tmp/reclient.ensure 20 21# generate reproxy config. 22echo " 23instance=projects/rbe-chrome-untrusted/instances/default_instance 24service=remotebuildexecution.googleapis.com:443 25server_address=unix:///tmp/reproxy.sock 26use_application_default_credentials=true 27proxy_log_dir=/tmp 28" > out/reproxy.cfg 29 30# download clang 31if [[ ! -d out/chromium-clang ]]; then 32 mkdir -p out/chromium-clang 33 ( 34 cd out/chromium-clang 35 git clone https://chromium.googlesource.com/chromium/src/tools/clang.git 36 ) 37fi 38 39./out/chromium-clang/clang/scripts/update.py 40 41# download reclient config corresponding to clang version 42revision=$(out/chromium-clang/clang/scripts/update.py --print-revision) 43echo 'infra_internal/rbe/reclient_cfgs/rbe-chrome-untrusted/chromium-browser-clang' "revision/$revision" > /tmp/reclient_cfgs.ensure 44cipd ensure --root ./out/reclient_cfgs --ensure-file /tmp/reclient_cfgs.ensure 45 46# generate args.gn using reclient 47case "${OSTYPE}" in 48 linux*) 49 mkdir -p out/.sysroot/usr 50 ln -sf /usr/include out/.sysroot/usr/ 51 ln -sf /usr/lib out/.sysroot/usr/ 52 echo ' 53cc_wrapper="../reclient/rewrapper -exec_root ../../ -cfg ../reclient_cfgs/rewrapper_linux.cfg" 54cc="../third_party/llvm-build/Release+Asserts/bin/clang" 55cxx="../third_party/llvm-build/Release+Asserts/bin/clang++" 56skia_build_fuzzers=false 57 58skia_use_system_freetype2 = false 59extra_cflags=["--sysroot=../.sysroot"] 60' > out/Static/args.gn 61 ;; 62 darwin*) 63 ln -sf $(xcrun --sdk macosx --show-sdk-path) out/.sysroot 64 echo ' 65cc_wrapper="../reclient/rewrapper -exec_root ../../ -cfg ../reclient_cfgs/rewrapper_mac.cfg" 66cc="../third_party/llvm-build/Release+Asserts/bin/clang" 67cxx="../third_party/llvm-build/Release+Asserts/bin/clang++" 68skia_build_fuzzers=false 69 70xcode_sysroot = "../.sysroot" 71' > out/Static/args.gn 72 ;; 73 *) 74 echo "${OSTYPE} is not supported to use reclient." 75 exit 1 76 ;; 77esac 78# start reclient 79./out/reclient/bootstrap -re_proxy=./out/reclient/reproxy -cfg=./out/reproxy.cfg 80 81# run given command. 82"$@" 83 84# stop reclient 85./out/reclient/bootstrap -re_proxy=./out/reclient/reproxy -cfg=./out/reproxy.cfg -shutdown 86