1 #!/usr/bin/env bash
2 # Copyright 2023 The Go Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style
4 # license that can be found in the LICENSE file.
5
6 # This script copies this directory to golang.org/x/exp/trace.
7 # Just point it at an golang.org/x/exp checkout.
8
9 set -e
10 if [ ! -f mkexp.bash ]; then
11 echo 'mkexp.bash must be run from $GOROOT/src/internal/trace/v2' 1>&2
12 exit 1
13 fi
14
15 if [ "$#" -ne 1 ]; then
16 echo 'mkexp.bash expects one argument: a path to a golang.org/x/exp git checkout'
17 exit 1
18 fi
19
20 # Copy.
21 mkdir -p $1/trace
22 cp -r ./* $1/trace
23
24 # Cleanup.
25
26 # Delete mkexp.bash.
27 rm $1/trace/mkexp.bash
28
29 # Move tools to cmd. Can't be cmd here because dist will try to build them.
30 mv $1/trace/tools $1/trace/cmd
31
32 # Make some packages internal.
33 mv $1/trace/raw $1/trace/internal/raw
34 mv $1/trace/event $1/trace/internal/event
35 mv $1/trace/version $1/trace/internal/version
36 mv $1/trace/testtrace $1/trace/internal/testtrace
37
38 # Move the debug commands out of testdata.
39 mv $1/trace/testdata/cmd $1/trace/cmd
40
41 # Fix up import paths.
42 find $1/trace -name '*.go' | xargs -- sed -i 's/internal\/trace\/v2/golang.org\/x\/exp\/trace/'
43 find $1/trace -name '*.go' | xargs -- sed -i 's/golang.org\/x\/exp\/trace\/raw/golang.org\/x\/exp\/trace\/internal\/raw/'
44 find $1/trace -name '*.go' | xargs -- sed -i 's/golang.org\/x\/exp\/trace\/event/golang.org\/x\/exp\/trace\/internal\/event/'
45 find $1/trace -name '*.go' | xargs -- sed -i 's/golang.org\/x\/exp\/trace\/event\/go122/golang.org\/x\/exp\/trace\/internal\/event\/go122/'
46 find $1/trace -name '*.go' | xargs -- sed -i 's/golang.org\/x\/exp\/trace\/version/golang.org\/x\/exp\/trace\/internal\/version/'
47 find $1/trace -name '*.go' | xargs -- sed -i 's/golang.org\/x\/exp\/trace\/testtrace/golang.org\/x\/exp\/trace\/internal\/testtrace/'
48
49 # Format the files.
50 find $1/trace -name '*.go' | xargs -- gofmt -w -s
51
View as plain text