cocoapods-binary-cache 0.1.2 → 0.1.8

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cocoapods-binary-cache/cache/validation_result.rb +4 -0
  3. data/lib/cocoapods-binary-cache/cache/validator.rb +2 -3
  4. data/lib/cocoapods-binary-cache/cache/validator_base.rb +28 -8
  5. data/lib/cocoapods-binary-cache/cache/validator_dependencies_graph.rb +7 -2
  6. data/lib/cocoapods-binary-cache/cache/validator_dev_pods.rb +21 -13
  7. data/lib/cocoapods-binary-cache/cache/validator_non_dev_pods.rb +1 -1
  8. data/lib/cocoapods-binary-cache/dependencies_graph/dependencies_graph.rb +20 -25
  9. data/lib/cocoapods-binary-cache/dependencies_graph/graph_visualizer.rb +29 -38
  10. data/lib/cocoapods-binary-cache/diagnosis/base.rb +13 -0
  11. data/lib/cocoapods-binary-cache/diagnosis/diagnosis.rb +24 -0
  12. data/lib/cocoapods-binary-cache/diagnosis/integration.rb +23 -0
  13. data/lib/cocoapods-binary-cache/env.rb +32 -0
  14. data/lib/cocoapods-binary-cache/helper/checksum.rb +10 -4
  15. data/lib/cocoapods-binary-cache/helper/lockfile.rb +26 -3
  16. data/lib/cocoapods-binary-cache/helper/podspec.rb +5 -1
  17. data/lib/cocoapods-binary-cache/helper/prebuild_order.rb +12 -0
  18. data/lib/cocoapods-binary-cache/hooks/post_install.rb +20 -2
  19. data/lib/cocoapods-binary-cache/hooks/pre_install.rb +14 -44
  20. data/lib/cocoapods-binary-cache/main.rb +2 -1
  21. data/lib/cocoapods-binary-cache/pod-binary/helper/build.rb +40 -0
  22. data/lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb +2 -2
  23. data/lib/cocoapods-binary-cache/pod-binary/helper/detected_prebuilt_pods/target_definition.rb +3 -10
  24. data/lib/cocoapods-binary-cache/pod-binary/helper/names.rb +2 -11
  25. data/lib/cocoapods-binary-cache/pod-binary/helper/prebuild_sandbox.rb +15 -15
  26. data/lib/cocoapods-binary-cache/pod-binary/helper/target_checker.rb +7 -10
  27. data/lib/cocoapods-binary-cache/pod-binary/integration.rb +1 -3
  28. data/lib/cocoapods-binary-cache/pod-binary/integration/alter_specs.rb +4 -1
  29. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/embed_framework_script.rb +1 -1
  30. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/resolve_dependencies.rb +0 -3
  31. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/sandbox_analyzer_state.rb +29 -0
  32. data/lib/cocoapods-binary-cache/pod-binary/integration/patch/source_installation.rb +6 -3
  33. data/lib/cocoapods-binary-cache/pod-binary/integration/source_installer.rb +42 -50
  34. data/lib/cocoapods-binary-cache/pod-binary/prebuild.rb +45 -110
  35. data/lib/cocoapods-binary-cache/pod-binary/prebuild_dsl.rb +2 -61
  36. data/lib/cocoapods-binary-cache/pod-binary/prebuild_hook.rb +0 -1
  37. data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_command.rb +192 -0
  38. data/lib/cocoapods-binary-cache/pod-rome/xcodebuild_raw.rb +43 -0
  39. data/lib/cocoapods-binary-cache/prebuild_output/metadata.rb +16 -0
  40. data/lib/cocoapods-binary-cache/prebuild_output/output.rb +12 -39
  41. data/lib/cocoapods-binary-cache/scheme_editor.rb +17 -16
  42. data/lib/cocoapods-binary-cache/state_store.rb +16 -6
  43. data/lib/command/binary.rb +21 -2
  44. data/lib/command/config.rb +173 -10
  45. data/lib/command/executor/base.rb +7 -0
  46. data/lib/command/executor/fetcher.rb +4 -4
  47. data/lib/command/executor/prebuilder.rb +2 -2
  48. data/lib/command/executor/pusher.rb +1 -1
  49. data/lib/command/executor/visualizer.rb +3 -2
  50. data/lib/command/fetch.rb +0 -1
  51. data/lib/command/prebuild.rb +14 -2
  52. data/lib/command/push.rb +22 -0
  53. metadata +15 -11
  54. data/lib/cocoapods-binary-cache/pod-binary/helper/feature_switches.rb +0 -90
  55. data/lib/cocoapods-binary-cache/pod-binary/helper/passer.rb +0 -25
  56. data/lib/cocoapods-binary-cache/pod-binary/integration/remove_target_files.rb +0 -29
  57. data/lib/cocoapods-binary-cache/pod-binary/tool/tool.rb +0 -12
  58. data/lib/cocoapods-binary-cache/pod-rome/build_framework.rb +0 -247
  59. data/lib/cocoapods-binary-cache/prebuild_cache.rb +0 -49
@@ -1,90 +0,0 @@
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
- # a switch for the `pod` DSL to make it only valid for ':binary => true'
10
- class Podfile
11
- module DSL
12
- @@enable_prebuild_patch = false
13
-
14
- # when enable, `pod` function will skip all pods without 'prebuild => true'
15
- def self.enable_prebuild_patch(value)
16
- @@enable_prebuild_patch = value
17
- end
18
-
19
- # --- patch ---
20
- old_method = instance_method(:pod)
21
-
22
- define_method(:pod) do |name, *args|
23
- if !@@enable_prebuild_patch
24
- old_method.bind(self).(name, *args)
25
- return
26
- end
27
-
28
- # patched content
29
- should_prebuild = Pod::Podfile::DSL.prebuild_all
30
- local = false
31
-
32
- options = args.last
33
- if options.is_a?(Hash) and options[Pod::Prebuild.keyword] != nil
34
- should_prebuild = options[Pod::Prebuild.keyword]
35
- local = (options[:path] != nil)
36
- end
37
-
38
- old_method.bind(self).call(name, *args) if should_prebuild && (!local || Podfile::DSL.dev_pods_enabled)
39
- end
40
- end
41
- end
42
-
43
- # a force disable option for integral
44
- class Installer
45
- def self.force_disable_integration(value)
46
- @@force_disable_integration = value
47
- end
48
-
49
- old_method = instance_method(:integrate_user_project)
50
- define_method(:integrate_user_project) do
51
- if @@force_disable_integration
52
- return
53
- end
54
- old_method.bind(self).()
55
- end
56
- end
57
-
58
- # a option to disable install complete message
59
- class Installer
60
- def self.disable_install_complete_message(value)
61
- @@disable_install_complete_message = value
62
- end
63
-
64
- old_method = instance_method(:print_post_install_message)
65
- define_method(:print_post_install_message) do
66
- if @@disable_install_complete_message
67
- return
68
- end
69
- old_method.bind(self).()
70
- end
71
- end
72
-
73
- # option to disable write lockfiles
74
- class Config
75
- @@force_disable_write_lockfile = false
76
- def self.force_disable_write_lockfile(value)
77
- @@force_disable_write_lockfile = value
78
- end
79
-
80
- old_method = instance_method(:lockfile_path)
81
- define_method(:lockfile_path) do
82
- if @@force_disable_write_lockfile
83
- # As config is a singleton, sandbox_root refer to the standard sandbox.
84
- return PrebuildSandbox.from_standard_sanbox_path(sandbox_root).root + "Manifest.lock.tmp"
85
- else
86
- return old_method.bind(self).()
87
- end
88
- end
89
- end
90
- end
@@ -1,25 +0,0 @@
1
- require_relative "../tool/tool"
2
-
3
- module Pod
4
- class Prebuild
5
- # Pass the data between the 2 steps
6
- #
7
- # At step 2, the normal pod install, it needs some info of the
8
- # prebuilt step. So we store it here.
9
- #
10
- class Passer
11
- # indicate the add/remove/update of prebuit pods
12
- # @return [Analyzer::SpecsState]
13
- #
14
- class_attr_accessor :prebuild_pods_changes
15
-
16
- # Some pod won't be build in prebuild stage even if it have `binary=>true`.
17
- # The targets of this pods have `oshould_build? == true`.
18
- # We should skip integration (patch spec) for this pods
19
- #
20
- # @return [Array<String>]
21
- class_attr_accessor :target_names_to_skip_integration_framework
22
- self.target_names_to_skip_integration_framework = []
23
- end
24
- end
25
- end
@@ -1,29 +0,0 @@
1
- module Pod
2
- class Installer
3
- # Remove the old target files if prebuild frameworks changed
4
- def remove_target_files_if_needed
5
- changes = Pod::Prebuild::Passer.prebuild_pods_changes
6
- updated_names = []
7
- if changes.nil?
8
- updated_names = PrebuildSandbox.from_standard_sandbox(sandbox).exsited_framework_pod_names
9
- else
10
- added = changes.added
11
- changed = changes.changed
12
- deleted = changes.deleted
13
- updated_names = added + changed + deleted
14
- end
15
-
16
- updated_names.each do |name|
17
- root_name = Specification.root_name(name)
18
- next if !Pod::Podfile::DSL.dev_pods_enabled && sandbox.local?(root_name)
19
-
20
- UI.puts "Delete cached files: #{root_name}"
21
- target_path = sandbox.pod_dir(root_name)
22
- target_path.rmtree if target_path.exist?
23
-
24
- support_path = sandbox.target_support_files_dir(root_name)
25
- support_path.rmtree if support_path.exist?
26
- end
27
- end
28
- end
29
- end
@@ -1,12 +0,0 @@
1
- # attr_accessor for class variable.
2
- # usage:
3
- #
4
- # ```
5
- # class Pod
6
- # class_attr_accessor :is_prebuild_stage
7
- # end
8
- # ```
9
- #
10
- def class_attr_accessor(symbol)
11
- self.class.send(:attr_accessor, symbol)
12
- end
@@ -1,247 +0,0 @@
1
- require 'fourflusher'
2
- require 'xcpretty' # TODO (thuyen): Revise this dependency
3
-
4
- PLATFORMS = { 'iphonesimulator' => 'iOS',
5
- 'appletvsimulator' => 'tvOS',
6
- 'watchsimulator' => 'watchOS' }
7
-
8
- # Build specific target to framework file
9
- # @param [PodTarget] target
10
- # a specific pod target
11
- #
12
- def build_for_iosish_platform(sandbox,
13
- build_dir,
14
- output_path,
15
- target,
16
- configuration,
17
- device,
18
- simulator,
19
- bitcode_enabled,
20
- custom_build_options = [], # Array<String>
21
- custom_build_options_simulator = [], # Array<String>
22
- enable_device_build = false
23
- )
24
-
25
- deployment_target = target.platform.deployment_target.to_s
26
-
27
- target_label = target.label # name with platform if it's used in multiple platforms
28
- Pod::UI.puts "Prebuilding #{target_label}..."
29
-
30
- other_options = []
31
- # bitcode enabled
32
- other_options += ['BITCODE_GENERATION_MODE=bitcode'] if bitcode_enabled
33
- # make less arch to iphone simulator for faster build
34
- custom_build_options_simulator += ['ARCHS=x86_64', 'ONLY_ACTIVE_ARCH=NO'] if simulator == 'iphonesimulator'
35
-
36
- # paths
37
- target_name = target.name # equals target.label, like "AFNeworking-iOS" when AFNetworking is used in multiple platforms.
38
- module_name = target.product_module_name
39
- device_framework_path = "#{build_dir}/#{configuration}-#{device}/#{target_name}/#{module_name}.framework"
40
- simulator_framework_path = "#{build_dir}/#{configuration}-#{simulator}/#{target_name}/#{module_name}.framework"
41
- simulator_target_products_path = "#{build_dir}/#{configuration}-#{simulator}/#{target_name}"
42
-
43
- if !Dir.exist?(simulator_framework_path)
44
- is_succeed, = xcodebuild(
45
- sandbox,
46
- target_label,
47
- configuration,
48
- simulator,
49
- deployment_target,
50
- other_options + custom_build_options_simulator
51
- )
52
- raise "Build simulator framework failed: #{target_label}" unless is_succeed
53
- else
54
- puts "Simulator framework already exist at: #{simulator_framework_path}"
55
- end
56
-
57
- unless enable_device_build
58
- FileUtils.cp_r Dir["#{simulator_target_products_path}/*"], output_path
59
- return
60
- end
61
-
62
- if !Dir.exist?(device_framework_path)
63
- is_succeed, = xcodebuild(
64
- sandbox,
65
- target_label,
66
- configuration,
67
- device,
68
- deployment_target,
69
- other_options + custom_build_options
70
- )
71
- raise "Build device framework failed: #{target_label}" unless is_succeed
72
- else
73
- puts "Device framework already exist at: #{device_framework_path}"
74
- end
75
-
76
- device_binary = device_framework_path + "/#{module_name}"
77
- simulator_binary = simulator_framework_path + "/#{module_name}"
78
- return unless File.file?(device_binary) && File.file?(simulator_binary)
79
-
80
- # the device_lib path is the final output file path
81
- # combine the binaries
82
- tmp_lipoed_binary_path = "#{build_dir}/#{target_name}"
83
- lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_binary} #{simulator_binary}`
84
- puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
85
- FileUtils.mv tmp_lipoed_binary_path, device_binary, :force => true
86
-
87
- # collect the swiftmodule file for various archs.
88
- device_swiftmodule_path = device_framework_path + "/Modules/#{module_name}.swiftmodule"
89
- simulator_swiftmodule_path = simulator_framework_path + "/Modules/#{module_name}.swiftmodule"
90
- if File.exist?(device_swiftmodule_path)
91
- FileUtils.cp_r simulator_swiftmodule_path + "/.", device_swiftmodule_path
92
- end
93
-
94
- # combine the generated swift headers
95
- # (In xcode 10.2, the generated swift headers vary for each archs)
96
- # https://github.com/leavez/cocoapods-binary/issues/58
97
- simulator_generated_swift_header_path = simulator_framework_path + "/Headers/#{module_name}-Swift.h"
98
- device_generated_swift_header_path = device_framework_path + "/Headers/#{module_name}-Swift.h"
99
- if File.exist? simulator_generated_swift_header_path
100
- device_header = File.read(device_generated_swift_header_path)
101
- simulator_header = File.read(simulator_generated_swift_header_path)
102
- # https://github.com/Carthage/Carthage/issues/2718#issuecomment-473870461
103
- combined_header_content = %Q{
104
- #if TARGET_OS_SIMULATOR // merged by cocoapods-binary
105
-
106
- #{simulator_header}
107
-
108
- #else // merged by cocoapods-binary
109
-
110
- #{device_header}
111
-
112
- #endif // merged by cocoapods-binary
113
- }
114
- File.write(device_generated_swift_header_path, combined_header_content.strip)
115
- end
116
-
117
- # handle the dSYM files
118
- device_dsym = "#{device_framework_path}.dSYM"
119
- if File.exist? device_dsym
120
- # lipo the simulator dsym
121
- simulator_dsym = "#{simulator_framework_path}.dSYM"
122
- if File.exist? simulator_dsym
123
- tmp_lipoed_binary_path = "#{output_path}/#{module_name}.draft"
124
- lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_dsym}/Contents/Resources/DWARF/#{module_name} #{simulator_dsym}/Contents/Resources/DWARF/#{module_name}`
125
- puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
126
- FileUtils.mv tmp_lipoed_binary_path, "#{device_framework_path}.dSYM/Contents/Resources/DWARF/#{module_name}", :force => true
127
- end
128
- # move
129
- FileUtils.mv device_dsym, output_path, :force => true
130
- end
131
-
132
- # output
133
- output_path.mkpath unless output_path.exist?
134
- FileUtils.mv device_framework_path, output_path, :force => true
135
-
136
- end
137
-
138
- def xcodebuild(sandbox, target, configuration, sdk='macosx', deployment_target=nil, other_options=[])
139
- args = %W(-project #{sandbox.project_path.realdirpath} -scheme #{target} -configuration #{configuration} -sdk #{sdk} )
140
- platform = PLATFORMS[sdk]
141
- args += Fourflusher::SimControl.new.destination(:oldest, platform, deployment_target) unless platform.nil?
142
- args += other_options
143
-
144
- args_str = args.join(" ")
145
- cmd = "xcodebuild #{args_str} 2>&1"
146
- puts "xcodebuild command: #{cmd}"
147
- log = `#{cmd}`
148
-
149
- exit_code = $?.exitstatus # Process::Status
150
- is_succeed = (exit_code == 0)
151
-
152
- if !is_succeed
153
- begin
154
- if log.include?('** BUILD FAILED **')
155
- # use xcpretty to print build log
156
- # 64 represent command invalid. http://www.manpagez.com/man/3/sysexits/
157
- printer = XCPretty::Printer.new({:formatter => XCPretty::Simple, :colorize => 'auto'})
158
- log.each_line do |line|
159
- printer.pretty_print(line)
160
- end
161
- else
162
- raise "shouldn't be handle by xcpretty"
163
- end
164
- rescue
165
- puts log.red
166
- end
167
- end
168
- [is_succeed, log]
169
- end
170
-
171
-
172
-
173
- module Pod
174
- class Prebuild
175
-
176
- # Build the frameworks with sandbox and targets
177
- #
178
- # @param [String] sandbox_root_path
179
- # The sandbox root path where the targets project place
180
- #
181
- # [PodTarget] target
182
- # The pod targets to build
183
- #
184
- # [Pathname] output_path
185
- # output path for generated frameworks
186
- #
187
- def self.build(sandbox_root_path, target, configuration, output_path, bitcode_enabled = false, custom_build_options=[], custom_build_options_simulator=[])
188
- return if target.nil?
189
-
190
- sandbox_root = Pathname(sandbox_root_path)
191
- sandbox = Pod::Sandbox.new(sandbox_root)
192
- build_dir = self.build_dir(sandbox_root)
193
-
194
- # -- build the framework
195
- case target.platform.name
196
- when :ios
197
- build_for_iosish_platform(
198
- sandbox,
199
- build_dir,
200
- output_path,
201
- target,
202
- configuration,
203
- "iphoneos",
204
- "iphonesimulator",
205
- bitcode_enabled,
206
- custom_build_options,
207
- custom_build_options_simulator
208
- )
209
- when :osx
210
- xcodebuild(
211
- sandbox,
212
- target.label,
213
- configuration,
214
- "macosx",
215
- nil,
216
- custom_build_options
217
- )
218
- # when :tvos then build_for_iosish_platform(sandbox, build_dir, target, 'appletvos', 'appletvsimulator')
219
- when :watchos
220
- build_for_iosish_platform(
221
- sandbox,
222
- build_dir,
223
- output_path,
224
- target,
225
- configuration,
226
- "watchos",
227
- "watchsimulator",
228
- true,
229
- custom_build_options,
230
- custom_build_options_simulator
231
- )
232
- else raise "Unsupported platform for '#{target.name}': '#{target.platform.name}'" end
233
-
234
- raise Pod::Informative, "The build directory was not found in the expected location" unless build_dir.directory?
235
- end
236
-
237
- def self.remove_build_dir(sandbox_root)
238
- path = build_dir(sandbox_root)
239
- path.rmtree if path.exist?
240
- end
241
-
242
- def self.build_dir(sandbox_root)
243
- sandbox_root.parent + "build"
244
- end
245
-
246
- end
247
- end
@@ -1,49 +0,0 @@
1
- # Copyright 2019 Grabtaxi Holdings PTE LTE (GRAB), All rights reserved.
2
- # Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
3
-
4
- require 'json'
5
- require 'cocoapods'
6
- require_relative "helper/checksum"
7
-
8
- class PodCacheValidator
9
-
10
- # Cache miss/hit checking for development pods
11
- # Return 2 Hashes for cache miss and cache hit libraries
12
- def self.verify_devpod_checksum(sandbox_root, generated_framework_path, lock_file)
13
- devpod_path = "#{sandbox_root}/devpod/"
14
- target_path = generated_framework_path
15
- Pod::UI.puts "verify_devpod_checksum: #{devpod_path}"
16
- external_sources = lock_file.to_hash["EXTERNAL SOURCES"]
17
- unless File.directory?(target_path)
18
- FileUtils.mkdir_p(target_path)
19
- end
20
- missing_pods_dic = Hash[]
21
- dev_pods_count = 0
22
- cachehit_pods_dic = Hash[]
23
- if !external_sources
24
- Pod::UI.puts 'No development pods!'
25
- return missing_pods_dic, cachehit_pods
26
- end
27
- external_sources.each do |name, attribs|
28
- if attribs.class == Hash
29
- path = attribs[:path]
30
- if path
31
- hash = FolderChecksum.checksum(path)
32
- dev_pods_count += 1
33
- cached_path = "#{devpod_path}#{name}_#{hash}"
34
- if !Dir.exists?(cached_path)
35
- missing_pods_dic[name] = hash
36
- else
37
- cachehit_pods_dic[name] = hash
38
- target_dir = "#{target_path}/#{name}"
39
- FileUtils.rm_r(target_dir, :force => true)
40
- FileUtils.cp_r(cached_path, target_dir)
41
- end
42
- end
43
- else
44
- Pod::UI.puts "Error, wrong type: #{attribs}"
45
- end
46
- end
47
- return missing_pods_dic, cachehit_pods_dic
48
- end
49
- end