cocoapods-packagerthk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 959f71cdce0d32b764ff3562e063e06b846368251b993689c49a267d4b1bc559
4
+ data.tar.gz: ea86498810fda143881f499e54609d75fdf04061edb7135f0000f956b8080794
5
+ SHA512:
6
+ metadata.gz: ab3de2e8f9ea098cdacf382c8a9b9ece994a499d4e0aa291e46ed073b98016395381887f8ecb18ab0fc60a9d4efa5c0a4f57434693fb5a557fb45abc047d1361
7
+ data.tar.gz: 1a47e1bad199971ad6a5bc54ecc270869bff5920baf047b64ff82fccccaf56aa2af0ccc0b389406573ad100fd89914b1e171d04418d89eaa49bf2b7732645e4e
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
@@ -0,0 +1,24 @@
1
+ {
2
+ // 使用 IntelliSense 了解相关属性。
3
+ // 悬停以查看现有属性的描述。
4
+ // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "showDebuggerOutput": true,
9
+ "name": "Debug Local File",
10
+ "type": "Ruby",
11
+ "request": "launch",
12
+ "cwd": "/Users/joe.cheng/cocoapods-debug",
13
+ "program": "/usr/local/lib/ruby/gems/3.0.0/bin/pod",
14
+ "args" : ["packagethk","THKMacroKit.podspec","--force","--generate-spec","--spec-sources=https://github.com/CocoaPods/Specs.git,git@repo.we.com:iosfeaturelibraries/thkbusinesskitspecs.git,git@repo.we.com:ios/tspecsrepo.git"],
15
+ "useBundler": true,
16
+ "env": {
17
+ "PATH": "/usr/local/opt/ruby/bin:/usr/local/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/joe.cheng/.rvm/bin",
18
+ "GEM_HOME": "/usr/local/lib/ruby/gems/3.0.0",
19
+ "GEM_PATH": "/usr/local/lib/ruby/gems/3.0.0",
20
+ "RUBY_VERSION": "ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]"
21
+ }
22
+ }
23
+ ]
24
+ }
data/Gemfile ADDED
@@ -0,0 +1,35 @@
1
+ SKIP_UNRELEASED_VERSIONS = false
2
+
3
+ # Specify your gem's dependencies in cocoapods-imy-bin.gemspec
4
+
5
+
6
+ def cp_gem(name, repo_name, branch = 'master', path: false)
7
+ return gem name if SKIP_UNRELEASED_VERSIONS
8
+ opts = if path
9
+ { :path => "./#{repo_name}" }
10
+ else
11
+ url = "https://github.com/chengzongxin/#{repo_name}.git"
12
+ { :git => url, :branch => branch }
13
+ end
14
+ gem name, opts
15
+ p "cp_gem"
16
+ p opts
17
+ end
18
+
19
+ source 'https://rubygems.org'
20
+
21
+ # Specify your gem's dependencies in cocoapods-packagerthk.gemspec
22
+ gemspec
23
+
24
+ group :development do
25
+ gem 'bacon'
26
+ gem 'mocha-on-bacon'
27
+ gem 'mocha'
28
+ gem 'prettybacon'
29
+ gem 'coveralls', :require => false
30
+ gem 'rubocop'
31
+ gem 'ruby-debug-ide'
32
+ gem 'debase', '0.2.5.beta2'
33
+
34
+ # gem 'cocoapods-packagerthk', :path => "./cocoapods-packagerthk"
35
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-packagerthk (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ bacon (1.2.0)
11
+ coveralls (0.8.23)
12
+ json (>= 1.8, < 3)
13
+ simplecov (~> 0.16.1)
14
+ term-ansicolor (~> 1.3)
15
+ thor (>= 0.19.4, < 2.0)
16
+ tins (~> 1.6)
17
+ debase (0.2.5.beta2)
18
+ debase-ruby_core_source (>= 0.10.12)
19
+ debase-ruby_core_source (3.2.0)
20
+ docile (1.4.0)
21
+ json (2.6.3)
22
+ mocha (2.0.2)
23
+ ruby2_keywords (>= 0.0.5)
24
+ mocha-on-bacon (0.2.3)
25
+ mocha (>= 0.13.0)
26
+ parallel (1.22.1)
27
+ parser (3.2.1.1)
28
+ ast (~> 2.4.1)
29
+ prettybacon (0.0.2)
30
+ bacon (~> 1.2)
31
+ rainbow (3.1.1)
32
+ rake (13.0.6)
33
+ regexp_parser (2.7.0)
34
+ rexml (3.2.5)
35
+ rubocop (1.48.1)
36
+ json (~> 2.3)
37
+ parallel (~> 1.10)
38
+ parser (>= 3.2.0.0)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 1.8, < 3.0)
41
+ rexml (>= 3.2.5, < 4.0)
42
+ rubocop-ast (>= 1.26.0, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 2.4.0, < 3.0)
45
+ rubocop-ast (1.27.0)
46
+ parser (>= 3.2.1.0)
47
+ ruby-debug-ide (0.7.3)
48
+ rake (>= 0.8.1)
49
+ ruby-progressbar (1.13.0)
50
+ ruby2_keywords (0.0.5)
51
+ simplecov (0.16.1)
52
+ docile (~> 1.1)
53
+ json (>= 1.8, < 3)
54
+ simplecov-html (~> 0.10.0)
55
+ simplecov-html (0.10.2)
56
+ sync (0.5.0)
57
+ term-ansicolor (1.7.1)
58
+ tins (~> 1.0)
59
+ thor (1.2.1)
60
+ tins (1.32.1)
61
+ sync
62
+ unicode-display_width (2.4.2)
63
+
64
+ PLATFORMS
65
+ x86_64-darwin-19
66
+
67
+ DEPENDENCIES
68
+ bacon
69
+ bundler
70
+ cocoapods-packagerthk!
71
+ coveralls
72
+ debase (= 0.2.5.beta2)
73
+ mocha
74
+ mocha-on-bacon
75
+ prettybacon
76
+ rake
77
+ rubocop
78
+ ruby-debug-ide
79
+
80
+ BUNDLED WITH
81
+ 2.4.7
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2023 Joe.cheng <joe.cheng@corp.to8to.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # cocoapods-packagerthk
2
+
3
+ A description of cocoapods-packagerthk.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-packagerthk
8
+
9
+ ## Usage
10
+
11
+ $ pod spec packagerthk POD_NAME
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-packagerthk/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-packagerthk'
8
+ spec.version = CocoapodsPackagerthk::VERSION
9
+ spec.authors = ['Joe.cheng']
10
+ spec.email = ['joe.cheng@corp.to8to.com']
11
+ spec.description = %q{A short description of cocoapods-packagerthk.}
12
+ spec.summary = %q{A longer description of cocoapods-packagerthk.}
13
+ spec.homepage = 'https://github.com/chengzongxin/cocoapods-packagerthk'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,336 @@
1
+ module Pod
2
+ class Builder
3
+ def initialize(platform, static_installer, source_dir, static_sandbox_root, dynamic_sandbox_root, public_headers_root, spec, embedded, mangle, dynamic, config, bundle_identifier, exclude_deps)
4
+ @platform = platform
5
+ @static_installer = static_installer
6
+ @source_dir = source_dir
7
+ @static_sandbox_root = static_sandbox_root
8
+ @dynamic_sandbox_root = dynamic_sandbox_root
9
+ @public_headers_root = public_headers_root
10
+ @spec = spec
11
+ @embedded = embedded
12
+ @mangle = mangle
13
+ @dynamic = dynamic
14
+ @config = config
15
+ @bundle_identifier = bundle_identifier
16
+ @exclude_deps = exclude_deps
17
+
18
+ @file_accessors = @static_installer.pod_targets.select { |t| t.pod_name == @spec.name }.flat_map(&:file_accessors)
19
+ end
20
+
21
+ def build(package_type)
22
+ case package_type
23
+ when :static_library
24
+ build_static_library
25
+ when :static_framework
26
+ build_static_framework
27
+ when :dynamic_framework
28
+ build_dynamic_framework
29
+ end
30
+ end
31
+
32
+ def build_static_library
33
+ UI.puts("Building static library #{@spec} with configuration #{@config}")
34
+
35
+ defines = compile
36
+ build_sim_libraries(defines)
37
+
38
+ platform_path = Pathname.new(@platform.name.to_s)
39
+ platform_path.mkdir unless platform_path.exist?
40
+
41
+ output = platform_path + "lib#{@spec.name}.a"
42
+
43
+ if @platform.name == :ios
44
+ build_static_library_for_ios(output)
45
+ else
46
+ build_static_library_for_mac(output)
47
+ end
48
+ end
49
+
50
+ def build_static_framework
51
+ UI.puts("Building static framework #{@spec} with configuration #{@config}")
52
+
53
+ defines = compile
54
+ build_sim_libraries(defines)
55
+
56
+ create_framework
57
+ output = @fwk.versions_path + Pathname.new(@spec.name)
58
+
59
+ if @platform.name == :ios
60
+ build_static_library_for_ios(output)
61
+ else
62
+ build_static_library_for_mac(output)
63
+ end
64
+
65
+ copy_headers
66
+ copy_license
67
+ copy_resources
68
+ end
69
+
70
+ def link_embedded_resources
71
+ target_path = @fwk.root_path + Pathname.new('Resources')
72
+ target_path.mkdir unless target_path.exist?
73
+
74
+ Dir.glob(@fwk.resources_path.to_s + '/*').each do |resource|
75
+ resource = Pathname.new(resource).relative_path_from(target_path)
76
+ `ln -sf #{resource} #{target_path}`
77
+ end
78
+ end
79
+
80
+ def build_dynamic_framework
81
+ UI.puts("Building dynamic framework #{@spec} with configuration #{@config}")
82
+
83
+ defines = compile
84
+ build_sim_libraries(defines)
85
+
86
+ if @bundle_identifier
87
+ defines = "#{defines} PRODUCT_BUNDLE_IDENTIFIER='#{@bundle_identifier}'"
88
+ end
89
+
90
+ output = "#{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name}"
91
+
92
+ clean_directory_for_dynamic_build
93
+ if @platform.name == :ios
94
+ build_dynamic_framework_for_ios(defines, output)
95
+ else
96
+ build_dynamic_framework_for_mac(defines, output)
97
+ end
98
+
99
+ copy_resources
100
+ end
101
+
102
+ def build_dynamic_framework_for_ios(defines, output)
103
+ # Specify frameworks to link and search paths
104
+ linker_flags = static_linker_flags_in_sandbox
105
+ defines = "#{defines} OTHER_LDFLAGS='$(inherited) #{linker_flags.join(' ')}'"
106
+
107
+ # Build Target Dynamic Framework for both device and Simulator
108
+ device_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
109
+ device_options = ios_build_options << ' -sdk iphoneos'
110
+ xcodebuild(device_defines, device_options, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
111
+
112
+ sim_defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build-sim\" ONLY_ACTIVE_ARCH=NO"
113
+ xcodebuild(sim_defines, '-sdk iphonesimulator', 'build-sim', @spec.name.to_s, @dynamic_sandbox_root.to_s)
114
+
115
+ # Combine architectures
116
+ `lipo #{@dynamic_sandbox_root}/build/#{@spec.name}.framework/#{@spec.name} #{@dynamic_sandbox_root}/build-sim/#{@spec.name}.framework/#{@spec.name} -create -output #{output}`
117
+
118
+ FileUtils.mkdir(@platform.name.to_s)
119
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
120
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
121
+ end
122
+
123
+ def build_dynamic_framework_for_mac(defines, _output)
124
+ # Specify frameworks to link and search paths
125
+ linker_flags = static_linker_flags_in_sandbox
126
+ defines = "#{defines} OTHER_LDFLAGS=\"#{linker_flags.join(' ')}\""
127
+
128
+ # Build Target Dynamic Framework for osx
129
+ defines = "#{defines} LIBRARY_SEARCH_PATHS=\"#{Dir.pwd}/#{@static_sandbox_root}/build\""
130
+ xcodebuild(defines, nil, 'build', @spec.name.to_s, @dynamic_sandbox_root.to_s)
131
+
132
+ FileUtils.mkdir(@platform.name.to_s)
133
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework #{@platform.name}`
134
+ `mv #{@dynamic_sandbox_root}/build/#{@spec.name}.framework.dSYM #{@platform.name}`
135
+ end
136
+
137
+ def build_sim_libraries(defines)
138
+ if @platform.name == :ios
139
+ xcodebuild(defines, '-sdk iphonesimulator', 'build-sim')
140
+ end
141
+ end
142
+
143
+ def build_static_library_for_ios(output)
144
+ static_libs = static_libs_in_sandbox('build') + static_libs_in_sandbox('build-sim') + vendored_libraries
145
+ libs = ios_architectures.map do |arch|
146
+ library = "#{@static_sandbox_root}/build/package-#{arch}.a"
147
+ `libtool -arch_only #{arch} -static -o #{library} #{static_libs.join(' ')}`
148
+ library
149
+ end
150
+
151
+ `lipo -create -output #{output} #{libs.join(' ')}`
152
+ end
153
+
154
+ def build_static_library_for_mac(output)
155
+ static_libs = static_libs_in_sandbox + vendored_libraries
156
+ `libtool -static -o #{output} #{static_libs.join(' ')}`
157
+ end
158
+
159
+ def build_with_mangling(options)
160
+ UI.puts 'Mangling symbols'
161
+ defines = Symbols.mangle_for_pod_dependencies(@spec.name, @static_sandbox_root)
162
+ defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
163
+
164
+ UI.puts 'Building mangled framework'
165
+ xcodebuild(defines, options)
166
+ defines
167
+ end
168
+
169
+ def clean_directory_for_dynamic_build
170
+ # Remove static headers to avoid duplicate declaration conflicts
171
+ FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Public/#{@spec.name}")
172
+ FileUtils.rm_rf("#{@static_sandbox_root}/Headers/Private/#{@spec.name}")
173
+
174
+ # Equivalent to removing derrived data
175
+ FileUtils.rm_rf('Pods/build')
176
+ end
177
+
178
+ def compile
179
+ defines = "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) PodsDummy_Pods_#{@spec.name}=PodsDummy_PodPackage_#{@spec.name}'"
180
+ defines << ' ' << @spec.consumer(@platform).compiler_flags.join(' ')
181
+
182
+ if @platform.name == :ios
183
+ options = ios_build_options
184
+ end
185
+
186
+ xcodebuild(defines, options)
187
+
188
+ if @mangle
189
+ return build_with_mangling(options)
190
+ end
191
+
192
+ defines
193
+ end
194
+
195
+ def copy_headers
196
+ headers_source_root = "#{@public_headers_root}/#{@spec.name}"
197
+
198
+ Dir.glob("#{headers_source_root}/**/*.h").
199
+ each { |h| `ditto #{h} #{@fwk.headers_path}/#{h.sub(headers_source_root, '')}` }
200
+
201
+ # If custom 'module_map' is specified add it to the framework distribution
202
+ # otherwise check if a header exists that is equal to 'spec.name', if so
203
+ # create a default 'module_map' one using it.
204
+ if !@spec.module_map.nil?
205
+ module_map_file = @file_accessors.flat_map(&:module_map).first
206
+ module_map = File.read(module_map_file) if Pathname(module_map_file).exist?
207
+ elsif File.exist?("#{@public_headers_root}/#{@spec.name}/#{@spec.name}.h")
208
+ module_map = <<MAP
209
+ framework module #{@spec.name} {
210
+ umbrella header "#{@spec.name}.h"
211
+
212
+ export *
213
+ module * { export * }
214
+ }
215
+ MAP
216
+ end
217
+
218
+ unless module_map.nil?
219
+ @fwk.module_map_path.mkpath unless @fwk.module_map_path.exist?
220
+ File.write("#{@fwk.module_map_path}/module.modulemap", module_map)
221
+ end
222
+ end
223
+
224
+ def copy_license
225
+ license_file = @spec.license[:file] || 'LICENSE'
226
+ license_file = Pathname.new("#{@static_sandbox_root}/#{@spec.name}/#{license_file}")
227
+ FileUtils.cp(license_file, '.') if license_file.exist?
228
+ end
229
+
230
+ def copy_resources
231
+ bundles = Dir.glob("#{@static_sandbox_root}/build/*.bundle")
232
+ if @dynamic
233
+ resources_path = "ios/#{@spec.name}.framework"
234
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{resources_path} 2>&1`
235
+ else
236
+ `cp -rp #{@static_sandbox_root}/build/*.bundle #{@fwk.resources_path} 2>&1`
237
+ resources = expand_paths(@spec.consumer(@platform).resources)
238
+ if resources.count == 0 && bundles.count == 0
239
+ @fwk.delete_resources
240
+ return
241
+ end
242
+ if resources.count > 0
243
+ `cp -rp #{resources.join(' ')} #{@fwk.resources_path}`
244
+ end
245
+ end
246
+ end
247
+
248
+ def create_framework
249
+ @fwk = Framework::Tree.new(@spec.name, @platform.name.to_s, @embedded)
250
+ @fwk.make
251
+ end
252
+
253
+ def dependency_count
254
+ count = @spec.dependencies.count
255
+
256
+ @spec.subspecs.each do |subspec|
257
+ count += subspec.dependencies.count
258
+ end
259
+
260
+ count
261
+ end
262
+
263
+ def expand_paths(path_specs)
264
+ path_specs.map do |path_spec|
265
+ Dir.glob(File.join(@source_dir, path_spec))
266
+ end
267
+ end
268
+
269
+ def static_libs_in_sandbox(build_dir = 'build')
270
+ if @exclude_deps
271
+ UI.puts 'Excluding dependencies'
272
+ Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib#{@spec.name}.a")
273
+ else
274
+ Dir.glob("#{@static_sandbox_root}/#{build_dir}/lib*.a")
275
+ end
276
+ end
277
+
278
+ def vendored_libraries
279
+ if @vendored_libraries
280
+ @vendored_libraries
281
+ end
282
+ file_accessors = if @exclude_deps
283
+ @file_accessors
284
+ else
285
+ @static_installer.pod_targets.flat_map(&:file_accessors)
286
+ end
287
+ libs = file_accessors.flat_map(&:vendored_static_frameworks).map { |f| f + f.basename('.*') } || []
288
+ libs += file_accessors.flat_map(&:vendored_static_libraries)
289
+ @vendored_libraries = libs.compact.map(&:to_s)
290
+ @vendored_libraries
291
+ end
292
+
293
+ def static_linker_flags_in_sandbox
294
+ linker_flags = static_libs_in_sandbox.map do |lib|
295
+ lib.slice!('lib')
296
+ lib_flag = lib.chomp('.a').split('/').last
297
+ "-l#{lib_flag}"
298
+ end
299
+ linker_flags.reject { |e| e == "-l#{@spec.name}" || e == '-lPods-packager' }
300
+ end
301
+
302
+ def ios_build_options
303
+ "ARCHS=\'#{ios_architectures.join(' ')}\' OTHER_CFLAGS=\'-fembed-bitcode -Qunused-arguments\'"
304
+ end
305
+
306
+ def ios_architectures
307
+ # archs = %w(x86_64 i386 arm64 armv7 armv7s) 暂时只编译x86_64 arm64
308
+ archs = %w(x86_64 arm64)
309
+ puts "archs support: #{archs}"
310
+ vendored_libraries.each do |library|
311
+ archs = `lipo -info #{library}`.split & archs
312
+ end
313
+ archs
314
+ end
315
+
316
+ def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-packager', project_root = @static_sandbox_root, config = @config)
317
+ if defined?(Pod::DONT_CODESIGN)
318
+ args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
319
+ end
320
+
321
+ command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj 2>&1"
322
+ output = `#{command}`.lines.to_a
323
+
324
+ if $?.exitstatus != 0
325
+ puts UI::BuildFailedReport.report(command, output)
326
+
327
+ # Note: We use `Process.exit` here because it fires a `SystemExit`
328
+ # exception, which gives the caller a chance to clean up before the
329
+ # process terminates.
330
+ #
331
+ # See http://ruby-doc.org/core-1.9.3/Process.html#method-c-exit
332
+ Process.exit
333
+ end
334
+ end
335
+ end
336
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-packagerthk/command/packagerthk'
@@ -0,0 +1,66 @@
1
+ module Framework
2
+ class Tree
3
+ attr_reader :headers_path
4
+ attr_reader :module_map_path
5
+ attr_reader :resources_path
6
+ attr_reader :root_path
7
+ attr_reader :versions_path
8
+
9
+ def delete_resources
10
+ Pathname.new(@resources_path).rmtree
11
+ (Pathname.new(@fwk_path) + Pathname.new('Resources')).delete
12
+ end
13
+
14
+ def initialize(name, platform, embedded)
15
+ @name = name
16
+ @platform = platform
17
+ @embedded = embedded
18
+ end
19
+
20
+ def make
21
+ make_root
22
+ make_framework
23
+ make_headers
24
+ make_resources
25
+ make_current_version
26
+ end
27
+
28
+ private
29
+
30
+ def make_current_version
31
+ current_version_path = @versions_path + Pathname.new('../Current')
32
+ `ln -sf A #{current_version_path}`
33
+ `ln -sf Versions/Current/Headers #{@fwk_path}/`
34
+ `ln -sf Versions/Current/Resources #{@fwk_path}/`
35
+ `ln -sf Versions/Current/#{@name} #{@fwk_path}/`
36
+ end
37
+
38
+ def make_framework
39
+ @fwk_path = @root_path + Pathname.new(@name + '.framework')
40
+ @fwk_path.mkdir unless @fwk_path.exist?
41
+
42
+ @module_map_path = @fwk_path + Pathname.new('Modules')
43
+ @versions_path = @fwk_path + Pathname.new('Versions/A')
44
+ end
45
+
46
+ def make_headers
47
+ @headers_path = @versions_path + Pathname.new('Headers')
48
+ @headers_path.mkpath unless @headers_path.exist?
49
+ end
50
+
51
+ def make_resources
52
+ @resources_path = @versions_path + Pathname.new('Resources')
53
+ @resources_path.mkpath unless @resources_path.exist?
54
+ end
55
+
56
+ def make_root
57
+ @root_path = Pathname.new(@platform)
58
+
59
+ if @embedded
60
+ @root_path += Pathname.new(@name + '.embeddedframework')
61
+ end
62
+
63
+ @root_path.mkpath unless @root_path.exist?
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsPackagerthk
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,32 @@
1
+ module Symbols
2
+ #
3
+ # performs symbol aliasing
4
+ #
5
+ # for each dependency:
6
+ # - determine symbols for classes and global constants
7
+ # - alias each symbol to Pod#{pod_name}_#{symbol}
8
+ # - put defines into `GCC_PREPROCESSOR_DEFINITIONS` for passing to Xcode
9
+ #
10
+ def mangle_for_pod_dependencies(pod_name, sandbox_root)
11
+ pod_libs = Dir.glob("#{sandbox_root}/build/lib*.a").select do |file|
12
+ file !~ /lib#{pod_name}.a$/
13
+ end
14
+
15
+ dummy_alias = alias_symbol "PodsDummy_#{pod_name}", pod_name
16
+ all_syms = [dummy_alias]
17
+
18
+ pod_libs.each do |pod_lib|
19
+ syms = Symbols.symbols_from_library(pod_lib)
20
+ all_syms += syms.map! { |sym| alias_symbol sym, pod_name }
21
+ end
22
+
23
+ "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) #{all_syms.uniq.join(' ')}'"
24
+ end
25
+
26
+ def alias_symbol(sym, pod_name)
27
+ pod_name = pod_name.tr('-', '_')
28
+ sym + "=Pod#{pod_name}_" + sym
29
+ end
30
+
31
+ module_function :mangle_for_pod_dependencies, :alias_symbol
32
+ end