1#!/bin/bash
2
3set -e
4
5DIR=$(mktemp -d out/perfetto.XXXXXX)
6
7function cleanup {
8  rm -rf "$DIR"
9  echo "Deleted temp working directory $DIR"
10}
11
12#trap cleanup EXIT
13
14function is_mac {
15  ! test -d /proc
16  return $?
17}
18
19tools/gn gen $DIR --args='is_clang=true is_debug=false'
20tools/ninja -C $DIR trace_processor_shell
21
22if is_mac; then
23  platform=mac
24else
25  platform=linux
26  strip $DIR/trace_processor_shell
27fi
28
29if which shasum; then
30  NEW_SHA=$(shasum $DIR/trace_processor_shell | cut -f1 -d' ') # Mac OS
31else
32  NEW_SHA=$(sha1sum $DIR/trace_processor_shell | cut -f1 -d' ') # Linux
33fi
34
35name=trace_processor_shell-$platform-$NEW_SHA
36
37gsutil cp $DIR/trace_processor_shell gs://perfetto/$name
38gsutil acl ch -u AllUsers:R gs://perfetto/$name
39
40echo 'Now run the following command to update tools/trace_processor:'
41echo "sed \"s/'$platform': '[^']*',/'$platform': '$NEW_SHA',/\" --in-place tools/trace_processor"
42