Skip to content

Commit 375e83c

Browse files
authored
Improvements to Protobuf.Makefile (#821)
- Sync `Protobuf.Makefile` with other projects. - Also see apple/containerization#356.
1 parent 7e4eadd commit 375e83c

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

Protobuf.Makefile

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414

1515
ROOT_DIR := $(shell git rev-parse --show-toplevel)
1616
LOCAL_DIR := $(ROOT_DIR)/.local
17-
LOCALBIN := $(LOCAL_DIR)/bin
17+
LOCAL_BIN_DIR := $(LOCAL_DIR)/bin
1818

1919
BUILDER_SHIM_REPO ?= https://github.com/apple/container-builder-shim.git
2020

21-
## Versions
21+
# Versions
2222
BUILDER_SHIM_VERSION ?= $(shell sed -n 's/let builderShimVersion *= *"\(.*\)"/\1/p' Package.swift)
23-
PROTOC_VERSION=26.1
23+
PROTOC_VERSION := 26.1
2424

25-
# protoc binary installation
26-
PROTOC_ZIP = protoc-$(PROTOC_VERSION)-osx-universal_binary.zip
27-
PROTOC = $(LOCALBIN)/protoc@$(PROTOC_VERSION)/protoc
25+
# Protoc binary installation
26+
PROTOC_ZIP := protoc-$(PROTOC_VERSION)-osx-universal_binary.zip
27+
PROTOC := $(LOCAL_BIN_DIR)/protoc@$(PROTOC_VERSION)/protoc
2828
$(PROTOC):
2929
@echo Downloading protocol buffers...
3030
@mkdir -p $(LOCAL_DIR)
@@ -34,16 +34,18 @@ $(PROTOC):
3434
@unzip -o $(PROTOC_ZIP) 'include/*' -d $(dir $@)
3535
@rm -f $(PROTOC_ZIP)
3636

37-
protoc_gen_grpc_swift:
38-
@$(SWIFT) build --product protoc-gen-grpc-swift
39-
37+
.PHONY: protoc-gen-swift
4038
protoc-gen-swift:
4139
@$(SWIFT) build --product protoc-gen-swift
40+
@$(SWIFT) build --product protoc-gen-grpc-swift
4241

43-
protos: $(PROTOC) protoc-gen-swift protoc_gen_grpc_swift
42+
.PHONY: protos
43+
protos: $(PROTOC) protoc-gen-swift
4444
@echo Generating protocol buffers source code...
4545
@mkdir -p $(LOCAL_DIR)
46-
@cd $(LOCAL_DIR) && git clone --branch $(BUILDER_SHIM_VERSION) --depth 1 $(BUILDER_SHIM_REPO)
46+
@if [ ! -d "$(LOCAL_DIR)/container-builder-shim" ]; then \
47+
cd $(LOCAL_DIR) && git clone --branch $(BUILDER_SHIM_VERSION) --depth 1 $(BUILDER_SHIM_REPO); \
48+
fi
4749
@$(PROTOC) $(LOCAL_DIR)/container-builder-shim/pkg/api/Builder.proto \
4850
--plugin=protoc-gen-grpc-swift=$(BUILD_BIN_DIR)/protoc-gen-grpc-swift \
4951
--plugin=protoc-gen-swift=$(BUILD_BIN_DIR)/protoc-gen-swift \
@@ -55,7 +57,8 @@ protos: $(PROTOC) protoc-gen-swift protoc_gen_grpc_swift
5557
-I.
5658
@"$(MAKE)" update-licenses
5759

60+
.PHONY: clean-proto-tools
5861
clean-proto-tools:
59-
@rm -rf $(LOCAL_DIR)/bin
62+
@echo Cleaning proto tools...
63+
@rm -rf $(LOCAL_DIR)/bin/protoc*
6064
@rm -rf $(LOCAL_DIR)/container-builder-shim
61-
@echo "Removed $(LOCAL_DIR)/bin toolchains."

0 commit comments

Comments
 (0)