Skip to content

Commit 775a17c

Browse files
chore(*): allow prebuild with device
1 parent 3961b72 commit 775a17c

File tree

3 files changed

+37
-32
lines changed

3 files changed

+37
-32
lines changed

lib/cocoapods-binary-cache/pod-binary/prebuild.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,14 @@ def prebuild_frameworks!
118118
output_path = sandbox.framework_folder_path_for_target_name(target.name)
119119
output_path.mkpath unless output_path.exist?
120120
Pod::Prebuild.build(
121-
sandbox_path,
122-
target,
123-
Pod::Podfile::DSL.prebuild_config,
124-
output_path,
125-
bitcode_enabled,
126-
Pod::Podfile::DSL.custom_device_build_options,
127-
Pod::Podfile::DSL.custom_simulator_build_options
121+
sandbox_root_path: sandbox_path,
122+
target: target,
123+
configuration: Pod::Podfile::DSL.prebuild_config,
124+
output_path: output_path,
125+
bitcode_enabled: bitcode_enabled,
126+
device_build_enabled: Pod::Podfile::DSL.device_build_enabled,
127+
custom_build_options: Pod::Podfile::DSL.custom_device_build_options,
128+
custom_build_options_simulator: Pod::Podfile::DSL.custom_simulator_build_options
128129
)
129130
collect_metadata(target, output_path)
130131
end

lib/cocoapods-binary-cache/pod-binary/prebuild_dsl.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def config_cocoapods_binary_cache(options)
1414
apply_config.call(:excluded_pods)
1515
apply_config.call(:dev_pods_enabled)
1616
apply_config.call(:bitcode_enabled)
17+
apply_config.call(:device_build_enabled)
1718
apply_config.call(:dont_remove_source_code)
1819
apply_config.call(:custom_device_build_options)
1920
apply_config.call(:custom_simulator_build_options)
@@ -28,6 +29,7 @@ def config_cocoapods_binary_cache(options)
2829
@excluded_pods = Set.new
2930
@dev_pods_enabled = false
3031
@bitcode_enabled = false
32+
@device_build_enabled = false
3133
@dont_remove_source_code = false
3234
@custom_device_build_options = []
3335
@custom_simulator_build_options = []
@@ -52,6 +54,7 @@ class << self
5254
attr_accessor :excluded_pods
5355
attr_accessor :dev_pods_enabled
5456
attr_accessor :bitcode_enabled
57+
attr_accessor :device_build_enabled
5558
attr_accessor :dont_remove_source_code
5659
attr_accessor :custom_device_build_options
5760
attr_accessor :custom_simulator_build_options

lib/cocoapods-binary-cache/pod-rome/build_framework.rb

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
require 'fourflusher'
22
require 'xcpretty' # TODO (thuyen): Revise this dependency
33

4+
module FileUtils
5+
def self.mvpath(src, dst, **options)
6+
FileUtils.rm_rf(File.join(dst, File.basename(src)))
7+
FileUtils.mv(src, dst, **options)
8+
end
9+
end
10+
411
PLATFORMS = { 'iphonesimulator' => 'iOS',
512
'appletvsimulator' => 'tvOS',
613
'watchsimulator' => 'watchOS' }
@@ -76,14 +83,14 @@ def build_for_iosish_platform(sandbox,
7683
device_binary = device_framework_path + "/#{module_name}"
7784
simulator_binary = simulator_framework_path + "/#{module_name}"
7885
return unless File.file?(device_binary) && File.file?(simulator_binary)
79-
86+
8087
# the device_lib path is the final output file path
8188
# combine the binaries
8289
tmp_lipoed_binary_path = "#{build_dir}/#{target_name}"
8390
lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_binary} #{simulator_binary}`
8491
puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
85-
FileUtils.mv tmp_lipoed_binary_path, device_binary, :force => true
86-
92+
FileUtils.mvpath tmp_lipoed_binary_path, device_binary
93+
8794
# collect the swiftmodule file for various archs.
8895
device_swiftmodule_path = device_framework_path + "/Modules/#{module_name}.swiftmodule"
8996
simulator_swiftmodule_path = simulator_framework_path + "/Modules/#{module_name}.swiftmodule"
@@ -123,16 +130,14 @@ def build_for_iosish_platform(sandbox,
123130
tmp_lipoed_binary_path = "#{output_path}/#{module_name}.draft"
124131
lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_dsym}/Contents/Resources/DWARF/#{module_name} #{simulator_dsym}/Contents/Resources/DWARF/#{module_name}`
125132
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
133+
FileUtils.mvpath tmp_lipoed_binary_path, "#{device_framework_path}.dSYM/Contents/Resources/DWARF/#{module_name}"
127134
end
128-
# move
129-
FileUtils.mv device_dsym, output_path, :force => true
135+
FileUtils.mvpath device_dsym, output_path
130136
end
131137

132138
# output
133139
output_path.mkpath unless output_path.exist?
134-
FileUtils.mv device_framework_path, output_path, :force => true
135-
140+
FileUtils.mvpath device_framework_path, output_path
136141
end
137142

138143
def xcodebuild(sandbox, target, configuration, sdk='macosx', deployment_target=nil, other_options=[])
@@ -168,23 +173,18 @@ def xcodebuild(sandbox, target, configuration, sdk='macosx', deployment_target=n
168173
[is_succeed, log]
169174
end
170175

171-
172-
173176
module Pod
174177
class Prebuild
178+
def self.build(options)
179+
sandbox_root_path = options[:sandbox_root_path]
180+
target = options[:target]
181+
configuration = options[:configuration]
182+
output_path = options[:output_path]
183+
bitcode_enabled = options[:bitcode_enabled] || false
184+
device_build_enabled = options[:device_build_enabled] || false
185+
custom_build_options = options[:custom_build_options] || []
186+
custom_build_options_simulator = options[:custom_build_options_simulator] || []
175187

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=[])
188188
return if target.nil?
189189

190190
sandbox_root = Pathname(sandbox_root_path)
@@ -204,7 +204,8 @@ def self.build(sandbox_root_path, target, configuration, output_path, bitcode_en
204204
"iphonesimulator",
205205
bitcode_enabled,
206206
custom_build_options,
207-
custom_build_options_simulator
207+
custom_build_options_simulator,
208+
device_build_enabled
208209
)
209210
when :osx
210211
xcodebuild(
@@ -227,7 +228,8 @@ def self.build(sandbox_root_path, target, configuration, output_path, bitcode_en
227228
"watchsimulator",
228229
true,
229230
custom_build_options,
230-
custom_build_options_simulator
231+
custom_build_options_simulator,
232+
device_build_enabled
231233
)
232234
else raise "Unsupported platform for '#{target.name}': '#{target.platform.name}'" end
233235

@@ -242,6 +244,5 @@ def self.remove_build_dir(sandbox_root)
242244
def self.build_dir(sandbox_root)
243245
sandbox_root.parent + "build"
244246
end
245-
246247
end
247248
end

0 commit comments

Comments
 (0)