blob: 0c8d0d4e5b0518e59e3ccfa51d2ad18a88f5814b [file] [log] [blame]
Primiano Tucci1c752c12018-10-23 09:27:19 +01001#!/bin/bash
2# Copyright (C) 2018 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
16# Builds the current version of catapult, uploads it to GCS and updates the
17# pinned SHA1 in install-build-deps.
18
19set -e
20
21PROJECT_ROOT="$(cd -P ${BASH_SOURCE[0]%/*}/..; pwd)"
22
23if [ "$1" == "" ]; then
24 echo "Usage: $0 /path/to/catapult/repo"
25 exit 1
26fi
27
28CATAPULT="$1"
29if [ ! -d "$CATAPULT/.git" ]; then
30 echo "$CATAPULT must point to a valid catapult repo"
31 exit 1
32fi
33
34REVISION=$(git -C "$CATAPULT" rev-parse --short HEAD)
35OUTDIR="$(mktemp -d)"
36echo "Building vulcanized Trace Viewer @ $REVISION into $OUTDIR"
37git -C "$CATAPULT" log -1 | cat
38echo
39set -x
40"$CATAPULT/tracing/bin/generate_about_tracing_contents" --outdir "$OUTDIR"
41ARCHIVE="$OUTDIR/catapult_trace_viewer.tar.gz"
42
43(
44 cd "$OUTDIR"
45 mv about_tracing.html catapult_trace_viewer.html
46 mv about_tracing.js catapult_trace_viewer.js
47 sed -i '' -e \
48 's|src="tracing.js"|src="/assets/catapult_trace_viewer.js"|g' \
49 catapult_trace_viewer.html
50 tar -zcf "$ARCHIVE" catapult_trace_viewer.{js,html}
51)
52
53SHA1CMD='import hashlib; import sys; sha1=hashlib.sha1(); sha1.update(sys.stdin.read()); print(sha1.hexdigest())'
54SHA1=$(python -c "$SHA1CMD" < "$ARCHIVE")
55GCS_TARGET="gs://perfetto/catapult_trace_viewer-$SHA1.tar.gz"
56gsutil cp -n -a public-read "$ARCHIVE" "$GCS_TARGET"
57rm -rf "$OUTDIR"
58
59# Update the reference to the new prebuilt in tools/install-build-deps.
60sed -i '' -e \
61 "s/^CATAPULT_SHA1 =.*/CATAPULT_SHA1 = '"$SHA1"'/g" \
62 "$PROJECT_ROOT/tools/install-build-deps"
63
Primiano Tucci69132a12020-02-07 22:33:06 +000064"$PROJECT_ROOT/tools/install-build-deps" --ui