Debian Codegraph @

tools/build_with_reclient.sh

raw
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
13 set -eux
14
15 cd $(dirname $(dirname $0))
16
17 # download reclient binary.
18 echo 'infra/rbe/client/${platform}' 're_client_version:0.116.1.9128bc4-gomaip' > /tmp/reclient.ensure
19 cipd ensure --root ./out/reclient --ensure-file /tmp/reclient.ensure
20
21 # generate reproxy config.
22 echo "
23 instance=projects/rbe-chrome-untrusted/instances/default_instance
24 service=remotebuildexecution.googleapis.com:443
25 server_address=unix:///tmp/reproxy.sock
26 use_application_default_credentials=true
27 proxy_log_dir=/tmp
28 " > out/reproxy.cfg
29
30 # download clang
31 if [[ ! -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 )
37 fi
38
39 ./out/chromium-clang/clang/scripts/update.py
40
41 # download reclient config corresponding to clang version
42 revision=$(out/chromium-clang/clang/scripts/update.py --print-revision)
43 echo 'infra_internal/rbe/reclient_cfgs/rbe-chrome-untrusted/chromium-browser-clang' "revision/$revision" > /tmp/reclient_cfgs.ensure
44 cipd ensure --root ./out/reclient_cfgs --ensure-file /tmp/reclient_cfgs.ensure
45
46 # generate args.gn using reclient
47 case "${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 '
53 cc_wrapper="../reclient/rewrapper -exec_root ../../ -cfg ../reclient_cfgs/rewrapper_linux.cfg"
54 cc="../third_party/llvm-build/Release+Asserts/bin/clang"
55 cxx="../third_party/llvm-build/Release+Asserts/bin/clang++"
56 skia_build_fuzzers=false
57
58 skia_use_system_freetype2 = false
59 extra_cflags=["--sysroot=../.sysroot"]
60 ' > out/Static/args.gn
61 ;;
62 darwin*)
63 ln -sf $(xcrun --sdk macosx --show-sdk-path) out/.sysroot
64 echo '
65 cc_wrapper="../reclient/rewrapper -exec_root ../../ -cfg ../reclient_cfgs/rewrapper_mac.cfg"
66 cc="../third_party/llvm-build/Release+Asserts/bin/clang"
67 cxx="../third_party/llvm-build/Release+Asserts/bin/clang++"
68 skia_build_fuzzers=false
69
70 xcode_sysroot = "../.sysroot"
71 ' > out/Static/args.gn
72 ;;
73 *)
74 echo "${OSTYPE} is not supported to use reclient."
75 exit 1
76 ;;
77 esac
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