cocoapods-binaryhqp 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE +10 -0
- data/.gitignore +33 -0
- data/.travis.yml +23 -0
- data/.vscode/launch.json +15 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +131 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +13 -0
- data/cocoapods-binaryhqp-0.4.6.gem +0 -0
- data/cocoapods-binaryhqp-0.4.7.gem +0 -0
- data/cocoapods-binaryhqp.gemspec +29 -0
- data/lib/cocoapods-binaryhqp/Integration.rb +292 -0
- data/lib/cocoapods-binaryhqp/Main.rb +165 -0
- data/lib/cocoapods-binaryhqp/Prebuild.rb +291 -0
- data/lib/cocoapods-binaryhqp/gem_version.rb +3 -0
- data/lib/cocoapods-binaryhqp/helper/feature_switches.rb +97 -0
- data/lib/cocoapods-binaryhqp/helper/names.rb +78 -0
- data/lib/cocoapods-binaryhqp/helper/passer.rb +41 -0
- data/lib/cocoapods-binaryhqp/helper/podfile_options.rb +135 -0
- data/lib/cocoapods-binaryhqp/helper/prebuild_sandbox.rb +82 -0
- data/lib/cocoapods-binaryhqp/helper/target_checker.rb +49 -0
- data/lib/cocoapods-binaryhqp/rome/build_framework.rb +202 -0
- data/lib/cocoapods-binaryhqp/tool/tool.rb +12 -0
- data/lib/cocoapods-binaryhqp.rb +1 -0
- data/lib/cocoapods_plugin.rb +2 -0
- data/spec/spec_helper.rb +50 -0
- metadata +157 -0
@@ -0,0 +1,165 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative 'helper/podfile_options'
|
3
|
+
require_relative 'tool/tool'
|
4
|
+
require_relative 'gem_version'
|
5
|
+
|
6
|
+
module Pod
|
7
|
+
class Podfile
|
8
|
+
module DSL
|
9
|
+
|
10
|
+
# Enable prebuiding for all pods
|
11
|
+
# it has a lower priority to other binary settings
|
12
|
+
def all_binary!
|
13
|
+
DSL.prebuild_all = true
|
14
|
+
end
|
15
|
+
|
16
|
+
# Enable bitcode for prebuilt frameworks
|
17
|
+
def enable_bitcode_for_prebuilt_frameworks!
|
18
|
+
DSL.bitcode_enabled = true
|
19
|
+
end
|
20
|
+
|
21
|
+
# Don't remove source code of prebuilt pods
|
22
|
+
# It may speed up the pod install if git didn't
|
23
|
+
# include the `Pods` folder
|
24
|
+
def keep_source_code_for_prebuilt_frameworks!
|
25
|
+
DSL.dont_remove_source_code = true
|
26
|
+
end
|
27
|
+
|
28
|
+
# Add custom xcodebuild option to the prebuilding action
|
29
|
+
#
|
30
|
+
# You may use this for your special demands. For example: the default archs in dSYMs
|
31
|
+
# of prebuilt frameworks is 'arm64 armv7 x86_64', and no 'i386' for 32bit simulator.
|
32
|
+
# It may generate a warning when building for a 32bit simulator. You may add following
|
33
|
+
# to your podfile
|
34
|
+
#
|
35
|
+
# ` set_custom_xcodebuild_options_for_prebuilt_frameworks :simulator => "ARCHS=$(ARCHS_STANDARD)" `
|
36
|
+
#
|
37
|
+
# Another example to disable the generating of dSYM file:
|
38
|
+
#
|
39
|
+
# ` set_custom_xcodebuild_options_for_prebuilt_frameworks "DEBUG_INFORMATION_FORMAT=dwarf"`
|
40
|
+
#
|
41
|
+
#
|
42
|
+
# @param [String or Hash] options
|
43
|
+
#
|
44
|
+
# If is a String, it will apply for device and simulator. Use it just like in the commandline.
|
45
|
+
# If is a Hash, it should be like this: { :device => "XXXXX", :simulator => "XXXXX" }
|
46
|
+
#
|
47
|
+
def set_custom_xcodebuild_options_for_prebuilt_frameworks(options)
|
48
|
+
if options.kind_of? Hash
|
49
|
+
DSL.custom_build_options = [ options[:device] ] unless options[:device].nil?
|
50
|
+
DSL.custom_build_options_simulator = [ options[:simulator] ] unless options[:simulator].nil?
|
51
|
+
elsif options.kind_of? String
|
52
|
+
DSL.custom_build_options = [options]
|
53
|
+
DSL.custom_build_options_simulator = [options]
|
54
|
+
else
|
55
|
+
raise "Wrong type."
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
class_attr_accessor :prebuild_all
|
61
|
+
prebuild_all = false
|
62
|
+
|
63
|
+
class_attr_accessor :bitcode_enabled
|
64
|
+
bitcode_enabled = false
|
65
|
+
|
66
|
+
class_attr_accessor :dont_remove_source_code
|
67
|
+
dont_remove_source_code = false
|
68
|
+
|
69
|
+
class_attr_accessor :custom_build_options
|
70
|
+
class_attr_accessor :custom_build_options_simulator
|
71
|
+
self.custom_build_options = []
|
72
|
+
self.custom_build_options_simulator = []
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
Pod::HooksManager.register('cocoapods-binaryhqp', :pre_install) do |installer_context|
|
78
|
+
|
79
|
+
require_relative 'helper/feature_switches'
|
80
|
+
if Pod.is_prebuild_stage
|
81
|
+
next
|
82
|
+
end
|
83
|
+
|
84
|
+
Pod::UI.puts("当前版本: #{CocoapodsBinaryHqp::VERSION}")
|
85
|
+
|
86
|
+
# [Check Environment]
|
87
|
+
# check user_framework is on
|
88
|
+
podfile = installer_context.podfile
|
89
|
+
podfile.target_definition_list.each do |target_definition|
|
90
|
+
next if target_definition.prebuild_framework_pod_names.empty?
|
91
|
+
if not target_definition.uses_frameworks?
|
92
|
+
STDERR.puts "[!] Cocoapods-binaryhqp requires `use_frameworks!`".red
|
93
|
+
exit
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
# -- step 1: prebuild framework ---
|
99
|
+
# Execute a sperated pod install, to generate targets for building framework,
|
100
|
+
# then compile them to framework files.
|
101
|
+
require_relative 'helper/prebuild_sandbox'
|
102
|
+
require_relative 'Prebuild'
|
103
|
+
|
104
|
+
Pod::UI.puts "🚀 Prebuild frameworks"
|
105
|
+
|
106
|
+
# Fetch original installer (which is running this pre-install hook) options,
|
107
|
+
# then pass them to our installer to perform update if needed
|
108
|
+
# Looks like this is the most appropriate way to figure out that something should be updated
|
109
|
+
|
110
|
+
update = nil
|
111
|
+
repo_update = nil
|
112
|
+
|
113
|
+
include ObjectSpace
|
114
|
+
ObjectSpace.each_object(Pod::Installer) { |installer|
|
115
|
+
update = installer.update
|
116
|
+
repo_update = installer.repo_update
|
117
|
+
}
|
118
|
+
|
119
|
+
# control features
|
120
|
+
Pod.is_prebuild_stage = true
|
121
|
+
Pod::Podfile::DSL.enable_prebuild_patch true # enable sikpping for prebuild targets
|
122
|
+
Pod::Installer.force_disable_integration true # don't integrate targets
|
123
|
+
Pod::Config.force_disable_write_lockfile true # disbale write lock file for perbuild podfile
|
124
|
+
Pod::Installer.disable_install_complete_message true # disable install complete message
|
125
|
+
|
126
|
+
# make another custom sandbox
|
127
|
+
standard_sandbox = installer_context.sandbox
|
128
|
+
prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sandbox)
|
129
|
+
|
130
|
+
# get the podfile for prebuild
|
131
|
+
prebuild_podfile = Pod::Podfile.from_ruby(podfile.defined_in_file)
|
132
|
+
|
133
|
+
# install
|
134
|
+
lockfile = installer_context.lockfile
|
135
|
+
binary_installer = Pod::Installer.new(prebuild_sandbox, prebuild_podfile, lockfile)
|
136
|
+
|
137
|
+
if binary_installer.have_exact_prebuild_cache? && !update
|
138
|
+
binary_installer.install_when_cache_hit!
|
139
|
+
else
|
140
|
+
binary_installer.update = update
|
141
|
+
binary_installer.repo_update = repo_update
|
142
|
+
binary_installer.install!
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
# reset the environment
|
147
|
+
Pod.is_prebuild_stage = false
|
148
|
+
Pod::Installer.force_disable_integration false
|
149
|
+
Pod::Podfile::DSL.enable_prebuild_patch false
|
150
|
+
Pod::Config.force_disable_write_lockfile false
|
151
|
+
Pod::Installer.disable_install_complete_message false
|
152
|
+
Pod::UserInterface.warnings = [] # clean the warning in the prebuild step, it's duplicated.
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
# -- step 2: pod install ---
|
159
|
+
# install
|
160
|
+
Pod::UI.puts "\n"
|
161
|
+
Pod::UI.puts "🤖 Pod Install"
|
162
|
+
require_relative 'Integration'
|
163
|
+
# go on the normal install step ...
|
164
|
+
end
|
165
|
+
|
@@ -0,0 +1,291 @@
|
|
1
|
+
require_relative 'rome/build_framework'
|
2
|
+
require_relative 'helper/passer'
|
3
|
+
require_relative 'helper/target_checker'
|
4
|
+
require 'cfpropertylist'
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
# patch prebuild ability
|
10
|
+
module Pod
|
11
|
+
class Installer
|
12
|
+
|
13
|
+
include Config::Mixin
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def local_manifest
|
18
|
+
if not @local_manifest_inited
|
19
|
+
@local_manifest_inited = true
|
20
|
+
raise "This method should be call before generate project" unless self.analysis_result == nil
|
21
|
+
@local_manifest = self.sandbox.manifest
|
22
|
+
end
|
23
|
+
@local_manifest
|
24
|
+
end
|
25
|
+
# @return [Analyzer::SpecsState]
|
26
|
+
def prebuild_pods_changes
|
27
|
+
local_manifest = self.sandbox.manifest
|
28
|
+
return nil if local_manifest.nil?
|
29
|
+
# if @prebuild_pods_changes.nil?
|
30
|
+
changes = local_manifest.detect_changes_with_podfile(podfile)
|
31
|
+
unchanged_pod_names = changes[:unchanged]
|
32
|
+
changed_pod_names = changes[:changed]
|
33
|
+
unchanged_pod_names.reverse_each do |name|
|
34
|
+
mainfest_pod_version = local_manifest.version(name).to_s
|
35
|
+
already_prebuild_version = prebuilded_framework_version(name) || "未找到"
|
36
|
+
if already_prebuild_version != mainfest_pod_version
|
37
|
+
Pod::UI.puts("- #{name} 已编译版本 #{already_prebuild_version}, manifest中的版本: #{mainfest_pod_version}") if config.verbose
|
38
|
+
changed_pod_names = changed_pod_names.push(name)
|
39
|
+
unchanged_pod_names.delete(name)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
changes[:changed] = changed_pod_names
|
44
|
+
changes[:unchanged] = unchanged_pod_names
|
45
|
+
Pod::UI.puts("需要重编译的framework : #{changed_pod_names.to_s}") if config.verbose
|
46
|
+
@prebuild_pods_changes = Analyzer::SpecsState.new(changes)
|
47
|
+
# save the chagnes info for later stage
|
48
|
+
Pod::Prebuild::Passer.prebuild_pods_changes = @prebuild_pods_changes
|
49
|
+
@prebuild_pods_changes
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
public
|
54
|
+
|
55
|
+
# pod update 之后 lockfile 文件更新,更新lockfile对象,再次检查与预编译的版本是否一致
|
56
|
+
def post_update_pods_changes
|
57
|
+
changes = lockfile.detect_changes_with_podfile(podfile)
|
58
|
+
unchanged_pod_names = changes[:unchanged]
|
59
|
+
changed_pod_names = changes[:changed]
|
60
|
+
unchanged_pod_names.reverse_each do |name|
|
61
|
+
mainfest_pod_version = lockfile.version(name).to_s
|
62
|
+
already_prebuild_version = prebuilded_framework_version(name) || "未找到"
|
63
|
+
if already_prebuild_version != mainfest_pod_version
|
64
|
+
Pod::UI.puts("- #{name} 已编译版本 #{already_prebuild_version}, manifest中的版本: #{mainfest_pod_version}") if config.verbose
|
65
|
+
changed_pod_names = changed_pod_names.push(name)
|
66
|
+
unchanged_pod_names.delete(name)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
changes[:changed] = changed_pod_names
|
71
|
+
changes[:unchanged] = unchanged_pod_names
|
72
|
+
Pod::UI.puts("需要重编译的framework : #{changed_pod_names.to_s}") if config.verbose
|
73
|
+
@prebuild_pods_changes = Analyzer::SpecsState.new(changes)
|
74
|
+
# save the chagnes info for later stage
|
75
|
+
Pod::Prebuild::Passer.prebuild_pods_changes = @prebuild_pods_changes
|
76
|
+
@prebuild_pods_changes
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
# check if need to prebuild
|
81
|
+
def have_exact_prebuild_cache?
|
82
|
+
|
83
|
+
# check if need build frameworks
|
84
|
+
return false if local_manifest == nil
|
85
|
+
|
86
|
+
changes = prebuild_pods_changes
|
87
|
+
added = changes.added
|
88
|
+
changed = changes.changed
|
89
|
+
unchanged = changes.unchanged
|
90
|
+
deleted = changes.deleted
|
91
|
+
|
92
|
+
exsited_framework_pod_names = sandbox.exsited_framework_pod_names
|
93
|
+
missing = unchanged.select do |pod_name|
|
94
|
+
not exsited_framework_pod_names.include?(pod_name)
|
95
|
+
end
|
96
|
+
|
97
|
+
needed = (added + changed + deleted + missing)
|
98
|
+
|
99
|
+
return needed.empty?
|
100
|
+
end
|
101
|
+
# 当前已编译的framework的版本
|
102
|
+
def prebuilded_framework_version(name)
|
103
|
+
path = self.sandbox.plist_path_for_target_name(name)
|
104
|
+
framework_version = ""
|
105
|
+
if Pathname.new(path).exist?
|
106
|
+
plist_file = CFPropertyList::List.new(:file => path)
|
107
|
+
data = CFPropertyList.native_types(plist_file.value)
|
108
|
+
framework_version = data["CFBundleShortVersionString"]
|
109
|
+
end
|
110
|
+
framework_version
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
# The install method when have completed cache
|
115
|
+
def install_when_cache_hit!
|
116
|
+
# just print log
|
117
|
+
self.sandbox.exsited_framework_target_names.each do |name|
|
118
|
+
UI.puts "Using #{name}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
# Build the needed framework files
|
124
|
+
def prebuild_frameworks!(after_write_lock)
|
125
|
+
# build options
|
126
|
+
sandbox_path = sandbox.root
|
127
|
+
existed_framework_folder = sandbox.generate_framework_path
|
128
|
+
bitcode_enabled = Pod::Podfile::DSL.bitcode_enabled
|
129
|
+
targets = []
|
130
|
+
|
131
|
+
if local_manifest != nil
|
132
|
+
|
133
|
+
if after_write_lock
|
134
|
+
changes = post_update_pods_changes
|
135
|
+
elsif
|
136
|
+
changes = prebuild_pods_changes
|
137
|
+
end
|
138
|
+
|
139
|
+
added = changes.added
|
140
|
+
changed = changes.changed
|
141
|
+
unchanged = changes.unchanged
|
142
|
+
deleted = changes.deleted
|
143
|
+
|
144
|
+
existed_framework_folder.mkdir unless existed_framework_folder.exist?
|
145
|
+
exsited_framework_pod_names = sandbox.exsited_framework_pod_names
|
146
|
+
|
147
|
+
# additions
|
148
|
+
missing = unchanged.select do |pod_name|
|
149
|
+
not exsited_framework_pod_names.include?(pod_name)
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
root_names_to_update = (added + changed + missing)
|
154
|
+
|
155
|
+
# transform names to targets
|
156
|
+
cache = []
|
157
|
+
targets = root_names_to_update.map do |pod_name|
|
158
|
+
tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache)
|
159
|
+
if tars.nil? || tars.empty?
|
160
|
+
raise "There's no target named (#{pod_name}) in Pod.xcodeproj.\n #{self.pod_targets.map(&:name)}" if t.nil?
|
161
|
+
end
|
162
|
+
tars
|
163
|
+
end.flatten
|
164
|
+
|
165
|
+
# add the dendencies
|
166
|
+
dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
|
167
|
+
targets = (targets + dependency_targets).uniq
|
168
|
+
else
|
169
|
+
targets = self.pod_targets
|
170
|
+
end
|
171
|
+
|
172
|
+
targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
|
173
|
+
|
174
|
+
|
175
|
+
# build!
|
176
|
+
Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
|
177
|
+
Pod::Prebuild.remove_build_dir(sandbox_path)
|
178
|
+
targets.each do |target|
|
179
|
+
if !target.should_build?
|
180
|
+
UI.puts "Prebuilding #{target.label}"
|
181
|
+
next
|
182
|
+
end
|
183
|
+
|
184
|
+
output_path = sandbox.framework_folder_path_for_target_name(target.name)
|
185
|
+
output_path.rmtree if output_path.exist?
|
186
|
+
output_path.mkpath unless output_path.exist?
|
187
|
+
Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
|
188
|
+
|
189
|
+
# save the resource paths for later installing
|
190
|
+
if target.static_framework? and !target.resource_paths.empty?
|
191
|
+
framework_path = output_path + target.framework_name
|
192
|
+
standard_sandbox_path = sandbox.standard_sanbox_path
|
193
|
+
|
194
|
+
resources = begin
|
195
|
+
if Pod::VERSION.start_with? "1.5"
|
196
|
+
target.resource_paths
|
197
|
+
else
|
198
|
+
# resource_paths is Hash{String=>Array<String>} on 1.6 and above
|
199
|
+
# (use AFNetworking to generate a demo data)
|
200
|
+
# https://github.com/leavez/cocoapods-binary/issues/50
|
201
|
+
target.resource_paths.values.flatten
|
202
|
+
end
|
203
|
+
end
|
204
|
+
raise "Wrong type: #{resources}" unless resources.kind_of? Array
|
205
|
+
|
206
|
+
path_objects = resources.map do |path|
|
207
|
+
object = Prebuild::Passer::ResourcePath.new
|
208
|
+
object.real_file_path = framework_path + File.basename(path)
|
209
|
+
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
|
210
|
+
object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
|
211
|
+
object
|
212
|
+
end
|
213
|
+
Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
Pod::Prebuild.remove_build_dir(sandbox_path)
|
218
|
+
|
219
|
+
|
220
|
+
# copy vendored libraries and frameworks
|
221
|
+
targets.each do |target|
|
222
|
+
root_path = self.sandbox.pod_dir(target.name)
|
223
|
+
target_folder = sandbox.framework_folder_path_for_target_name(target.name)
|
224
|
+
|
225
|
+
# If target shouldn't build, we copy all the original files
|
226
|
+
# This is for target with only .a and .h files
|
227
|
+
if not target.should_build?
|
228
|
+
Prebuild::Passer.target_names_to_skip_integration_framework << target.name
|
229
|
+
FileUtils.cp_r(root_path, target_folder, :remove_destination => true)
|
230
|
+
next
|
231
|
+
end
|
232
|
+
|
233
|
+
target.spec_consumers.each do |consumer|
|
234
|
+
file_accessor = Sandbox::FileAccessor.new(root_path, consumer)
|
235
|
+
lib_paths = file_accessor.vendored_frameworks || []
|
236
|
+
lib_paths += file_accessor.vendored_libraries
|
237
|
+
# @TODO dSYM files
|
238
|
+
lib_paths.each do |lib_path|
|
239
|
+
relative = lib_path.relative_path_from(root_path)
|
240
|
+
destination = target_folder + relative
|
241
|
+
destination.dirname.mkpath unless destination.dirname.exist?
|
242
|
+
FileUtils.cp_r(lib_path, destination, :remove_destination => true)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# save the pod_name for prebuild framwork in sandbox
|
248
|
+
targets.each do |target|
|
249
|
+
sandbox.save_pod_name_for_target target
|
250
|
+
end
|
251
|
+
|
252
|
+
# Remove useless files
|
253
|
+
# remove useless pods
|
254
|
+
all_needed_names = self.pod_targets.map(&:name).uniq
|
255
|
+
useless_target_names = sandbox.exsited_framework_target_names.reject do |name|
|
256
|
+
all_needed_names.include? name
|
257
|
+
end
|
258
|
+
useless_target_names.each do |name|
|
259
|
+
path = sandbox.framework_folder_path_for_target_name(name)
|
260
|
+
path.rmtree if path.exist?
|
261
|
+
end
|
262
|
+
|
263
|
+
if not Podfile::DSL.dont_remove_source_code
|
264
|
+
# only keep manifest.lock and framework folder in _Prebuild
|
265
|
+
to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
|
266
|
+
to_delete_files = sandbox_path.children.select do |file|
|
267
|
+
filename = File.basename(file)
|
268
|
+
not to_remain_files.include?(filename)
|
269
|
+
end
|
270
|
+
to_delete_files.each do |path|
|
271
|
+
path.rmtree if path.exist?
|
272
|
+
end
|
273
|
+
else
|
274
|
+
# just remove the tmp files
|
275
|
+
path = sandbox.root + 'Manifest.lock.tmp'
|
276
|
+
path.rmtree if path.exist?
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
# patch the post install hook
|
281
|
+
old_method2 = instance_method(:run_plugins_post_install_hooks)
|
282
|
+
define_method(:run_plugins_post_install_hooks) do
|
283
|
+
old_method2.bind(self).()
|
284
|
+
if Pod::is_prebuild_stage
|
285
|
+
self.prebuild_frameworks!(true)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
|
290
|
+
end
|
291
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require_relative '../tool/tool'
|
2
|
+
require_relative 'prebuild_sandbox'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
|
6
|
+
# a flag that indicate stages
|
7
|
+
class_attr_accessor :is_prebuild_stage
|
8
|
+
|
9
|
+
|
10
|
+
# a switch for the `pod` DSL to make it only valid for ':binary => true'
|
11
|
+
class Podfile
|
12
|
+
module DSL
|
13
|
+
|
14
|
+
@@enable_prebuild_patch = false
|
15
|
+
|
16
|
+
# when enable, `pod` function will skip all pods without 'prebuild => true'
|
17
|
+
def self.enable_prebuild_patch(value)
|
18
|
+
@@enable_prebuild_patch = value
|
19
|
+
end
|
20
|
+
|
21
|
+
# --- patch ---
|
22
|
+
old_method = instance_method(:pod)
|
23
|
+
|
24
|
+
define_method(:pod) do |name, *args|
|
25
|
+
if !@@enable_prebuild_patch
|
26
|
+
old_method.bind(self).(name, *args)
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
# patched content
|
31
|
+
should_prebuild = Pod::Podfile::DSL.prebuild_all
|
32
|
+
local = false
|
33
|
+
|
34
|
+
options = args.last
|
35
|
+
if options.is_a?(Hash) and options[Pod::Prebuild.keyword] != nil
|
36
|
+
should_prebuild = options[Pod::Prebuild.keyword]
|
37
|
+
local = (options[:path] != nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
if should_prebuild and (not local)
|
41
|
+
old_method.bind(self).(name, *args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
# a force disable option for integral
|
49
|
+
class Installer
|
50
|
+
def self.force_disable_integration(value)
|
51
|
+
@@force_disable_integration = value
|
52
|
+
end
|
53
|
+
|
54
|
+
old_method = instance_method(:integrate_user_project)
|
55
|
+
define_method(:integrate_user_project) do
|
56
|
+
if @@force_disable_integration
|
57
|
+
return
|
58
|
+
end
|
59
|
+
old_method.bind(self).()
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# a option to disable install complete message
|
64
|
+
class Installer
|
65
|
+
def self.disable_install_complete_message(value)
|
66
|
+
@@disable_install_complete_message = value
|
67
|
+
end
|
68
|
+
|
69
|
+
old_method = instance_method(:print_post_install_message)
|
70
|
+
define_method(:print_post_install_message) do
|
71
|
+
if @@disable_install_complete_message
|
72
|
+
return
|
73
|
+
end
|
74
|
+
old_method.bind(self).()
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# option to disable write lockfiles
|
79
|
+
class Config
|
80
|
+
|
81
|
+
@@force_disable_write_lockfile = false
|
82
|
+
def self.force_disable_write_lockfile(value)
|
83
|
+
@@force_disable_write_lockfile = value
|
84
|
+
end
|
85
|
+
|
86
|
+
old_method = instance_method(:lockfile_path)
|
87
|
+
define_method(:lockfile_path) do
|
88
|
+
if @@force_disable_write_lockfile
|
89
|
+
# As config is a singleton, sandbox_root refer to the standard sandbox.
|
90
|
+
return PrebuildSandbox.from_standard_sanbox_path(sandbox_root).root + 'Manifest.lock.tmp'
|
91
|
+
else
|
92
|
+
return old_method.bind(self).()
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# ABOUT NAMES
|
2
|
+
#
|
3
|
+
# There are many kinds of name in cocoapods. Two main names are widely used in this plugin.
|
4
|
+
# - root_spec.name (spec.root_name, targe.pod_name):
|
5
|
+
# aka "pod_name"
|
6
|
+
# the name we use in podfile. the concept.
|
7
|
+
#
|
8
|
+
# - target.name:
|
9
|
+
# aka "target_name"
|
10
|
+
# the name of the final target in xcode project. the final real thing.
|
11
|
+
#
|
12
|
+
# One pod may have multiple targets in xcode project, due to one pod can be used in mutiple
|
13
|
+
# platform simultaneously. So one `root_spec.name` may have multiple coresponding `target.name`s.
|
14
|
+
# Therefore, map a spec to/from targets is a little complecated. It's one to many.
|
15
|
+
#
|
16
|
+
|
17
|
+
# Tool to transform Pod_name to target efficiently
|
18
|
+
module Pod
|
19
|
+
def self.fast_get_targets_for_pod_name(pod_name, targets, cache)
|
20
|
+
pod_name_to_targets_hash = nil
|
21
|
+
if cache.empty?
|
22
|
+
pod_name_to_targets_hash = targets.reduce({}) do |sum, target|
|
23
|
+
array = sum[target.pod_name] || []
|
24
|
+
array << target
|
25
|
+
sum[target.pod_name] = array
|
26
|
+
sum
|
27
|
+
end
|
28
|
+
cache << pod_name_to_targets_hash
|
29
|
+
else
|
30
|
+
pod_name_to_targets_hash = cache.first
|
31
|
+
end
|
32
|
+
|
33
|
+
pod_name_to_targets_hash[pod_name] || []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
# Target:
|
43
|
+
|
44
|
+
# def pod_name
|
45
|
+
# root_spec.name
|
46
|
+
# end
|
47
|
+
|
48
|
+
# def name
|
49
|
+
# pod_name + #{scope_suffix}
|
50
|
+
# end
|
51
|
+
|
52
|
+
# def product_module_name
|
53
|
+
# root_spec.module_name
|
54
|
+
# end
|
55
|
+
|
56
|
+
# def framework_name
|
57
|
+
# "#{product_module_name}.framework"
|
58
|
+
# end
|
59
|
+
|
60
|
+
# def product_name
|
61
|
+
# if requires_frameworks?
|
62
|
+
# framework_name
|
63
|
+
# else
|
64
|
+
# static_library_name
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
|
68
|
+
# def product_basename
|
69
|
+
# if requires_frameworks?
|
70
|
+
# product_module_name
|
71
|
+
# else
|
72
|
+
# label
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
|
76
|
+
# def framework_name
|
77
|
+
# "#{product_module_name}.framework"
|
78
|
+
# end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../tool/tool'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Prebuild
|
5
|
+
|
6
|
+
# Pass the data between the 2 steps
|
7
|
+
#
|
8
|
+
# At step 2, the normal pod install, it needs some info of the
|
9
|
+
# prebuilt step. So we store it here.
|
10
|
+
#
|
11
|
+
class Passer
|
12
|
+
|
13
|
+
# indicate the add/remove/update of prebuit pods
|
14
|
+
# @return [Analyzer::SpecsState]
|
15
|
+
#
|
16
|
+
class_attr_accessor :prebuild_pods_changes
|
17
|
+
|
18
|
+
|
19
|
+
# represent the path of resurces to copy
|
20
|
+
class ResourcePath
|
21
|
+
attr_accessor :real_file_path
|
22
|
+
attr_accessor :target_file_path
|
23
|
+
end
|
24
|
+
# Save the resoures for static framework, and used when installing the prebuild framework
|
25
|
+
# static framework needs copy the resurces mannully
|
26
|
+
#
|
27
|
+
# @return [Hash<String, [Passer::ResourcePath]>]
|
28
|
+
class_attr_accessor :resources_to_copy_for_static_framework
|
29
|
+
self.resources_to_copy_for_static_framework = {}
|
30
|
+
|
31
|
+
# Some pod won't be build in prebuild stage even if it have `binary=>true`.
|
32
|
+
# The targets of this pods have `oshould_build? == true`.
|
33
|
+
# We should skip integration (patch spec) for this pods
|
34
|
+
#
|
35
|
+
# @return [Array<String>]
|
36
|
+
class_attr_accessor :target_names_to_skip_integration_framework
|
37
|
+
self.target_names_to_skip_integration_framework = []
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|