cocoapods-ppbuild 0.0.1 → 0.0.5

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
  SHA256:
3
- metadata.gz: 560423786a1c2f0fff91e7d25ee783420a6f18d4115c8c551427f9960a7fd4ae
4
- data.tar.gz: 2b3c92a07bd963e42bcb5fd5b220c2d8f2fa26ed7152d813a7af0e110a81ac8e
3
+ metadata.gz: c5573fd6b439b3b7f14cd3af40775271c6adb2df5d2694ea06a052b765e7bca7
4
+ data.tar.gz: 34ff8d8e4212d82b442b950191569c232b4abbcc4e2767520d579c9be8ba940c
5
5
  SHA512:
6
- metadata.gz: b8cec8ef3b7783945f203ad4ad499ac88b7321d41e8b04112fe2a8d2feda60e3e6a5ad579c49ac58a84ba946394ff6f5db4b33502638de3a69db0ebb57170639
7
- data.tar.gz: e284d38c0a277e4d6002a6c513d7eba496aa086883624733766990dbc043dc162f8d104a5204e50aff788e907e1afdaf865c1e4a104447f14993aef00ed710cf
6
+ metadata.gz: 16dc03357ff651e30773a1b12a2c166e0c30316f85662265ed553eb483302a6fec5f48fc3a75eaf23958db718c1b6a1259cca9285f90bddbaf1ab197a69b699b
7
+ data.tar.gz: 3bd1ae9b7287f11c96eea8969c23e07125d8d820ad7cd147973920bf39c3a466b4a612c07fd67f2a08c4db88cf19ed84da36262ac70cf84a4548435000d8f546
@@ -62,6 +62,7 @@ module Pod
62
62
 
63
63
  target_names.each do |name|
64
64
 
65
+ Pod::UI.puts "........... oname: #{name}"
65
66
  # symbol link copy all substructure
66
67
  real_file_folder = prebuild_sandbox.framework_folder_path_for_target_name(name)
67
68
 
@@ -79,6 +80,7 @@ module Pod
79
80
 
80
81
  walk(real_file_folder) do |child|
81
82
  source = child
83
+
82
84
  # only make symlink to file and `.framework` folder
83
85
  if child.directory?
84
86
  if [".framework"].include? child.extname
@@ -87,6 +89,9 @@ module Pod
87
89
  elsif [".dSYM"].include? child.extname
88
90
  mirror_with_symlink(source, real_file_folder, target_folder, false)
89
91
  next false # return false means don't go deeper
92
+ elsif [".bundle"].include? child.extname
93
+ mirror_with_symlink(source, real_file_folder, target_folder, false)
94
+ next false
90
95
  else
91
96
  next true
92
97
  end
@@ -105,6 +110,9 @@ module Pod
105
110
  if path_objects != nil
106
111
  path_objects.each do |object|
107
112
  if object.real_file_path != nil
113
+ real_path = Pathname.new(object.target_file_path)
114
+ real_path.rmtree if real_path.exist?
115
+ Pod::UI.puts "........... object.target_file_path: #{object.target_file_path}"
108
116
  make_link(object.real_file_path, object.target_file_path, false)
109
117
  end
110
118
  end
@@ -129,15 +137,13 @@ module Pod
129
137
  # Remove the old target files if prebuild frameworks changed
130
138
  def remove_target_files_if_needed
131
139
 
132
- changes = Pod::Prebuild::Passer.prebuild_pods_changes
140
+ changes = Pod::Prebuild::Passer.prebuild_pod_targets_changes
133
141
  updated_names = []
134
142
  if changes == nil
135
143
  updated_names = PrebuildSandbox.from_standard_sandbox(self.sandbox).exsited_framework_pod_names
136
144
  else
137
- added = changes.added
138
- changed = changes.changed
139
- deleted = changes.deleted
140
- updated_names = added + changed + deleted
145
+ t_names = changes.map { |e| e.pod_name }
146
+ updated_names = (updated_names + t_names).uniq
141
147
  end
142
148
 
143
149
  updated_names.each do |name|
@@ -158,7 +164,6 @@ module Pod
158
164
  # Modify specification to use only the prebuild framework after analyzing
159
165
  old_method2 = instance_method(:resolve_dependencies)
160
166
  define_method(:resolve_dependencies) do
161
-
162
167
  # Remove the old target files, else it will not notice file changes
163
168
  self.remove_target_files_if_needed
164
169
 
@@ -11,6 +11,7 @@ module Pod
11
11
  def use_dynamic_binary!
12
12
  DSL.prebuild_all = true
13
13
  DSL.static_binary = false
14
+ DSL.dont_remove_source_code = true
14
15
  end
15
16
  # 设置当前swift版本
16
17
  def use_swift_version(version)
@@ -21,6 +22,12 @@ module Pod
21
22
  def use_static_binary!
22
23
  DSL.prebuild_all = true
23
24
  DSL.static_binary = true
25
+ DSL.dont_remove_source_code = true
26
+ end
27
+
28
+ # 设置是否保存源码,默认 true
29
+ def remove_source_code_for_prebuilt_frameworks!
30
+ DSL.dont_remove_source_code = false
24
31
  end
25
32
 
26
33
  # Enable bitcode for prebuilt frameworks
@@ -62,7 +62,43 @@ module Pod
62
62
  UI.puts "Using #{name}"
63
63
  end
64
64
  end
65
+
66
+ def save_change_targets!
67
+ sandbox_path = sandbox.root
68
+ existed_framework_folder = sandbox.generate_framework_path
69
+
70
+ if local_manifest != nil
71
+ changes = prebuild_pods_changes
72
+ added = changes.added
73
+ changed = changes.changed
74
+ unchanged = changes.unchanged
75
+ deleted = changes.deleted.to_a
65
76
 
77
+ existed_framework_folder.mkdir unless existed_framework_folder.exist?
78
+ exsited_framework_pod_names = sandbox.exsited_framework_pod_names
79
+
80
+ # additions
81
+ missing = unchanged.select do |pod_name|
82
+ not exsited_framework_pod_names.include?(pod_name)
83
+ end
84
+
85
+ # 保存有改变的target列表
86
+ root_names_to_update = (added + changed + missing).uniq
87
+ updates_target_names = (root_names_to_update + deleted).uniq
88
+ cache = []
89
+ updates_targets = []
90
+ updates_target_names.each do |pod_name|
91
+ tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
92
+ if tars.nil? || tars.empty?
93
+ Pod::UI.puts "There's no target named (#{pod_name}) in Pod.xcodeproj." if t.nil?
94
+ else
95
+ updates_targets = (updates_targets + tars).uniq
96
+ end
97
+ end
98
+ updates_dependency_targets = updates_targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
99
+ Pod::Prebuild::Passer.prebuild_pod_targets_changes = (updates_targets + updates_dependency_targets).uniq
100
+ end
101
+ end
66
102
 
67
103
  # Build the needed framework files
68
104
  def prebuild_frameworks!
@@ -87,11 +123,8 @@ module Pod
87
123
  missing = unchanged.select do |pod_name|
88
124
  not exsited_framework_pod_names.include?(pod_name)
89
125
  end
90
-
91
-
92
- root_names_to_update = (added + changed + missing)
93
-
94
- # transform names to targets
126
+ root_names_to_update = (added + changed + missing).uniq
127
+ # 生成预编译target
95
128
  cache = []
96
129
  targets = root_names_to_update.map do |pod_name|
97
130
  tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
@@ -101,8 +134,11 @@ module Pod
101
134
  tars
102
135
  end.flatten
103
136
 
104
- # add the dendencies
137
+ # 添加依赖
105
138
  dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
139
+ dependency_targets = dependency_targets.select do |tar|
140
+ sandbox.existed_target_version_for_pod_name(tar.pod_name) != tar.version
141
+ end
106
142
  targets = (targets + dependency_targets).uniq
107
143
  else
108
144
  targets = self.pod_targets
@@ -135,24 +171,27 @@ module Pod
135
171
  else
136
172
  # resource_paths is Hash{String=>Array<String>} on 1.6 and above
137
173
  # (use AFNetworking to generate a demo data)
174
+ # https://github.com/leavez/cocoapods-binary/issues/50
138
175
  target.resource_paths.values.flatten
139
176
  end
140
177
  end
141
178
  raise "Wrong type: #{resources}" unless resources.kind_of? Array
142
-
143
- path_objects = resources.flat_map do |path|
144
- real_path = framework_path + File.basename(path)
179
+ path_objects = resources.map do |path|
180
+ object = Prebuild::Passer::ResourcePath.new
181
+ object.real_file_path = framework_path + File.basename(path)
145
182
  # 静态库资源目录处理
146
183
  if use_static_framework
147
- real_bundle_path = sandbox.real_bundle_path_for_pod(path)
148
- if File.exists?(real_bundle_path)
149
- FileUtils.cp_r(real_bundle_path, framework_path, :remove_destination => true)
184
+ object.real_file_path = path.gsub('${PODS_ROOT}', existed_framework_folder.to_s) if path.start_with? '${PODS_ROOT}'
185
+ object.real_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", existed_framework_folder.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
186
+ real_bundle_path = path.gsub('${PODS_ROOT}', sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
187
+ real_bundle_path = path.gsub('${PODS_CONFIGURATION_BUILD_DIR}', sandbox_path.to_s) if path.start_with? '${PODS_CONFIGURATION_BUILD_DIR}'
188
+ real_origin_path = Pathname.new(real_bundle_path)
189
+ real_file_path_obj = Pathname.new(object.real_file_path)
190
+ if real_origin_path.exist?
191
+ real_file_path_obj.parent.mkpath unless real_file_path_obj.parent.exist?
192
+ FileUtils.cp_r(real_origin_path, real_file_path_obj, :remove_destination => true)
150
193
  end
151
194
  end
152
- object = Prebuild::Passer::ResourcePath.new
153
- if File.exists?(real_path)
154
- object.real_file_path = real_path
155
- end
156
195
  object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
157
196
  object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
158
197
  object
@@ -225,12 +264,13 @@ module Pod
225
264
  # patch the post install hook
226
265
  old_method2 = instance_method(:run_plugins_post_install_hooks)
227
266
  define_method(:run_plugins_post_install_hooks) do
267
+ if Pod::is_prebuild_stage
268
+ self.save_change_targets!
269
+ end
228
270
  old_method2.bind(self).()
229
271
  if Pod::is_prebuild_stage
230
272
  self.prebuild_frameworks!
231
273
  end
232
274
  end
233
-
234
-
235
275
  end
236
276
  end
@@ -1,215 +1,43 @@
1
1
  module Pod
2
2
  class Command
3
+ # This is an example of a cocoapods plugin adding a top-level subcommand
4
+ # to the 'pod' command.
5
+ #
6
+ # You can also create subcommands of existing or new commands. Say you
7
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
8
+ # (e.g. `pod list deprecated`), there are a few things that would need
9
+ # to change.
10
+ #
11
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
12
+ # the class to exist in the the Pod::Command::List namespace
13
+ # - change this class to extend from `List` instead of `Command`. This
14
+ # tells the plugin system that it is a subcommand of `list`.
15
+ # - edit `lib/cocoapods_plugins.rb` to require this file
16
+ #
17
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
18
+ # in the `plugins.json` file, once your plugin is released.
3
19
  #
4
20
  class Ppbuild < Command
5
- self.summary = '通过将二进制对应源码放置在临时目录中,让二进制出现断点时可以跳到对应的源码,方便调试。'
21
+ self.summary = 'Short description of cocoapods-Ppbuild.'
6
22
 
7
23
  self.description = <<-DESC
8
- 通过将二进制对应源码放置在临时目录中,让二进制出现断点时可以跳到对应的源码,方便调试。
9
- 在不删除二进制的情况下为某个组件添加源码调试能力,多个组件名称用空格分隔
24
+ Longer description of cocoapods-Ppbuild.
10
25
  DESC
11
26
 
12
- self.arguments = [
13
- CLAide::Argument.new('NAME', false)
14
- ]
15
- def self.options
16
- [
17
- ['--all-clean', '删除所有已经下载的源码'],
18
- ['--clean', '删除所有指定下载的源码'],
19
- ['--list', '展示所有一级下载的源码以及其大小'],
20
- ['--source', '源码路径,本地路径,会去自动链接本地源码']
21
- ]
22
- end
27
+ # self.arguments = 'NAME'
23
28
 
24
29
  def initialize(argv)
25
- @codeSource = argv.option('source') || nil
26
- @names = argv.arguments! unless argv.arguments.empty?
27
- @list = argv.flag?('list', false )
28
- @all_clean = argv.flag?('all-clean', false )
29
- @clean = argv.flag?('clean', false )
30
- @config = Pod::Config.instance
31
- @analyzer = nil
32
- @podfile_dependency_cache = Pod::Installer::Analyzer::PodfileDependencyCache.from_podfile(@config.podfile)
30
+ @name = argv.shift_argument
33
31
  super
34
32
  end
35
33
 
36
-
37
- def run
38
- podfile_lock = File.join(Pathname.pwd,"Podfile.lock")
39
- raise "podfile.lock,不存在,请先pod install/update" unless File.exist?(podfile_lock)
40
- @lockfile ||= Lockfile.from_file(Pathname.new(podfile_lock) )
41
-
42
- if @list
43
- list
44
- elsif @clean
45
- clean
46
- elsif @all_clean
47
- all_clean
48
- elsif @names
49
- add
50
- end
51
-
52
- if @list && @clean && @names
53
- raise "请选择您要执行的命令。"
54
- end
55
- end
56
-
57
- #==========================begin add ==============
58
-
59
- def add
60
- if @names == nil
61
- raise "请输入要调试组件名,多个组件名称用空格分隔"
62
- end
63
- @names.each do |name|
64
- lib_file = get_lib_path(name)
65
- unless File.exist?(lib_file)
66
- raise "找不到 #{lib_file}"
67
- end
68
- UI.puts "#{lib_file}"
69
-
70
- target_path = @codeSource || download_source(name)
71
-
72
- link(lib_file,target_path,name)
73
- end
74
- end
75
-
76
- #下载源码到本地
77
- def download_source(name)
78
- target_path = File.join(source_root, name)
79
- UI.puts target_path
80
- FileUtils.rm_rf(target_path)
81
- find_dependency = find_dependency(name)
82
- spec = fetch_external_source(find_dependency, @config.podfile,@config.lockfile, @config.sandbox,true )
83
-
84
- download_request = Pod::Downloader::Request.new(:name => name, :spec => spec)
85
- Downloader.download(download_request, Pathname.new(target_path), :can_cache => true)
86
-
87
- target_path
88
- end
89
-
90
- #找出依赖
91
- def find_dependency (name)
92
- find_dependency = nil
93
-
94
- @config.podfile.dependencies.each do |dependency|
95
- if dependency.root_name.downcase == name.downcase
96
- find_dependency = dependency
97
- break
98
- end
99
- end
100
- if find_dependency.external_source.nil?
101
-
102
- end
103
- find_dependency
104
- end
105
-
106
- # 获取external_source 下的仓库
107
- # @return spec
108
- def fetch_external_source(dependency ,podfile , lockfile, sandbox,use_lockfile_options)
109
- checkout_options = lockfile.checkout_options_for_pod_named(dependency.root_name)
110
- source = if use_lockfile_options && lockfile && checkout_options
111
- ExternalSources.from_params(checkout_options, dependency, podfile.defined_in_file, podfile.installation_options.clean?)
112
- else
113
- ExternalSources.from_dependency(dependency, podfile.defined_in_file, podfile.installation_options.clean?)
114
- end
115
- source.fetch(sandbox)
116
- end
117
-
118
-
119
- #==========================link begin ==============
120
-
121
- #链接,.a文件位置, 源码目录
122
- def link(lib_file,target_path,basename)
123
- check(lib_file,dir,basename)
124
- end
125
-
126
- def check(lib_file,dir,basename)
127
- file = `dwarfdump "#{lib_file}" | grep -E "DW_AT_decl_file.*#{basename}.*\\.m|\\.c" | head -1 | cut -d \\" -f2`
128
- if File.exist?(file)
129
- raise "#{file} 不存在 请检测代码源是否正确~"
130
- end
131
- UI.puts "link successfully!"
132
- UI.puts "view linked source at path: #{dir}"
133
- end
134
-
135
- def get_lib_path(name)
136
- dir = Pathname.new(File.join(Pathname.pwd,"Pods",name))
137
- dir = get_framework_path(dir, name)
138
- if !Dir.exist?(dir)
139
- raise "找不到组件:#{name}, 请输入正确名称!! 者将组件名在git上提issues"
140
- end
141
- lib_path = File.join(dir, name)
142
- lib_path
143
- end
144
-
145
- def get_framework_path(basepath, name)
146
- dir = Pathname.new(File.join(basepath, "#{name}.framework"))
147
- if !Dir.exist?(dir)
148
- dir = dir.children.first
149
- if Dir.exist?(dir)
150
- return get_framework_path(dir, name)
151
- end
152
- end
153
- return dir
154
- end
155
-
156
-
157
- #源码地址
158
- # def get_gitlib_iOS_path(name)
159
- # "git@gitlab.xxx.com:iOS/#{name}.git"
160
- # end
161
- #要转换的地址,Github-iOS默认都是静态库
162
- # def git_gitlib_iOS_path
163
- # 'git@gitlab.xxx.com:Github-iOS/'
164
- # end
165
-
166
-
167
- #要转换的地址,Github-iOS默认都是静态库
168
- # def http_gitlib_GitHub_iOS_path
169
- # 'https://gitlab.xxx.com/Github-iOS/'
170
- # end
171
-
172
- #要转换的地址,iOS默认都是静态库
173
- # def http_gitlib_iOS_path
174
- # 'https://gitlab.xxx.com/iOS/'
175
- # end
176
-
177
- #==========================list begin ==============
178
-
179
- def list
180
- Dir.entries(source_root).each do |sub|
181
- UI.puts "- #{sub}" unless sub.include?('.')
182
- end
183
- UI.puts "加载完成"
184
- end
185
-
186
-
187
- #==========================clean begin ==============
188
- def all_clean
189
- FileUtils.rm_rf(source_root) if File.directory?(source_root)
190
- UI.puts "清理完成 #{source_root}"
191
- end
192
-
193
- def clean
194
- raise "请输入要删除的组件库" if @names.nil?
195
- @names.each do |name|
196
- full_path = File.join(source_root,name)
197
- if File.directory?(full_path)
198
- FileUtils.rm_rf(full_path)
199
- else
200
- UI.puts "找不到 #{full_path}".yellow
201
- end
202
- end
203
- UI.puts "清理完成 #{@names.to_s}"
34
+ def validate!
35
+ super
36
+ help! 'A Pod name is required.' unless @name
204
37
  end
205
38
 
206
- private
207
-
208
- def source_root
209
- dir = File.join(@config.cache_root,"Source")
210
- FileUtils.mkdir_p(dir) unless File.exist? dir
211
- UI.puts "缓存目录 #{dir}"
212
- dir
39
+ def run
40
+ UI.puts "Add your implementation for the cocoapods-Ppbuild plugin in #{__FILE__}"
213
41
  end
214
42
  end
215
43
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPpbuild
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -14,7 +14,7 @@ module Pod
14
14
  # @return [Analyzer::SpecsState]
15
15
  #
16
16
  class_attr_accessor :prebuild_pods_changes
17
-
17
+ class_attr_accessor :prebuild_pod_targets_changes
18
18
 
19
19
  # represent the path of resurces to copy
20
20
  class ResourcePath
@@ -77,9 +77,10 @@ module Pod
77
77
 
78
78
  # filter prebuild
79
79
  prebuild_names = target_definition.prebuild_framework_pod_names
80
- if not Podfile::DSL.prebuild_all
81
- targets = targets.select { |pod_target| prebuild_names.include?(pod_target.pod_name) }
82
- end
80
+ # if not Podfile::DSL.prebuild_all
81
+ # targets = targets.select { |pod_target| prebuild_names.include?(pod_target.pod_name) }
82
+ # end
83
+ targets = targets.select { |pod_target| prebuild_names.include?(pod_target.pod_name) }
83
84
  dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
84
85
  targets = (targets + dependency_targets).uniq
85
86
 
@@ -67,13 +67,21 @@ module Pod
67
67
  exsited_framework_name_pairs.select {|pair| pair[1] == pod_name }.map { |pair| pair[0]}
68
68
  end
69
69
 
70
-
70
+ def existed_target_version_for_pod_name(pod_name)
71
+ folder = framework_folder_path_for_target_name(pod_name)
72
+ return "" unless folder.exist?
73
+ flag_file_path = folder + "#{pod_name}.pod_name"
74
+ return "" unless flag_file_path.exist?
75
+ version = File.read(flag_file_path)
76
+ Pod::UI.puts "............ version: #{version}"
77
+ version
78
+ end
71
79
 
72
80
  def save_pod_name_for_target(target)
73
81
  folder = framework_folder_path_for_target_name(target.name)
74
82
  return unless folder.exist?
75
83
  flag_file_path = folder + "#{target.pod_name}.pod_name"
76
- File.write(flag_file_path.to_s, "")
84
+ File.write(flag_file_path.to_s, "#{target.version}")
77
85
  end
78
86
 
79
87
  def real_bundle_path_for_pod(path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-ppbuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - 彭懂
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-18 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: A short description of cocoapods-ppbuild.
41
+ description: 工程静态库编译,提高编译速度.
42
42
  email:
43
43
  - pengdong2014@xiaochuankeji.cn
44
44
  executables: []
@@ -61,7 +61,7 @@ files:
61
61
  - lib/cocoapods-ppbuild/rome/build_framework.rb
62
62
  - lib/cocoapods-ppbuild/tool/tool.rb
63
63
  - lib/cocoapods_plugin.rb
64
- homepage: https://github.com/EXAMPLE/cocoapods-ppbuild
64
+ homepage: https://github.com/pdcodeunder/cocoapods-ppbuild.git
65
65
  licenses:
66
66
  - MIT
67
67
  metadata: {}
@@ -83,5 +83,5 @@ requirements: []
83
83
  rubygems_version: 3.0.9
84
84
  signing_key:
85
85
  specification_version: 4
86
- summary: A longer description of cocoapods-ppbuild.
86
+ summary: 工程静态库编译,提高编译速度.
87
87
  test_files: []