cocoapods-mtxx-bin 0.0.9.1 → 0.0.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c65c28411ebe84f39594b4edc5a6c83729b48faf97715af4439f9df0b5c61553
4
- data.tar.gz: 3fd4c776db20bdfa9c3284a50b4d4d55f50f7cb1a5ce024719a998e616b8b802
3
+ metadata.gz: 6887cb67f5682b2edff6ac1e6ba31233d4b58a2ae509fecf4fcbcecd5e7af693
4
+ data.tar.gz: ce7199feb46ac2a4e2e49b30b6ee2e99acf26f4300164f4e7a6689f520c7de31
5
5
  SHA512:
6
- metadata.gz: cd94102dd7f8d97eb32155f7090d6cdde300ee7f159872658e35ad2338380f43f28d8f7be04725f11d185166e0f05b5130e4694b5ad53375cb3bfc16b954493d
7
- data.tar.gz: 676ebc6e13e65715e86464b783f7c157506915985664a609ba697cb0db1853ec806a347327c4e66b3c624c2b8a6d7204c12b7757b5a7527a9bec731277abac11
6
+ metadata.gz: cd5da7bb0b6476632cc6323ba276cf17264adcdfadd000aa1965333860905e43c74d3b8d5072414e81777f8cef92bea5c522057a473c5351e31b17626cf2d839
7
+ data.tar.gz: 8c4bc558c517cb54bb453026b1222f7f4ddadd67bffaba2c1a5b3868ff08288694b71a37daaa836ec36145c1da404246d93c4a60a2dd3dfb23bf8ffb5c88d8c1
@@ -35,6 +35,7 @@ module Pod
35
35
  @repo_update = argv.flag?('repo-update', false)
36
36
  @full_build = argv.flag?('full-build', false)
37
37
  @base_dir = "#{Pathname.pwd}/build_pods"
38
+ @version_helper = BinHelper.new
38
39
  super
39
40
  end
40
41
 
@@ -187,7 +188,7 @@ module Pod
187
188
  created_pods = []
188
189
  pod_targets.map do |pod_target|
189
190
  begin
190
- version = BinHelper.version(pod_target.pod_name, pod_target.root_spec.version.to_s, @analyze_result.specifications)
191
+ version = @version_helper.version(pod_target.pod_name, pod_target.root_spec.version.to_s, @analyze_result.specifications)
191
192
  # 全量
192
193
  if @full_build
193
194
  # 黑名单
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+ require 'cocoapods-mtxx-bin/helpers/buildAll/bin_helper'
2
3
 
3
4
  module Pod
4
5
  class Command
@@ -38,6 +39,7 @@ pod bin upload Pod1 1.0.0 Pod1.framework mtxxspecs --spec=Pod1.podspec
38
39
  @file = argv.shift_argument
39
40
  @repo = argv.shift_argument
40
41
  @spec = argv.option('spec', nil)
42
+ @xcode_version = BinHelper.xcode_version
41
43
  super
42
44
  end
43
45
 
@@ -125,7 +127,7 @@ pod bin upload Pod1 1.0.0 Pod1.framework mtxxspecs --spec=Pod1.podspec
125
127
  end
126
128
 
127
129
  def source
128
- url = "#{CBin.config.binary_download_url_str}/#{@name}/#{@version}/#{zip_file_name}"
130
+ url = "#{CBin.config.binary_download_url_str}/#{@xcode_version}/#{@name}/#{@version}/#{zip_file_name}"
129
131
  { http: url, type: 'zip' }
130
132
  end
131
133
 
@@ -2,7 +2,7 @@
2
2
  require 'cocoapods-mtxx-bin/command/bin/init'
3
3
  require 'cocoapods-mtxx-bin/command/bin/archive'
4
4
  require 'cocoapods-mtxx-bin/command/bin/auto'
5
- require 'cocoapods-mtxx-bin/command/bin/code'
5
+ # require 'cocoapods-mtxx-bin/command/bin/code'
6
6
  require 'cocoapods-mtxx-bin/command/bin/update'
7
7
  require 'cocoapods-mtxx-bin/command/bin/install'
8
8
  # require 'cocoapods-mtxx-bin/command/bin/imy'
@@ -1,5 +1,5 @@
1
1
  module CBin
2
- VERSION = "0.0.9.1"
2
+ VERSION = "0.0.12"
3
3
  end
4
4
 
5
5
  module Pod
@@ -5,15 +5,37 @@ module CBin
5
5
  class BinHelper
6
6
  include Pod
7
7
 
8
+ def initialize
9
+ super
10
+ @specs_str_md5_hash = Hash.new
11
+ end
12
+
8
13
  # 二进制版本号(x.y.z.bin[md5前6位])
9
- def self.version(pod_name, original_version, specifications)
10
- specs = specifications.map(&:name).select { |spec|
11
- spec.include?(pod_name) && !spec.include?('/Binary')
12
- }.sort!
13
- xcode_version = `xcodebuild -version`.split(' ').join('')
14
- specs << xcode_version
15
- specs_str = specs.join('')
16
- "#{original_version}.bin#{Digest::MD5.hexdigest(specs_str)[0,6]}"
14
+ def version(pod_name, original_version, specifications)
15
+ # 有缓存从缓存中取,没有则新建
16
+ if @specs_str_md5_hash[pod_name].nil?
17
+ specs = specifications.map(&:name).select { |spec|
18
+ spec.include?(pod_name) && !spec.include?('/Binary')
19
+ }.sort!
20
+ specs << xcode_version
21
+ specs_str = specs.join('')
22
+ specs_str_md5 = Digest::MD5.hexdigest(specs_str)[0,6]
23
+ @specs_str_md5_hash[pod_name] = specs_str_md5
24
+ else
25
+ specs_str_md5 = @specs_str_md5_hash[pod_name]
26
+ end
27
+ "#{original_version}.bin#{specs_str_md5}"
28
+ end
29
+
30
+ def xcode_version
31
+ @xcode_version ||= begin
32
+ `xcodebuild -version`.split(' ').join('')
33
+ end
34
+ end
35
+
36
+ def self.xcode_version
37
+ xcode_version = `xcodebuild -version`.split(' ').join('')
38
+ xcode_version
17
39
  end
18
40
 
19
41
  end
@@ -140,9 +140,13 @@ clean build \
140
140
  BUILD
141
141
  UI.info "#{command}"
142
142
  output = `#{command}`
143
- puts output
143
+ # puts output
144
144
  if $CHILD_STATUS.exitstatus != 0
145
145
  UI.info "#{@pod_target}(#{sdk}) 编译失败!".red
146
+ error_log_file = "#{temp_dir}/#{@pod_target}_error.log"
147
+ File.open(error_log_file, "w+") do |f|
148
+ f.write(output)
149
+ end
146
150
  return false
147
151
  end
148
152
  return true
@@ -119,7 +119,7 @@ module CBin
119
119
 
120
120
  def source
121
121
  # url = "http://localhost:8080/frameworks/#{@pod_target.root_spec.module_name}/#{version}/zip"
122
- url = "#{CBin.config.binary_download_url_str}/#{@pod_target.root_spec.module_name}/#{version}/#{@pod_target.root_spec.module_name}.framework_#{version}.zip"
122
+ url = "#{CBin.config.binary_download_url_str}/#{BinHelper.xcode_version}/#{@pod_target.root_spec.module_name}/#{version}/#{@pod_target.root_spec.module_name}.framework_#{version}.zip"
123
123
  { http: url, type: 'zip' }
124
124
  end
125
125
 
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+ require 'cocoapods-mtxx-bin/helpers/buildAll/bin_helper'
2
3
 
3
4
  module CBin
4
5
  module BuildAll
@@ -22,8 +23,9 @@ module CBin
22
23
  end
23
24
  UI.info "Uploading binary zip file #{@pod_target.root_spec.name} (#{@version || @pod_target.root_spec.version})".yellow do
24
25
  upload_url = CBin.config.binary_upload_url_str
25
- # upload_url = "http://localhost:8080/frameworks"
26
- command = "curl -F \"name=#{@pod_target.product_module_name}\" -F \"version=#{@version || @pod_target.root_spec.version}\" -F \"file=@#{zip_file}\" #{upload_url}"
26
+ # upload_url = "http://localhost:8080/frameworks" xcode_version
27
+ xcode_version = BinHelper.xcode_version
28
+ command = "curl -F \"name=#{@pod_target.product_module_name}\" -F \"version=#{@version || @pod_target.root_spec.version}\" -F \"xcode_version=#{xcode_version}\" -F \"file=@#{zip_file}\" #{upload_url}"
27
29
  UI.info "#{command}"
28
30
  json = `#{command}`
29
31
  UI.info json
@@ -0,0 +1,36 @@
1
+ module CBin
2
+ class PodSize
3
+ include Pod
4
+
5
+ # 存放大于阈值的Pod
6
+ @@pods = []
7
+ # 阈值,单位MB
8
+ @@size_threshold = 500
9
+
10
+ # 添加超过阈值的pod
11
+ def self.add_pod(pod)
12
+ if pod['size'].to_i < @@size_threshold * 1024
13
+ return
14
+ end
15
+ @@pods << pod
16
+ end
17
+
18
+ # 打印超过阈值的Pod库
19
+ def self.print_pods
20
+ if @@pods.empty?
21
+ return
22
+ end
23
+ UI.puts "\n"
24
+ UI.puts "以下Pod库下载大小大于阈值`#{@@size_threshold}MB`:".green
25
+ @@pods.map do |pod|
26
+ unit = 'KB'
27
+ size = pod['size'].to_i
28
+ if size >= 1024
29
+ unit = 'MB'
30
+ size = ('%.1f' % (size / 1024.0)).to_f
31
+ end
32
+ UI.puts " - #{pod['name']}:#{size}#{unit}".green
33
+ end
34
+ end
35
+ end
36
+ end
@@ -3,9 +3,103 @@ require 'parallel'
3
3
  require 'cocoapods'
4
4
  require 'xcodeproj'
5
5
  require 'cocoapods-mtxx-bin/native/pod_source_installer'
6
+ require 'cocoapods-mtxx-bin/helpers/pod_size_helper'
6
7
 
7
8
  module Pod
8
9
  class Installer
10
+
11
+ def cost_time_hash
12
+ @cost_time_hash ||= begin
13
+ Hash.new
14
+ end
15
+ end
16
+
17
+ # TODO: 不知道为啥无法hook
18
+ # 准备
19
+ alias old_prepare prepare
20
+ def prepare
21
+ start_time = Time.now
22
+ old_prepare
23
+ cost_time_hash['prepare'] = Time.now - start_time
24
+ end
25
+
26
+ # 依赖分析
27
+ alias old_resolve_dependencies resolve_dependencies
28
+ def resolve_dependencies
29
+ start_time = Time.now
30
+ analyzer = old_resolve_dependencies
31
+ cost_time_hash['resolve_dependencies'] = Time.now - start_time
32
+ analyzer
33
+ end
34
+
35
+ # 依赖下载
36
+ alias old_download_dependencies download_dependencies
37
+ def download_dependencies
38
+ start_time = Time.now
39
+ old_download_dependencies
40
+ cost_time_hash['download_dependencies'] = Time.now - start_time
41
+ end
42
+
43
+ # 验证target
44
+ alias old_validate_targets validate_targets
45
+ def validate_targets
46
+ start_time = Time.now
47
+ old_validate_targets
48
+ cost_time_hash['validate_targets'] = Time.now - start_time
49
+ end
50
+
51
+ # 集成
52
+ alias old_integrate integrate
53
+ def integrate
54
+ start_time = Time.now
55
+ old_integrate
56
+ cost_time_hash['integrate'] = Time.now - start_time
57
+ end
58
+
59
+ # 写入lock文件
60
+ def write_lockfiles
61
+ start_time = Time.now
62
+ @lockfile = generate_lockfile
63
+
64
+ UI.message "- Writing Lockfile in #{UI.path config.lockfile_path}" do
65
+ # No need to invoke Sandbox#update_changed_file here since this logic already handles checking if the
66
+ # contents of the file are the same.
67
+ @lockfile.write_to_disk(config.lockfile_path)
68
+ end
69
+
70
+ UI.message "- Writing Manifest in #{UI.path sandbox.manifest_path}" do
71
+ # No need to invoke Sandbox#update_changed_file here since this logic already handles checking if the
72
+ # contents of the file are the same.
73
+ @lockfile.write_to_disk(sandbox.manifest_path)
74
+ end
75
+ cost_time_hash['write_lockfiles'] = Time.now - start_time
76
+ end
77
+
78
+ # 执行post install
79
+ alias old_perform_post_install_actions perform_post_install_actions
80
+ def perform_post_install_actions
81
+ start_time = Time.now
82
+ old_perform_post_install_actions
83
+ cost_time_hash['perform_post_install_actions'] = Time.now - start_time
84
+ # 打印耗时
85
+ print_cost_time
86
+ # 打印大小大于阈值的库
87
+ CBin::PodSize.print_pods
88
+ end
89
+
90
+ # 打印耗时
91
+ def print_cost_time
92
+ UI.title '执行耗时:'.green do
93
+ UI.info '———————————————————————————————————————————————'.green
94
+ UI.info "|#{'Stage'.center(30)}|#{'Time(s)'.center(15)}|".green
95
+ UI.info '———————————————————————————————————————————————'.green
96
+ cost_time_hash.each do |key, value|
97
+ UI.info "|#{key.center(30)}|#{('%.3f' % value).to_s.center(15)}|".green
98
+ end
99
+ UI.info '———————————————————————————————————————————————'.green
100
+ end
101
+ end
102
+
9
103
  alias old_create_pod_installer create_pod_installer
10
104
  def create_pod_installer(pod_name)
11
105
  installer = old_create_pod_installer(pod_name)
@@ -79,6 +173,7 @@ module Pod
79
173
 
80
174
  module Downloader
81
175
  class Cache
176
+ require 'cocoapods-mtxx-bin/helpers/pod_size_helper'
82
177
  # 多线程锁
83
178
  @@lock = Mutex.new
84
179
 
@@ -100,6 +195,30 @@ module Pod
100
195
  version_file.open('w') { |f| f << Pod::VERSION }
101
196
  end
102
197
  end
198
+
199
+ def uncached_pod(request)
200
+ in_tmpdir do |target|
201
+ result, podspecs = download(request, target)
202
+ result.location = nil
203
+
204
+ # 记录下载大小大于阈值的库及大小
205
+ if File.exist?(target.to_s)
206
+ dir_size = `du -sk #{target.to_s}`.strip().split(' ')[0]
207
+ CBin::PodSize.add_pod({'name' => request.name, 'size' => dir_size})
208
+ end
209
+
210
+ podspecs.each do |name, spec|
211
+ destination = path_for_pod(request, :name => name, :params => result.checkout_options)
212
+ copy_and_clean(target, destination, spec)
213
+ write_spec(spec, path_for_spec(request, :name => name, :params => result.checkout_options))
214
+ if request.name == name
215
+ result.location = destination
216
+ end
217
+ end
218
+
219
+ result
220
+ end
221
+ end
103
222
  end
104
223
  end
105
224
  end
@@ -0,0 +1,69 @@
1
+ module Pod
2
+ class Lockfile
3
+ def detect_changes_with_podfile(podfile)
4
+ result = {}
5
+ [:added, :changed, :removed, :unchanged].each { |k| result[k] = [] }
6
+
7
+ installed_deps = {}
8
+ dependencies.each do |dep|
9
+ name = dep.root_name
10
+ installed_deps[name] ||= dependencies_to_lock_pod_named(name)
11
+ end
12
+
13
+ installed_deps = installed_deps.values.flatten(1).group_by(&:name)
14
+
15
+ podfile_dependencies = podfile.dependencies
16
+ podfile_dependencies_by_name = podfile_dependencies.group_by(&:name)
17
+
18
+ all_dep_names = (dependencies + podfile_dependencies).map(&:name).uniq
19
+ all_dep_names.each do |name|
20
+ installed_dep = installed_deps[name]
21
+ installed_dep &&= installed_dep.first
22
+
23
+ # 需要将二进制版本的 specific_version 最后一位去掉,否则二进制下依赖解析很慢
24
+ unless installed_dep.nil?
25
+ installed_dep_version = installed_dep.specific_version.to_s
26
+ if installed_dep_version.include?('bin')
27
+ req_arr = installed_dep_version.split('.').delete_if { |r| r.include?('bin') }
28
+ installed_dep_version = req_arr.join('.')
29
+ installed_dep.specific_version = Pod::Version.create(installed_dep_version)
30
+ end
31
+ end
32
+
33
+ podfile_dep = podfile_dependencies_by_name[name]
34
+ podfile_dep &&= podfile_dep.first
35
+
36
+ if installed_dep.nil? then key = :added
37
+ elsif podfile_dep.nil? then key = :removed
38
+ elsif podfile_dep.compatible?(installed_dep) then key = :unchanged
39
+ else key = :changed
40
+ end
41
+ result[key] << name
42
+ end
43
+ result
44
+ end
45
+
46
+ class << self
47
+ def generate_spec_repos(spec_repos)
48
+ result = Hash.new
49
+ spec_repos.map do |source, specs|
50
+ next unless source
51
+ next if specs.empty?
52
+ key = source.url || source.name
53
+
54
+ # save `trunk` as 'trunk' so that the URL itself can be changed without lockfile churn
55
+ key = Pod::TrunkSource::TRUNK_REPO_NAME if source.name == Pod::TrunkSource::TRUNK_REPO_NAME
56
+
57
+ value = specs.map { |s| s.root.name }.uniq
58
+ # 合并重复的source源,而不是替换
59
+ if result[key].nil?
60
+ result[key] = YAMLHelper.sorted_array(value)
61
+ else
62
+ result[key] = YAMLHelper.sorted_array(result[key].concat(value))
63
+ end
64
+ end
65
+ result.compact
66
+ end
67
+ end
68
+ end
69
+ end
@@ -131,7 +131,9 @@ module Pod
131
131
  value.payload = dep
132
132
  end
133
133
 
134
+ start_time = Time.now
134
135
  @activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies)
136
+ UI.puts "Molinillo resolve耗时:#{'%.1f' % (Time.now - start_time)}s".green
135
137
  resolver_specs_by_target
136
138
  rescue Molinillo::ResolverError => e
137
139
  handle_resolver_error(e)
@@ -177,7 +179,7 @@ module Pod
177
179
  use_binary = use_binary_rspecs.include?(rspec)
178
180
  if use_binary
179
181
  source = sources_manager.binary_source
180
- spec_version = CBin::BuildAll::BinHelper.version(rspec.root.name, rspec.spec.version, specifications)
182
+ spec_version = version_helper.version(rspec.root.name, rspec.spec.version, specifications)
181
183
  else
182
184
  # 获取podfile中的source
183
185
  podfile_sources = podfile.sources.uniq.map { |source| sources_manager.source_with_name_or_url(source) }
@@ -263,6 +265,12 @@ module Pod
263
265
  specs_by_target
264
266
  end
265
267
  end
268
+
269
+ def version_helper
270
+ @version_helper ||= begin
271
+ CBin::BuildAll::BinHelper.new
272
+ end
273
+ end
266
274
  end
267
275
 
268
276
  if Pod.match_version?('~> 1.4.0')
@@ -21,5 +21,6 @@ if Pod.match_version?('~> 1.4')
21
21
  require 'cocoapods-mtxx-bin/native/pod_target_installer'
22
22
  require 'cocoapods-mtxx-bin/native/target_validator'
23
23
  require 'cocoapods-mtxx-bin/native/gen'
24
+ require 'cocoapods-mtxx-bin/native/lockfile'
24
25
 
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-mtxx-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9.1
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-26 00:00:00.000000000 Z
11
+ date: 2022-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -135,6 +135,7 @@ files:
135
135
  - lib/cocoapods-mtxx-bin/helpers/framework_builder.rb
136
136
  - lib/cocoapods-mtxx-bin/helpers/library.rb
137
137
  - lib/cocoapods-mtxx-bin/helpers/library_builder.rb
138
+ - lib/cocoapods-mtxx-bin/helpers/pod_size_helper.rb
138
139
  - lib/cocoapods-mtxx-bin/helpers/sources_helper.rb
139
140
  - lib/cocoapods-mtxx-bin/helpers/spec_creator.rb
140
141
  - lib/cocoapods-mtxx-bin/helpers/spec_files_helper.rb
@@ -148,6 +149,7 @@ files:
148
149
  - lib/cocoapods-mtxx-bin/native/installation_options.rb
149
150
  - lib/cocoapods-mtxx-bin/native/installer.rb
150
151
  - lib/cocoapods-mtxx-bin/native/linter.rb
152
+ - lib/cocoapods-mtxx-bin/native/lockfile.rb
151
153
  - lib/cocoapods-mtxx-bin/native/path_source.rb
152
154
  - lib/cocoapods-mtxx-bin/native/pod_source_installer.rb
153
155
  - lib/cocoapods-mtxx-bin/native/pod_target_installer.rb