cocoapods-imy-bin 0.2.1 → 0.2.7

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.
@@ -29,6 +29,7 @@ module Pod
29
29
  ['--sources', '私有源地址,多个用分号区分'],
30
30
  ['--framework-output', '输出framework文件'],
31
31
  ['--no-zip', '不压缩静态库 为 zip'],
32
+ ['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
32
33
  ['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
33
34
  ].concat(Pod::Command::Gen.options).concat(super).uniq
34
35
  end
@@ -51,6 +52,8 @@ module Pod
51
52
  @sources = argv.option('sources') || []
52
53
  @platform = Platform.new(:ios)
53
54
 
55
+ @config = argv.option('configuration', 'Release')
56
+
54
57
  @framework_path
55
58
  super
56
59
 
@@ -81,7 +84,8 @@ module Pod
81
84
  @framework_output,
82
85
  @zip,
83
86
  @spec,
84
- CBin::Config::Builder.instance.white_pod_list.include?(@spec.name))
87
+ CBin::Config::Builder.instance.white_pod_list.include?(@spec.name),
88
+ @config)
85
89
  builder.build
86
90
  builder.clean_workspace if @clean && !@all_make
87
91
  end
@@ -119,7 +123,9 @@ module Pod
119
123
  @platform,
120
124
  @framework_output,
121
125
  @zip,
122
- @spec)
126
+ @spec,
127
+ false ,
128
+ @config)
123
129
  builder.build
124
130
  rescue
125
131
  fail_build_specs << spec
@@ -148,6 +154,7 @@ module Pod
148
154
  "--sources=#{sources_option(@code_dependencies, @sources)}",
149
155
  "--gen-directory=#{CBin::Config::Builder.instance.gen_dir}",
150
156
  '--clean',
157
+ '--use-podfile',
151
158
  *@additional_args
152
159
  ]
153
160
 
@@ -19,6 +19,7 @@ module Pod
19
19
  ['--framework-output', '输出framework文件'],
20
20
  ['--no-zip', '不压缩静态 framework 为 zip'],
21
21
  ['--all-make', '对该组件的依赖库,全部制作为二进制组件'],
22
+ ['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
22
23
  ['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"]
23
24
  ]
24
25
  end
@@ -38,6 +39,9 @@ module Pod
38
39
  @zip = argv.flag?('zip', true)
39
40
  @all_make = argv.flag?('all-make', false )
40
41
  @verbose = argv.flag?('verbose',true)
42
+
43
+ @config = argv.option('configuration', 'Release')
44
+
41
45
  super
42
46
  end
43
47
 
@@ -113,7 +117,7 @@ module Pod
113
117
  if @env
114
118
  argvs += ["--env=#{@env}"]
115
119
  end
116
-
120
+ argvs += ["--configuration=#{@config}"]
117
121
 
118
122
  archive = Pod::Command::Bin::Archive.new(CLAide::ARGV.new(argvs))
119
123
  archive.validate!
@@ -83,11 +83,6 @@ module Pod
83
83
  FileUtils.rm_rf(target_path)
84
84
 
85
85
  find_dependency = find_dependency(name)
86
- # 意义不大,需要可以使用--source参数 对 github-ios 仓库对做特殊处理
87
- # if find_dependency && find_dependency.external_source[:podspec].include?(http_gitlib_GitHub_iOS_path)
88
- # github_ios = find_dependency.external_source[:podspec]
89
- # find_dependency.external_source[:podspec] = github_ios.gsub(http_gitlib_GitHub_iOS_path,http_gitlib_iOS_path)
90
- # end
91
86
 
92
87
  spec = fetch_external_source(find_dependency, @config.podfile,@config.lockfile, @config.sandbox,true )
93
88
 
@@ -106,7 +101,6 @@ module Pod
106
101
  break
107
102
  end
108
103
  end
109
-
110
104
  find_dependency
111
105
  end
112
106
 
@@ -150,6 +144,7 @@ module Pod
150
144
  FileUtils.rm_rf(File.join(dir,basename))
151
145
  `ln -s #{target_path} #{dir}/#{basename}`
152
146
  end
147
+
153
148
  check(lib_file,dir,basename)
154
149
  end
155
150
 
@@ -73,26 +73,31 @@ module Pod
73
73
 
74
74
  podfile.instance_eval do
75
75
  begin
76
+
77
+ # podfile HASH_KEYS才有plugins字段,否则会被限制
78
+ if local_podfile.plugins.any?
79
+ hash_plugins = podfile.plugins || {}
80
+ hash_plugins = hash_plugins.merge(local_podfile.plugins)
81
+ set_hash_value(%w[plugins].first, hash_plugins)
82
+
83
+ # 加入源码白名单,避免本地库被二进制了
84
+ podfile.set_use_source_pods(local_podfile.use_source_pods) if local_podfile.use_source_pods
85
+ podfile.use_binaries!(local_podfile.use_binaries?)
86
+ end
87
+
76
88
  # 在target把local-target中到dependencies值删除了,再设置
77
89
  # 把本地和原始到dependencies 合并,设置dependencies
78
90
  local_podfile&.target_definition_list&.each do |local_target|
79
91
  next if local_target.name == 'Pods'
80
92
 
81
93
  target_definition_list.each do |target|
94
+
82
95
  unless target.name == local_target.name &&
83
96
  (local_target.to_hash['dependencies'] &&local_target.to_hash['dependencies'].any?)
84
97
  next
85
98
  end
86
99
 
87
- # podfile HASH_KEYS才有plugins字段,否则会被限制
88
- if local_podfile.plugins.any?
89
- hash_plugins = podfile.plugins || {}
90
- hash_plugins = hash_plugins.merge(local_podfile.plugins)
91
- set_hash_value(%w[plugins].first, hash_plugins)
92
- end
93
- # 加入源码白名单,避免本地库被二进制了
94
- podfile.set_use_source_pods(local_podfile.use_source_pods) if local_podfile.use_source_pods
95
- podfile.use_binaries!(local_podfile.use_binaries?)
100
+
96
101
 
97
102
  target.instance_exec do
98
103
  # 在target把local-target中到dependencies值删除了,再设置
@@ -126,6 +131,7 @@ module Pod
126
131
 
127
132
  end
128
133
  end
134
+
129
135
  end
130
136
 
131
137
  if local_pre_install_callback
@@ -1,6 +1,6 @@
1
1
 
2
2
  module CBin
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.7'
4
4
  end
5
5
 
6
6
  module Pod
@@ -51,7 +51,7 @@ module CBin
51
51
  source_dir = Dir.pwd
52
52
  file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform))
53
53
  Dir.chdir(workspace_directory) do
54
- builder = CBin::Framework::Builder.new(@spec, file_accessor, @platform, source_dir,@isRootSpec)
54
+ builder = CBin::Framework::Builder.new(@spec, file_accessor, @platform, source_dir, @isRootSpec, @build_model )
55
55
  @@build_defines = builder.build if @isRootSpec
56
56
  begin
57
57
  @framework_path = builder.lipo_build(@@build_defines) unless @skip_archive
@@ -38,7 +38,7 @@ module CBin
38
38
  end
39
39
 
40
40
  def lipo_build(defines)
41
- UI.section("Building static framework #{@spec}") do
41
+ UI.section("Building static Library #{@spec}") do
42
42
  # defines = compile
43
43
 
44
44
  # build_sim_libraries(defines)
@@ -68,118 +68,22 @@ module CBin
68
68
  `cp -fa #{@platform}/#{framework_name} #{target_dir}`
69
69
  end
70
70
 
71
+ #模拟器,目前只支持 debug x86-64
71
72
  def build_sim_libraries(defines)
72
73
  UI.message 'Building simulator libraries'
73
74
 
74
75
  if is_debug_model
75
76
  # archs = %w[i386 x86_64]
76
- archs = %w[x86_64]
77
+ archs = ios_architectures_sim
77
78
  archs.map do |arch|
78
79
  xcodebuild(defines, "-sdk iphonesimulator ARCHS=\'#{arch}\' ", "build-#{arch}","Debug")
79
80
  end
80
81
  else
81
- xcodebuild(defines, "-sdk iphonesimulator ", 'build-simulator')
82
+ xcodebuild(defines, "-sdk iphonesimulator ", 'build-simulator', "Release")
82
83
  end
83
84
 
84
85
  end
85
86
 
86
- def copy_headers
87
- #走 podsepc中的public_headers
88
- public_headers = Array.new
89
-
90
- #by slj 如果没有头文件,去 "Headers/Public"拿
91
- # if public_headers.empty?
92
- Dir.chdir("./Headers/Public/#{@spec.name}") do
93
- headers = Dir.glob('*.h')
94
- headers.each do |h|
95
- public_headers << Pathname.new(File.join(Dir.pwd,h))
96
- end
97
- end
98
- # end
99
-
100
- # UI.message "Copying public headers #{public_headers.map(&:basename).map(&:to_s)}"
101
-
102
- public_headers.each do |h|
103
- `ditto #{h} #{framework.headers_path}/#{h.basename}`
104
- end
105
-
106
- # If custom 'module_map' is specified add it to the framework distribution
107
- # otherwise check if a header exists that is equal to 'spec.name', if so
108
- # create a default 'module_map' one using it.
109
- if !@spec.module_map.nil?
110
- module_map_file = @file_accessor.module_map
111
- if Pathname(module_map_file).exist?
112
- module_map = File.read(module_map_file)
113
- end
114
- elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}.h")
115
- module_map = <<-MAP
116
- framework module #{@spec.name} {
117
- umbrella header "#{@spec.name}.h"
118
-
119
- export *
120
- module * { export * }
121
- }
122
- MAP
123
- end
124
-
125
- unless module_map.nil?
126
- UI.message "Writing module map #{module_map}"
127
- unless framework.module_map_path.exist?
128
- framework.module_map_path.mkpath
129
- end
130
- File.write("#{framework.module_map_path}/module.modulemap", module_map)
131
- end
132
- end
133
-
134
- def copy_license
135
- UI.message 'Copying license'
136
- license_file = @spec.license[:file] || 'LICENSE'
137
- `cp "#{license_file}" .` if Pathname(license_file).exist?
138
- end
139
-
140
- def copy_resources
141
-
142
- bundles = Dir.glob('./build/*.bundle')
143
-
144
- bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
145
- consumer = spec.consumer(@platform)
146
- consumer.resource_bundles.keys +
147
- consumer.resources.map do |r|
148
- File.basename(r, '.bundle') if File.extname(r) == 'bundle'
149
- end
150
- end.compact.uniq
151
-
152
- bundles.select! do |bundle|
153
- bundle_name = File.basename(bundle, '.bundle')
154
- bundle_names.include?(bundle_name)
155
- end
156
-
157
- if bundles.count > 0
158
- UI.message "Copying bundle files #{bundles}"
159
- bundle_files = bundles.join(' ')
160
- `cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
161
- end
162
-
163
- real_source_dir = @isRootSpec ? @source_dir : Pathname.new(File.join(Dir.pwd,"#{@spec.name}"))
164
- resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
165
- expand_paths(real_source_dir, spec.consumer(@platform).resources)
166
- end.compact.uniq
167
-
168
- if resources.count == 0 && bundles.count == 0
169
- framework.delete_resources
170
- return
171
- end
172
-
173
- if resources.count > 0
174
- #把 路径转义。 避免空格情况下拷贝失败
175
- escape_resource = []
176
- resources.each do |source|
177
- escape_resource << Shellwords.join(source)
178
- end
179
- UI.message "Copying resources #{escape_resource}"
180
- `cp -rp #{escape_resource.join(' ')} #{framework.resources_path}`
181
- end
182
- end
183
87
 
184
88
  def static_libs_in_sandbox(build_dir = 'build')
185
89
  file = Dir.glob("#{build_dir}/lib#{target_name}.a")
@@ -194,21 +98,32 @@ module CBin
194
98
  static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-simulator') + @vendored_libraries
195
99
  if is_debug_model
196
100
  ios_architectures.map do |arch|
197
- static_libs += static_libs_in_sandbox("build-#{arch}") + static_libs_in_sandbox('build-simulator') + @vendored_libraries
101
+ static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
102
+ end
103
+ ios_architectures_sim do |arch|
104
+ static_libs += static_libs_in_sandbox("build-#{arch}") + @vendored_libraries
198
105
  end
199
106
  end
200
107
 
201
108
  build_path = Pathname("build")
202
109
  build_path.mkpath unless build_path.exist?
203
110
 
204
- libs = ios_architectures.map do |arch|
205
- library = "build/package-#{@spec.name}-#{arch}.a"
206
- # libtool -arch_only arm64 -static -o build/package-armv64.a build/libIMYFoundation.a build-simulator/libIMYFoundation.a
207
- # 从liBFoundation.a 文件中,提取出 arm64 架构的文件,命名为build/package-armv64.a
208
- UI.message "libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}"
209
- `libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
210
- library
111
+ if is_debug_model
112
+ libs = (ios_architectures + ios_architectures_sim) .map do |arch|
113
+ library = "build-#{arch}/lib#{@spec.name}.a"
114
+ library
115
+ end
116
+ else
117
+ libs = ios_architectures.map do |arch|
118
+ library = "build/package-#{@spec.name}-#{arch}.a"
119
+ # libtool -arch_only arm64 -static -o build/package-armv64.a build/libIMYFoundation.a build-simulator/libIMYFoundation.a
120
+ # 从liBFoundation.a 文件中,提取出 arm64 架构的文件,命名为build/package-armv64.a
121
+ UI.message "libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}"
122
+ `libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
123
+ library
124
+ end
211
125
  end
126
+
212
127
  UI.message "lipo -create -output #{output} #{libs.join(' ')}"
213
128
  `lipo -create -output #{output} #{libs.join(' ')}`
214
129
  end
@@ -230,11 +145,18 @@ module CBin
230
145
  # iphone5,iphone5s以下的模拟器
231
146
  # >x86_64
232
147
  # iphone6以上的模拟器
233
- archs = %w[x86_64 arm64 armv7]
148
+ archs = %w[arm64 armv7]
234
149
  # archs = %w[x86_64 arm64 armv7s i386]
235
- @vendored_libraries.each do |library|
236
- archs = `lipo -info #{library}`.split & archs
237
- end
150
+ # @vendored_libraries.each do |library|
151
+ # archs = `lipo -info #{library}`.split & archs
152
+ # end
153
+ archs
154
+ end
155
+
156
+ def ios_architectures_sim
157
+
158
+ archs = %w[x86_64]
159
+ # TODO 处理是否需要 i386
238
160
  archs
239
161
  end
240
162
 
@@ -245,7 +167,7 @@ module CBin
245
167
 
246
168
  options = ios_build_options
247
169
  if is_debug_model
248
- archs = %w[arm64 armv7]
170
+ archs = ios_architectures
249
171
  # archs = %w[arm64 armv7 armv7s]
250
172
  archs.map do |arch|
251
173
  xcodebuild(defines, "ARCHS=\'#{arch}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'","build-#{arch}",@build_model)
@@ -271,10 +193,14 @@ module CBin
271
193
  # end
272
194
  end
273
195
 
274
- def xcodebuild(defines = '', args = '', build_dir = 'build',build_model = 'Release')
275
- #xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(inherited)' ARCHS='x86_64 arm64 armv7 armv7s i386' OTHER_CFLAGS='-fembed-bitcode -Qunused-arguments' CONFIGURATION_BUILD_DIR=build clean build -configuration Debug -target IMYTCP -project ./Pods.xcodeproj 2>&1
276
- # xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(inherited)' -sdk iphoneos CONFIGURATION_BUILD_DIR=build-simulator clean build -configuration Release -target IMYFoundation -project ./Pods/Pods.xcodeproj 2>&1
277
- command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{build_model} -target #{target_name} -project ./Pods.xcodeproj 2>&1"
196
+ def xcodebuild(defines = '', args = '', build_dir = 'build',build_model = 'Debug')
197
+
198
+ unless File.exist?("Pods.xcodeproj") #cocoapods-generate v2.0.0
199
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{File.join(File.expand_path("..", build_dir), File.basename(build_dir))} clean build -configuration #{build_model} -target #{target_name} -project ./Pods/Pods.xcodeproj 2>&1"
200
+ else
201
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{build_model} -target #{target_name} -project ./Pods.xcodeproj 2>&1"
202
+ end
203
+
278
204
  UI.message "command = #{command}"
279
205
  output = `#{command}`.lines.to_a
280
206
 
@@ -289,6 +215,104 @@ module CBin
289
215
  end
290
216
  end
291
217
 
218
+ def copy_headers
219
+ #走 podsepc中的public_headers
220
+ public_headers = Array.new
221
+
222
+ #by slj 如果没有头文件,去 "Headers/Public"拿
223
+ # if public_headers.empty?
224
+ Dir.chdir("./Headers/Public/#{@spec.name}") do
225
+ headers = Dir.glob('*.h')
226
+ headers.each do |h|
227
+ public_headers << Pathname.new(File.join(Dir.pwd,h))
228
+ end
229
+ end
230
+ # end
231
+
232
+ # UI.message "Copying public headers #{public_headers.map(&:basename).map(&:to_s)}"
233
+
234
+ public_headers.each do |h|
235
+ `ditto #{h} #{framework.headers_path}/#{h.basename}`
236
+ end
237
+
238
+ # If custom 'module_map' is specified add it to the framework distribution
239
+ # otherwise check if a header exists that is equal to 'spec.name', if so
240
+ # create a default 'module_map' one using it.
241
+ if !@spec.module_map.nil?
242
+ module_map_file = @file_accessor.module_map
243
+ if Pathname(module_map_file).exist?
244
+ module_map = File.read(module_map_file)
245
+ end
246
+ elsif public_headers.map(&:basename).map(&:to_s).include?("#{@spec.name}.h")
247
+ module_map = <<-MAP
248
+ framework module #{@spec.name} {
249
+ umbrella header "#{@spec.name}.h"
250
+
251
+ export *
252
+ module * { export * }
253
+ }
254
+ MAP
255
+ end
256
+
257
+ unless module_map.nil?
258
+ UI.message "Writing module map #{module_map}"
259
+ unless framework.module_map_path.exist?
260
+ framework.module_map_path.mkpath
261
+ end
262
+ File.write("#{framework.module_map_path}/module.modulemap", module_map)
263
+ end
264
+ end
265
+
266
+ def copy_license
267
+ UI.message 'Copying license'
268
+ license_file = @spec.license[:file] || 'LICENSE'
269
+ `cp "#{license_file}" .` if Pathname(license_file).exist?
270
+ end
271
+
272
+ def copy_resources
273
+
274
+ bundles = Dir.glob('./build/*.bundle')
275
+
276
+ bundle_names = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
277
+ consumer = spec.consumer(@platform)
278
+ consumer.resource_bundles.keys +
279
+ consumer.resources.map do |r|
280
+ File.basename(r, '.bundle') if File.extname(r) == 'bundle'
281
+ end
282
+ end.compact.uniq
283
+
284
+ bundles.select! do |bundle|
285
+ bundle_name = File.basename(bundle, '.bundle')
286
+ bundle_names.include?(bundle_name)
287
+ end
288
+
289
+ if bundles.count > 0
290
+ UI.message "Copying bundle files #{bundles}"
291
+ bundle_files = bundles.join(' ')
292
+ `cp -rp #{bundle_files} #{framework.resources_path} 2>&1`
293
+ end
294
+
295
+ real_source_dir = @isRootSpec ? @source_dir : Pathname.new(File.join(Dir.pwd,"#{@spec.name}"))
296
+ resources = [@spec, *@spec.recursive_subspecs].flat_map do |spec|
297
+ expand_paths(real_source_dir, spec.consumer(@platform).resources)
298
+ end.compact.uniq
299
+
300
+ if resources.count == 0 && bundles.count == 0
301
+ framework.delete_resources
302
+ return
303
+ end
304
+
305
+ if resources.count > 0
306
+ #把 路径转义。 避免空格情况下拷贝失败
307
+ escape_resource = []
308
+ resources.each do |source|
309
+ escape_resource << Shellwords.join(source)
310
+ end
311
+ UI.message "Copying resources #{escape_resource}"
312
+ `cp -rp #{escape_resource.join(' ')} #{framework.resources_path}`
313
+ end
314
+ end
315
+
292
316
  def expand_paths(source_dir, path_specs)
293
317
  path_specs.map do |path_spec|
294
318
  Dir.glob(File.join(source_dir, path_spec))
@@ -302,6 +326,8 @@ module CBin
302
326
  framework
303
327
  end
304
328
  end
329
+
330
+
305
331
  end
306
332
  end
307
333
  end