cocoapods-tdfire-binary 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +3 -0
- data/cocoapods-tdfire-binary.gemspec +2 -2
- data/lib/cocoapods-tdfire-binary.rb +6 -0
- data/lib/cocoapods-tdfire-binary/binary_specification_refactor.rb +114 -52
- data/lib/cocoapods-tdfire-binary/binary_state_store.rb +3 -0
- data/lib/cocoapods-tdfire-binary/command/assemble.rb +1 -1
- data/lib/cocoapods-tdfire-binary/command/lint.rb +1 -1
- data/lib/cocoapods-tdfire-binary/command/package.rb +39 -3
- data/lib/cocoapods-tdfire-binary/gem_version.rb +1 -1
- data/lib/cocoapods-tdfire-binary/specification_dsl.rb +5 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4f9de30f1f300cf522c497fa292cfa432f88747
|
4
|
+
data.tar.gz: be89ce05a1e6ac3877dba51a3bb9cfb52fcd7180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a53412925b6e6bec7ea72778974cb56fa5b133a7a1d7653956621042260f1ca3e3ce0d9338836b8e1b66bc77864ab4ca73d58c6b48ace0088a64af1c8bcc8fa7
|
7
|
+
data.tar.gz: 9c4f615d3b377c3fff51706cb152496ad980b428fa21099c59007243b0f8955ccb84d240269d2defa5f61e8a0650ae8d3a2a7d8b4bffbcb7af203bda7d9bbaee
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -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.
|
25
|
-
spec.
|
24
|
+
spec.add_runtime_dependency 'cocoapods', '~> 1.2'
|
25
|
+
spec.add_runtime_dependency 'cocoapods-packager', '~> 1.5.0'
|
26
26
|
end
|
@@ -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
|
-
|
9
|
-
(Array(self) + Array(recursive_subspecs))
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
all_value_for_attribute(name).reduce({}, :merge)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
all_value_for_attribute(name).flatten
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
33
|
-
|
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
|
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.
|
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
|
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
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
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
|
-
|
89
|
-
|
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
|
133
|
+
def set_preserve_paths(spec)
|
134
|
+
# 这里一般不会和上面那个方法一样,不同平台的配置还不一致,所以就不用 consumer 了
|
94
135
|
# 源码、资源文件
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
-
|
105
|
-
|
106
|
-
|
145
|
+
# 二进制文件
|
146
|
+
framework_preserve_paths = [framework_name]
|
147
|
+
preserve_paths = source_preserve_paths + framework_preserve_paths
|
107
148
|
|
108
|
-
|
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
|
@@ -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
|
-
|
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.
|
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
|
-
|
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
|
@@ -28,8 +28,7 @@ module Pod
|
|
28
28
|
|
29
29
|
configurator.call self
|
30
30
|
|
31
|
-
|
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.
|
53
|
-
tdfire_refactor.
|
51
|
+
unless @tdfire_reference_spec.recursive_subspecs.empty?
|
52
|
+
tdfire_refactor.configure_binary_default_subspec(@tdfire_reference_spec)
|
54
53
|
else
|
55
|
-
tdfire_refactor.
|
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.
|
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.
|
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-
|
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
|
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
|
54
|
+
version: '1.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: cocoapods-packager
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|