...
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
9set -e
10if [ ! -f mkexp.bash ]; then
11 echo 'mkexp.bash must be run from $GOROOT/src/internal/trace/v2' 1>&2
12 exit 1
13fi
14
15if [ "$#" -ne 1 ]; then
16 echo 'mkexp.bash expects one argument: a path to a golang.org/x/exp git checkout'
17 exit 1
18fi
19
20# Copy.
21mkdir -p $1/trace
22cp -r ./* $1/trace
23
24# Cleanup.
25
26# Delete mkexp.bash.
27rm $1/trace/mkexp.bash
28
29# Move tools to cmd. Can't be cmd here because dist will try to build them.
30mv $1/trace/tools $1/trace/cmd
31
32# Make some packages internal.
33mv $1/trace/raw $1/trace/internal/raw
34mv $1/trace/event $1/trace/internal/event
35mv $1/trace/version $1/trace/internal/version
36mv $1/trace/testtrace $1/trace/internal/testtrace
37
38# Move the debug commands out of testdata.
39mv $1/trace/testdata/cmd $1/trace/cmd
40
41# Fix up import paths.
42find $1/trace -name '*.go' | xargs -- sed -i 's/internal\/trace\/v2/golang.org\/x\/exp\/trace/'
43find $1/trace -name '*.go' | xargs -- sed -i 's/golang.org\/x\/exp\/trace\/raw/golang.org\/x\/exp\/trace\/internal\/raw/'
44find $1/trace -name '*.go' | xargs -- sed -i 's/golang.org\/x\/exp\/trace\/event/golang.org\/x\/exp\/trace\/internal\/event/'
45find $1/trace -name '*.go' | xargs -- sed -i 's/golang.org\/x\/exp\/trace\/event\/go122/golang.org\/x\/exp\/trace\/internal\/event\/go122/'
46find $1/trace -name '*.go' | xargs -- sed -i 's/golang.org\/x\/exp\/trace\/version/golang.org\/x\/exp\/trace\/internal\/version/'
47find $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.
50find $1/trace -name '*.go' | xargs -- gofmt -w -s
View as plain text