forked from DataDog/agent-payload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
96 lines (74 loc) · 2.88 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#
# Rakefile for agent-payload
#
protoc_binary="protoc"
protoc_version="3.5.1"
gogo_dir="/tmp/gogo"
namespace :codegen do
task :install_protoc do
if `bash -c "protoc --version"` != "libprotoc ${protoc_version}"
protoc_binary="/tmp/protoc#{protoc_version}"
sh <<-EOF
/bin/bash <<BASH
if [ ! -f #{protoc_binary} ] ; then
echo "Downloading protoc #{protoc_version}"
cd /tmp
if [ "$(uname -s)" = "Darwin" ] ; then
curl -OL https://github.com/google/protobuf/releases/download/v#{protoc_version}/protoc-#{protoc_version}-osx-x86_64.zip
else
curl -OL https://github.com/google/protobuf/releases/download/v#{protoc_version}/protoc-#{protoc_version}-linux-x86_64.zip
fi
unzip protoc-#{protoc_version}*.zip
mv bin/protoc #{protoc_binary}
fi
BASH
EOF
end
end
task :protoc => ['install_protoc'] do
sh <<-EOF
/bin/bash <<BASH
set -euo pipefail
export GO111MODULE=auto
rm -rf #{gogo_dir}
rm -rf /tmp/gogo-bin-*
mkdir -p #{gogo_dir}/src/github.com/gogo
git clone https://github.com/gogo/protobuf.git #{gogo_dir}/src/github.com/gogo/protobuf
# Install v1.0.0
pushd #{gogo_dir}/src/github.com/gogo/protobuf
git checkout v1.0.0
GOBIN=/tmp/gogo-bin-v1.0.0 GOPATH=#{gogo_dir} make clean install
popd
echo "Generating logs proto"
PATH=/tmp/gogo-bin-v1.0.0 #{protoc_binary} --proto_path=$GOPATH/src:#{gogo_dir}/src:. --gogofast_out=$GOPATH/src --java_out=java proto/logs/agent_logs_payload.proto
echo "Generating metrics proto (go)"
PATH=/tmp/gogo-bin-v1.0.0 #{protoc_binary} --proto_path=$GOPATH/src:#{gogo_dir}/src:. --gogofast_out=$GOPATH/src proto/metrics/agent_payload.proto
echo "Generating metrics proto (python)"
#{protoc_binary} --proto_path=#{gogo_dir}/src:$GOPATH/src:./proto/metrics --python_out=python agent_payload.proto
# Install the specific tag that the process-agent needs
pushd #{gogo_dir}/src/github.com/gogo/protobuf
git checkout d76fbc1373015ced59b43ac267f28d546b955683
GOBIN=/tmp/gogo-bin-d76fbc1373015ced59b43ac267f28d546b955683 GOPATH=#{gogo_dir} make clean install
popd
echo "Generating process proto"
PATH=/tmp/gogo-bin-d76fbc1373015ced59b43ac267f28d546b955683 #{protoc_binary} --proto_path=$GOPATH/src:#{gogo_dir}/src:. --gogofaster_out=$GOPATH/src proto/process/agent.proto
BASH
EOF
end
desc 'Run all code generators.'
multitask :all => [:protoc]
end
desc "Setup dependencies"
task :deps do
system("go mod tidy")
end
desc "Run tests"
task :test do
cmd = "go list ./... | grep -v vendor | xargs go test -v "
sh cmd
end
desc "Run all code generation."
task :codegen => ['codegen:all']
desc "Run all protobuf code generation."
task :protobuf => ['codegen:protoc']
task :default => [:deps, :test, :codegen]