cocoapods-mtxx-bin 0.0.13 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cocoapods-mtxx-bin/command/bin/buildAll.rb +45 -23
- data/lib/cocoapods-mtxx-bin/command/bin/init.rb +14 -36
- data/lib/cocoapods-mtxx-bin/command/bin/lock/dependency.rb +82 -0
- data/lib/cocoapods-mtxx-bin/command/bin/lock/spec_repo.rb +105 -0
- data/lib/cocoapods-mtxx-bin/command/bin/lock/version.rb +41 -0
- data/lib/cocoapods-mtxx-bin/command/bin/lock.rb +36 -0
- data/lib/cocoapods-mtxx-bin/command/bin/outputSource.rb +18 -11
- data/lib/cocoapods-mtxx-bin/command/bin/upload.rb +2 -2
- data/lib/cocoapods-mtxx-bin/command/bin.rb +11 -12
- data/lib/cocoapods-mtxx-bin/config/config.rb +24 -49
- data/lib/cocoapods-mtxx-bin/config/config_asker.rb +1 -4
- data/lib/cocoapods-mtxx-bin/gem_version.rb +1 -1
- data/lib/cocoapods-mtxx-bin/helpers/buildAll/bin_helper.rb +11 -0
- data/lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb +44 -39
- data/lib/cocoapods-mtxx-bin/helpers/buildAll/podspec_util.rb +11 -8
- data/lib/cocoapods-mtxx-bin/helpers/buildAll/zip_file_helper.rb +17 -13
- data/lib/cocoapods-mtxx-bin/helpers/pod_size_helper.rb +30 -12
- data/lib/cocoapods-mtxx-bin/native/installer.rb +8 -7
- data/lib/cocoapods-mtxx-bin/native/podfile.rb +8 -0
- data/lib/cocoapods-mtxx-bin/native/podfile_env.rb +1 -0
- data/lib/cocoapods-mtxx-bin/native/resolver.rb +31 -32
- data/lib/cocoapods-mtxx-bin/native/sources_manager.rb +2 -1
- data/lib/cocoapods-mtxx-bin/source_provider_hook.rb +4 -2
- metadata +6 -6
- data/lib/cocoapods-mtxx-bin/command/bin/imy.rb +0 -45
- data/lib/cocoapods-mtxx-bin/command/bin/initHotKey.rb +0 -70
- data/lib/cocoapods-mtxx-bin/config/config_hot_key.rb +0 -103
- data/lib/cocoapods-mtxx-bin/config/config_hot_key_asker.rb +0 -57
@@ -3,7 +3,6 @@ require 'cocoapods-mtxx-bin/native/podfile'
|
|
3
3
|
require 'cocoapods-mtxx-bin/native/podfile_env'
|
4
4
|
require 'cocoapods/generate'
|
5
5
|
|
6
|
-
|
7
6
|
module CBin
|
8
7
|
class Config
|
9
8
|
def config_file
|
@@ -13,11 +12,9 @@ module CBin
|
|
13
12
|
def template_hash
|
14
13
|
{
|
15
14
|
'configuration_env' => { description: '编译环境', default: 'dev', selection: %w[dev debug_iphoneos release_iphoneos] },
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
# 'binary_type' => { description: '二进制打包类型', default: 'framework', selection: %w[framework library] },
|
20
|
-
'binary_download_url' => { description: '二进制文件下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s', default: 'https://manhattan-test.obs.cn-north-4.myhuaweicloud.com:443/ios/binary' },
|
15
|
+
'binary_repo_url' => { description: '二进制podspec私有源地址', default: 'git@github.com:Zhangyanshen/example-private-spec-bin.git' },
|
16
|
+
'binary_upload_url' => { description: '二进制文件上传地址', default: 'http://localhost:8080/frameworks' },
|
17
|
+
'binary_download_url' => { description: '二进制文件下载地址,后面会依次传入Xcode版本、configuration、组件名称与组件版本', default: 'http://localhost:8080/frameworks' },
|
21
18
|
'download_file_type' => { description: '二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] }
|
22
19
|
}
|
23
20
|
end
|
@@ -26,32 +23,15 @@ module CBin
|
|
26
23
|
file = config_dev_file
|
27
24
|
if configuration_env == "release_iphoneos"
|
28
25
|
file = config_release_iphoneos_file
|
29
|
-
# puts "====== #{configuration_env} 环境 ========"
|
30
26
|
elsif configuration_env == "debug_iphoneos"
|
31
27
|
file = config_debug_iphoneos_file
|
32
|
-
# puts "====== #{configuration_env} 环境 ========"
|
33
28
|
elsif configuration_env == "dev"
|
34
|
-
|
29
|
+
file = config_dev_file
|
35
30
|
else
|
36
31
|
raise "===== #{configuration_env} %w[dev debug_iphoneos release_iphoneos]===="
|
37
32
|
end
|
38
33
|
|
39
|
-
|
40
|
-
File.expand_path("#{binary_dir}/#{file}")
|
41
|
-
end
|
42
|
-
|
43
|
-
def config_file_with_configuration_env_list(configuration_env)
|
44
|
-
file = config_dev_file
|
45
|
-
# File.expand_path("#{Pod::Config.instance.home_dir}/#{file}")
|
46
|
-
File.expand_path("#{binary_dir}/#{file}")
|
47
|
-
end
|
48
|
-
|
49
|
-
def binary_dir
|
50
|
-
@binary_dir ||= begin
|
51
|
-
binary_dir = "#{Pod::Config.instance.project_root}/binary"
|
52
|
-
FileUtils.mkdir(binary_dir) unless File.exist?(binary_dir)
|
53
|
-
binary_dir
|
54
|
-
end
|
34
|
+
File.expand_path("#{Pod::Config.instance.project_root}/#{file}")
|
55
35
|
end
|
56
36
|
|
57
37
|
def configuration_env
|
@@ -66,13 +46,14 @@ module CBin
|
|
66
46
|
@configuration_env
|
67
47
|
end
|
68
48
|
|
69
|
-
|
49
|
+
# 上传二进制的url
|
70
50
|
def binary_upload_url_str
|
71
51
|
CBin.config.binary_upload_url
|
72
52
|
end
|
73
53
|
|
54
|
+
# 下载二进制的url
|
74
55
|
def binary_download_url_str
|
75
|
-
binary_download_url
|
56
|
+
CBin.config.binary_download_url
|
76
57
|
end
|
77
58
|
|
78
59
|
def set_configuration_env(env)
|
@@ -81,40 +62,29 @@ module CBin
|
|
81
62
|
|
82
63
|
#包含arm64 armv7架构,xcodebuild 是Debug模式
|
83
64
|
def config_debug_iphoneos_file
|
84
|
-
"bin_debug_iphoneos.yml"
|
65
|
+
".bin_debug_iphoneos.yml"
|
85
66
|
end
|
86
67
|
#包含arm64 armv7架构,xcodebuild 是Release模式
|
87
68
|
def config_release_iphoneos_file
|
88
|
-
"bin_release_iphoneos.yml"
|
69
|
+
".bin_release_iphoneos.yml"
|
89
70
|
end
|
90
71
|
#包含x86 arm64 armv7架构,xcodebuild 是Release模式
|
91
72
|
def config_dev_file
|
92
|
-
"bin_dev.yml"
|
73
|
+
".bin_dev.yml"
|
93
74
|
end
|
94
75
|
|
76
|
+
# 配置信息写入文件
|
95
77
|
def sync_config(config)
|
96
78
|
File.open(config_file_with_configuration_env(config['configuration_env']), 'w+') do |f|
|
97
79
|
f.write(config.to_yaml)
|
98
80
|
end
|
99
81
|
end
|
100
82
|
|
101
|
-
def
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
textTo = text.strip
|
107
|
-
list = textTo.split(": ")
|
108
|
-
configTo[list.first] = list.last
|
109
|
-
}
|
110
|
-
configTo
|
111
|
-
end
|
112
|
-
|
113
|
-
def sync_config_code_repo_url_list(config)
|
114
|
-
File.open(config_file_with_configuration_env_list(config['code_repo_url_list']), 'w+') do |f|
|
115
|
-
f.write(config.to_yaml)
|
116
|
-
end
|
117
|
-
end
|
83
|
+
# def sync_config_code_repo_url_list(config)
|
84
|
+
# File.open(config_file_with_configuration_env_list(config['code_repo_url_list']), 'w+') do |f|
|
85
|
+
# f.write(config.to_yaml)
|
86
|
+
# end
|
87
|
+
# end
|
118
88
|
|
119
89
|
def default_config
|
120
90
|
@default_config ||= Hash[template_hash.map { |k, v| [k, v[:default]] }]
|
@@ -164,11 +134,16 @@ module CBin
|
|
164
134
|
super
|
165
135
|
end
|
166
136
|
end
|
137
|
+
|
138
|
+
public
|
139
|
+
|
140
|
+
# 判断配置文件是否存在
|
141
|
+
def config_file_exist?
|
142
|
+
raise Pod::Informative, "当前目录下没有配置文件,请先执行`pod bin init`" unless File.exist?(config_file)
|
143
|
+
end
|
167
144
|
end
|
168
145
|
|
169
146
|
def self.config
|
170
147
|
@config ||= Config.new
|
171
148
|
end
|
172
|
-
|
173
|
-
|
174
149
|
end
|
@@ -37,7 +37,7 @@ module CBin
|
|
37
37
|
answer
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def welcome_message
|
41
41
|
print <<~EOF
|
42
42
|
|
43
43
|
设置插件配置信息.
|
@@ -52,9 +52,6 @@ module CBin
|
|
52
52
|
def done_message
|
53
53
|
print "\n设置完成.\n".green
|
54
54
|
end
|
55
|
-
def done_message_update
|
56
|
-
print "\n更新完成.\n".green
|
57
|
-
end
|
58
55
|
end
|
59
56
|
end
|
60
57
|
end
|
@@ -18,6 +18,7 @@ module CBin
|
|
18
18
|
spec.include?(pod_name) && !spec.include?('/Binary')
|
19
19
|
}.sort!
|
20
20
|
specs << xcode_version
|
21
|
+
specs << configuration
|
21
22
|
specs_str = specs.join('')
|
22
23
|
specs_str_md5 = Digest::MD5.hexdigest(specs_str)[0,6]
|
23
24
|
@specs_str_md5_hash[pod_name] = specs_str_md5
|
@@ -32,12 +33,22 @@ module CBin
|
|
32
33
|
`xcodebuild -version`.split(' ').join('')
|
33
34
|
end
|
34
35
|
end
|
36
|
+
|
37
|
+
def configuration
|
38
|
+
@configuration ||= begin
|
39
|
+
Pod::Config.instance.podfile.configuration
|
40
|
+
end
|
41
|
+
end
|
35
42
|
|
36
43
|
def self.xcode_version
|
37
44
|
xcode_version = `xcodebuild -version`.split(' ').join('')
|
38
45
|
xcode_version
|
39
46
|
end
|
40
47
|
|
48
|
+
def self.configuration
|
49
|
+
Pod::Config.instance.podfile.configuration
|
50
|
+
end
|
51
|
+
|
41
52
|
end
|
42
53
|
end
|
43
54
|
end
|
@@ -4,47 +4,54 @@ module CBin
|
|
4
4
|
class Builder
|
5
5
|
include Pod
|
6
6
|
|
7
|
-
def initialize(pod_target, checkout_sources)
|
7
|
+
def initialize(pod_target, checkout_sources, skip_simulator = false, configuration = 'Debug')
|
8
8
|
@pod_target = pod_target
|
9
9
|
@checkout_sources = checkout_sources
|
10
|
+
@skip_simulator = skip_simulator
|
11
|
+
@configuration = configuration
|
10
12
|
@file_accessors = pod_target.file_accessors unless pod_target.nil?
|
11
13
|
@base_dir = "#{Pathname.pwd}/build_pods"
|
12
14
|
end
|
13
15
|
|
14
16
|
# 构建
|
15
17
|
def build
|
16
|
-
UI.info "
|
18
|
+
UI.info "编译`#{@pod_target}`".yellow
|
17
19
|
dir = result_product_dir
|
18
20
|
FileUtils.rm_rf(dir) if File.exist?(dir)
|
19
21
|
# 编译模拟器
|
20
|
-
|
21
|
-
|
22
|
+
unless @skip_simulator
|
23
|
+
result = build_pod_target
|
24
|
+
return false unless result
|
25
|
+
end
|
22
26
|
# 编译真机
|
23
|
-
build_pod_target(false
|
27
|
+
build_pod_target(false)
|
24
28
|
end
|
25
29
|
|
26
30
|
# 创建binary
|
27
31
|
def create_binary
|
28
|
-
UI.info "
|
32
|
+
UI.info "创建`#{@pod_target.framework_name}`".yellow
|
29
33
|
# 如果是framework需要先copy
|
30
|
-
if build_as_framework
|
34
|
+
if build_as_framework?
|
31
35
|
copy_framework
|
32
36
|
else
|
33
37
|
create_framework_dir
|
34
|
-
end
|
35
|
-
# 合并真机模拟器
|
36
|
-
merge_device_sim
|
37
|
-
# 如果是lib需要拷贝头文件
|
38
|
-
unless build_as_framework
|
39
38
|
copy_headers
|
40
39
|
copy_headers(false )
|
41
40
|
generate_umbrella_header
|
42
41
|
generate_module_map
|
43
42
|
compile_resources
|
44
43
|
if @pod_target.uses_swift?
|
45
|
-
|
44
|
+
copy_iphoneos_swiftmodules
|
45
|
+
copy_simulator_swiftmodules unless @skip_simulator
|
46
|
+
end
|
47
|
+
if @skip_simulator
|
48
|
+
device_lib = "#{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.static_library_name}"
|
49
|
+
output = "#{result_product_dir}/#{@pod_target.product_module_name}"
|
50
|
+
`cp -f #{device_lib} #{output}`
|
46
51
|
end
|
47
52
|
end
|
53
|
+
# 合并真机模拟器
|
54
|
+
merge_device_sim unless @skip_simulator
|
48
55
|
# 拷贝资源文件
|
49
56
|
copy_resources
|
50
57
|
# 拷贝 vendored_frameworks 和 vendored_libraries
|
@@ -53,7 +60,7 @@ module CBin
|
|
53
60
|
end
|
54
61
|
|
55
62
|
# 是否以framework形式构建
|
56
|
-
def build_as_framework
|
63
|
+
def build_as_framework?
|
57
64
|
path = "#{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.framework_name}"
|
58
65
|
File.exist?(path)
|
59
66
|
end
|
@@ -94,16 +101,12 @@ module CBin
|
|
94
101
|
"#{@base_dir}/#{@pod_target}/Temp"
|
95
102
|
end
|
96
103
|
|
97
|
-
def configuration
|
98
|
-
"Debug"
|
99
|
-
end
|
100
|
-
|
101
104
|
def iphoneos
|
102
|
-
"#{configuration}-iphoneos"
|
105
|
+
"#{@configuration}-iphoneos"
|
103
106
|
end
|
104
107
|
|
105
108
|
def iphonesimulator
|
106
|
-
"#{configuration}-iphonesimulator"
|
109
|
+
"#{@configuration}-iphonesimulator"
|
107
110
|
end
|
108
111
|
|
109
112
|
# 需要排除的资源文件后缀
|
@@ -134,15 +137,14 @@ CONFIGURATION_TEMP_DIR=#{temp_dir} \
|
|
134
137
|
BUILD_ROOT=#{product_dir} \
|
135
138
|
BUILD_DIR=#{product_dir} \
|
136
139
|
clean build \
|
137
|
-
-configuration #{configuration} \
|
140
|
+
-configuration #{@configuration} \
|
138
141
|
-target #{@pod_target} \
|
139
142
|
-project #{project}
|
140
143
|
BUILD
|
141
144
|
UI.info "#{command}"
|
142
145
|
output = `#{command}`
|
143
|
-
# puts output
|
144
146
|
if $CHILD_STATUS.exitstatus != 0
|
145
|
-
UI.info "
|
147
|
+
UI.info "`#{@pod_target}(#{sdk})`编译失败!".red
|
146
148
|
error_log_file = "#{temp_dir}/#{@pod_target}_error.log"
|
147
149
|
File.open(error_log_file, "w+") do |f|
|
148
150
|
f.write(output)
|
@@ -154,7 +156,7 @@ clean build \
|
|
154
156
|
|
155
157
|
# 合并真机模拟器
|
156
158
|
def merge_device_sim
|
157
|
-
if build_as_framework
|
159
|
+
if build_as_framework?
|
158
160
|
device_lib_dir = "#{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.framework_name}/#{@pod_target.product_module_name}"
|
159
161
|
sim_lib_dir = "#{product_dir}/#{iphonesimulator}/#{@pod_target}/#{@pod_target.framework_name}/#{@pod_target.product_module_name}"
|
160
162
|
else
|
@@ -317,30 +319,33 @@ ibtool \
|
|
317
319
|
if File.exist?(source_path)
|
318
320
|
`rsync -av #{source_path} #{product_dir}`
|
319
321
|
end
|
320
|
-
# 如果包含Swift
|
322
|
+
# 如果包含Swift代码且需要编译模拟器,则copy模拟器swiftmodules
|
321
323
|
if @pod_target.uses_swift?
|
322
|
-
|
324
|
+
copy_simulator_swiftmodules unless @skip_simulator
|
323
325
|
end
|
324
326
|
end
|
325
327
|
|
326
|
-
#
|
327
|
-
def
|
328
|
-
|
329
|
-
|
330
|
-
|
328
|
+
# 拷贝真机swiftmodules(只用于static library)
|
329
|
+
def copy_iphoneos_swiftmodules
|
330
|
+
FileUtils.mkdir(modules_dir) unless File.exist?(modules_dir)
|
331
|
+
`cp -rf #{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.product_module_name}.swiftmodule #{modules_dir}`
|
332
|
+
end
|
333
|
+
|
334
|
+
# 拷贝模拟器swiftmodules
|
335
|
+
def copy_simulator_swiftmodules
|
336
|
+
target_swift_module = "#{modules_dir}/#{@pod_target.product_module_name}.swiftmodule"
|
337
|
+
if build_as_framework?
|
338
|
+
src_swift_module = "#{product_dir}/#{iphonesimulator}/#{@pod_target}/#{@pod_target.framework_name}/Modules/#{@pod_target.product_module_name}.swiftmodule"
|
331
339
|
else
|
332
|
-
|
333
|
-
`cp -rf #{product_dir}/#{iphoneos}/#{@pod_target}/#{@pod_target.product_module_name}.swiftmodule #{modules_dir}`
|
334
|
-
swift_module = "#{modules_dir}/#{@pod_target.product_module_name}.swiftmodule"
|
335
|
-
src_swift = "#{product_dir}/#{iphonesimulator}/#{@pod_target}/#{@pod_target.product_module_name}.swiftmodule"
|
340
|
+
src_swift_module = "#{product_dir}/#{iphonesimulator}/#{@pod_target}/#{@pod_target.product_module_name}.swiftmodule"
|
336
341
|
end
|
337
|
-
if File.exist?(
|
338
|
-
`cp -af #{
|
339
|
-
`cp -af #{
|
342
|
+
if File.exist?(target_swift_module)
|
343
|
+
`cp -af #{src_swift_module}/* #{target_swift_module}`
|
344
|
+
`cp -af #{src_swift_module}/Project/* #{target_swift_module}/Project`
|
340
345
|
end
|
341
346
|
end
|
342
347
|
|
343
|
-
# --------------------------
|
348
|
+
# -------------------------- clang module --------------------------------
|
344
349
|
|
345
350
|
# 生成 module map
|
346
351
|
def generate_module_map
|
@@ -4,15 +4,16 @@ module CBin
|
|
4
4
|
class PodspecUtil
|
5
5
|
include Pod
|
6
6
|
|
7
|
-
def initialize(pod_target, version, build_as_framework = false )
|
7
|
+
def initialize(pod_target, version, build_as_framework = false, configuration = 'Debug')
|
8
8
|
@pod_target = pod_target
|
9
9
|
@version = version
|
10
10
|
@build_as_framework = build_as_framework
|
11
|
+
@configuration = configuration
|
11
12
|
end
|
12
13
|
|
13
14
|
# 创建二进制podspec
|
14
15
|
def create_binary_podspec
|
15
|
-
UI.info "创建二进制podspec
|
16
|
+
UI.info "创建二进制podspec:`#{@pod_target}`".yellow
|
16
17
|
spec = @pod_target.root_spec.to_hash
|
17
18
|
root_dir = @pod_target.framework_name
|
18
19
|
# 处理版本号
|
@@ -45,7 +46,7 @@ module CBin
|
|
45
46
|
|
46
47
|
# podspec写入文件
|
47
48
|
def write_binary_podspec(spec)
|
48
|
-
UI.info "写入podspec
|
49
|
+
UI.info "写入podspec:`#{@pod_target}`".yellow
|
49
50
|
podspec_dir = "#{Pathname.pwd}/build_pods/#{@pod_target}/Products/podspec"
|
50
51
|
FileUtils.mkdir(podspec_dir) unless File.exist?(podspec_dir)
|
51
52
|
file = "#{podspec_dir}/#{@pod_target.pod_name}.podspec.json"
|
@@ -59,7 +60,7 @@ module CBin
|
|
59
60
|
|
60
61
|
# 上传二进制podspec
|
61
62
|
def push_binary_podspec(binary_podsepc_json)
|
62
|
-
UI.info "推送podspec
|
63
|
+
UI.info "推送podspec:`#{@pod_target}`".yellow
|
63
64
|
return unless File.exist?(binary_podsepc_json)
|
64
65
|
repo_name = Pod::Config.instance.sources_manager.binary_source.name
|
65
66
|
# repo_name = 'example-private-spec-bin'
|
@@ -69,8 +70,10 @@ module CBin
|
|
69
70
|
push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
|
70
71
|
push.validate!
|
71
72
|
push.run
|
73
|
+
return true
|
72
74
|
rescue Pod::StandardError => e
|
73
|
-
UI.info "推送podspec
|
75
|
+
UI.info "推送podspec:`#{@pod_target}`失败,#{e.to_s}".red
|
76
|
+
return false
|
74
77
|
end
|
75
78
|
end
|
76
79
|
|
@@ -118,9 +121,9 @@ module CBin
|
|
118
121
|
end
|
119
122
|
|
120
123
|
def source
|
121
|
-
# url = "http://localhost:8080/frameworks/#{@pod_target.root_spec.module_name}/#{version}/zip"
|
122
|
-
url = "#{CBin.config.binary_download_url_str}/#{BinHelper.xcode_version}/#{@pod_target.root_spec.module_name}/#{version}/#{@pod_target.
|
123
|
-
{ http: url, type:
|
124
|
+
# url = "http://localhost:8080/frameworks/#{BinHelper.xcode_version}/#{@pod_target.root_spec.module_name}/#{version}/zip"
|
125
|
+
url = "#{CBin.config.binary_download_url_str}/#{BinHelper.xcode_version}/#{@configuration}/#{@pod_target.root_spec.module_name}/#{version}/#{@pod_target.framework_name}_#{version}.zip"
|
126
|
+
{ http: url, type: CBin.config.download_file_type }
|
124
127
|
end
|
125
128
|
|
126
129
|
def version
|
@@ -6,11 +6,12 @@ module CBin
|
|
6
6
|
class ZipFileHelper
|
7
7
|
include Pod
|
8
8
|
|
9
|
-
def initialize(pod_target, version, product_dir, build_as_framework = false)
|
9
|
+
def initialize(pod_target, version, product_dir, build_as_framework = false, configuration = 'Debug')
|
10
10
|
@pod_target = pod_target
|
11
11
|
@version = version
|
12
12
|
@product_dir = product_dir
|
13
13
|
@build_as_framework = build_as_framework
|
14
|
+
@configuration = configuration
|
14
15
|
end
|
15
16
|
|
16
17
|
# 上传静态库
|
@@ -18,28 +19,27 @@ module CBin
|
|
18
19
|
Dir.chdir(@product_dir) do
|
19
20
|
zip_file = File.join(Dir.pwd, "#{zip_file_name}")
|
20
21
|
unless File.exist?(zip_file)
|
21
|
-
UI.info "
|
22
|
+
UI.info "`#{Dir.pwd}`目录下无`#{zip_file_name}`文件".red
|
22
23
|
return false
|
23
24
|
end
|
24
|
-
UI.info "Uploading binary zip file
|
25
|
+
UI.info "Uploading binary zip file `#{@pod_target.root_spec.name} (#{version})`".yellow do
|
25
26
|
upload_url = CBin.config.binary_upload_url_str
|
26
|
-
# upload_url = "http://localhost:8080/frameworks" xcode_version
|
27
27
|
xcode_version = BinHelper.xcode_version
|
28
|
-
command = "curl -F \"name=#{@pod_target.product_module_name}\" -F \"version=#{
|
28
|
+
command = "curl -F \"name=#{@pod_target.product_module_name}\" -F \"version=#{version}\" -F \"xcode_version=#{xcode_version}\" -F \"configuration=#{@configuration}\" -F \"file=@#{zip_file}\" #{upload_url}"
|
29
29
|
UI.info "#{command}"
|
30
30
|
json = `#{command}`
|
31
31
|
UI.info json
|
32
32
|
begin
|
33
|
-
|
34
|
-
if
|
35
|
-
Pod::UI.info "#{@pod_target.root_spec.name} (#{
|
33
|
+
success = JSON.parse(json)["success"]
|
34
|
+
if success
|
35
|
+
Pod::UI.info "#{@pod_target.root_spec.name} (#{version}) 上传成功".green
|
36
36
|
return true
|
37
37
|
else
|
38
|
-
Pod::UI.info "#{@pod_target.root_spec.name} (#{
|
38
|
+
Pod::UI.info "#{@pod_target.root_spec.name} (#{version}) 上传失败".red
|
39
39
|
return false
|
40
40
|
end
|
41
41
|
rescue JSON::ParserError => e
|
42
|
-
Pod::UI.info "#{@pod_target.root_spec.name} (#{
|
42
|
+
Pod::UI.info "#{@pod_target.root_spec.name} (#{version}) 上传失败".red
|
43
43
|
Pod::UI.info "#{e.to_s}".red
|
44
44
|
return false
|
45
45
|
end
|
@@ -54,16 +54,16 @@ module CBin
|
|
54
54
|
output_library = File.join(Dir.pwd, zip_file_name)
|
55
55
|
FileUtils.rm_f(output_library) if File.exist?(output_library)
|
56
56
|
unless File.exist?(input_library)
|
57
|
-
UI.info "
|
57
|
+
UI.info "没有需要压缩的二进制文件:`#{input_library}`".red
|
58
58
|
return false
|
59
59
|
end
|
60
60
|
|
61
|
-
UI.info "Compressing
|
61
|
+
UI.info "Compressing `#{input_library}` into `#{zip_file_name}`".yellow do
|
62
62
|
command = "zip --symlinks -r #{output_library} #{input_library}"
|
63
63
|
UI.info "#{command}"
|
64
64
|
`#{command}`
|
65
65
|
unless File.exist?(output_library)
|
66
|
-
UI.info "
|
66
|
+
UI.info "压缩`#{output_library}`失败".red
|
67
67
|
return false
|
68
68
|
end
|
69
69
|
return true
|
@@ -78,6 +78,10 @@ module CBin
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
def version
|
82
|
+
@version || @pod_target.root_spec.version
|
83
|
+
end
|
84
|
+
|
81
85
|
end
|
82
86
|
end
|
83
87
|
end
|
@@ -2,35 +2,53 @@ module CBin
|
|
2
2
|
class PodSize
|
3
3
|
include Pod
|
4
4
|
|
5
|
-
#
|
6
|
-
@@
|
5
|
+
# 多线程锁
|
6
|
+
@@lock = Mutex.new
|
7
7
|
# 阈值,单位MB
|
8
8
|
@@size_threshold = 500
|
9
|
+
# 存放过大Pod信息的临时文件
|
10
|
+
@@tmp_file_path = File.join(Dir.pwd, '.mtxx_big_pods.log')
|
9
11
|
|
10
12
|
# 添加超过阈值的pod
|
11
13
|
def self.add_pod(pod)
|
12
|
-
if pod[
|
14
|
+
if pod[:size].to_i < @@size_threshold * 1024
|
13
15
|
return
|
14
16
|
end
|
15
|
-
@@
|
17
|
+
@@lock.synchronize do
|
18
|
+
File.open(@@tmp_file_path, "a") do |f|
|
19
|
+
f.write(format_pod_size(pod))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# 格式化pod
|
25
|
+
def self.format_pod_size(pod)
|
26
|
+
unit = 'KB'
|
27
|
+
size = pod[:size].to_i
|
28
|
+
if size >= 1024 * 1024
|
29
|
+
unit = 'GB'
|
30
|
+
size = ('%.1f' % (size / 1024.0 / 1024.0)).to_f
|
31
|
+
elsif size >= 1024
|
32
|
+
unit = 'MB'
|
33
|
+
size = ('%.1f' % (size / 1024.0)).to_f
|
34
|
+
end
|
35
|
+
"#{pod[:name]}:#{size}#{unit}\n"
|
16
36
|
end
|
17
37
|
|
18
38
|
# 打印超过阈值的Pod库
|
19
39
|
def self.print_pods
|
20
|
-
|
40
|
+
unless File.exist?(@@tmp_file_path)
|
21
41
|
return
|
22
42
|
end
|
23
43
|
UI.puts "\n"
|
24
44
|
UI.puts "以下Pod库下载大小大于阈值`#{@@size_threshold}MB`:".green
|
25
|
-
@@
|
26
|
-
|
27
|
-
|
28
|
-
if size >= 1024
|
29
|
-
unit = 'MB'
|
30
|
-
size = ('%.1f' % (size / 1024.0)).to_f
|
45
|
+
File.open(@@tmp_file_path, "r") do |f|
|
46
|
+
f.readlines.map do |line|
|
47
|
+
UI.puts " - #{line.strip}".green
|
31
48
|
end
|
32
|
-
UI.puts " - #{pod['name']}:#{size}#{unit}".green
|
33
49
|
end
|
50
|
+
# 打印完成后,删除临时文件
|
51
|
+
FileUtils.rm_f(@@tmp_file_path) if File.exist?(@@tmp_file_path)
|
34
52
|
end
|
35
53
|
end
|
36
54
|
end
|
@@ -97,14 +97,15 @@ module Pod
|
|
97
97
|
|
98
98
|
# 打印耗时
|
99
99
|
def print_cost_time
|
100
|
-
|
101
|
-
|
102
|
-
UI.info "
|
103
|
-
UI.info '
|
100
|
+
prefix = 'pod_time_profiler:'
|
101
|
+
UI.title "#{prefix} pod执行耗时:".green do
|
102
|
+
UI.info "#{prefix} ———————————————————————————————————————————————".green
|
103
|
+
UI.info "#{prefix} |#{'Stage'.center(30)}|#{'Time(s)'.center(15)}|".green
|
104
|
+
UI.info "#{prefix} ———————————————————————————————————————————————".green
|
104
105
|
cost_time_hash.each do |key, value|
|
105
|
-
UI.info "|#{key.center(30)}|#{('%.3f' % value).to_s.center(15)}|".green
|
106
|
+
UI.info "#{prefix} |#{key.center(30)}|#{('%.3f' % value).to_s.center(15)}|".green
|
106
107
|
end
|
107
|
-
UI.info
|
108
|
+
UI.info "#{prefix} ———————————————————————————————————————————————".green
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
@@ -212,7 +213,7 @@ module Pod
|
|
212
213
|
# 记录下载大小大于阈值的库及大小
|
213
214
|
if File.exist?(target.to_s)
|
214
215
|
dir_size = `du -sk #{target.to_s}`.strip().split(' ')[0]
|
215
|
-
CBin::PodSize.add_pod({
|
216
|
+
CBin::PodSize.add_pod({:name => request.name, :size => dir_size})
|
216
217
|
end
|
217
218
|
|
218
219
|
podspecs.each do |name, spec|
|
@@ -28,6 +28,10 @@ module Pod
|
|
28
28
|
set_internal_hash_value(USE_SOURCE_PODS, hash_pods_use_source)
|
29
29
|
end
|
30
30
|
|
31
|
+
def set_configuration(config = 'Debug')
|
32
|
+
set_internal_hash_value(CONFIGURATION, config)
|
33
|
+
end
|
34
|
+
|
31
35
|
# 0 dev
|
32
36
|
# 1 debug_iphoneos
|
33
37
|
# 2 release_iphoneos
|
@@ -69,6 +73,10 @@ module Pod
|
|
69
73
|
get_internal_hash_value(CONFIGURATION_ENV, "dev") || ENV[CONFIGURATION_ENV] == "dev"
|
70
74
|
end
|
71
75
|
|
76
|
+
def configuration
|
77
|
+
get_internal_hash_value(CONFIGURATION, "Debug")
|
78
|
+
end
|
79
|
+
|
72
80
|
private
|
73
81
|
|
74
82
|
def valid_bin_plugin
|