cocoapods-jxedt 0.0.12 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-jxedt/binary/Intergation.rb +18 -13
  3. data/lib/cocoapods-jxedt/binary/config.rb +72 -0
  4. data/lib/cocoapods-jxedt/binary/helper/podfile_post_install_hook.rb +29 -0
  5. data/lib/cocoapods-jxedt/binary/helper/prebuild_installer.rb +11 -0
  6. data/lib/cocoapods-jxedt/binary/helper/prebuild_sandbox.rb +58 -53
  7. data/lib/cocoapods-jxedt/binary/hooks/CocoapodsJxedtHook.rb +6 -9
  8. data/lib/cocoapods-jxedt/binary/hooks/post_install.rb +4 -4
  9. data/lib/cocoapods-jxedt/binary/hooks/pre_install.rb +32 -12
  10. data/lib/cocoapods-jxedt/binary/main.rb +1 -0
  11. data/lib/cocoapods-jxedt/binary/pod-room/framework.rb +40 -0
  12. data/lib/cocoapods-jxedt/binary/pod-room/xcodebuild_command.rb +83 -1
  13. data/lib/cocoapods-jxedt/binary/pod-room/xcodebuild_raw.rb +1 -1
  14. data/lib/cocoapods-jxedt/binary/prebuild.rb +94 -16
  15. data/lib/cocoapods-jxedt/command/binary/binary.rb +38 -0
  16. data/lib/cocoapods-jxedt/command/binary/command/build.rb +84 -0
  17. data/lib/cocoapods-jxedt/command/binary/command/clean.rb +101 -0
  18. data/lib/cocoapods-jxedt/command/binary/command/code.rb +66 -0
  19. data/lib/cocoapods-jxedt/command/binary/command/fetch.rb +36 -0
  20. data/lib/cocoapods-jxedt/command/binary/command/push.rb +41 -0
  21. data/lib/cocoapods-jxedt/command/binary/command/source_project.rb +51 -0
  22. data/lib/cocoapods-jxedt/command/binary/command/statistics.rb +104 -0
  23. data/lib/cocoapods-jxedt/command/jxedt.rb +2 -1
  24. data/lib/cocoapods-jxedt/command/options/options.rb +85 -2
  25. data/lib/cocoapods-jxedt/command/user/user.rb +57 -0
  26. data/lib/cocoapods-jxedt/gem_version.rb +1 -1
  27. data/lib/cocoapods-jxedt/git_helper/cache_fetcher.rb +34 -0
  28. data/lib/cocoapods-jxedt/git_helper/cache_pucher.rb +42 -0
  29. data/lib/cocoapods-jxedt/git_helper/git_command.rb +48 -0
  30. data/lib/cocoapods-jxedt/git_helper/zip.rb +22 -0
  31. metadata +18 -3
  32. data/lib/cocoapods-jxedt/command/statistics/statistics.rb +0 -98
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad01cd6bd2da4418b03764271caab2236a186ea81f3c9f77a885910d12263d78
4
- data.tar.gz: aa9f410bbbea81420a9d04f01c379428aece86e8449c9ec10a461a79d03825fe
3
+ metadata.gz: 9a42af93bf587f17cb6256301bdcc0b744cad56e731f8d00b4c11e072bf22058
4
+ data.tar.gz: bfd62a6afcaf885d939778b70d21779730ce3b5bc1c59df7cf1d781ea10fb77a
5
5
  SHA512:
6
- metadata.gz: a0a5d962b702c2fde4f3ac10a81e027ba555f72310b31fee0530e94587eb7e56019ddf0d5e64951dd8f3c0e50626afbf286aa3c15b31a678bbb99413dcc5e8d1
7
- data.tar.gz: 60e70a3f5be60178cf721b4d69b113d065275eb415f70655feb718279b9b2ad9de3bfb8a9ce0a01050b2972a7c2346ef7bbcd723849054d40bf79dc7b84db124
6
+ metadata.gz: 3d6963c2b36104bc5dbbd8b9d87c354d1074219662de03fac82b757245997a1b149c0c77711ca1cd640eb73181824aa9606181edf25372f0d891d91c1d2a7b42
7
+ data.tar.gz: 7bf5ed75aae47c6eb983962d8a4e6f13725e179351d4b2a48f46876932a6f6e406f445248f0a780bf9c853489fb01a84f63e3b93d8b115ecbf02529a943897c0
@@ -138,7 +138,7 @@ module Pod
138
138
  specs = self.analysis_result.specifications
139
139
  prebuilt_specs = (specs.select do |spec|
140
140
  # rmtree
141
- target_prebuild_files = self.sandbox.root + spec.root.name + "_Prebuild"
141
+ target_prebuild_files = self.sandbox.pod_dir(spec.name) + "_Prebuild"
142
142
  target_prebuild_files.rmtree if target_prebuild_files.exist?
143
143
 
144
144
  self.prebuild_pod_names.include? spec.root.name
@@ -149,18 +149,6 @@ module Pod
149
149
  checked_specs[spec.root.name] = [] if checked_specs[spec.root.name].nil?
150
150
  checked_specs[spec.root.name] << spec
151
151
 
152
- # Use the prebuild framworks as vendered frameworks
153
- # get_corresponding_targets
154
- targets = Pod.fast_get_targets_for_pod_name(spec.root.name, self.pod_targets, cache)
155
- targets.each do |target|
156
- # the framework_file_path rule is decided when `install_for_prebuild`,
157
- # as to compitable with older version and be less wordy.
158
- check_sandbox.prebuild_vendored_frameworks(spec.root.name).each do |frame_file_path|
159
- framework_file_path = "_Prebuild/" + frame_file_path
160
- framework_file_path = nil if checked_specs[spec.root.name].size > 1 # spec.root.name相同的只添加一次framework文件
161
- add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
162
- end
163
- end
164
152
  # Clean the source files
165
153
  # we just add the prebuilt framework to specific platform and set no source files
166
154
  # for all platform, so it doesn't support the sence that 'a pod perbuild for one
@@ -186,8 +174,25 @@ module Pod
186
174
  spec.attributes_hash["resources"] += prebuild_bundles
187
175
  end
188
176
 
177
+ # Use the prebuild framworks as vendered frameworks
178
+ # get_corresponding_targets
179
+ targets = Pod.fast_get_targets_for_pod_name(spec.root.name, self.pod_targets, cache)
180
+ targets.each do |target|
181
+ # the framework_file_path rule is decided when `install_for_prebuild`,
182
+ # as to compitable with older version and be less wordy.
183
+ check_sandbox.prebuild_vendored_frameworks(spec.root.name).each do |frame_file_path|
184
+ framework_file_path = "_Prebuild/" + frame_file_path
185
+ framework_file_path = nil if checked_specs[spec.root.name].size > 1 # spec.root.name相同的只添加一次framework文件
186
+ add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
187
+ end
188
+
189
+ # clear resource when target is a dynamic framework
190
+ spec.attributes_hash["resources"] = [] if target.build_as_dynamic_framework?
191
+ end
192
+
189
193
  # to avoid the warning of missing license
190
194
  spec.attributes_hash["license"] = {}
195
+ # keep all file in pods
191
196
  spec.attributes_hash["preserve_paths"] = "**/*"
192
197
 
193
198
  end
@@ -24,12 +24,23 @@ module Jxedt
24
24
  :device_build_enabled => "编译真机。默认true",
25
25
  :simulator_build_enabled => "编译模拟器。默认false",
26
26
  :disable_dsym => "禁止编译dsym产物。默认true",
27
+ :disable_resource_compilable_pods => "禁止编译有需要编译的resource文件(xib、xcdatamodeld等)的pod",
27
28
  :build_log_path => "编译的log输出路径",
29
+ :prebuild_sandbox_path => '预编译的sandbox路径,可以配置一个多台电脑都可访问的路径,可以做源码和二进制的link。必须以`/Users/cocoapods-jxedt`开头',
28
30
  :build_args => "编译的配置。了解xcodebuild命令的可以配置编译参数,例如配置 ARCHS='arm64 armv7'",
31
+ :git_cache => 'git缓存配置,A Hash. 详情查看 GIT_CACHE_CONFIG'
29
32
  }.freeze
30
33
 
34
+ GIT_CACHE_CONFIG = {
35
+ :repo => '配置缓存仓库地址,如:{:remote => "https://github.com/user/cocoapods-cache.git", :local => "~/.cocoapods-jxedt/cocoapods-cache"},或者直接写远程仓库地址"https://github.com/user/cocoapods-cache.git"',
36
+ :branch => 'git cache的branch,默认是master分支',
37
+ :auto_fetch => 'pod install过程是否自动拉取远程的二进制,默认true',
38
+ :auto_push => 'pod install过程是否自动同步二进制结果到远程仓库,默认false',
39
+ }.freeze
40
+
31
41
  def initialize()
32
42
  @dsl_config = {}
43
+ @git_config = {}
33
44
  end
34
45
 
35
46
  def self.instance
@@ -108,6 +119,10 @@ module Jxedt
108
119
  @dsl_config[:disable_dsym] || @dsl_config[:disable_dsym].nil?
109
120
  end
110
121
 
122
+ def disable_resource_compilable_pods?
123
+ @dsl_config[:disable_resource_compilable_pods] || false
124
+ end
125
+
111
126
  def device_build_enabled?
112
127
  @dsl_config[:device_build_enabled] || @dsl_config[:device_build_enabled].nil?
113
128
  end
@@ -120,6 +135,15 @@ module Jxedt
120
135
  @dsl_config[:build_log_path]
121
136
  end
122
137
 
138
+ def prebuild_sandbox_path
139
+ @sandbox_path ||= begin
140
+ sandbox_path = @dsl_config[:prebuild_sandbox_path]
141
+ sandbox_path = nil unless sandbox_path =~ /^\/Users\/cocoapods-jxedt\/.{1,}$/
142
+ sandbox_path = nil unless File.exist?('/Users/cocoapods-jxedt')
143
+ sandbox_path
144
+ end
145
+ end
146
+
123
147
  def build_args
124
148
  @args ||= begin
125
149
  args = @dsl_config[:build_args] || {}
@@ -140,5 +164,53 @@ module Jxedt
140
164
  configurations
141
165
  end
142
166
  end
167
+
168
+ # git配置 ======================================= git配置
169
+ def git_cache_config
170
+ @git_cache ||= @dsl_config[:git_cache] || {}
171
+ end
172
+
173
+ def cache_repo
174
+ @cache_repo ||= begin
175
+ cache_repo = {}
176
+ user_config = git_cache_config[:repo]
177
+ cache_repo[:remote] = user_config if user_config.is_a?(String)
178
+ cache_repo.merge!(user_config) if user_config.is_a?(Hash)
179
+ cache_repo
180
+ end
181
+ end
182
+
183
+ def git_remote_repo
184
+ @remote ||= cache_repo[:remote]
185
+ end
186
+
187
+ def cache_repo_enabled?
188
+ remote = git_remote_repo
189
+ remote && remote.is_a?(String) && remote =~ /.*\.git$/
190
+ end
191
+
192
+ def git_cache_path
193
+ return nil unless cache_repo_enabled?
194
+
195
+ local = cache_repo[:local]
196
+ return File.expand_path(local) if local && local.is_a?(String) && local.split('/').size > 1
197
+
198
+ remote = git_remote_repo
199
+ repo_name = Pathname.new(remote).basename.sub_ext('').to_s
200
+ File.expand_path("~/.cocoapods-jxedt/#{repo_name}")
201
+ end
202
+
203
+ def auto_fetch?
204
+ git_cache_config[:auto_fetch] || git_cache_config[:auto_fetch].nil?
205
+ end
206
+
207
+ def auto_push?
208
+ git_cache_config[:auto_push]
209
+ end
210
+
211
+ def cache_branch
212
+ git_cache_config[:branch] || 'master'
213
+ end
214
+ # git配置 ======================================= git配置
143
215
  end
144
216
  end
@@ -0,0 +1,29 @@
1
+ module Pod
2
+ class Podfile
3
+ if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
4
+ # Calls the post install callback if defined.
5
+ #
6
+ # @param [Pod::Installer] installer
7
+ # the installer that is performing the installation.
8
+ #
9
+ # @return [Bool] whether a post install callback was specified and it was
10
+ # called.
11
+ #
12
+ # This allows the user to customize, for instance, the generated Xcode project _before_ it’s written to disk.
13
+ alias_method :old_post_install!, :post_install!
14
+ def post_install!(installer)
15
+ executed = old_post_install!(installer)
16
+ handle_pods_project_configurations!(installer) unless executed
17
+ executed
18
+ end
19
+
20
+ def handle_pods_project_configurations!(installer)
21
+ installer.pods_project.targets.each do |target|
22
+ target.build_configurations.each do |config|
23
+ config.build_settings["CODE_SIGN_IDENTITY"] = "" if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+
2
+ module Pod
3
+ class JxedtPrebuildInstaller < Installer # rubocop:disable Metrics/ClassLength
4
+ def installation_options
5
+ # Skip integrating user targets for prebuild Pods project.
6
+ @installation_options ||= Pod::Installer::InstallationOptions.new(
7
+ super.to_h.merge(:integrate_targets => false)
8
+ )
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,13 @@
1
1
  module Pod
2
+ class Sandbox
3
+ attr_accessor :standard_sandbox
4
+
5
+ def standard_sandbox_root
6
+ return root if standard_sandbox.nil?
7
+ standard_sandbox.root
8
+ end
9
+ end
10
+
2
11
  # The sandbox provides support for the directory that CocoaPods uses for an
3
12
  # installation. In this directory the Pods projects, the support files and
4
13
  # the sources of the Pods are stored.
@@ -41,60 +50,69 @@ module Pod
41
50
  # +-- PodTargetN.xcodeproj
42
51
  #
43
52
  #
44
- class PrebuildSandbox < Sandbox
45
- # [String] standard_sandbox_path
46
- def self.from_standard_sandbox_path(path)
47
- prebuild_sandbox_path = Pathname.new(path).realpath
48
- new(prebuild_sandbox_path)
49
- end
50
-
51
- def self.from_standard_sandbox(sandbox)
52
- from_standard_sandbox_path(sandbox.root)
53
+ class JxedtPrebuildSandbox < Sandbox
54
+ # [Pod::Sandbox] standard_sandbox
55
+ def self.from_standard_sandbox(sandbox, sandbox_path: nil, real_path_compiler: false)
56
+ prebuild_sandbox_path = Pathname.new(sandbox.root).realpath + '../Pods-Source'
57
+ prebuild_sandbox = new(prebuild_sandbox_path)
58
+ # initialize
59
+ prebuild_sandbox.standard_sandbox = sandbox
60
+ # prepare
61
+ prebuild_sandbox.prepare_dir
62
+ prebuild_sandbox
53
63
  end
54
64
 
55
- def make_source_link(source, target)
56
- source = Pathname.new(source)
57
- target = Pathname.new(target)
58
- target.parent.mkpath unless target.parent.exist?
59
- target.rmtree if target.exist?
60
- relative_source = source.relative_path_from(target.parent)
61
- FileUtils.ln_sf(relative_source, target)
62
- end
63
-
64
- def source_path
65
- '../Pods-Source'
65
+ def real_path_compiler?
66
+ @real_path_compiler ||= begin
67
+ prebuild_sandbox_path = Jxedt.config.prebuild_sandbox_path
68
+ real_path_compiler = prebuild_sandbox_path && prebuild_sandbox_path.length > 0
69
+ if real_path_compiler
70
+ prebuild_sources_root = Pathname.new(prebuild_sandbox_path)
71
+ prebuild_sources_root.rmtree if prebuild_sources_root.exist?
72
+ prebuild_sources_root.mkpath
73
+ end
74
+ real_path_compiler
75
+ end
66
76
  end
67
77
 
68
- def headers_root
69
- root + source_path + 'Headers'
70
- end
78
+ def prepare_dir
79
+ # clear
80
+ root.children.each { |child| child.rmtree if '.xcodeproj' != child.extname }
71
81
 
72
- def project_path
73
- root + source_path + 'Pods-Source.xcodeproj'
74
- end
82
+ # copy
83
+ standard_sandbox.root.children.each do |child|
84
+ # skip headers_root & target_support_files_root & project_path
85
+ should_skip_paths = [standard_sandbox.headers_root, standard_sandbox.target_support_files_root, standard_sandbox.project_path]
86
+ next if should_skip_paths.include?(child)
75
87
 
76
- def specifications_root
77
- # root + source_path + 'Local Podspecs'
78
- super
88
+ should_copy_paths = [standard_sandbox.specifications_root, standard_sandbox.manifest_path]
89
+ if should_copy_paths.include?(child)
90
+ # copy Local Podspecs & manifest path
91
+ FileUtils.cp_r(child, root + child.basename)
92
+ else
93
+ # 真实的路径去编译,则拷贝文件到prebuild_sandbox
94
+ FileUtils.cp_r(child, sources_root) if real_path_compiler?
95
+ end
96
+ end
79
97
  end
80
98
 
81
- def target_support_files_root
82
- root + source_path + 'Target Support Files'
99
+ def sources_root
100
+ if real_path_compiler?
101
+ # 真实的路径去编译,则返回prebuild sources root
102
+ return @prebuild_sources_root ||= Pathname.new(Jxedt.config.prebuild_sandbox_path)
103
+ end
104
+ standard_sandbox.root
83
105
  end
84
106
 
85
- def link_source_project!
86
- root.children.each do |child|
87
- next if ['Headers', 'Local Podspecs', 'Target Support Files'].include? child.basename.to_s
88
- next if ['.lock', '.xcodeproj'].include? child.extname.to_s
89
- make_source_link(child, root + source_path + child.basename)
90
- end
107
+ def project_path
108
+ root + 'Pods-Source.xcodeproj'
91
109
  end
92
110
 
93
111
  def clean_source_project!
94
112
  return if Jxedt.config.keep_source_project?
95
113
 
96
- source_project_path = root + source_path
97
- source_project_path.rmtree if source_project_path.exist?
114
+ sources_root.rmtree if sources_root.exist?
115
+ root.rmtree if root.exist?
98
116
  end
99
117
  end
100
118
  end
@@ -108,20 +126,7 @@ module Pod
108
126
  class UserProjectIntegrator
109
127
  alias_method :old_create_workspace, :create_workspace
110
128
  def create_workspace
111
- old_create_workspace unless sandbox.is_a?(Pod::PrebuildSandbox)
112
- end
113
- end
114
- end
115
- end
116
-
117
- module Pod
118
- class Installer
119
- # Cleans up the sandbox directory by removing stale target support files and headers.
120
- #
121
- class SandboxDirCleaner
122
- alias_method :old_clean!, :clean!
123
- def clean!
124
- old_clean! unless @sandbox.is_a?(Pod::PrebuildSandbox)
129
+ old_create_workspace unless sandbox.is_a?(Pod::JxedtPrebuildSandbox)
125
130
  end
126
131
  end
127
132
  end
@@ -6,20 +6,17 @@ module CocoapodsJxedtHook
6
6
  Jxedt::PreInstall.new(installer_context).run
7
7
  end
8
8
 
9
- Pod::HooksManager.register('cocoapods-jxedt', :pre_integrate) do |context, _|
10
-
11
- end
9
+ # Pod::HooksManager.register('cocoapods-jxedt', :pre_integrate) do |context, _|
10
+ # end
12
11
 
13
12
  Pod::HooksManager.register('cocoapods-jxedt', :post_install) do |context, _|
14
13
  require_relative 'post_install'
15
14
  Jxedt::PostInstall.new(context).run
16
15
  end
17
16
 
18
- Pod::HooksManager.register('cocoapods-jxedt', :post_integrate) do |context, _|
19
-
20
- end
17
+ # Pod::HooksManager.register('cocoapods-jxedt', :post_integrate) do |context, _|
18
+ # end
21
19
 
22
- Pod::HooksManager.register('cocoapods-jxedt', :source_provider) do |context, _|
23
-
24
- end
20
+ # Pod::HooksManager.register('cocoapods-jxedt', :source_provider) do |context, _|
21
+ # end
25
22
  end
@@ -11,11 +11,11 @@ module Jxedt
11
11
  require_relative '../helper/prebuild_sandbox'
12
12
 
13
13
  # :post_install过程校验两次`pod install`的值
14
- validate_pod_checksum unless @installer_context.sandbox.is_a?(Pod::PrebuildSandbox)
14
+ validate_pod_checksum unless @installer_context.sandbox.is_a?(Pod::JxedtPrebuildSandbox)
15
15
  end
16
16
 
17
- def validate_pod_checksum
18
- original_installer = ObjectSpace.each_object(Pod::Installer).reject {|installer| installer.sandbox.is_a?(Pod::PrebuildSandbox) }.first
17
+ def validate_pod_checksum
18
+ original_installer = ObjectSpace.each_object(Pod::Installer).reject {|installer| installer.sandbox.is_a?(Pod::JxedtPrebuildSandbox) }.first
19
19
  return if original_installer.nil?
20
20
 
21
21
  check_result = original_installer.lockfile == @installer_context.sandbox.source_lockfile
@@ -28,7 +28,7 @@ module Jxedt
28
28
  value2 = source_lockfile.spec_checksums_hash_key(name)
29
29
  validation_failed << name if value1.nil? || value2.nil? || value1 != value2
30
30
  }
31
- Pod::UI.warn "Lockfile文件校验失败,请检查Pod组件: #{validation_failed}"
31
+ Pod::UI.warn "⚠️ ⚠️ ⚠️ Lockfile文件校验失败,请检查Pod组件: #{validation_failed}"
32
32
  end
33
33
  end
34
34
  end
@@ -16,21 +16,20 @@ module Jxedt
16
16
  # check binary switch
17
17
  return unless Jxedt.config.binary_switch?
18
18
 
19
- # [Check Environment]
20
- podfile = @installer_context.podfile
21
- podfile.target_definition_list.each do |target_definition|
22
- raise STDERR.puts "[!] Cocoapods-binary requires `use_frameworks!`".red if not target_definition.uses_frameworks?
19
+ unless Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
20
+ raise STDERR.puts "[!] cocoapods-jxedt binary plugin should use cocoapods version greater than '1.10.0'`".red
23
21
  end
24
22
 
25
23
  require_relative '../helper/prebuild_sandbox'
24
+ require_relative '../helper/prebuild_installer'
26
25
 
27
- # 如果是Pod::PrebuildSandbox类则直接返回
28
- return if @installer_context.sandbox.is_a?(Pod::PrebuildSandbox)
26
+ # 如果是Pod::JxedtPrebuildSandbox类则直接返回
27
+ return if @installer_context.sandbox.is_a?(Pod::JxedtPrebuildSandbox)
29
28
 
30
29
  # 获取原始的installer对象,必须先获取对象
31
30
  original_installer = ObjectSpace.each_object(Pod::Installer).first
32
- sandbox = Pod::PrebuildSandbox.from_standard_sandbox(@installer_context.sandbox)
33
- source_installer = Pod::Installer.new(sandbox, @installer_context.podfile, @installer_context.lockfile)
31
+ prebuild_sandbox = Pod::JxedtPrebuildSandbox.from_standard_sandbox(@installer_context.sandbox)
32
+ source_installer = Pod::JxedtPrebuildInstaller.new(prebuild_sandbox, @installer_context.podfile, @installer_context.lockfile)
34
33
  # 设置原始的installer携带的参数
35
34
  source_installer.update = original_installer.update
36
35
  source_installer.repo_update = original_installer.repo_update
@@ -38,18 +37,39 @@ module Jxedt
38
37
  source_installer.install!
39
38
 
40
39
  # 保存首次`pod install`的lockfile结果,用来验证二进制文件和后面做结果校验
41
- @installer_context.sandbox.source_lockfile = sandbox.source_lockfile = source_installer.lockfile
40
+ @installer_context.sandbox.source_lockfile = prebuild_sandbox.source_lockfile = source_installer.lockfile
42
41
 
43
42
  require_relative '../helper/podfile_options'
44
43
  require_relative '../prebuild'
45
44
 
45
+ # fetch cache and sync
46
+ if Jxedt.config.cache_repo_enabled? && Jxedt.config.auto_fetch?
47
+ log_section "🚗 Fetch git cache"
48
+ pods = prebuild_sandbox.source_lockfile.internal_data["SPEC CHECKSUMS"].keys
49
+ binary_hash = pods.reduce({}) do |hash, name|
50
+ checksum = prebuild_sandbox.source_lockfile.spec_checksums_hash_key(name)
51
+ hash.update(name => checksum) unless checksum.nil?
52
+ end
53
+
54
+ require 'cocoapods-jxedt/git_helper/cache_fetcher'
55
+ binary_dir = @installer_context.sandbox.standard_sandbox_root + Jxedt.config.binary_dir
56
+ Jxedt::CacheFetcher.sync(binary_hash, binary_dir)
57
+ end
58
+
46
59
  # prebuild_job
47
- sandbox.link_source_project!
48
60
  if Jxedt.config.prebuild_job?
49
61
  log_section "🚀 Prebuild frameworks"
50
- Jxedt::Prebuild.new(source_installer).build
62
+ build_targets = Jxedt::Prebuild.new(source_installer).build
63
+
64
+ # cache push
65
+ if Jxedt.config.cache_repo_enabled? && Jxedt.config.auto_push? && build_targets && build_targets.size > 0
66
+ log_section "🚄 Push git cache"
67
+ require 'cocoapods-jxedt/git_helper/cache_pucher'
68
+ output_dir = prebuild_sandbox.standard_sandbox_root + Jxedt.config.binary_dir
69
+ Jxedt::CachePucher.push(output_dir, build_targets, false)
70
+ end
51
71
  end
52
- sandbox.clean_source_project!
72
+ prebuild_sandbox.clean_source_project!
53
73
 
54
74
  log_section "🤖 Resume pod installation"
55
75
  require_relative '../targets/pod_target'
@@ -1,3 +1,4 @@
1
1
  require_relative 'config'
2
2
  require_relative 'podfile_dsl'
3
3
  require_relative 'hooks/CocoapodsJxedtHook'
4
+ require_relative 'helper/podfile_post_install_hook'
@@ -0,0 +1,40 @@
1
+ module StaticFramework
2
+ class Tree
3
+ attr_reader :headers_path
4
+ attr_reader :private_headers_path
5
+ attr_reader :module_map_path
6
+ attr_reader :root_path
7
+ attr_reader :fwk_path
8
+
9
+ def initialize(name, at_path)
10
+ @name = name
11
+ @at_path = at_path
12
+ make
13
+ end
14
+
15
+ def make
16
+ make_root
17
+ make_framework
18
+ end
19
+
20
+ private
21
+ def make_framework
22
+ @fwk_path = @root_path + Pathname.new(@name + '.framework')
23
+ @fwk_path.rmtree if @fwk_path.exist?
24
+ @fwk_path.mkdir
25
+
26
+ @module_map_path = @fwk_path + Pathname.new('Modules')
27
+
28
+ @headers_path = @fwk_path + Pathname.new('Headers')
29
+ @headers_path.mkpath unless @headers_path.exist?
30
+
31
+ @private_headers_path = @fwk_path + Pathname.new('PrivateHeaders')
32
+ end
33
+
34
+ def make_root
35
+ @root_path = Pathname.new(@at_path)
36
+ @root_path.mkpath unless @root_path.exist?
37
+ end
38
+ end
39
+ end
40
+
@@ -19,9 +19,15 @@ module Jxedt
19
19
  end
20
20
 
21
21
  def run
22
- sdks.each { |sdk| build_for_sdk(sdk) }
22
+ sdks.each { |sdk|
23
+ build_for_sdk(sdk)
24
+ @options[:clean_build] = false # 如果需要编译真机和模拟器,那么第二次编译的时候不能clean
25
+ }
23
26
 
24
27
  targets.each do |target|
28
+ # create static framework with library
29
+ create_framework_from_library(target) if target.build_as_library?
30
+
25
31
  if Jxedt.config.xcframework?
26
32
  create_xcframework(target)
27
33
  elsif sdks.count > 1
@@ -83,10 +89,82 @@ module Jxedt
83
89
  sdk: sdk,
84
90
  deployment_target: targets.map { |t| t.platform.deployment_target }.max.to_s,
85
91
  log_path: log_path(sdk),
92
+ clean_build: clean_build?,
86
93
  args: sdk == simulator ? @build_args[:simulator] : @build_args[:device]
87
94
  )
88
95
  end
89
96
 
97
+ def create_framework_from_library(target)
98
+ require_relative 'framework'
99
+
100
+ sdks.each do |sdk|
101
+ procuct_dir = Pathname.new(target_products_dir_of(target, sdk))
102
+ # make static framework
103
+ fwk = StaticFramework::Tree.new(target.product_module_name, procuct_dir.to_s)
104
+
105
+ # copy library
106
+ lib_output = fwk.fwk_path + target.product_module_name
107
+ lib_file = procuct_dir + "lib#{target.name}.a"
108
+ `lipo -create -output #{lib_output} #{lib_file}` if lib_file.exist?
109
+
110
+ # copy public headers
111
+ headers_source = target.sandbox.headers_root + 'Public' + target.pod_name
112
+ Dir.glob("#{headers_source}/**/*.h").each { |h| `ditto #{h} #{fwk.headers_path}/#{File.basename(h)}` }
113
+
114
+ # target support module
115
+ if target.defines_module?
116
+ # create modulemap path
117
+ fwk.module_map_path.mkpath unless fwk.module_map_path.exist?
118
+
119
+ # check and copy umbrella headers
120
+ umbrella_headers = Dir.glob("#{procuct_dir}/*-umbrella.h")
121
+ umbrella_headers.each { |h| FileUtils.cp_r(h.to_s, fwk.headers_path) }
122
+
123
+ # check and copy swift headers
124
+ swift_headers = Dir.glob("#{procuct_dir}/*/*-Swift.h")
125
+ swift_headers.each { |h| FileUtils.cp_r(h.to_s, fwk.headers_path) }
126
+
127
+ # check and copy swiftmodule files
128
+ swiftmodule_path = procuct_dir + "#{target.product_module_name}.swiftmodule"
129
+ FileUtils.cp_r(swiftmodule_path, fwk.module_map_path) if swiftmodule_path.exist?
130
+
131
+ # umbrella header name
132
+ umbrella_header_name = "#{target.pod_name}-umbrella.h"
133
+ unless File.exist?("#{fwk.headers_path}/#{umbrella_header_name}")
134
+ # 从Target Support Files文件夹中获取unbrella header
135
+ target_support_files_root = target.sandbox.target_support_files_root + target.name
136
+ Dir.glob("#{target_support_files_root}/*-umbrella.h").each { |h| FileUtils.cp_r(h.to_s, fwk.headers_path + umbrella_header_name) }
137
+ end
138
+
139
+ # make modulemap
140
+ if File.exist?("#{fwk.headers_path}/#{umbrella_header_name}")
141
+ module_map = <<MODULE_MAP
142
+ framework module #{target.product_module_name} {
143
+ umbrella header "#{umbrella_header_name}"
144
+
145
+ export *
146
+ module * { export * }
147
+ }
148
+ MODULE_MAP
149
+ unless swift_headers.empty?
150
+ module_map << swift_module_map = <<SWIFT_MODULE_MAP
151
+ module #{target.product_module_name}.Swift {
152
+ header "#{target.product_module_name}-Swift.h"
153
+ requires objc
154
+ }
155
+ SWIFT_MODULE_MAP
156
+ end
157
+ File.write("#{fwk.module_map_path}/module.modulemap", module_map) unless module_map.nil?
158
+ end
159
+ end
160
+
161
+ # remove library product
162
+ procuct_dir.children.each do |child|
163
+ FileUtils.rm_rf(child) if ['.h', '.modulemap', '.a', '.swiftmodule'].include?(child.extname) || "#{child.basename}" == 'Swift Compatibility Header'
164
+ end
165
+ end
166
+ end
167
+
90
168
  def create_xcframework(target)
91
169
  non_framework_paths = Dir[target_products_dir_of(target, preferred_sdk) + "/*"] \
92
170
  - [framework_path_of(target, preferred_sdk)] \
@@ -261,5 +339,9 @@ module Jxedt
261
339
  def log_path(sdk)
262
340
  @options[:log_path].nil? ? nil : "#{@options[:log_path]}_#{sdk}"
263
341
  end
342
+
343
+ def clean_build?
344
+ @options[:clean_build]
345
+ end
264
346
  end
265
347
  end
@@ -34,7 +34,7 @@ module Jxedt
34
34
  end
35
35
  end
36
36
  cmd += options[:args] if options[:args]
37
- cmd += "clean" if options[:clean_build]
37
+ cmd << "clean" if options[:clean_build]
38
38
  cmd << "build"
39
39
 
40
40
  if options[:log_path].nil?