-
Notifications
You must be signed in to change notification settings - Fork 1
/
Podfile
123 lines (100 loc) · 3.65 KB
/
Podfile
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
TOKEN_PROTOS_VER = "1.4.4"
FANK_PROTOS_VER = "1.2.4"
RPC_PROTOS_VER = "1.0.124"
platform :ios, '9.0'
inhibit_all_warnings!
target 'TokenSdk' do
pod '!ProtoCompiler'#, '3.8.0'
pod '!ProtoCompiler-gRPCPlugin'#, '1.23.0'
pod "OrderedDictionary"
pod 'Unirest', '~>1.1.4'
# A workaround for issue https://github.com/firebase/firebase-ios-sdk/issues/2665
pod 'Protobuf', :inhibit_warnings => true
target 'TokenSdkTests' do
inherit! :search_paths
pod 'Protobuf', :inhibit_warnings => true
end
end
require 'open-uri'
#
# Fetches specified proto files from the artifact repository.
#
def fetch_protos()
def download(path, name, type, version)
file = "#{name}-#{type}-#{version}.jar"
puts("Downloading #{file} ...")
m2path = ENV["HOME"] + "/.m2/repository/#{path}/#{name}-#{type}/#{version}/#{file}"
if File.file?(m2path) then
FileUtils.cp(m2path, file)
else
url = "https://token.jfrog.io/token/libs-release/#{path}/#{name}-#{type}/#{version}/#{file}"
open(file, 'wb') do |file|
file << URI.open(url).read
end
end
file
end
system("rm protos/common/*.proto")
system("rm -rf protos/external")
file = download("io/token/proto", "tokenio-proto", "external", TOKEN_PROTOS_VER)
system("unzip -d protos/external -o #{file} 'gateway/*.proto'")
system("rm -f #{file}");
file = download("io/token/proto", "tokenio-proto", "common", TOKEN_PROTOS_VER)
system("unzip -d protos/common -o #{file} '*.proto'")
system("unzip -d protos/common -o #{file} 'google/api/*.proto'")
system("rm -f #{file}");
file = download("io/token/fank", "tokenio-fank", "proto", FANK_PROTOS_VER)
system("unzip -d protos -o #{file} '*.proto'")
system("rm -f #{file}");
file = download("io/token/rpc", "tokenio-rpc", "proto", RPC_PROTOS_VER)
system("unzip -d protos -o #{file} '*.proto'")
system("rm -f #{file}");
end
#
# Generates Objective-C code for the protos.
#
def generate_protos_cmd(path_to_protos, out_dir)
# Base directory where the .proto files are.
src = "./protos"
# Pods directory corresponding to this app's Podfile, relative to the location of this podspec.
pods_root = 'Pods'
# Path where Cocoapods downloads protoc and the gRPC plugin.
protoc_dir = "#{pods_root}/!ProtoCompiler"
protoc = "#{protoc_dir}/protoc"
plugin = "#{pods_root}/!ProtoCompiler-gRPCPlugin/grpc_objective_c_plugin"
result = <<-CMD
mkdir -p #{out_dir}
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--objc_out=#{out_dir} \
--grpc_out=#{out_dir} \
-I #{src}/common \
-I #{src}/external \
-I #{src} \
-I #{protoc_dir} \
#{src}/#{path_to_protos}/*.proto
CMD
result
end
post_install do |installer|
# Fetch the protos.
fetch_protos();
# Build the command that generates the protos.
dir = "src/generated"
system("rm -rf #{dir}");
gencommand =
generate_protos_cmd("common", dir) +
generate_protos_cmd("common/provider", dir) +
generate_protos_cmd("common/google/api", dir) +
generate_protos_cmd("common/google/protobuf", dir) +
generate_protos_cmd("external/gateway", dir) +
generate_protos_cmd("fank", dir) +
generate_protos_cmd("extensions", dir) ;
system(gencommand)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.12'
end
end
end