Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

- name: Install protoc and plugins
run: |
sudo make install-protoc
make install-protoc
make install-protoc-dependencies install-ttrpc-plugin install-wasm-plugin

- name: Force regeneration of protobuf files on build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: Install protoc and plugins
run: |
sudo make install-protoc
make install-protoc
make install-protoc-dependencies install-ttrpc-plugin install-wasm-plugin

- run: make
Expand Down
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

PROTO_SOURCES = $(shell find . -name '*.proto' | grep -v /vendor/)
PROTO_GOFILES = $(patsubst %.proto,%.pb.go,$(PROTO_SOURCES))
PROTO_INCLUDE = -I$(PWD):/usr/local/include:/usr/include
PROTO_OPTIONS = --proto_path=. $(PROTO_INCLUDE) \
--go_opt=paths=source_relative --go_out=. \
--go-ttrpc_opt=paths=source_relative --go-ttrpc_out=. \
--go-plugin_opt=paths=source_relative,disable_pb_gen=true --go-plugin_out=.
PROTO_COMPILE = PATH=$(PATH):$(shell go env GOPATH)/bin; protoc $(PROTO_OPTIONS)

GO_CMD := go
GO_BUILD := $(GO_CMD) build
GO_INSTALL := $(GO_CMD) install
Expand All @@ -39,8 +30,18 @@ GINKGO := ginkgo
RESOLVED_PWD := $(shell realpath $(shell pwd))
BUILD_PATH := $(RESOLVED_PWD)/build
BIN_PATH := $(BUILD_PATH)/bin
TOOLS_PATH := $(BUILD_PATH)/tools
COVERAGE_PATH := $(BUILD_PATH)/coverage

PROTO_SOURCES = $(shell find pkg -name '*.proto' | grep -v /vendor/)
PROTO_GOFILES = $(patsubst %.proto,%.pb.go,$(PROTO_SOURCES))
PROTO_INCLUDE = -I $(PWD) -I$(TOOLS_PATH)/include
PROTO_OPTIONS = --proto_path=. $(PROTO_INCLUDE) \
--go_opt=paths=source_relative --go_out=. \
--go-ttrpc_opt=paths=source_relative --go-ttrpc_out=. \
--go-plugin_opt=paths=source_relative,disable_pb_gen=true --go-plugin_out=.
PROTO_COMPILE = PATH=$(TOOLS_PATH)/bin protoc $(PROTO_OPTIONS)

PLUGINS := \
$(BIN_PATH)/logger \
$(BIN_PATH)/device-injector \
Expand Down Expand Up @@ -190,13 +191,13 @@ install-protoc install-protobuf:
$(Q)./scripts/install-protobuf

install-ttrpc-plugin:
$(Q)$(GO_INSTALL) -mod=mod github.com/containerd/ttrpc/cmd/protoc-gen-go-ttrpc@74421d10189e8c118870d294c9f7f62db2d33ec1
$(Q)GOBIN="$(TOOLS_PATH)/bin" $(GO_INSTALL) -mod=mod github.com/containerd/ttrpc/cmd/protoc-gen-go-ttrpc@74421d10189e8c118870d294c9f7f62db2d33ec1

install-wasm-plugin:
$(Q)$(GO_INSTALL) -mod=mod github.com/knqyf263/go-plugin/cmd/protoc-gen-go-plugin@$(shell go list -m -f {{.Version}} github.com/knqyf263/go-plugin)
$(Q)GOBIN="$(TOOLS_PATH)/bin" $(GO_INSTALL) -mod=mod github.com/knqyf263/go-plugin/cmd/protoc-gen-go-plugin@$(shell go list -m -f {{.Version}} github.com/knqyf263/go-plugin)

install-protoc-dependencies:
$(Q)$(GO_INSTALL) -mod=mod google.golang.org/protobuf/cmd/[email protected]
$(Q)GOBIN="$(TOOLS_PATH)/bin" $(GO_INSTALL) -mod=mod google.golang.org/protobuf/cmd/[email protected]

install-ginkgo:
$(Q)$(GO_INSTALL) -mod=mod github.com/onsi/ginkgo/v2/ginkgo
25 changes: 14 additions & 11 deletions scripts/install-protobuf
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ PROTOBUF_VERSION=3.20.1
GOARCH=$(go env GOARCH)
GOOS=$(go env GOOS)
PROTOBUF_DIR=$(mktemp -d)
INSTALL_DIR="$PWD/build/tools"

mkdir -p "$INSTALL_DIR"

case $GOARCH in

arm64)
wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-aarch_64.zip"
unzip "$PROTOBUF_DIR/protobuf" -d /usr/local
unzip "$PROTOBUF_DIR/protobuf" -d "$INSTALL_DIR"
;;

amd64|386)
Expand All @@ -38,31 +41,31 @@ amd64|386)
elif [ "$GOOS" = linux ]; then
wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-x86_64.zip"
fi
unzip "$PROTOBUF_DIR/protobuf" -d /usr/local
unzip -o "$PROTOBUF_DIR/protobuf" -d "$INSTALL_DIR"
;;

ppc64le)
wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-ppcle_64.zip"
unzip "$PROTOBUF_DIR/protobuf" -d /usr/local
unzip -o "$PROTOBUF_DIR/protobuf" -d "$INSTALL_DIR"
;;
*)
wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-cpp-$PROTOBUF_VERSION.zip"
unzip "$PROTOBUF_DIR/protobuf" -d /usr/src/protobuf
cd "/usr/src/protobuf/protobuf-$PROTOBUF_VERSION"
mkdir -p "$INSTALL_DIR/src/protobuf"
unzip -o "$PROTOBUF_DIR/protobuf" -d "$INSTALL_DIR/src/protobuf"
cd "$INSTALL_DIR/src/protobuf/protobuf-$PROTOBUF_VERSION"
./autogen.sh
./configure --disable-shared
make
make check
./configure --disable-shared --prefix="$INSTALL_DIR"
make -j $(nproc)
make check -j $(nproc)
make install
ldconfig
;;
esac
rm -rf "$PROTOBUF_DIR"

# Download status.proto. grpc repos' one seems copied from
# https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto,
# but we use grpc's since the repos has tags/releases.
mkdir -p /usr/local/include/google/rpc
mkdir -p "$INSTALL_DIR/include/google/rpc"
curl \
-L https://raw.githubusercontent.com/grpc/grpc/v1.45.2/src/proto/grpc/status/status.proto \
-o /usr/local/include/google/rpc/status.proto
-o "$INSTALL_DIR/include/google/rpc/status.proto"
Loading