cocoapods-jxedt 0.0.10 → 0.0.13
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 +4 -4
- data/lib/cocoapods-jxedt/binary/Intergation.rb +18 -13
- data/lib/cocoapods-jxedt/binary/config.rb +67 -0
- data/lib/cocoapods-jxedt/binary/helper/podfile_post_install_hook.rb +29 -0
- data/lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb +112 -2
- data/lib/cocoapods-jxedt/binary/hooks/CocoapodsJxedtHook.rb +6 -9
- data/lib/cocoapods-jxedt/binary/hooks/post_install.rb +2 -2
- data/lib/cocoapods-jxedt/binary/hooks/pre_install.rb +33 -9
- data/lib/cocoapods-jxedt/binary/main.rb +1 -0
- data/lib/cocoapods-jxedt/binary/pod-room/framework.rb +40 -0
- data/lib/cocoapods-jxedt/binary/pod-room/xcodebuild_command.rb +79 -1
- data/lib/cocoapods-jxedt/binary/pod-room/xcodebuild_raw.rb +1 -1
- data/lib/cocoapods-jxedt/binary/prebuild.rb +92 -14
- data/lib/cocoapods-jxedt/binary/targets/pod_target.rb +50 -0
- data/lib/cocoapods-jxedt/command/binary/binary.rb +36 -0
- data/lib/cocoapods-jxedt/command/binary/command/build.rb +84 -0
- data/lib/cocoapods-jxedt/command/binary/command/clean.rb +101 -0
- data/lib/cocoapods-jxedt/command/binary/command/fetch.rb +36 -0
- data/lib/cocoapods-jxedt/command/binary/command/push.rb +41 -0
- data/lib/cocoapods-jxedt/command/binary/command/statistics.rb +104 -0
- data/lib/cocoapods-jxedt/command/jxedt.rb +1 -1
- data/lib/cocoapods-jxedt/command/options/options.rb +85 -2
- data/lib/cocoapods-jxedt/gem_version.rb +1 -1
- data/lib/cocoapods-jxedt/git_helper/cache_fetcher.rb +34 -0
- data/lib/cocoapods-jxedt/git_helper/cache_pucher.rb +42 -0
- data/lib/cocoapods-jxedt/git_helper/git_command.rb +48 -0
- data/lib/cocoapods-jxedt/git_helper/zip.rb +22 -0
- metadata +14 -3
- data/lib/cocoapods-jxedt/command/statistics/statistics.rb +0 -98
@@ -22,12 +22,19 @@ module Jxedt
|
|
22
22
|
return [] if @sandbox_path.nil?
|
23
23
|
return [] unless binary_dir.exist?
|
24
24
|
return [] if @sandbox.source_lockfile.nil?
|
25
|
-
@targets ||=
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
@targets ||= begin
|
26
|
+
prebuild_targets = binary_dir.children().map do |target_path|
|
27
|
+
if target_path.directory? && (not target_path.children.empty?)
|
28
|
+
hash_key = @sandbox.source_lockfile.spec_checksums_hash_key(target_path.basename.to_s)
|
29
|
+
next if hash_key.nil?
|
30
|
+
|
31
|
+
checksum_files = target_path.children().select { |path| path.extname == '.checksum' }
|
32
|
+
checksum_exists = (target_path + "#{hash_key}.checksum").exist?
|
33
|
+
target_path if checksum_files.count == 1 && checksum_exists
|
34
|
+
end
|
35
|
+
end.reject(&:nil?).uniq
|
36
|
+
prebuild_targets
|
37
|
+
end
|
31
38
|
@targets
|
32
39
|
end
|
33
40
|
|
@@ -80,21 +87,44 @@ module Jxedt
|
|
80
87
|
target.target_definition.reject_prebuild_pod_names
|
81
88
|
}.uniq
|
82
89
|
|
90
|
+
targets = all_supports_targets.select { |target|
|
91
|
+
next if reject_prebuild_pod_names.include?(target.pod_name)
|
92
|
+
explicit_prebuild_pod_names.include?(target.pod_name) || Jxedt.config.all_binary_enabled?
|
93
|
+
}
|
94
|
+
targets
|
95
|
+
end
|
96
|
+
|
97
|
+
def all_supports_targets
|
83
98
|
targets = @source_installer.pod_targets.select { |target|
|
99
|
+
# 排除不需要编译
|
84
100
|
next unless target.should_build?
|
101
|
+
# 排除target name和pod name不一致的(有两种情况)
|
102
|
+
# 1. 同一个pod,在两个target下使用了不同的subspec
|
103
|
+
# 2. 同一个pod,在两个不同ios版本的target种引用
|
85
104
|
next unless target.name == target.pod_name
|
86
|
-
|
87
|
-
explicit_prebuild_pod_names.include?(target.pod_name) || Jxedt.config.all_binary_enabled?
|
105
|
+
true
|
88
106
|
}
|
107
|
+
# 排除本地pod
|
89
108
|
targets.reject! { |target| @source_installer.sandbox.local?(target.pod_name) } unless Jxedt.config.dev_pods_enabled?
|
109
|
+
# 配置中排除的pods
|
90
110
|
targets.reject! { |target| Jxedt.config.excluded_pods.include?(target.pod_name) }
|
111
|
+
# target中可能存在需要编译的resource文件
|
112
|
+
Jxedt.config.disable_resource_compilable_pods? && targets.reject! { |target|
|
113
|
+
# 因为编译library静态库会把需要编译的文件拷贝到宿主工程编译,后面我们要把静态库组装成framework,所以需要过滤掉
|
114
|
+
resource_extension_compilable = false
|
115
|
+
target.resource_paths.each {|name, resources|
|
116
|
+
resources.each {|resource_file|
|
117
|
+
resource_extname = Pathname.new(resource_file).basename.extname
|
118
|
+
resource_extension_compilable = target.class.resource_extension_compilable?(resource_extname)
|
119
|
+
break if resource_extension_compilable
|
120
|
+
}
|
121
|
+
break if resource_extension_compilable
|
122
|
+
}
|
123
|
+
resource_extension_compilable
|
124
|
+
}
|
91
125
|
targets
|
92
126
|
end
|
93
127
|
|
94
|
-
def pods_to_prebuild
|
95
|
-
targets_to_prebuild.map(&:name).to_a
|
96
|
-
end
|
97
|
-
|
98
128
|
def build
|
99
129
|
check_sandbox = Jxedt::Sandbox.from_sandbox(@source_installer.sandbox)
|
100
130
|
existed_target_names = check_sandbox.target_paths.map { |pair| pair.basename.to_s }
|
@@ -102,7 +132,7 @@ module Jxedt
|
|
102
132
|
|
103
133
|
Pod::UI.puts "Prebuild total count: #{targets.size}"
|
104
134
|
Pod::UI.puts "Prebuild targets: #{ targets.map(&:name)}"
|
105
|
-
return if targets.empty?
|
135
|
+
return [] if targets.empty?
|
106
136
|
|
107
137
|
require_relative 'pod-room/xcodebuild_command'
|
108
138
|
|
@@ -135,15 +165,63 @@ module Jxedt
|
|
135
165
|
|
136
166
|
make_prebuild(targets)
|
137
167
|
clear_output_path
|
168
|
+
|
169
|
+
targets.map(&:pod_name).to_a
|
170
|
+
end
|
171
|
+
|
172
|
+
def build_targets(names: nil, binary_output: nil)
|
173
|
+
targets = all_supports_targets
|
174
|
+
targets.select! { |target| names.include?(target.pod_name) } if names && names.is_a?(Array) && names.size > 0
|
175
|
+
|
176
|
+
Pod::UI.puts "Prebuild total count: #{targets.size}"
|
177
|
+
Pod::UI.puts "Prebuild targets: #{ targets.map(&:name)}"
|
178
|
+
return [] if targets.empty?
|
179
|
+
|
180
|
+
require_relative 'pod-room/xcodebuild_command'
|
181
|
+
|
182
|
+
clear_output_path
|
183
|
+
case targets[0].platform.name
|
184
|
+
when :ios, :tvos, :watchos
|
185
|
+
Jxedt.config.support_configurations.each do |configuration|
|
186
|
+
Pod::UI.puts "Prebuild configuration: #{configuration}"
|
187
|
+
options = make_options
|
188
|
+
options[:configuration] = configuration
|
189
|
+
options[:targets] = targets
|
190
|
+
options[:output_path] = output_path + configuration
|
191
|
+
Jxedt::XcodebuildCommand.new(options).run
|
192
|
+
end
|
193
|
+
when :osx
|
194
|
+
Jxedt.config.support_configurations.each do |configuration|
|
195
|
+
Pod::UI.puts "Prebuild configuration: #{configuration}"
|
196
|
+
options = make_options
|
197
|
+
xcodebuild(
|
198
|
+
sandbox: options[:sandbox],
|
199
|
+
targets: targets,
|
200
|
+
configuration: configuration,
|
201
|
+
sdk: "macosx",
|
202
|
+
clean_build: Jxedt.config.clean_build?,
|
203
|
+
args: options[:args]
|
204
|
+
)
|
205
|
+
end
|
206
|
+
else
|
207
|
+
raise "Unsupported platform for '#{targets[0].name}': '#{targets[0].platform.name}'"
|
208
|
+
end
|
209
|
+
|
210
|
+
binary_output = Pathname.new(binary_output)
|
211
|
+
make_prebuild(targets, binary_output)
|
212
|
+
clear_output_path
|
213
|
+
|
214
|
+
targets.map(&:pod_name).to_a
|
138
215
|
end
|
139
216
|
|
140
|
-
def make_prebuild(targets)
|
217
|
+
def make_prebuild(targets, binary_output=nil)
|
141
218
|
lockfile = @source_installer.lockfile
|
142
219
|
checksums = lockfile.internal_data["SPEC CHECKSUMS"] || {}
|
143
220
|
checkout_options = lockfile.internal_data["CHECKOUT OPTIONS"] || {}
|
144
221
|
|
145
222
|
# 目标binary路径
|
146
223
|
binary_path = output_path.parent
|
224
|
+
binary_path = binary_output if binary_output && binary_output.parent.exist?
|
147
225
|
prebuild_targets = targets.map(&:name).to_a
|
148
226
|
prebuild_targets.map {|target_name|
|
149
227
|
target_path = binary_path + target_name
|
@@ -1,4 +1,54 @@
|
|
1
1
|
module Pod
|
2
|
+
class PodTarget < Target
|
3
|
+
alias_method :old_resource_paths, :resource_paths
|
4
|
+
def resource_paths
|
5
|
+
resource_paths = old_resource_paths
|
6
|
+
# 没有使用二进制不处理
|
7
|
+
return resource_paths unless self.use_binary
|
8
|
+
|
9
|
+
# 遍历所有的resources
|
10
|
+
resource_paths.each do |name, resources|
|
11
|
+
resources.map! {|resource_file|
|
12
|
+
resource_extname = Pathname.new(resource_file).basename.extname
|
13
|
+
# 如果文件不需要编译,跳过
|
14
|
+
next resource_file unless self.class.resource_extension_compilable?(resource_extname)
|
15
|
+
|
16
|
+
# 确定编译后的文件名称
|
17
|
+
output_extname = self.class.output_extension_for_resource(resource_extname)
|
18
|
+
output_file_name = "#{Pathname.new(resource_file).basename.sub_ext('')}#{output_extname}"
|
19
|
+
# 从framework中查找编译后的文件
|
20
|
+
file_accessors.each do |file_accessor|
|
21
|
+
file_accessor.vendored_frameworks.each do |framework_file|
|
22
|
+
framework_name = Pathname.new(framework_file).basename.sub_ext('').to_s
|
23
|
+
# 只处理和当前target module_name相同的framework,否则跳过
|
24
|
+
next if self.product_module_name != framework_name
|
25
|
+
|
26
|
+
# xcframework和framework文件分别处理,而且只查找.framework根目录下的文件
|
27
|
+
if '.xcframework' == Pathname.new(framework_file).basename.extname
|
28
|
+
files = Dir.glob("#{framework_file}/**/#{framework_name}.framework/#{output_file_name}")
|
29
|
+
next if files.size == 0 # 没有查找到文件跳过
|
30
|
+
|
31
|
+
if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
|
32
|
+
resource_file = "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{self.name}/#{framework_name}.framework/#{output_file_name}"
|
33
|
+
else
|
34
|
+
resource_file = "${PODS_CONFIGURATION_BUILD_DIR}/#{framework_name}.framework/#{output_file_name}"
|
35
|
+
end
|
36
|
+
else
|
37
|
+
files = Dir.glob("#{framework_file}/#{output_file_name}")
|
38
|
+
next if files.size == 0 # 没有查找到文件跳过
|
39
|
+
|
40
|
+
resource_path = Pathname.new("#{framework_file}/#{output_file_name}") # 真实路径
|
41
|
+
resource_file = "${PODS_ROOT}/#{resource_path.relative_path_from(self.sandbox.root)}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
resource_file
|
46
|
+
}.reject!(&:nil?)
|
47
|
+
end
|
48
|
+
resource_paths
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
2
52
|
class Target
|
3
53
|
# @since 1.5.0
|
4
54
|
class BuildSettings
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'command/statistics'
|
2
|
+
require_relative 'command/build'
|
3
|
+
require_relative 'command/fetch'
|
4
|
+
require_relative 'command/push'
|
5
|
+
require_relative 'command/clean'
|
6
|
+
|
7
|
+
module Pod
|
8
|
+
class Command
|
9
|
+
class JxedtCommand < Command
|
10
|
+
class Binary < JxedtCommand
|
11
|
+
self.summary = '二进制相关操作,二进制build、fetch、clean、statistics'
|
12
|
+
self.description = <<-DESC
|
13
|
+
二进制相关操作,二进制build、fetch、push、statistics
|
14
|
+
DESC
|
15
|
+
self.command = 'binary'
|
16
|
+
self.abstract_command = true
|
17
|
+
|
18
|
+
self.arguments = [
|
19
|
+
]
|
20
|
+
def self.options
|
21
|
+
[]
|
22
|
+
end
|
23
|
+
def initialize(argv)
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def validate!
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class JxedtCommand < Command
|
4
|
+
class Binary < JxedtCommand
|
5
|
+
class Build < Binary
|
6
|
+
self.summary = '组件编译成二进制'
|
7
|
+
self.description = <<-DESC
|
8
|
+
统计二进制组件
|
9
|
+
DESC
|
10
|
+
self.command = 'build'
|
11
|
+
self.arguments = [
|
12
|
+
]
|
13
|
+
def self.options
|
14
|
+
[
|
15
|
+
['--name', '编译的组件name,多个以,分隔'],
|
16
|
+
['--output-path', '编译的二进制文件输出路径'],
|
17
|
+
['--push', 'prebuild frameworks push origin.'],
|
18
|
+
['--force-push', 'force push generated frameworks']
|
19
|
+
]
|
20
|
+
end
|
21
|
+
def initialize(argv)
|
22
|
+
@names = argv.option('name', '').split(',')
|
23
|
+
@output_path = argv.option('output-path')
|
24
|
+
@force_push = argv.flag?('force-push', false)
|
25
|
+
@should_push = argv.flag?('push', false) || @force_push
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate!
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def run
|
34
|
+
podfile = Pod::Config.instance.podfile
|
35
|
+
lockfile = Pod::Config.instance.lockfile
|
36
|
+
sandbox = Pod::Config.instance.sandbox
|
37
|
+
help! '请检查命令执行路径,需要在Podfile文件所在目录执行' if podfile.nil? || lockfile.nil? || sandbox.nil?
|
38
|
+
|
39
|
+
# 修改config配置
|
40
|
+
options = {
|
41
|
+
:keep_source_project => true, # 保留源码工程
|
42
|
+
}
|
43
|
+
Jxedt.config.dsl_config.merge!(options)
|
44
|
+
|
45
|
+
require 'cocoapods-jxedt/binary/helper/target_definition'
|
46
|
+
require 'cocoapods-jxedt/binary/helper/prebuild_sandbox'
|
47
|
+
require 'cocoapods-jxedt/binary/helper/podfile_post_install_hook'
|
48
|
+
|
49
|
+
# 获取原始的installer对象,必须先获取对象
|
50
|
+
prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(sandbox)
|
51
|
+
source_installer = Pod::Installer.new(prebuild_sandbox, podfile, lockfile)
|
52
|
+
# 执行install
|
53
|
+
source_installer.install!
|
54
|
+
|
55
|
+
# 保存首次`pod install`的lockfile结果,用来验证二进制文件和后面做结果校验
|
56
|
+
sandbox.source_lockfile = prebuild_sandbox.source_lockfile = source_installer.lockfile
|
57
|
+
|
58
|
+
require 'cocoapods-jxedt/binary/helper/podfile_options'
|
59
|
+
require 'cocoapods-jxedt/binary/prebuild'
|
60
|
+
|
61
|
+
# prebuild_job
|
62
|
+
prebuild_sandbox.link_source_project!
|
63
|
+
log_section "🚀 Prebuild frameworks"
|
64
|
+
# 默认放在Pods源码工程同级目录下
|
65
|
+
@output_path = prebuild_sandbox.project_path.parent + '.command_build' if @output_path.nil?
|
66
|
+
build_targets = Jxedt::Prebuild.new(source_installer).build_targets :names => @names, :binary_output => @output_path
|
67
|
+
if @should_push && Jxedt.config.cache_repo_enabled?
|
68
|
+
require 'cocoapods-jxedt/git_helper/cache_pucher'
|
69
|
+
output_dir = Pathname.new(@output_path)
|
70
|
+
Jxedt::CachePucher.push(output_dir, build_targets, @force_push)
|
71
|
+
end
|
72
|
+
prebuild_sandbox.clean_source_project!
|
73
|
+
end
|
74
|
+
|
75
|
+
def log_section(message)
|
76
|
+
Pod::UI.puts "-----------------------------------------"
|
77
|
+
Pod::UI.puts message
|
78
|
+
Pod::UI.puts "-----------------------------------------"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class JxedtCommand < Command
|
4
|
+
class Clean < JxedtCommand
|
5
|
+
class Fecth < Binary
|
6
|
+
self.summary = 'clean cache repo.'
|
7
|
+
self.description = <<-DESC
|
8
|
+
clean cache repo.
|
9
|
+
DESC
|
10
|
+
self.command = 'clean'
|
11
|
+
self.arguments = [
|
12
|
+
]
|
13
|
+
def self.options
|
14
|
+
[
|
15
|
+
['--name', 'Remove the file with the corresponding name.'],
|
16
|
+
['--local', 'Remove local cache.'],
|
17
|
+
['--all', 'Remove all files.'],
|
18
|
+
]
|
19
|
+
end
|
20
|
+
def initialize(argv)
|
21
|
+
@names = argv.option('name', '').split(',')
|
22
|
+
@local = argv.flag?('local', false)
|
23
|
+
@all = argv.flag?('all', false)
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def validate!
|
28
|
+
help! "Please enter the necessary options." if @names.empty? && !@all
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
podfile = Pod::Config.instance.podfile
|
34
|
+
help! '请检查命令执行路径,需要在Podfile文件所在目录执行' if podfile.nil?
|
35
|
+
|
36
|
+
require 'cocoapods-jxedt/git_helper/git_command'
|
37
|
+
|
38
|
+
repo = Jxedt.config.git_remote_repo
|
39
|
+
cache_path = Jxedt.config.git_cache_path
|
40
|
+
branch = Jxedt.config.cache_branch
|
41
|
+
|
42
|
+
local_cache_dir = Pod::Config.instance.sandbox.root + Jxedt.config.binary_dir
|
43
|
+
|
44
|
+
commander = nil
|
45
|
+
commander = Jxedt::GitCommand.new(cache_path) if !@local && Jxedt.config.cache_repo_enabled?
|
46
|
+
# fetch
|
47
|
+
commander.git_fetch(repo, branch) if commander
|
48
|
+
|
49
|
+
if @names.size > 0
|
50
|
+
local_deleted, remote_deleted = [], []
|
51
|
+
@names.each do |name|
|
52
|
+
local_cache = local_cache_dir + name
|
53
|
+
if local_cache.exist?
|
54
|
+
local_cache.rmtree
|
55
|
+
local_deleted << name
|
56
|
+
end
|
57
|
+
|
58
|
+
if commander
|
59
|
+
remote_cache_dir = Pathname.new(cache_path) + "GeneratedFrameworks"
|
60
|
+
remote_cache = remote_cache_dir + name
|
61
|
+
if remote_cache.exist?
|
62
|
+
remote_cache.rmtree
|
63
|
+
remote_deleted << name
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
# push
|
68
|
+
commander.git_commit_and_push(branch) if commander && remote_deleted.size > 0
|
69
|
+
UI.puts "⚠️ ⚠️ ⚠️ 本地缓存文件已清除: #{local_deleted}" if local_deleted.size > 0
|
70
|
+
UI.puts "⚠️ ⚠️ ⚠️ 远程缓存文件已清除: #{remote_deleted}" if remote_deleted.size > 0
|
71
|
+
else
|
72
|
+
random = (0...10).map { (97 + rand(26)).chr }.join
|
73
|
+
input = get_stdin("你确认要清除所有缓存吗?包括远程仓库的缓存。确认请输入: #{random}")
|
74
|
+
help! "输入错误,自动退出。" if random != input
|
75
|
+
|
76
|
+
local_cache_dir.rmtree if local_cache_dir.exist?
|
77
|
+
|
78
|
+
if commander
|
79
|
+
remote_cache_dir = Pathname.new(cache_path) + "GeneratedFrameworks"
|
80
|
+
if remote_cache_dir.exist?
|
81
|
+
remote_cache_dir.rmtree
|
82
|
+
# push
|
83
|
+
commander.git_commit_and_push(branch)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
UI.puts "⚠️ ⚠️ ⚠️ 所有缓存文件已清除"
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
def get_stdin(message)
|
92
|
+
UI.puts "#{message}".red
|
93
|
+
print "请输入--> ".green
|
94
|
+
val = STDIN.gets.chomp.strip
|
95
|
+
val
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class JxedtCommand < Command
|
4
|
+
class Binary < JxedtCommand
|
5
|
+
class Fecth < Binary
|
6
|
+
self.summary = 'fetch cache repo.'
|
7
|
+
self.description = <<-DESC
|
8
|
+
fetch cache repo.
|
9
|
+
DESC
|
10
|
+
self.command = 'fetch'
|
11
|
+
self.arguments = [
|
12
|
+
]
|
13
|
+
def self.options
|
14
|
+
[]
|
15
|
+
end
|
16
|
+
def initialize(argv)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate!
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
podfile = Pod::Config.instance.podfile
|
26
|
+
help! '请检查命令执行路径,需要在Podfile文件所在目录执行' if podfile.nil?
|
27
|
+
help! '你需要在cache_repo中配置正确的git仓库地址!' unless Jxedt.config.cache_repo_enabled?
|
28
|
+
|
29
|
+
require 'cocoapods-jxedt/git_helper/cache_fetcher'
|
30
|
+
Jxedt::CacheFetcher.fetch
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class JxedtCommand < Command
|
4
|
+
class Binary < JxedtCommand
|
5
|
+
class Push < Binary
|
6
|
+
self.summary = 'sync local files to git repo.'
|
7
|
+
self.description = <<-DESC
|
8
|
+
sync local files to git repo.
|
9
|
+
DESC
|
10
|
+
self.command = 'push'
|
11
|
+
self.arguments = [
|
12
|
+
]
|
13
|
+
def self.options
|
14
|
+
[
|
15
|
+
['--force-push', 'force push generated frameworks']
|
16
|
+
]
|
17
|
+
end
|
18
|
+
def initialize(argv)
|
19
|
+
@force_push = argv.flag?('force-push', false)
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate!
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
podfile = Pod::Config.instance.podfile
|
29
|
+
help! '请检查命令执行路径,需要在Podfile文件所在目录执行' if podfile.nil?
|
30
|
+
help! '你需要在cache_repo中配置正确的git仓库地址!' unless Jxedt.config.cache_repo_enabled?
|
31
|
+
|
32
|
+
require 'cocoapods-jxedt/git_helper/cache_pucher'
|
33
|
+
|
34
|
+
output_dir = Pod::Config.instance.sandbox.root + Jxedt.config.binary_dir
|
35
|
+
Jxedt::CachePucher.push(output_dir, nil, @force_push)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class JxedtCommand < Command
|
4
|
+
class Binary < JxedtCommand
|
5
|
+
class Statistics < Binary
|
6
|
+
self.summary = '统计二进制使用情况'
|
7
|
+
self.description = <<-DESC
|
8
|
+
统计二进制使用详情
|
9
|
+
DESC
|
10
|
+
self.command = 'statistics'
|
11
|
+
self.arguments = [
|
12
|
+
]
|
13
|
+
def self.options
|
14
|
+
[
|
15
|
+
['--failed', '统计校验失败的二进制'],
|
16
|
+
]
|
17
|
+
end
|
18
|
+
def initialize(argv)
|
19
|
+
@check_failed = argv.flag?('failed')
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate!
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
podfile = Pod::Config.instance.podfile
|
29
|
+
lockfile = Pod::Config.instance.lockfile
|
30
|
+
help! '请检查命令执行路径,需要在Podfile文件所在目录执行' if podfile.nil? || lockfile.nil?
|
31
|
+
|
32
|
+
require 'cocoapods-jxedt/binary/config'
|
33
|
+
require 'cocoapods-jxedt/binary/helper/podfile_options'
|
34
|
+
|
35
|
+
pods_root = Pathname.new(File.dirname(podfile.defined_in_file)) + "Pods"
|
36
|
+
binary_dir = pods_root + Jxedt.config.binary_dir
|
37
|
+
|
38
|
+
used_binary = []
|
39
|
+
Dir.glob("#{pods_root}/*/_Prebuild") do |file_path|
|
40
|
+
next unless File.directory?(file_path)
|
41
|
+
dir_name = File.dirname(file_path)
|
42
|
+
name = File.basename(dir_name).to_s
|
43
|
+
target_path = binary_dir + name
|
44
|
+
next unless target_path.exist? # 路径不存在,跳过
|
45
|
+
|
46
|
+
new_hash = {}
|
47
|
+
# name
|
48
|
+
new_hash[:name] = name
|
49
|
+
|
50
|
+
# multiple_configuration
|
51
|
+
configuration_enable = target_path.children().select { |path| "#{path.basename}" == 'Debug' || "#{path.basename}" == 'Release' }.count == 2
|
52
|
+
new_hash[:multiple_configuration] = configuration_enable
|
53
|
+
|
54
|
+
# checksum validation
|
55
|
+
checksum_files = target_path.children().select { |path| path.extname == '.checksum' }
|
56
|
+
checksum_file = checksum_files.first
|
57
|
+
new_hash[:checksum] = checksum_file.basename.to_s.gsub('.checksum', '') unless checksum_file.nil?
|
58
|
+
new_hash[:checksum_count] = checksum_files.count
|
59
|
+
|
60
|
+
used_binary << new_hash
|
61
|
+
end
|
62
|
+
|
63
|
+
# print
|
64
|
+
index, failed = 0, []
|
65
|
+
used_binary.sort_by {|hash| hash[:name].capitalize }.each do |hash|
|
66
|
+
name = hash[:name]
|
67
|
+
|
68
|
+
checksum = lockfile.spec_checksums_hash_key(name)
|
69
|
+
validation_passed = checksum && checksum == hash[:checksum] && hash[:checksum_count] == 1
|
70
|
+
failed << name unless validation_passed
|
71
|
+
|
72
|
+
# 校验和是否用的 git commitid
|
73
|
+
checkout_options = lockfile.internal_data["CHECKOUT OPTIONS"] || {}
|
74
|
+
is_git_commitid = checkout_options[name] && checkout_options[name][:commit]
|
75
|
+
|
76
|
+
if validation_passed
|
77
|
+
next if @check_failed
|
78
|
+
index += 1
|
79
|
+
log = <<~LOG
|
80
|
+
#{index}). #{name}:
|
81
|
+
multiple configuration: #{hash[:multiple_configuration]}
|
82
|
+
checksum#{"(git commitid)" if is_git_commitid}: #{hash[:checksum]}
|
83
|
+
LOG
|
84
|
+
Pod::UI.puts log
|
85
|
+
else
|
86
|
+
index += 1
|
87
|
+
log = <<~LOG
|
88
|
+
#{index}). #{name}:
|
89
|
+
multiple configuration: #{hash[:multiple_configuration]}
|
90
|
+
checksum: #{hash[:checksum]}
|
91
|
+
checksum in lockfile#{"(git commitid)" if is_git_commitid}: #{checksum}
|
92
|
+
checksum file count: #{hash[:checksum_count]}
|
93
|
+
LOG
|
94
|
+
Pod::UI.puts log.red
|
95
|
+
end
|
96
|
+
end
|
97
|
+
Pod::UI.puts "checksum校验失败的组件: #{failed}".red if failed.size > 0
|
98
|
+
Pod::UI.puts "建议使用命令清除prebuild缓存,再重新pod install或使用pod jxedt binary build。clean命令:`pod jxedt binary clean --name=#{failed.join(',')}`".red if failed.size > 0
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|