cocoapods-binary-gcp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+
2
+ module Pod
3
+ class Prebuild
4
+
5
+ # Check the targets, for the current limitation of the plugin
6
+ #
7
+ # @param [Array<PodTarget>] prebuilt_targets
8
+ def self.check_one_pod_should_have_only_one_target(prebuilt_targets)
9
+
10
+ targets_have_different_platforms = prebuilt_targets.select {|t| t.pod_name != t.name }
11
+
12
+ if targets_have_different_platforms.count > 0
13
+ names = targets_have_different_platforms.map(&:pod_name)
14
+ raw_names = targets_have_different_platforms.map(&:name)
15
+ message = "Oops, you came across a limitation of cocoapods-binary.
16
+
17
+ The plugin requires that one pod should have ONLY ONE target in the 'Pod.xcodeproj'. There are mainly 2 situations \
18
+ causing this problem:
19
+
20
+ 1. One pod integrates in 2 or more different platforms' targets. e.g.
21
+ ```
22
+ target 'iphoneApp' do
23
+ pod 'A', :binary => true
24
+ end
25
+ target 'watchApp' do
26
+ pod 'A'
27
+ end
28
+ ```
29
+
30
+ 2. Use different subspecs in multiple targets. e.g.
31
+ ```
32
+ target 'iphoneApp' do
33
+ pod 'A/core'
34
+ pod 'A/network'
35
+ end
36
+ target 'iphoneAppTest' do
37
+ pod 'A/core'
38
+ end
39
+ ```
40
+
41
+ Related pods: #{names}, target names: #{raw_names}
42
+ "
43
+ raise Informative, message
44
+ end
45
+ end
46
+
47
+
48
+ end
49
+ end
@@ -0,0 +1,216 @@
1
+ require 'fourflusher'
2
+ require 'xcpretty'
3
+
4
+ CONFIGURATION = "Release"
5
+ PLATFORMS = { 'iphonesimulator' => 'iOS',
6
+ 'appletvsimulator' => 'tvOS',
7
+ 'watchsimulator' => 'watchOS' }
8
+
9
+ # Build specific target to framework file
10
+ # @param [PodTarget] target
11
+ # a specific pod target
12
+ #
13
+ def build_for_iosish_platform(sandbox,
14
+ build_dir,
15
+ output_path,
16
+ target,
17
+ deployment_target,
18
+ device,
19
+ simulator,
20
+ bitcode_enabled,
21
+ custom_build_options = [], # Array<String>
22
+ custom_build_options_simulator = [] # Array<String>
23
+ )
24
+ # deployment_target = target.platform.deployment_target.to_s
25
+
26
+ target_label = target.label # name with platform if it's used in multiple platforms
27
+ Pod::UI.puts "Prebuilding #{target_label}..."
28
+
29
+ other_options = []
30
+ # bitcode enabled
31
+ other_options += ['BITCODE_GENERATION_MODE=bitcode'] if bitcode_enabled
32
+ # make less arch to iphone simulator for faster build
33
+ custom_build_options_simulator += ['ARCHS=x86_64', 'ONLY_ACTIVE_ARCH=NO'] if simulator == 'iphonesimulator'
34
+
35
+ is_succeed, _ = xcodebuild(sandbox, target_label, device, deployment_target, other_options + custom_build_options)
36
+ Pod::UI.puts "Builded Device #{target_label} #{is_succeed}"
37
+ exit 1 unless is_succeed
38
+ is_succeed, _ = xcodebuild(sandbox, target_label, simulator, deployment_target, other_options + custom_build_options_simulator)
39
+ Pod::UI.puts "Builded Simulator #{target_label} #{is_succeed}"
40
+ exit 1 unless is_succeed
41
+
42
+ # paths
43
+ target_name = target.name # equals target.label, like "AFNeworking-iOS" when AFNetworking is used in multiple platforms.
44
+ module_name = target.product_module_name
45
+ device_framework_path = "#{build_dir}/#{CONFIGURATION}-#{device}/#{target_name}/#{module_name}.framework"
46
+ simulator_framework_path = "#{build_dir}/#{CONFIGURATION}-#{simulator}/#{target_name}/#{module_name}.framework"
47
+ output_framework_path = "#{output_path}/#{module_name}.framework"
48
+
49
+ device_binary = device_framework_path + "/#{module_name}"
50
+ simulator_binary = simulator_framework_path + "/#{module_name}"
51
+ return unless File.file?(device_binary) && File.file?(simulator_binary)
52
+
53
+ # the device_lib path is the final output file path
54
+ # combine the binaries
55
+ tmp_lipoed_binary_path = "#{build_dir}/#{target_name}"
56
+ lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_binary} #{simulator_binary}`
57
+ puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
58
+ FileUtils.mv tmp_lipoed_binary_path, device_binary, :force => true
59
+
60
+ # collect the swiftmodule file for various archs.
61
+ device_swiftmodule_path = device_framework_path + "/Modules/#{module_name}.swiftmodule"
62
+ simulator_swiftmodule_path = simulator_framework_path + "/Modules/#{module_name}.swiftmodule"
63
+ if File.exist?(device_swiftmodule_path)
64
+ FileUtils.cp_r simulator_swiftmodule_path + "/.", device_swiftmodule_path
65
+ end
66
+
67
+ # combine the generated swift headers
68
+ # (In xcode 10.2, the generated swift headers vary for each archs)
69
+ # https://github.com/leavez/cocoapods-binary/issues/58
70
+ simulator_generated_swift_header_path = simulator_framework_path + "/Headers/#{module_name}-Swift.h"
71
+ device_generated_swift_header_path = device_framework_path + "/Headers/#{module_name}-Swift.h"
72
+ if File.exist? simulator_generated_swift_header_path
73
+ device_header = File.read(device_generated_swift_header_path)
74
+ simulator_header = File.read(simulator_generated_swift_header_path)
75
+ # https://github.com/Carthage/Carthage/issues/2718#issuecomment-473870461
76
+ combined_header_content = %Q{
77
+ #if TARGET_OS_SIMULATOR // merged by cocoapods-binary
78
+
79
+ #{simulator_header}
80
+
81
+ #else // merged by cocoapods-binary
82
+
83
+ #{device_header}
84
+
85
+ #endif // merged by cocoapods-binary
86
+ }
87
+ File.write(device_generated_swift_header_path, combined_header_content.strip)
88
+ end
89
+
90
+ # handle the dSYM files
91
+ device_dsym = "#{device_framework_path}.dSYM"
92
+ device_dsym_output_path = "#{output_framework_path}.dSYM"
93
+ if File.exist? device_dsym
94
+ # lipo the simulator dsym
95
+ simulator_dsym = "#{simulator_framework_path}.dSYM"
96
+ if File.exist? simulator_dsym
97
+ tmp_lipoed_binary_path = "#{output_path}/#{module_name}.draft"
98
+ lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_dsym}/Contents/Resources/DWARF/#{module_name} #{simulator_dsym}/Contents/Resources/DWARF/#{module_name}`
99
+ puts "LIPO COMMAND"
100
+ puts "lipo -create -output #{tmp_lipoed_binary_path} #{device_dsym}/Contents/Resources/DWARF/#{module_name} #{simulator_dsym}/Contents/Resources/DWARF/#{module_name}"
101
+
102
+ puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
103
+ FileUtils.mv tmp_lipoed_binary_path, "#{device_framework_path}.dSYM/Contents/Resources/DWARF/#{module_name}", :force => true
104
+ end
105
+ # move
106
+ FileUtils.rm_r device_dsym_output_path if Dir.exist? device_dsym_output_path
107
+ File.rename device_dsym, device_dsym_output_path
108
+ end
109
+
110
+ # output
111
+ output_path.mkpath unless output_path.exist?
112
+ FileUtils.rm_r output_framework_path if Dir.exist? output_framework_path
113
+ File.rename device_framework_path, output_framework_path
114
+
115
+ end
116
+
117
+ def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, other_options=[])
118
+ args = %W(-project #{sandbox.project_path.realdirpath} -scheme #{target} -configuration #{CONFIGURATION} -sdk #{sdk} )
119
+ platform = PLATFORMS[sdk]
120
+ args += Fourflusher::SimControl.new.destination(:oldest, platform, deployment_target) unless platform.nil?
121
+ args += other_options
122
+ log = `xcodebuild #{args.join(" ")} 2>&1`
123
+ exit_code = $?.exitstatus # Process::Status
124
+ is_succeed = (exit_code == 0)
125
+
126
+ Pod::UI.puts "BUILD COMMAND"
127
+ Pod::UI.puts "exit_code #{exit_code}"
128
+ Pod::UI.puts "xcodebuild #{args.join(" ")}"
129
+ Pod::UI.puts log
130
+
131
+ if !is_succeed
132
+ begin
133
+ if log.include?('** BUILD FAILED **')
134
+ # use xcpretty to print build log
135
+ # 64 represent command invalid. http://www.manpagez.com/man/3/sysexits/
136
+ printer = XCPretty::Printer.new({:formatter => XCPretty::Simple, :colorize => 'auto'})
137
+ log.each_line do |line|
138
+ printer.pretty_print(line)
139
+ end
140
+ else
141
+ raise "shouldn't be handle by xcpretty"
142
+ end
143
+ rescue
144
+ puts log.red
145
+ end
146
+ end
147
+ [is_succeed, log]
148
+ end
149
+
150
+
151
+
152
+ module Pod
153
+ class Prebuild
154
+
155
+ # Build the frameworks with sandbox and targets
156
+ #
157
+ # @param [String] sandbox_root_path
158
+ # The sandbox root path where the targets project place
159
+ #
160
+ # [PodTarget] target
161
+ # The pod targets to build
162
+ #
163
+ # [Pathname] output_path
164
+ # output path for generated frameworks
165
+ #
166
+ def self.build(sandbox_root_path, target, output_path, min_deployment_target, bitcode_enabled = false, custom_build_options=[], custom_build_options_simulator=[])
167
+
168
+ return if target.nil?
169
+
170
+ sandbox_root = Pathname(sandbox_root_path)
171
+ sandbox = Pod::Sandbox.new(sandbox_root)
172
+ build_dir = self.build_dir(sandbox_root)
173
+
174
+ # -- build the framework
175
+ case target.platform.name
176
+ when :ios then build_for_iosish_platform(sandbox, build_dir, output_path, target, min_deployment_target, 'iphoneos', 'iphonesimulator', bitcode_enabled, custom_build_options, custom_build_options_simulator)
177
+ when :osx then xcodebuild(sandbox, target.label, 'macosx', nil, custom_build_options)
178
+ # when :tvos then build_for_iosish_platform(sandbox, build_dir, target, 'appletvos', 'appletvsimulator')
179
+ when :watchos then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'watchos', 'watchsimulator', true, custom_build_options, custom_build_options_simulator)
180
+ else raise "Unsupported platform for '#{target.name}': '#{target.platform.name}'" end
181
+
182
+ raise Pod::Informative, 'The build directory was not found in the expected location.' unless build_dir.directory?
183
+
184
+ # # --- copy the vendored libraries and framework
185
+ # frameworks = build_dir.children.select{ |path| File.extname(path) == ".framework" }
186
+ # Pod::UI.puts "Built #{frameworks.count} #{'frameworks'.pluralize(frameworks.count)}"
187
+
188
+ # pod_target = target
189
+ # consumer = pod_target.root_spec.consumer(pod_target.platform.name)
190
+ # file_accessor = Pod::Sandbox::FileAccessor.new(sandbox.pod_dir(pod_target.pod_name), consumer)
191
+ # frameworks += file_accessor.vendored_libraries
192
+ # frameworks += file_accessor.vendored_frameworks
193
+
194
+ # frameworks.uniq!
195
+
196
+ # frameworks.each do |framework|
197
+ # FileUtils.mkdir_p destination
198
+ # FileUtils.cp_r framework, destination, :remove_destination => true
199
+ # end
200
+ # build_dir.rmtree if build_dir.directory?
201
+ end
202
+
203
+ def self.remove_build_dir(sandbox_root)
204
+ path = build_dir(sandbox_root)
205
+ path.rmtree if path.exist?
206
+ end
207
+
208
+ private
209
+
210
+ def self.build_dir(sandbox_root)
211
+ # don't know why xcode chose this folder
212
+ sandbox_root.parent + 'build'
213
+ end
214
+
215
+ end
216
+ end
@@ -0,0 +1,12 @@
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
@@ -0,0 +1,2 @@
1
+ require 'cocoapods-binary/Main'
2
+
@@ -0,0 +1,50 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+
21
+ # Disable the wrapping so the output is deterministic in the tests.
22
+ #
23
+ UI.disable_wrap = true
24
+
25
+ # Redirects the messages to an internal store.
26
+ #
27
+ module UI
28
+ @output = ''
29
+ @warnings = ''
30
+
31
+ class << self
32
+ attr_accessor :output
33
+ attr_accessor :warnings
34
+
35
+ def puts(message = '')
36
+ @output << "#{message}\n"
37
+ end
38
+
39
+ def warn(message = '', actions = [])
40
+ @warnings << "#{message}\n"
41
+ end
42
+
43
+ def print(message)
44
+ @output << message
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-binary-gcp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - leavez
8
+ - hellocore
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-02-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cocoapods
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 1.5.0
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '2.0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: 1.5.0
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ - !ruby/object:Gem::Dependency
35
+ name: fourflusher
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: xcpretty
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.0
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: google-cloud-storage
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.19'
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.19'
76
+ - !ruby/object:Gem::Dependency
77
+ name: rubyzip
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ - !ruby/object:Gem::Dependency
91
+ name: bundler
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.3'
104
+ - !ruby/object:Gem::Dependency
105
+ name: rake
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ description: integrate pods in form of prebuilt frameworks conveniently, reducing
119
+ compile time
120
+ email:
121
+ - gaojiji@gmail.com
122
+ - aukwat@gmail.com
123
+ executables: []
124
+ extensions: []
125
+ extra_rdoc_files: []
126
+ files:
127
+ - ".github/ISSUE_TEMPLATE"
128
+ - ".gitignore"
129
+ - ".travis.yml"
130
+ - Gemfile
131
+ - LICENSE.txt
132
+ - README.md
133
+ - Rakefile
134
+ - cocoapods-binary.gemspec
135
+ - lib/cocoapods-binary.rb
136
+ - lib/cocoapods-binary/Integration.rb
137
+ - lib/cocoapods-binary/Main.rb
138
+ - lib/cocoapods-binary/Prebuild.rb
139
+ - lib/cocoapods-binary/gem_version.rb
140
+ - lib/cocoapods-binary/helper/feature_switches.rb
141
+ - lib/cocoapods-binary/helper/names.rb
142
+ - lib/cocoapods-binary/helper/passer.rb
143
+ - lib/cocoapods-binary/helper/podfile_options.rb
144
+ - lib/cocoapods-binary/helper/prebuild_sandbox.rb
145
+ - lib/cocoapods-binary/helper/shared_cache.rb
146
+ - lib/cocoapods-binary/helper/target_checker.rb
147
+ - lib/cocoapods-binary/rome/build_framework.rb
148
+ - lib/cocoapods-binary/tool/tool.rb
149
+ - lib/cocoapods_plugin.rb
150
+ - spec/spec_helper.rb
151
+ homepage: https://github.com/HelloCore/cocoapods-binary
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.5.2
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: A CocoaPods plugin to integrate pods in form of prebuilt frameworks, not
175
+ source code, by adding just one flag in podfile. Speed up compiling dramatically.
176
+ test_files:
177
+ - spec/spec_helper.rb