cocoapods-tdfire-binary 1.0.6 → 1.0.7

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
  SHA1:
3
- metadata.gz: 93538d683f5a872ea846131cf45e346f5ca9d754
4
- data.tar.gz: 33836f8a6b47157a0e0add735259aa32204b5cdc
3
+ metadata.gz: c4f9de30f1f300cf522c497fa292cfa432f88747
4
+ data.tar.gz: be89ce05a1e6ac3877dba51a3bb9cfb52fcd7180
5
5
  SHA512:
6
- metadata.gz: 1b85fef5485aa1a420d921e5e1178e5ff0a9173ff0db2d4812e5d2bd5026108b20378bff6b15f8c2889ab5a053ffe0b6919827d7b5cc0f384c8646c716b36792
7
- data.tar.gz: 8cea5c8e40aab3d44fd644713f9ea63f6a0992f6086f30780818ecaf153bc642f2c4459b97b3c92af22ded4b1b38538e44bfc908cfedfffd403e90eb5f5993a8
6
+ metadata.gz: a53412925b6e6bec7ea72778974cb56fa5b133a7a1d7653956621042260f1ca3e3ce0d9338836b8e1b66bc77864ab4ca73d58c6b48ace0088a64af1c8bcc8fa7
7
+ data.tar.gz: 9c4f615d3b377c3fff51706cb152496ad980b428fa21099c59007243b0f8955ccb84d240269d2defa5f61e8a0650ae8d3a2a7d8b4bffbcb7af203bda7d9bbaee
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocoapods-tdfire-binary (1.0.6)
5
- cocoapods (= 1.2.1)
4
+ cocoapods-tdfire-binary (1.0.7)
5
+ cocoapods (~> 1.2)
6
6
  cocoapods-packager (~> 1.5.0)
7
7
 
8
8
  GEM
data/README.md CHANGED
@@ -58,6 +58,9 @@ use_frameworks!
58
58
 
59
59
  ### For podspec
60
60
 
61
+ > 目前只支持 iOS 平台 (插件内部也会进行限制)
62
+
63
+
61
64
  ```
62
65
  ...
63
66
 
@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'bundler', '~> 1.3'
22
22
  spec.add_development_dependency 'rake', '~> 12.0'
23
23
 
24
- spec.add_dependency 'cocoapods', '1.2.1'
25
- spec.add_dependency 'cocoapods-packager', '~> 1.5.0'
24
+ spec.add_runtime_dependency 'cocoapods', '~> 1.2'
25
+ spec.add_runtime_dependency 'cocoapods-packager', '~> 1.5.0'
26
26
  end
@@ -1 +1,7 @@
1
1
  require 'cocoapods-tdfire-binary/gem_version'
2
+
3
+ require 'cocoapods'
4
+ require 'cocoapods-tdfire-binary/podfile_dsl'
5
+ require 'cocoapods-tdfire-binary/specification_dsl'
6
+
7
+
@@ -1,36 +1,46 @@
1
1
  require 'cocoapods-tdfire-binary/binary_url_manager'
2
+ require 'cocoapods-tdfire-binary/binary_state_store'
2
3
 
3
4
  module Pod
4
5
  class Specification
5
6
  #--------------------------------------------------------------------#
6
7
  # => 获取自身以及子组件的属性合并值
7
8
  #--------------------------------------------------------------------#
8
- def all_value_for_attribute(name)
9
- (Array(self) + Array(recursive_subspecs))
10
- .map { |s| s.attributes_hash[name] }
11
- .compact
12
- end
13
-
14
- def all_hash_value_for_attribute(name)
15
- all_value_for_attribute(name).reduce({}, :merge)
16
- end
17
-
18
- def all_array_value_for_attribute(name)
19
- all_value_for_attribute(name).flatten
20
- end
21
-
22
- def store_array_value_with_attribute_and_reference_spec(name, spec)
23
- temp = spec.all_array_value_for_attribute(name)
24
- temp += attributes_hash[name] unless attributes_hash[name].nil?
25
- store_attribute(name, temp) unless temp.empty?
26
- end
27
-
28
- def store_hash_value_with_attribute_and_reference_spec(name, spec, &select)
29
- temp = spec.all_hash_value_for_attribute(name)
30
- temp.merge!(attributes_hash[name]) unless attributes_hash[name].nil?
31
- temp.select! { |k, v| yield k if block_given? }
32
- store_attribute(name, temp) unless temp.empty?
33
- end
9
+ # def all_value_for_attribute(name)
10
+ # (Array(self) + Array(recursive_subspecs))
11
+ # .map { |s| s.attributes_hash[name] }
12
+ # .compact
13
+ # end
14
+ #
15
+ # def all_hash_value_for_attribute(name)
16
+ # all_value_for_attribute(name).reduce({}, :merge)
17
+ # end
18
+ #
19
+ # def all_array_value_for_attribute(name)
20
+ # all_value_for_attribute(name).flatten
21
+ # end
22
+ #
23
+ # def store_array_value_with_attribute_and_reference_spec(name, spec)
24
+ # temp = spec.all_array_value_for_attribute(name)
25
+ # temp += attributes_hash[name] unless attributes_hash[name].nil?
26
+ # store_attribute(name, temp) unless temp.empty?
27
+ # end
28
+ #
29
+ # def store_hash_value_with_attribute_and_reference_spec(name, spec, &select)
30
+ # temp = spec.all_hash_value_for_attribute(name)
31
+ # temp.merge!(attributes_hash[name]) unless attributes_hash[name].nil?
32
+ # temp.select! { |k, v| yield k } if block_given?
33
+ # store_attribute(name, temp) unless temp.empty?
34
+ # end
35
+
36
+ def tdfire_recursive_value(name, platform = :ios)
37
+ subspec_consumers = recursive_subspecs
38
+ .select { |s| s.supported_on_platform?(platform) }
39
+ .map { |s| s.consumer(platform) }
40
+ .uniq
41
+ value = (Array(consumer(platform)) + subspec_consumers).map { |c| c.send(name) }.flatten
42
+ value
43
+ end
34
44
  #--------------------------------------------------------------------#
35
45
  end
36
46
  end
@@ -44,13 +54,24 @@ module Pod
44
54
  @target_spec = target_spec
45
55
  end
46
56
 
57
+ def configure_source
58
+ # 在设置了 use_frameworks! 的情况下才会生效
59
+ set_use_static_framework
60
+
61
+ # cocoapods-package 打包时,只让 iOS 平台生效
62
+ set_platform_limitation(target_spec) if Pod::Tdfire::BinaryStateStore.limit_platform
63
+ end
64
+
47
65
  #--------------------------------------------------------------------#
48
66
  # 生成default subspec TdfireBinary ,并将源码依赖时的配置转移到此 subspec 上
49
- def configure_binary_default_subspec_with_reference_spec(spec)
67
+ def configure_binary_default_subspec(spec)
68
+ # 限制二进制只支持 iOS 平台 (这里是 parent spec)
69
+ set_platform_limitation(spec)
70
+
50
71
  default_subspec = "TdfireBinary"
51
72
  target_spec.subspec default_subspec do |ss|
52
73
  subspec_refactor = BinarySpecificationRefactor.new(ss)
53
- subspec_refactor.configure_binary_with_reference_spec(spec)
74
+ subspec_refactor.configure_binary(spec)
54
75
  end
55
76
 
56
77
  # 创建源码依赖时的 subspec,并且设置所有的 subspec 依赖 default_subspec
@@ -68,44 +89,73 @@ module Pod
68
89
 
69
90
  #--------------------------------------------------------------------#
70
91
  # spec 是二进制依赖时的配置
71
- def configure_binary_with_reference_spec(spec)
92
+ def configure_binary(spec)
93
+ # 限制二进制只支持 iOS 平台 (这里是 spec 或者 subpsec)
94
+ set_platform_limitation(spec)
95
+
72
96
  # 组件 frameworks 的依赖
73
97
  target_spec.vendored_frameworks = "#{target_spec.root.name}.framework"
74
98
  # target_spec.source_files = "#{target_spec.root.name}.framework/Headers/*"
75
99
  # target_spec.public_header_files = "#{target_spec.root.name}.framework/Headers/*"
76
100
 
77
- # 保留对 frameworks lib 的依赖
78
- %w[frameworks libraries weak_frameworks].each do |name|
79
- target_spec.store_array_value_with_attribute_and_reference_spec(name, spec)
80
- end
101
+ available_platforms(spec).each do |platform|
102
+ Pod::UI.section("Tdfire: copying configuration for platform #{platform}") do
103
+ target_platform = target_spec.send(platform.to_sym)
81
104
 
82
- # 保留对其他组件的依赖
83
- target_spec.store_hash_value_with_attribute_and_reference_spec('dependencies', spec) do |name|
84
- # 去除对自身子组件的依赖
85
- name.split('/').first != target_spec.root.name
86
- end
105
+ # 保留对 frameworks lib 的依赖
106
+ %w[frameworks libraries weak_frameworks].each do |name|
107
+ value = spec.tdfire_recursive_value(name, platform )
108
+ target_platform.send("#{name}=", value) unless value.empty?
87
109
 
88
- Pod::UI.message "Tdfire: dependencies for #{target_spec.name}: #{target_spec.dependencies.map(&:name).join(', ')}"
89
- end
110
+ Pod::UI.message "Tdfire: #{name} for #{platform}: #{target_spec.tdfire_recursive_value(name, platform)}"
111
+ end
90
112
 
113
+ # 保留对其他组件的依赖
114
+ dependencies = spec.all_dependencies(platform) || []
115
+ target_dependencies = target_spec.all_dependencies(platform)
116
+ dependencies += target_dependencies unless target_dependencies.nil?
117
+
118
+ # 去除对自身子组件的依赖
119
+ dependencies
120
+ .select { |d| d.name.split('/').first != spec.root.name }
121
+ .each { |d| target_platform.send("dependency=", d.name, d.requirement.to_s) }
122
+
123
+ Pod::UI.message "Tdfire: dependencies for #{platform}: #{target_spec.all_dependencies.map(&:name).join(', ')}"
124
+ end
125
+ end
126
+ end
127
+
128
+ def set_platform_limitation(spec)
129
+ target_spec.platform = :ios, deployment_target(spec, :ios)
130
+ end
91
131
  #--------------------------------------------------------------------#
92
132
  # spec 是源码依赖时的配置
93
- def set_preserve_paths_with_reference_spec(spec)
133
+ def set_preserve_paths(spec)
134
+ # 这里一般不会和上面那个方法一样,不同平台的配置还不一致,所以就不用 consumer 了
94
135
  # 源码、资源文件
95
- source_files = spec.all_array_value_for_attribute('source_files')
96
- resources = spec.all_array_value_for_attribute('resources')
97
- resource_bundles = spec.all_hash_value_for_attribute('resource_bundles')
98
- source_preserve_paths = source_files + resources + resource_bundles.values.flatten
136
+ #
137
+ available_platforms(spec).each do |platform|
138
+ Pod::UI.section("Tdfire: set preserve paths for platform #{platform}") do
139
+ source_files = spec.tdfire_recursive_value('source_files', platform)
140
+ resources = spec.tdfire_recursive_value('resources', platform)
141
+ resource_bundles = spec.tdfire_recursive_value('resource_bundles', platform)
99
142
 
100
- # 二进制文件
101
- framework_preserve_paths = [framework_name]
102
- preserve_paths = source_preserve_paths + framework_preserve_paths
143
+ source_preserve_paths = source_files + resources + resource_bundles.map(&:values).flatten
103
144
 
104
- # 保留原有的 preserve_paths
105
- preserve_paths += target_spec.attributes_hash['preserve_paths'] unless target_spec.attributes_hash['preserve_paths'].nil?
106
- target_spec.preserve_paths = preserve_paths.uniq
145
+ # 二进制文件
146
+ framework_preserve_paths = [framework_name]
147
+ preserve_paths = source_preserve_paths + framework_preserve_paths
107
148
 
108
- Pod::UI.message "Tdfire: preserve paths for #{target_spec.name}: #{preserve_paths.join(', ')}"
149
+ # 保留原有的 preserve_paths
150
+ target_preserve_paths = target_spec.tdfire_recursive_value('preserve_paths', platform)
151
+ preserve_paths += target_preserve_paths unless target_preserve_paths.empty?
152
+
153
+ target_platform = target_spec.send(platform.to_sym)
154
+ target_platform.send("preserve_paths=", preserve_paths)
155
+
156
+ Pod::UI.message "Tdfire: preserve paths for #{platform}: #{preserve_paths.join(', ')}"
157
+ end
158
+ end
109
159
  end
110
160
 
111
161
  #--------------------------------------------------------------------#
@@ -156,6 +206,18 @@ module Pod
156
206
  #--------------------------------------------------------------------#
157
207
  private
158
208
 
209
+ def deployment_target(spec, platform = :ios)
210
+ target_spec.deployment_target(platform) || spec.deployment_target(platform)
211
+ end
212
+
213
+ def available_platforms(spec)
214
+ # 平台信息没设置,表示支持所有平台
215
+ # 所以二进制默认支持所有平台,或者和源码时支持平台一致(平台设置在源码配置lambda外)
216
+ # 支持多平台用 deployment_target,单平台用 platform
217
+ #
218
+ target_spec.available_platforms || spec.available_platforms || [:ios]
219
+ end
220
+
159
221
  def framework_name
160
222
  "#{target_spec.root.name}.framework"
161
223
  end
@@ -11,12 +11,14 @@ module Pod
11
11
  attr_accessor :use_frameworks
12
12
  attr_accessor :use_source
13
13
  attr_accessor :lib_lint_binary_pod
14
+ attr_accessor :limit_platform
14
15
  end
15
16
 
16
17
  @use_source_pods = []
17
18
  @use_binary_pods = []
18
19
  @printed_pods = []
19
20
  @use_frameworks = false
21
+ @limit_platform = false
20
22
 
21
23
  def self.real_use_source_pods
22
24
  (@use_source_pods + unpublished_pods).uniq
@@ -60,6 +62,7 @@ module Pod
60
62
  FORCE_USE_SOURCE_KEY = 'tdfire_force_use_source'
61
63
  FORCE_USE_BINARY_KEY = 'tdfire_force_use_binary'
62
64
  USE_BINARY_KEY = 'tdfire_use_binary'
65
+ LIMIT_PLATFORM_KEY = 'tdfire_limit_platform'
63
66
  USE_SURE_VALUE = '1'
64
67
  end
65
68
  end
@@ -20,7 +20,7 @@ module Pod
20
20
  end
21
21
 
22
22
  def run
23
- run_command Package
23
+ run_command Package, ['--clean']
24
24
  run_command Lint
25
25
  run_command Push
26
26
  run_command Publish
@@ -23,7 +23,7 @@ module Pod
23
23
  @sources = argv.option('sources')
24
24
  @one_binary = argv.flag?('one-binary')
25
25
  @spec_file = first_podspec
26
- @spec_name = @spec_file.split('/').last.split('.').first
26
+ @spec_name = @spec_file.split('/').last.split('.').first unless @spec_file.nil?
27
27
  unzip_framework
28
28
  super
29
29
  end
@@ -1,5 +1,6 @@
1
1
  require 'colored2'
2
2
  require 'fileutils'
3
+ require 'cocoapods_packager'
3
4
  require 'cocoapods-tdfire-binary/binary_url_manager'
4
5
  require 'cocoapods-tdfire-binary/binary_specification_refactor'
5
6
 
@@ -17,11 +18,15 @@ module Pod
17
18
  [
18
19
  ['--clean', '执行成功后,删除 zip 文件外的所有生成文件'],
19
20
  ['--spec-sources', '私有源地址'],
21
+ # ['--local', '使用本地代码'],
22
+ ['--use-carthage', 'carthage使用carthage进行打包'],
20
23
  ].concat(super)
21
24
  end
22
25
 
23
26
  def initialize(argv)
24
27
  @clean = argv.flag?('clean')
28
+ @local = argv.flag?('local')
29
+ @use_carthage = argv.flag?('use-carthage')
25
30
  @spec_sources = argv.option('spec-sources')
26
31
  @spec_file = first_podspec
27
32
  super
@@ -33,16 +38,40 @@ module Pod
33
38
  end
34
39
 
35
40
  def run
41
+ # 组件有多个 platform 时,限制 cocoapods-packager 只打 ios 代码
42
+ Pod::Tdfire::BinaryStateStore.limit_platform = true
43
+
36
44
  spec = Specification.from_file(@spec_file)
45
+ prepare(spec)
37
46
  package(spec)
38
47
  zip(spec)
48
+
49
+ Pod::Tdfire::BinaryStateStore.limit_platform = false
39
50
  end
40
51
 
41
52
  private
42
53
 
54
+ def prepare(spec)
55
+ UI.section("Tdfire: prepare for packaging ...") do
56
+ clean(spec)
57
+ end
58
+ end
59
+
43
60
  def package(spec)
44
61
  UI.section("Tdfire: package #{spec.name} ...") do
45
- system "pod package #{spec.name}.podspec --exclude-deps --force --no-mangle --spec-sources=#{@spec_sources || Pod::Tdfire::BinaryUrlManager.private_cocoapods_url}"
62
+ argvs = [
63
+ "#{spec.name}.podspec",
64
+ "--exclude-deps",
65
+ "--force",
66
+ "--no-mangle",
67
+ "--spec-sources=#{@spec_sources || Pod::Tdfire::BinaryUrlManager.private_cocoapods_url}",
68
+ ]
69
+
70
+ argvs << "--local" if @local
71
+
72
+ package = Pod::Command::Package.new(CLAide::ARGV.new(argvs))
73
+ package.validate!
74
+ package.run
46
75
  end
47
76
  end
48
77
 
@@ -56,7 +85,7 @@ module Pod
56
85
  # cocoapods-packager 使用了 --exclude-deps 后,虽然没有把 dependency 的符号信息打进可执行文件,但是它把 dependency 的 bundle 给拷贝过来了 (builder.rb 229 copy_resources)
57
86
  # 这里把多余的 bundle 删除
58
87
  # https://github.com/CocoaPods/cocoapods-packager/pull/199
59
- resource_bundles = spec.all_hash_value_for_attribute('resource_bundles').keys.flatten.uniq
88
+ resource_bundles = spec.tdfire_recursive_value('resource_bundles').map(&:keys).flatten.uniq
60
89
  FileUtils.chdir("#{framework_path}/Versions/A/Resources") do
61
90
  dependency_bundles = Dir.glob('*.bundle').select { |b| !resource_bundles.include?(b.split('.').first) }
62
91
  unless dependency_bundles.empty?
@@ -78,7 +107,14 @@ module Pod
78
107
 
79
108
  Pod::UI::puts "Tdfire: save framework zip file to #{Dir.pwd}/#{output_name}".green
80
109
 
81
- system "rm -fr #{spec.name}-#{@spec.version}" if @clean
110
+ clean(spec) if @clean
111
+ end
112
+
113
+ def clean(spec)
114
+ file = "#{spec.name}-#{spec.version}"
115
+
116
+ UI.message "Tdfire: cleaning #{file}"
117
+ system "rm -fr #{spec.name}-#{spec.version}" if File.exist?(file)
82
118
  end
83
119
 
84
120
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsTdfireBinary
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -28,8 +28,7 @@ module Pod
28
28
 
29
29
  configurator.call self
30
30
 
31
- # 在设置了 use_frameworks! 的情况下才会生效
32
- tdfire_refactor.set_use_static_framework
31
+ tdfire_refactor.configure_source
33
32
  end
34
33
  end
35
34
 
@@ -49,10 +48,10 @@ module Pod
49
48
 
50
49
  # 如果存在 subspec,则生成 default subpsec ,并将所有的 subspec 配置转移到此 subspec 中
51
50
  # 已存在的 subspec 依赖此 subspec
52
- unless @tdfire_reference_spec.subspecs.empty?
53
- tdfire_refactor.configure_binary_default_subspec_with_reference_spec( @tdfire_reference_spec)
51
+ unless @tdfire_reference_spec.recursive_subspecs.empty?
52
+ tdfire_refactor.configure_binary_default_subspec(@tdfire_reference_spec)
54
53
  else
55
- tdfire_refactor.configure_binary_with_reference_spec( @tdfire_reference_spec)
54
+ tdfire_refactor.configure_binary(@tdfire_reference_spec)
56
55
  end
57
56
  end
58
57
  end
@@ -60,7 +59,7 @@ module Pod
60
59
 
61
60
  # 配置二进制文件下载、cache 住解压好的 framework
62
61
  def tdfire_set_binary_download_configurations
63
- tdfire_refactor.set_preserve_paths_with_reference_spec(tdfire_reference_spec)
62
+ tdfire_refactor.set_preserve_paths(tdfire_reference_spec)
64
63
 
65
64
  # 没有发布的pod,没有二进制版本,不进行下载配置
66
65
  return if tdfire_should_skip_download?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-tdfire-binary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - tripleCC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-09 00:00:00.000000000 Z
11
+ date: 2018-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: cocoapods
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.1
47
+ version: '1.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2.1
54
+ version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cocoapods-packager
57
57
  requirement: !ruby/object:Gem::Requirement