-
Notifications
You must be signed in to change notification settings - Fork 54
/
make.ps1
86 lines (67 loc) · 2.04 KB
/
make.ps1
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
function Build-Binary {
param (
$Package,
$Output
)
go build -o $Output $Package
}
function Get-ProtoInclude {
$path = go list -m -f '{{.Dir}}' 'github.com/relab/gorums'
return $path
}
function Build-ProtoFile {
[CmdLetBinding()]
param (
$SrcFile,
$GoOut,
$GorumsOut
)
if ($null -eq $SrcFile) {
return
}
$protoInclude = Get-ProtoInclude
if ($null -ne $GoOut -And -Not (Compare-FileWriteTime $GoOut $SrcFile)) {
protoc -I. -Iinternal/proto -I"$protoInclude" --go_out=paths=source_relative:. "$SrcFile"
}
if ($null -ne $GorumsOut -And -Not (Compare-FileWriteTime $GorumsOut $SrcFile)) {
protoc -I. -Iinternal/proto -I"$protoInclude" --gorums_out=paths=source_relative:. "$SrcFile"
}
}
function Compare-FileWriteTime {
param (
$First,
$Second
)
$firstDate = (Get-ItemProperty -Path $First -Name LastWriteTime).LastWriteTime
$secondDate = (Get-ItemProperty -Path $Second -Name LastWriteTime).LastWriteTime
if ($null -eq $firstDate) {
return $false
}
if ([datetime]$firstDate -ge [datetime]$secondDate) {
return $true
}
return $false
}
go mod download
go install "github.com/relab/gorums/cmd/protoc-gen-gorums"
go install "google.golang.org/protobuf/cmd/protoc-gen-go"
Build-ProtoFile `
-SrcFile internal/proto/clientpb/client.proto `
-GoOut internal/proto/clientpb/client.pb.go `
-GorumsOut internal/proto/clientpb/client_gorums.pb.go
Build-ProtoFile `
-SrcFile internal/proto/hotstuffpb/hotstuff.proto `
-GoOut internal/proto/hotstuffpb/hotstuff.pb.go `
-GorumsOut internal/proto/hotstuffpb/hotstuff_gorums.pb.go
Build-ProtoFile `
-SrcFile internal/proto/orchestrationpb/orchestration.proto `
-GoOut internal/proto/orchestrationpb/orchestration.pb.go
Build-ProtoFile `
-SrcFile internal/proto/handelpb/handel.proto `
-GoOut internal/proto/handelpb/handel.pb.go `
-GorumsOut internal/proto/handelpb/handel_gorums.pb.go
Build-ProtoFile `
-SrcFile metrics/types/types.proto `
-GoOut metrics/types/types.pb.go
Build-Binary ./cmd/hotstuff ./hotstuff.exe
Build-Binary ./cmd/plot ./plot.exe