cocoapods-mtxx-bin 0.0.1 → 0.0.3

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.
@@ -7,6 +7,7 @@ require 'cocoapods-mtxx-bin/native/sources_manager'
7
7
  require 'cocoapods-mtxx-bin/native/installation_options'
8
8
  require 'cocoapods-mtxx-bin/gem_version'
9
9
  require 'cocoapods-mtxx-bin/command/bin/archive'
10
+ require 'cocoapods-mtxx-bin/helpers/buildAll/bin_helper'
10
11
 
11
12
  module Pod
12
13
  class Resolver
@@ -87,10 +88,54 @@ module Pod
87
88
  end
88
89
  end
89
90
 
91
+ # 读取黑名单
92
+ def read_black_list
93
+ project_root = Pod::Config.instance.project_root
94
+ config_file = File.join(project_root, 'BinConfig.yaml')
95
+ return nil unless File.exist?(config_file)
96
+ config = YAML.load(File.open(config_file))
97
+ return nil if config.nil?
98
+ install_config = config['install_config']
99
+ return nil if install_config.nil?
100
+ install_config['black_list']
101
+ end
102
+
90
103
  # >= 1.4.0 才有 resolver_specs_by_target 以及 ResolverSpecification
91
104
  # >= 1.5.0 ResolverSpecification 才有 source,供 install 或者其他操作时,输入 source 变更
92
105
  #
93
106
  if Pod.match_version?('~> 1.4')
107
+ old_resolve = instance_method(:resolve)
108
+ define_method(:resolve) do
109
+ dependencies = @podfile_dependency_cache.target_definition_list.flat_map do |target|
110
+ @podfile_dependency_cache.target_definition_dependencies(target).each do |dep|
111
+ next unless target.platform
112
+ @platforms_by_dependency[dep].push(target.platform)
113
+ end
114
+ end.uniq
115
+ @platforms_by_dependency.each_value(&:uniq!)
116
+
117
+ # 遍历locked_dependencies,将二进制版本号的最后一位删掉
118
+ locked_dependencies.each do |value|
119
+ next if value.nil?
120
+ # 获取 Pod::Dependency
121
+ dep = value.payload
122
+ next if dep.external_source
123
+ # 修改版本号限制
124
+ requirements = dep.requirement.as_list.map do |req|
125
+ req_arr = req.split('.').delete_if { |r| r.include?('bin') }
126
+ req_arr.join('.')
127
+ end
128
+ # 重新生成 Pod::Dependency
129
+ dep = Dependency.new(dep.name, requirements, {:source => dep.podspec_repo, :external_source => dep.external_source})
130
+ value.payload = dep
131
+ end
132
+
133
+ @activated = Molinillo::Resolver.new(self, self).resolve(dependencies, locked_dependencies)
134
+ resolver_specs_by_target
135
+ rescue Molinillo::ResolverError => e
136
+ handle_resolver_error(e)
137
+ end
138
+
94
139
  old_resolver_specs_by_target = instance_method(:resolver_specs_by_target)
95
140
  define_method(:resolver_specs_by_target) do
96
141
  specs_by_target = old_resolver_specs_by_target.bind(self).call
@@ -98,6 +143,12 @@ module Pod
98
143
  sources_manager = Config.instance.sources_manager
99
144
  use_source_pods = podfile.use_source_pods
100
145
 
146
+ # 从BinConfig读取black_list
147
+ black_list = read_black_list
148
+ use_source_pods.concat(black_list).uniq! unless black_list.nil?
149
+
150
+ specifications = specs_by_target.values.flatten.map(&:spec).uniq
151
+
101
152
  missing_binary_specs = []
102
153
  specs_by_target.each do |target, rspecs|
103
154
  # use_binaries 并且 use_source_pods 不包含 本地可过滤
@@ -125,19 +176,20 @@ module Pod
125
176
  use_binary = use_binary_rspecs.include?(rspec)
126
177
  if use_binary
127
178
  source = sources_manager.binary_source
179
+ spec_version = CBin::BuildAll::BinHelper.version(rspec.root.name, rspec.spec.version, specifications)
128
180
  else
129
181
  # 获取podfile中的source
130
- podfile_sources = podfile.sources.map { |source| sources_manager.source_with_name_or_url(source) }
131
- source = (sources_manager.code_source_list + podfile_sources).select do |s|
182
+ podfile_sources = podfile.sources.uniq.map { |source| sources_manager.source_with_name_or_url(source) }
183
+ source = (sources_manager.code_source_list + podfile_sources).uniq.select do |s|
132
184
  s.search(rspec.root.name)
133
185
  end.first
186
+ spec_version = rspec.spec.version
134
187
  end
135
188
 
136
- spec_version = rspec.spec.version
137
-
138
189
  raise Informative, "#{rspec.root.name}(#{spec_version})的podspec未找到,请执行 pod repo update 或添加相应的source源" unless source
139
190
 
140
- UI.message "- 开始处理 #{rspec.spec.name}(#{spec_version}) 组件."
191
+ UI.message "------------------- 分界线 -----------------------"
192
+ UI.message "- 开始处理 #{rspec.spec.name}(#{spec_version}) 组件(#{use_binary ? '二进制' : '源码'})."
141
193
 
142
194
  begin
143
195
  # 从新 source 中获取 spec,在bin archive中会异常,因为找不到
@@ -145,11 +197,19 @@ module Pod
145
197
 
146
198
  raise Informative, "Specification of #{rspec.root.name}(#{spec_version}) is nil" unless specification
147
199
 
148
- UI.message "#{rspec.root.name} #{spec_version} \r\n specification =#{specification} "
200
+ UI.message "specification = #{specification}"
149
201
  # 组件是 subspec
202
+ # subspec 需要特殊处理
203
+ # 如果是源码,则获取相应 subspec 的 specification
204
+ # 如果是二进制,则获取整个 specification
205
+ # if !use_binary && rspec.spec.subspec?
206
+ # specification = specification.subspec_by_name(rspec.name, false, true)
207
+ # end
208
+
150
209
  if rspec.spec.subspec?
151
210
  specification = specification.subspec_by_name(rspec.name, false, true)
152
211
  end
212
+
153
213
  # 这里可能出现分析依赖的 source 和切换后的 source 对应 specification 的 subspec 对应不上
154
214
  # 造成 subspec_by_name 返回 nil,这个是正常现象
155
215
  next unless specification
@@ -159,18 +219,17 @@ module Pod
159
219
  else
160
220
  rspec.used_by_tests_only
161
221
  end
162
- # used_by_only = rspec.respond_to?(:used_by_tests_only) ? rspec.used_by_tests_only : rspec.used_by_non_library_targets_only
163
222
  # 组装新的 rspec ,替换原 rspec
164
223
  rspec = if Pod.match_version?('~> 1.4.0')
165
224
  ResolverSpecification.new(specification, used_by_only)
166
225
  else
167
226
  ResolverSpecification.new(specification, used_by_only, source)
168
227
  end
169
- UI.message "组装新的 rspec ,替换原 rspec #{rspec.root.name} #{spec_version} \r\n specification =#{specification} \r\n #{rspec} "
228
+ UI.message "组装新的 rspec ,替换原 rspec #{rspec.root.name} (#{spec_version}) specification = #{specification} #{rspec} "
170
229
  rescue Pod::StandardError => e
171
230
  # 没有从新的 source 找到对应版本组件,直接返回原 rspec
172
231
  missing_binary_specs << rspec.spec if use_binary
173
- # missing_binary_specs << rspec.spec
232
+ UI.message "【#{rspec.spec.name} | #{rspec.spec.version}】组件无对应源码版本 , 将采用二进制版本依赖.".red unless use_binary
174
233
  rspec
175
234
  end
176
235
  rspec
@@ -179,7 +238,7 @@ module Pod
179
238
 
180
239
  if missing_binary_specs.any?
181
240
  missing_binary_specs.uniq.each do |spec|
182
- UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖."
241
+ UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖." unless spec.root.source[:type] == 'zip'
183
242
  end
184
243
  # 下面的代码为了实现 auto 命令的 --all-make
185
244
  Pod::Command::Bin::Archive.missing_binary_specs(missing_binary_specs)
@@ -13,6 +13,7 @@ module Pod
13
13
  # 二进制 source
14
14
  def binary_source
15
15
  source_with_name_or_url(CBin.config.binary_repo_url)
16
+ # source_with_name_or_url('git@github.com:Zhangyanshen/example-private-spec-bin.git')
16
17
  end
17
18
  end
18
19
  end
@@ -1,6 +1,7 @@
1
1
  require 'cocoapods-mtxx-bin/native/sources_manager'
2
2
  require 'cocoapods-mtxx-bin/command/bin/repo/update'
3
3
  require 'cocoapods/user_interface'
4
+ require 'yaml'
4
5
 
5
6
  Pod::HooksManager.register('cocoapods-mtxx-bin', :pre_install) do |_context, _|
6
7
  require 'cocoapods-mtxx-bin/native'
@@ -42,12 +43,23 @@ Pod::HooksManager.register('cocoapods-mtxx-bin', :source_provider) do |context,
42
43
  sources_manager = Pod::Config.instance.sources_manager
43
44
  podfile = Pod::Config.instance.podfile
44
45
  if podfile
46
+ # 读取配置文件
47
+ project_root = Pod::Config.instance.project_root
48
+ config_file = File.join(project_root, 'BinConfig.yaml')
49
+ if File.exist?(config_file)
50
+ config = YAML.load(File.open(config_file))
51
+ unless config.nil?
52
+ build_config = config['install_config'] || {}
53
+ use_binary = build_config['use_binary'] || false
54
+ podfile.use_binaries!(use_binary) if use_binary
55
+ end
56
+ end
45
57
  # 添加源码私有源 && 二进制私有源
46
58
  added_sources = sources_manager.code_source_list
47
- if podfile.use_binaries? || podfile.use_binaries_selector
48
- added_sources << sources_manager.binary_source
49
- added_sources.reverse!
50
- end
59
+ # if podfile.use_binaries? || podfile.use_binaries_selector
60
+ # added_sources << sources_manager.binary_source
61
+ # added_sources.reverse!
62
+ # end
51
63
  added_sources.each { |source| context.add_source(source)}
52
64
  end
53
65
  end
@@ -1,2 +1,11 @@
1
1
  require 'cocoapods-mtxx-bin/command'
2
2
  require 'cocoapods-mtxx-bin/source_provider_hook'
3
+ # require 'cocoapods-mtxx-bin/gem_version'
4
+ #
5
+ # msg = <<-MSG
6
+ # ————————————————————————————————
7
+ # |#{'cocoapods-mtxx-bin'.center(30)}|
8
+ # |#{CBin::VERSION.center(30)}|
9
+ # ————————————————————————————————
10
+ # MSG
11
+ # Pod::UI.puts msg.red
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.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-23 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -95,6 +95,7 @@ files:
95
95
  - lib/cocoapods-mtxx-bin/command/bin.rb
96
96
  - lib/cocoapods-mtxx-bin/command/bin/archive.rb
97
97
  - lib/cocoapods-mtxx-bin/command/bin/auto.rb
98
+ - lib/cocoapods-mtxx-bin/command/bin/buildAll.rb
98
99
  - lib/cocoapods-mtxx-bin/command/bin/code.rb
99
100
  - lib/cocoapods-mtxx-bin/command/bin/imy.rb
100
101
  - lib/cocoapods-mtxx-bin/command/bin/init.rb
@@ -116,6 +117,10 @@ files:
116
117
  - lib/cocoapods-mtxx-bin/gem_version.rb
117
118
  - lib/cocoapods-mtxx-bin/helpers.rb
118
119
  - lib/cocoapods-mtxx-bin/helpers/Info.plist
120
+ - lib/cocoapods-mtxx-bin/helpers/buildAll/bin_helper.rb
121
+ - lib/cocoapods-mtxx-bin/helpers/buildAll/builder.rb
122
+ - lib/cocoapods-mtxx-bin/helpers/buildAll/podspec_util.rb
123
+ - lib/cocoapods-mtxx-bin/helpers/buildAll/zip_file_helper.rb
119
124
  - lib/cocoapods-mtxx-bin/helpers/build_helper.rb
120
125
  - lib/cocoapods-mtxx-bin/helpers/build_utils.rb
121
126
  - lib/cocoapods-mtxx-bin/helpers/framework.rb