-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdep_protoc.mk
More file actions
66 lines (57 loc) · 2.26 KB
/
Copy pathdep_protoc.mk
File metadata and controls
66 lines (57 loc) · 2.26 KB
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
# Managed by makego. DO NOT EDIT.
# Must be set
$(call _assert_var,MAKEGO)
$(call _conditional_include,$(MAKEGO)/base.mk)
$(call _assert_var,UNAME_OS)
$(call _assert_var,UNAME_ARCH)
$(call _assert_var,CACHE_VERSIONS)
$(call _assert_var,CACHE_INCLUDE)
$(call _assert_var,CACHE_BIN)
# Settable
# https://github.com/protocolbuffers/protobuf/releases 20260109 checked 20260427
# NOTE: Set to version compatible with genproto source code (only used in tests).
# This version must be supported by the matching https://github.com/protocolbuffers/protobuf-go version.
PROTOC_VERSION ?= 33.3
# Google adds a dash to release candidate versions in the name of the
# release artifact, i.e. v27.0-rc1 -> v27.0-rc-1
ifeq (,$(findstring $(PROTOC_VERSION),-rc))
PROTOC_RELEASE_VERSION := $(subst -rc,-rc-,$(PROTOC_VERSION))
else
PROTOC_RELEASE_VERSION := $(PROTOC_VERSION)
endif
ifeq ($(UNAME_OS),Darwin)
PROTOC_OS := osx
ifeq ($(UNAME_ARCH),arm64)
PROTOC_ARCH := aarch_64
else
PROTOC_ARCH := x86_64
endif
endif
ifeq ($(UNAME_OS),Linux)
PROTOC_OS = linux
PROTOC_ARCH := $(UNAME_ARCH)
endif
PROTOC := $(CACHE_BIN)/protoc
PROTOC_INCLUDE := $(CACHE_INCLUDE)/google
$(CACHE_VERSIONS)/protoc/protoc-$(PROTOC_VERSION):
@if ! command -v curl >/dev/null 2>/dev/null; then echo "error: curl must be installed" >&2; exit 1; fi
@if ! command -v unzip >/dev/null 2>/dev/null; then echo "error: unzip must be installed" >&2; exit 1; fi
@rm -f $(PROTOC)
@rm -rf $(PROTOC_INCLUDE)
@rm -rf $(dir $@)
@mkdir -p $(dir $@)
@mkdir -p $(CACHE_VERSIONS)/protoc/protoc-$(PROTOC_VERSION)-include
$(eval PROTOC_TMP := $(shell mktemp -d))
cd $(PROTOC_TMP); curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_RELEASE_VERSION)-$(PROTOC_OS)-$(PROTOC_ARCH).zip -o protoc.zip
cd $(PROTOC_TMP); unzip protoc.zip && mv bin/protoc $@ && mv include/google $(CACHE_VERSIONS)/protoc/protoc-$(PROTOC_VERSION)-include/google
@rm -rf $(PROTOC_TMP)
@chmod +x $@
@test -x $@
@touch $@
$(PROTOC): $(CACHE_VERSIONS)/protoc/protoc-$(PROTOC_VERSION)
@mkdir -p $(dir $@)
@ln -sf $< $@
$(PROTOC_INCLUDE): $(CACHE_VERSIONS)/protoc/protoc-$(PROTOC_VERSION)
@mkdir -p $(dir $@)
@ln -sf $(CACHE_VERSIONS)/protoc/protoc-$(PROTOC_VERSION)-include/google $@
dockerdeps:: $(PROTOC) $(PROTOC_INCLUDE)