Skip to content

Commit a187ed4

Browse files
authored
check psrpc compiler version (#489)
* check psrpc compiler version * fix
1 parent 525419a commit a187ed4

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

magefile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"path/filepath"
2727

2828
"github.com/livekit/mageutil"
29+
"github.com/livekit/protocol/psrpc"
2930
)
3031

3132
var Default = Proto
@@ -141,6 +142,9 @@ func Proto() error {
141142
if err != nil {
142143
return err
143144
}
145+
if err := psrpc.CheckCompilerVersion(psrpcPath); err != nil {
146+
return err
147+
}
144148

145149
args = append([]string{
146150
"--go_out", ".",

psrpc/compilercheck.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2023 LiveKit, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package psrpc
16+
17+
import (
18+
"bytes"
19+
"fmt"
20+
"os/exec"
21+
22+
"github.com/livekit/psrpc/version"
23+
)
24+
25+
func CheckCompilerVersion(path string) error {
26+
b, err := exec.Command(path, "--version").Output()
27+
if err != nil {
28+
return err
29+
}
30+
31+
b = bytes.Trim(b, "\r\n")
32+
if string(b) != version.Version {
33+
return fmt.Errorf("found psrpc compiler version %s need %s. please run:\ngo install github.com/livekit/psrpc/protoc-gen-psrpc", string(b), version.Version)
34+
}
35+
return nil
36+
}

psrpc/logging.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package middleware
15+
package psrpc
1616

1717
import (
1818
"context"

psrpc/metrics.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
package middleware
1+
// Copyright 2023 LiveKit, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package psrpc
216

317
import (
418
"time"

0 commit comments

Comments
 (0)