cocoapods-mtxx-bin 0.0.9.1 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c65c28411ebe84f39594b4edc5a6c83729b48faf97715af4439f9df0b5c61553
4
- data.tar.gz: 3fd4c776db20bdfa9c3284a50b4d4d55f50f7cb1a5ce024719a998e616b8b802
3
+ metadata.gz: 40602fdc840e2eb27939c1f3eaffb2d008c35ac79834e9388a254b5663138510
4
+ data.tar.gz: bde311b8c960a178b1c033715d60e22281b97a90143602649ed4edff83d5ac51
5
5
  SHA512:
6
- metadata.gz: cd94102dd7f8d97eb32155f7090d6cdde300ee7f159872658e35ad2338380f43f28d8f7be04725f11d185166e0f05b5130e4694b5ad53375cb3bfc16b954493d
7
- data.tar.gz: 676ebc6e13e65715e86464b783f7c157506915985664a609ba697cb0db1853ec806a347327c4e66b3c624c2b8a6d7204c12b7757b5a7527a9bec731277abac11
6
+ metadata.gz: 6061d7be0b25cf7270f789cac3fa6984029a47ff4856c769615a96777a9b968b7de071d6eeb857729f15a18126293ff24571722b811e8ef807ac75116cf9a336
7
+ data.tar.gz: 8c1d5822f00a15c3613b4b9bb1a2b23c92e95e478c5e98fee6b92746d3d126c18351f6c64ea11895735995b6843f08b5196ab2e13ffb8a07f0c0a29c3c0cd420
@@ -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.10"
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
@@ -16,7 +16,7 @@ module Pod
16
16
  env_option :warn_for_unsecure_source, false
17
17
 
18
18
  # 是否多线程执行 install_pod_sources
19
- env_option :install_with_multi_threads, false
19
+ env_option :install_with_multi_threads, true
20
20
 
21
21
  # 是否多进程执行 update_repositories
22
22
  env_option :update_source_with_multi_threads, false
@@ -6,6 +6,86 @@ require 'cocoapods-mtxx-bin/native/pod_source_installer'
6
6
 
7
7
  module Pod
8
8
  class Installer
9
+
10
+ def cost_time_hash
11
+ @cost_time_hash ||= begin
12
+ Hash.new
13
+ end
14
+ end
15
+
16
+ # TODO: 不知道为啥无法hook
17
+ # 准备
18
+ alias old_prepare prepare
19
+ def prepare
20
+ start_time = Time.now
21
+ old_prepare
22
+ cost_time_hash['prepare'] = Time.now - start_time
23
+ end
24
+
25
+ # 依赖分析
26
+ alias old_resolve_dependencies resolve_dependencies
27
+ def resolve_dependencies
28
+ start_time = Time.now
29
+ analyzer = old_resolve_dependencies
30
+ cost_time_hash['resolve_dependencies'] = Time.now - start_time
31
+ analyzer
32
+ end
33
+
34
+ # 依赖下载
35
+ alias old_download_dependencies download_dependencies
36
+ def download_dependencies
37
+ start_time = Time.now
38
+ old_download_dependencies
39
+ cost_time_hash['download_dependencies'] = Time.now - start_time
40
+ end
41
+
42
+ # 验证target
43
+ alias old_validate_targets validate_targets
44
+ def validate_targets
45
+ start_time = Time.now
46
+ old_validate_targets
47
+ cost_time_hash['validate_targets'] = Time.now - start_time
48
+ end
49
+
50
+ # 集成
51
+ alias old_integrate integrate
52
+ def integrate
53
+ start_time = Time.now
54
+ old_integrate
55
+ cost_time_hash['integrate'] = Time.now - start_time
56
+ end
57
+
58
+ # 写入lock文件
59
+ alias old_write_lockfiles write_lockfiles
60
+ def write_lockfiles
61
+ start_time = Time.now
62
+ old_write_lockfiles
63
+ cost_time_hash['write_lockfiles'] = Time.now - start_time
64
+ end
65
+
66
+ # 执行post install
67
+ alias old_perform_post_install_actions perform_post_install_actions
68
+ def perform_post_install_actions
69
+ start_time = Time.now
70
+ old_perform_post_install_actions
71
+ cost_time_hash['perform_post_install_actions'] = Time.now - start_time
72
+ # 打印耗时
73
+ print_cost_time
74
+ end
75
+
76
+ # 打印耗时
77
+ def print_cost_time
78
+ UI.title '执行耗时:'.green do
79
+ UI.info '———————————————————————————————————————————————'.green
80
+ UI.info "|#{'Stage'.center(30)}|#{'Time(s)'.center(15)}|".green
81
+ UI.info '———————————————————————————————————————————————'.green
82
+ cost_time_hash.each do |key, value|
83
+ UI.info "|#{key.center(30)}|#{value.to_s.center(15)}|".green
84
+ end
85
+ UI.info '———————————————————————————————————————————————'.green
86
+ end
87
+ end
88
+
9
89
  alias old_create_pod_installer create_pod_installer
10
90
  def create_pod_installer(pod_name)
11
91
  installer = old_create_pod_installer(pod_name)
@@ -0,0 +1,46 @@
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
+ end
46
+ 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耗时:#{Time.now - start_time}".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.10
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-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -148,6 +148,7 @@ files:
148
148
  - lib/cocoapods-mtxx-bin/native/installation_options.rb
149
149
  - lib/cocoapods-mtxx-bin/native/installer.rb
150
150
  - lib/cocoapods-mtxx-bin/native/linter.rb
151
+ - lib/cocoapods-mtxx-bin/native/lockfile.rb
151
152
  - lib/cocoapods-mtxx-bin/native/path_source.rb
152
153
  - lib/cocoapods-mtxx-bin/native/pod_source_installer.rb
153
154
  - lib/cocoapods-mtxx-bin/native/pod_target_installer.rb