Skip to content

Commit

Permalink
check psrpc compiler version (#489)
Browse files Browse the repository at this point in the history
* check psrpc compiler version

* fix
  • Loading branch information
paulwe authored Oct 3, 2023
1 parent 525419a commit a187ed4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
4 changes: 4 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"path/filepath"

"github.com/livekit/mageutil"
"github.com/livekit/protocol/psrpc"
)

var Default = Proto
Expand Down Expand Up @@ -141,6 +142,9 @@ func Proto() error {
if err != nil {
return err
}
if err := psrpc.CheckCompilerVersion(psrpcPath); err != nil {
return err
}

args = append([]string{
"--go_out", ".",
Expand Down
36 changes: 36 additions & 0 deletions psrpc/compilercheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2023 LiveKit, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package psrpc

import (
"bytes"
"fmt"
"os/exec"

"github.com/livekit/psrpc/version"
)

func CheckCompilerVersion(path string) error {
b, err := exec.Command(path, "--version").Output()
if err != nil {
return err
}

b = bytes.Trim(b, "\r\n")
if string(b) != version.Version {
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)
}
return nil
}
2 changes: 1 addition & 1 deletion psrpc/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package middleware
package psrpc

import (
"context"
Expand Down
16 changes: 15 additions & 1 deletion psrpc/metrics.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
package middleware
// Copyright 2023 LiveKit, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package psrpc

import (
"time"
Expand Down

0 comments on commit a187ed4

Please sign in to comment.