cocoapods-xlbuild 1.0.1 → 1.1.2

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: 88a70a0fd0fecfb97bff88928a5c18b3f5eb9785c44f3c1b77d0fe6a7948be41
4
- data.tar.gz: 96246659761524bd8de69b383119e500b055317cb4c980d0639e03db2ab89597
3
+ metadata.gz: 676c4cfb3f76ad14c4de9334d69d9a9344b29663c77786a0678e250e97ed0c1c
4
+ data.tar.gz: 117d8cf76103b67b6c4ebc11c5f412ea2d60deb2a8d5b0f4461e39927e5770f5
5
5
  SHA512:
6
- metadata.gz: 9e5a06edc5b9c0bec004a0f7be2626dba0dbb7148c8912a9bba291e0812a487d1a7ea6b9c8da8725d2b16833189855a156feae5d353666910f79e0b616b50598
7
- data.tar.gz: 6f3ecb033fb70f154b566b0a3eb3f3dc9c71253bf0fd71302137a415e7161a085d1f4c2343416fb2d55229d793a7e74f88bd676a230c6f8bbdd1e0700944577b
6
+ metadata.gz: f0a9b3ec826607cfbd419d24b72e9bea0fb06420001edf15acbcff462bb5d6177048e1d74171753193c638f885b5b27dd780a0ff1c1a08b522387deaa53e1afb
7
+ data.tar.gz: ff64b76759437f9622cd611a91a6e5b5ea7b74cb6d3c8f907dee98581ee1f6dea90a1d85c0ae8fa7f67623c00d0974f55b4cdd68df490e76c80d43e2133d6807
@@ -310,6 +310,7 @@ module Pod
310
310
 
311
311
 
312
312
  # Override the download step to skip download and prepare file in target folder
313
+ # linpeng edit: hook集成安装源码的方法(源码下载完之后会将源码关联引用到Pod工程)
313
314
  old_method = instance_method(:install_source_of_pod)
314
315
  define_method(:install_source_of_pod) do |pod_name|
315
316
  if Pod::is_prebuild_stage
@@ -320,6 +321,7 @@ module Pod
320
321
  # \copy from original
321
322
 
322
323
  if self.prebuild_pod_names.include? pod_name
324
+ #linpeng edit: Pod::is_prebuild_stage 编译完成后 还会执行该步骤 该步骤会将_Prebuild/GenerateFramework/xxxx目录关联引用到Pod/xxxx目录里面 替换framework原本的源码
323
325
  pod_installer.install_for_prebuild!(self.sandbox)
324
326
  else
325
327
  pod_installer.install!
@@ -5,6 +5,9 @@ require_relative 'tool/tool'
5
5
  module Pod
6
6
  class Podfile
7
7
  module DSL
8
+ def set_local_frameworks_cache_path(path)
9
+ DSL.local_frameworks_cache_path = path
10
+ end
8
11
  # Enable prebuiding for all pods
9
12
  # it has a lower priority to other xlbuild settings
10
13
  def use_dynamic_binary!
@@ -83,10 +86,65 @@ module Pod
83
86
 
84
87
  class_attr_accessor :custom_build_options
85
88
  class_attr_accessor :custom_build_options_simulator
89
+
90
+ class_attr_accessor :local_frameworks_cache_path
91
+ local_frameworks_cache_path = nil
92
+
86
93
  self.custom_build_options = []
87
94
  self.custom_build_options_simulator = []
88
95
  end
89
96
  end
97
+
98
+ class Type
99
+ class_attr_accessor :pod_flag_file
100
+ @pod_flag_file = "build.xl"
101
+
102
+ def self.frameworks_type
103
+ is_static_binary = Pod::Podfile::DSL.static_binary
104
+ frameworks_type = is_static_binary ? "static" : "dynamic"
105
+ return frameworks_type
106
+ end
107
+
108
+ # 动静态库切换时候需要重新build(删除Pod目录重新构建)
109
+ def self.adjust_dynamic_static_change_pod(standard_sandbox)
110
+ # 动|静态库(mach-o type)切换需要重新build(删除Pod/_Prebuild目录)
111
+ _prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
112
+ _pod_prebuild_root_path = _prebuild_sandbox.root
113
+ is_pod_prebuild_root_path_exist = File.exist?(_pod_prebuild_root_path)
114
+
115
+ pod_root_path = standard_sandbox.root
116
+ pod_type_path = pod_root_path+Pod::Type.pod_flag_file
117
+ if not File.exist?(pod_type_path) and is_pod_prebuild_root_path_exist
118
+ FileUtils.remove_dir(_pod_prebuild_root_path)
119
+ else
120
+ frameworks_type = Pod::Type.frameworks_type
121
+ aFile = File.new(pod_type_path, "r")
122
+ if aFile
123
+ content = aFile.readlines[0]
124
+ if not frameworks_type.eql?(content) and is_pod_prebuild_root_path_exist
125
+ FileUtils.remove_dir(_pod_prebuild_root_path)
126
+ end
127
+ end
128
+
129
+ end
130
+
131
+ end
132
+
133
+ #构建结束 标记当前打包的是动|静态库
134
+ def self.adjust_dynamic_static_change_pod_finish(standard_sandbox)
135
+ # 标记状态
136
+ pod_root_path = standard_sandbox.root
137
+ pod_type_path = pod_root_path+Pod::Type.pod_flag_file
138
+ if File.exist?(pod_type_path)
139
+ File.delete(pod_type_path)
140
+ end
141
+
142
+ frameworks_type = Pod::Type.frameworks_type
143
+ File.open(pod_type_path, "w+") { |f|
144
+ f.write(frameworks_type)
145
+ }
146
+ end
147
+ end
90
148
  end
91
149
 
92
150
  Pod::HooksManager.register('cocoapods-xlbuild', :pre_install) do |installer_context|
@@ -138,8 +196,12 @@ Pod::HooksManager.register('cocoapods-xlbuild', :pre_install) do |installer_cont
138
196
 
139
197
  # make another custom sandbox
140
198
  standard_sandbox = installer_context.sandbox
199
+ #linpeng edit: 修改Pod目录为 Pod/_Prebuild
141
200
  prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
142
201
 
202
+ # 动|静态库(mach-o type)切换需要重新build(删除Pod/_Prebuild目录)
203
+ Pod::Type.adjust_dynamic_static_change_pod standard_sandbox
204
+
143
205
  # get the podfile for prebuild
144
206
  prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file)
145
207
 
@@ -168,6 +230,10 @@ Pod::HooksManager.register('cocoapods-xlbuild', :pre_install) do |installer_cont
168
230
  Pod::Installer.disable_install_complete_message false
169
231
  Pod::UserInterface.warnings = [] # clean the warning in the prebuild step, it's duplicated.
170
232
 
233
+
234
+ # install完成标记mach-o type
235
+ Pod::Type.adjust_dynamic_static_change_pod_finish standard_sandbox
236
+
171
237
  # -- step 2: pod install ---
172
238
  # install
173
239
  Pod::UI.puts "🤖 Pod Install "
@@ -176,10 +242,9 @@ Pod::HooksManager.register('cocoapods-xlbuild', :pre_install) do |installer_cont
176
242
  end
177
243
 
178
244
  ## pod 安装依赖的时候会执行install,install的时候会执行run_plugins_post_install_hooks(Prebuildhook了该方法)
179
- # 只要有触发install方法就会触发如下的
245
+ # 只要有触发install方法就会触发如下的 ,pre hook的时候有重新创建一个Install( binary_installer.install!)因此会触发两次的post_install的hook
180
246
  Pod::HooksManager.register('cocoapods-xlbuild', :post_install) do |installer_context|
181
247
  if Pod::Podfile::DSL.static_binary
182
- Pod::UI.puts "🤖 replace_tagert_copy_source_sh " + Time.new.inspect
183
248
  Pod::PrebuildSandbox.replace_tagert_copy_source_sh(installer_context)
184
249
  end
185
250
 
@@ -115,14 +115,52 @@ module Pod
115
115
  Pod::Prebuild.remove_build_dir(sandbox_path)
116
116
  targets.each do |target|
117
117
  #linpeng edit + target.version
118
- output_path = sandbox.framework_folder_path_for_target_name(target.name)
118
+ @sandbox_framework_folder_path_for_target_name = sandbox.framework_folder_path_for_target_name(target.name)
119
+ output_path = @sandbox_framework_folder_path_for_target_name
119
120
  output_path.rmtree if output_path.exist?
120
121
  if !target.should_build?
121
122
  UI.puts "Prebuilding #{target.label}"
122
123
  next
123
124
  end
124
125
  output_path.mkpath unless output_path.exist?
125
- Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
126
+
127
+ #local cache
128
+ localCachePathRoot = Pod::Podfile::DSL.local_frameworks_cache_path
129
+ is_static_binary = Pod::Podfile::DSL.static_binary
130
+ type_frameworks_dir = is_static_binary ? "static" : "dynamic"
131
+ is_has_local_cache = localCachePathRoot != nil
132
+ if not is_has_local_cache
133
+ #开始使用XcodeBuild进行编译静态库
134
+ Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
135
+ else
136
+ targetFrameworkPath = localCachePathRoot + "/#{type_frameworks_dir}/#{target.name}/#{target.version}"
137
+ if Dir.exist?(targetFrameworkPath)
138
+ puts "[XL].本地缓存仓库获取:#{target.name}(#{target.version}) #{type_frameworks_dir}"
139
+ Dir.foreach(targetFrameworkPath) do |file|
140
+ if file !="." and file !=".."
141
+ f = targetFrameworkPath+"/"+file
142
+ FileUtils.cp_r(f, output_path, :remove_destination => false )
143
+ end
144
+ end
145
+ else
146
+ #开始使用XcodeBuild进行编译静态库
147
+ Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
148
+
149
+ #save for cache
150
+ puts "[XL].本地缓存仓库新增:#{target.name}(#{target.version} #{type_frameworks_dir}"
151
+ local_cache_path = targetFrameworkPath
152
+ FileUtils.makedirs(local_cache_path) unless File.exists?local_cache_path
153
+ c_output_path = output_path.to_s
154
+ if Dir.exist?(output_path)
155
+ Dir.foreach(output_path) do |file|
156
+ if file !="." and file !=".."
157
+ f = c_output_path+"/"+file
158
+ FileUtils.cp_r(f, local_cache_path, :remove_destination => false )
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
126
164
 
127
165
  # save the resource paths for later installing,动态库需要将frameworkwork中资源链接到pod上
128
166
  if target.static_framework? and !target.resource_paths.empty?
@@ -228,7 +266,6 @@ module Pod
228
266
  # hook run_plugins_post_install_hooks 方法
229
267
  install_hooks_method = instance_method(:run_plugins_post_install_hooks)
230
268
  define_method(:run_plugins_post_install_hooks) do
231
- puts "[HY].run_plugins_post_install_hooks 触发 state:#{Pod::is_prebuild_stage}"
232
269
  install_hooks_method.bind(self).()
233
270
  if Pod::is_prebuild_stage
234
271
  #开始编译
@@ -13,9 +13,6 @@ module Pod
13
13
 
14
14
  exsited_framework_pod_names = pre_sandbox.exsited_framework_pod_names || []
15
15
  proj_path = sandbox_path + get_project_name("Pods")
16
-
17
- proj_path_new = Pathname.new(sandbox.project_path)
18
-
19
16
  project = Xcodeproj::Project.open(proj_path)
20
17
  exsited_framework_pod_names.each do |target_name|
21
18
  real_reference("_Prebuild/#{target_name}", project, target_name)
@@ -1,3 +1,3 @@
1
1
  module CocoapodsXLbuild
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -12,9 +12,7 @@ module Pod
12
12
  tn = "Pods-#{target.name}"
13
13
  dir = Pathname.new(File.join(installer_context.sandbox.root,"Target Support Files", tn))
14
14
  sh_path = File.join(dir, "#{tn}-resources.sh")
15
- puts "[HY].sh_path #{sh_path}"
16
15
  if File.exists?(sh_path)
17
- puts "[HY].resource.sh存在"
18
16
  list.each do |tarname|
19
17
  replace_content_file sh_path, tarname
20
18
  end
@@ -23,8 +23,7 @@ def build_for_iosish_platform(sandbox,
23
23
  deployment_target = target.platform.deployment_target.to_s
24
24
 
25
25
  target_label = target.label # name with platform if it's used in multiple platforms
26
- #linpeng edit
27
- Pod::UI.puts "[HY].Prebuilding #{target_label} -> #{target.version}"
26
+ Pod::UI.puts "[XL].Prebuilding #{target_label} -> #{target.version}"
28
27
 
29
28
  other_options = []
30
29
  # bitcode enabled
@@ -95,11 +94,13 @@ def build_for_iosish_platform(sandbox,
95
94
  FileUtils.mv tmp_lipoed_binary_path, "#{device_framework_path}.dSYM/Contents/Resources/DWARF/#{module_name}", :force => true
96
95
  end
97
96
  # move
97
+ # linpeng edit:xxxx.framework.DSYM文件挪到GenerateFramework的xxx目录下
98
98
  FileUtils.mv device_dsym, output_path, :force => true
99
99
  end
100
100
 
101
101
  # output
102
102
  output_path.mkpath unless output_path.exist?
103
+ #linpeng edit: 将build文件夹的xxxx.framework移动到GenerateFramework的xxxx目录下
103
104
  FileUtils.mv device_framework_path, output_path, :force => true
104
105
  # 如果是静态库则需要手动处理资源文件
105
106
  if Pod::Podfile::DSL.static_binary
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-xlbuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 林鹏
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-28 00:00:00.000000000 Z
11
+ date: 2022-08-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 工程静态库编译,提高编译速度.
14
14
  email:
@@ -38,7 +38,7 @@ homepage: https://github.com/Jacky-LinPeng/cocoapods-xlbuild.git
38
38
  licenses:
39
39
  - MIT
40
40
  metadata: {}
41
- post_install_message:
41
+ post_install_message:
42
42
  rdoc_options: []
43
43
  require_paths:
44
44
  - lib
@@ -53,8 +53,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  requirements: []
56
- rubygems_version: 3.2.22
57
- signing_key:
56
+ rubygems_version: 3.2.29
57
+ signing_key:
58
58
  specification_version: 4
59
59
  summary: 工程静态库编译,提高编译速度.
60
60
  test_files: []