forked from apple/swift-temporal-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (64 loc) · 3.45 KB
/
Copy pathMakefile
File metadata and controls
76 lines (64 loc) · 3.45 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
67
68
69
70
71
72
73
74
75
PROTO_OUT := ./Sources/Temporal/Generated
PROTO_BASE := ./dependencies/sdk-core/crates/common/protos
# Split proto files: public (non-local) and local (package-only)
PROTO_FILES_PUBLIC := $(shell find $(PROTO_BASE) -name "*.proto" -not -path "*/google/*" -not -path "*/health/*" -not -path "*/local/*")
PROTO_FILES_LOCAL := $(shell find $(PROTO_BASE)/local -name "*.proto" 2>/dev/null)
SWIFT_CONFIGURATION ?= debug
SWIFT_BIN_PATH := $(shell swift build -c $(SWIFT_CONFIGURATION) --show-bin-path)
PROTOC_GEN_SWIFT := $(shell swift build -c release --show-bin-path)/protoc-gen-swift
PROTOC_GEN_GRPC_SWIFT := $(shell swift build -c release --show-bin-path)/protoc-gen-grpc-swift-2
# Build swift protobuf generation tool using swift build for use in other steps
$(PROTOC_GEN_SWIFT): Package.swift
swift build -c release --product protoc-gen-swift
swift build -c release --product protoc-gen-grpc-swift-2
.PHONY: build-protos
build-protos: $(PROTOC_GEN_SWIFT) $(PROTOC_GEN_GRPC_SWIFT) ./dependencies/sdk-core/crates/common/protos
rm -rf $(PROTO_OUT)
mkdir -p $(PROTO_OUT)
# Generate proto message types (.pb.swift) - PUBLIC in Temporal module
protoc --plugin $(PROTOC_GEN_SWIFT) \
--swift_out $(PROTO_OUT) \
--swift_opt=FileNaming=PathToUnderscores \
--swift_opt=Visibility=Public \
--swift_opt=UseAccessLevelOnImports=true \
--swift_opt=EnumGeneration=Nonexhaustive \
-I ./dependencies/sdk-core/crates/common/protos/api_cloud_upstream \
-I ./dependencies/sdk-core/crates/common/protos/api_upstream \
-I ./dependencies/sdk-core/crates/common/protos/google \
-I ./dependencies/sdk-core/crates/common/protos/grpc \
-I ./dependencies/sdk-core/crates/common/protos/local \
-I ./dependencies/sdk-core/crates/common/protos/testsrv_upstream \
${PROTO_FILES_PUBLIC}
# Generate proto message types (.pb.swift) - PACKAGE in Temporal module
protoc --plugin $(PROTOC_GEN_SWIFT) \
--swift_out $(PROTO_OUT) \
--swift_opt=FileNaming=PathToUnderscores \
--swift_opt=Visibility=Package \
--swift_opt=UseAccessLevelOnImports=true \
-I ./dependencies/sdk-core/crates/common/protos/api_cloud_upstream \
-I ./dependencies/sdk-core/crates/common/protos/api_upstream \
-I ./dependencies/sdk-core/crates/common/protos/google \
-I ./dependencies/sdk-core/crates/common/protos/grpc \
-I ./dependencies/sdk-core/crates/common/protos/local \
-I ./dependencies/sdk-core/crates/common/protos/testsrv_upstream \
${PROTO_FILES_LOCAL}
# Generate gRPC service interfaces (.grpc.swift) - PACKAGE in Temporal module
protoc --plugin $(PROTOC_GEN_GRPC_SWIFT) \
--grpc-swift-2_out $(PROTO_OUT) \
--grpc-swift-2_opt=FileNaming=PathToUnderscores \
--grpc-swift-2_opt=Visibility=Package \
--grpc-swift-2_opt=UseAccessLevelOnImports=true \
--grpc-swift-2_opt=Client=true \
--grpc-swift-2_opt=Server=false \
-I ./dependencies/sdk-core/crates/common/protos/api_cloud_upstream \
-I ./dependencies/sdk-core/crates/common/protos/api_upstream \
-I ./dependencies/sdk-core/crates/common/protos/google \
-I ./dependencies/sdk-core/crates/common/protos/grpc \
-I ./dependencies/sdk-core/crates/common/protos/local \
-I ./dependencies/sdk-core/crates/common/protos/testsrv_upstream \
${PROTO_FILES_PUBLIC}
# Reorganize protobuf types into nested namespaces
swift run -c release NamespaceRefactorTool $(PROTO_OUT)
# Move generated Namespaces.swift to main sources
mv $(PROTO_OUT)/Namespaces.swift ./Sources/Temporal/Generated/Namespaces.swift
swift format -rip ./Sources/Temporal/Generated