1
1
require 'fourflusher'
2
2
require 'xcpretty' # TODO (thuyen): Revise this dependency
3
3
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
+
4
11
PLATFORMS = { 'iphonesimulator' => 'iOS' ,
5
12
'appletvsimulator' => 'tvOS' ,
6
13
'watchsimulator' => 'watchOS' }
@@ -76,14 +83,14 @@ def build_for_iosish_platform(sandbox,
76
83
device_binary = device_framework_path + "/#{ module_name } "
77
84
simulator_binary = simulator_framework_path + "/#{ module_name } "
78
85
return unless File . file? ( device_binary ) && File . file? ( simulator_binary )
79
-
86
+
80
87
# the device_lib path is the final output file path
81
88
# combine the binaries
82
89
tmp_lipoed_binary_path = "#{ build_dir } /#{ target_name } "
83
90
lipo_log = `lipo -create -output #{ tmp_lipoed_binary_path } #{ device_binary } #{ simulator_binary } `
84
91
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
+
87
94
# collect the swiftmodule file for various archs.
88
95
device_swiftmodule_path = device_framework_path + "/Modules/#{ module_name } .swiftmodule"
89
96
simulator_swiftmodule_path = simulator_framework_path + "/Modules/#{ module_name } .swiftmodule"
@@ -123,16 +130,14 @@ def build_for_iosish_platform(sandbox,
123
130
tmp_lipoed_binary_path = "#{ output_path } /#{ module_name } .draft"
124
131
lipo_log = `lipo -create -output #{ tmp_lipoed_binary_path } #{ device_dsym } /Contents/Resources/DWARF/#{ module_name } #{ simulator_dsym } /Contents/Resources/DWARF/#{ module_name } `
125
132
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 } "
127
134
end
128
- # move
129
- FileUtils . mv device_dsym , output_path , :force => true
135
+ FileUtils . mvpath device_dsym , output_path
130
136
end
131
137
132
138
# output
133
139
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
136
141
end
137
142
138
143
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
168
173
[ is_succeed , log ]
169
174
end
170
175
171
-
172
-
173
176
module Pod
174
177
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 ] || [ ]
175
187
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
188
return if target . nil?
189
189
190
190
sandbox_root = Pathname ( sandbox_root_path )
@@ -204,7 +204,8 @@ def self.build(sandbox_root_path, target, configuration, output_path, bitcode_en
204
204
"iphonesimulator" ,
205
205
bitcode_enabled ,
206
206
custom_build_options ,
207
- custom_build_options_simulator
207
+ custom_build_options_simulator ,
208
+ device_build_enabled
208
209
)
209
210
when :osx
210
211
xcodebuild (
@@ -227,7 +228,8 @@ def self.build(sandbox_root_path, target, configuration, output_path, bitcode_en
227
228
"watchsimulator" ,
228
229
true ,
229
230
custom_build_options ,
230
- custom_build_options_simulator
231
+ custom_build_options_simulator ,
232
+ device_build_enabled
231
233
)
232
234
else raise "Unsupported platform for '#{ target . name } ': '#{ target . platform . name } '" end
233
235
@@ -242,6 +244,5 @@ def self.remove_build_dir(sandbox_root)
242
244
def self . build_dir ( sandbox_root )
243
245
sandbox_root . parent + "build"
244
246
end
245
-
246
247
end
247
248
end
0 commit comments