cocoapods-packager-qcloud 1.5.1

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.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +4 -0
  4. data/.idea/.rakeTasks +7 -0
  5. data/.idea/misc.xml +4 -0
  6. data/.idea/modules.xml +8 -0
  7. data/.idea/vcs.xml +6 -0
  8. data/.rubocop-cocoapods.yml +71 -0
  9. data/.rubocop.yml +38 -0
  10. data/.travis.yml +9 -0
  11. data/Gemfile +12 -0
  12. data/Gemfile.lock +121 -0
  13. data/LICENSE +22 -0
  14. data/README.md +42 -0
  15. data/Rakefile +12 -0
  16. data/cocoapods-packager.gemspec +23 -0
  17. data/lib/cocoapods-packager/builder.rb +298 -0
  18. data/lib/cocoapods-packager/framework.rb +66 -0
  19. data/lib/cocoapods-packager/mangle.rb +32 -0
  20. data/lib/cocoapods-packager/pod_utils.rb +265 -0
  21. data/lib/cocoapods-packager/spec_builder.rb +63 -0
  22. data/lib/cocoapods-packager/symbols.rb +35 -0
  23. data/lib/cocoapods-packager/user_interface/build_failed_report.rb +15 -0
  24. data/lib/cocoapods_packager.rb +5 -0
  25. data/lib/cocoapods_plugin.rb +8 -0
  26. data/lib/pod/command/package.rb +173 -0
  27. data/scripts/lstconst.sh +9 -0
  28. data/scripts/lstsym.sh +8 -0
  29. data/spec/command/error_spec.rb +74 -0
  30. data/spec/command/package_spec.rb +359 -0
  31. data/spec/command/rctl_spec.rb +13 -0
  32. data/spec/command/subspecs_spec.rb +30 -0
  33. data/spec/fixtures/Builder.podspec +25 -0
  34. data/spec/fixtures/CPDColors.podspec +19 -0
  35. data/spec/fixtures/FH.podspec +18 -0
  36. data/spec/fixtures/KFData.podspec +73 -0
  37. data/spec/fixtures/LibraryConsumerDemo/.gitignore +22 -0
  38. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.pbxproj +340 -0
  39. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  40. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/xcshareddata/xcschemes/LibraryConsumer.xcscheme +100 -0
  41. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.h +17 -0
  42. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.m +27 -0
  43. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/Info.plist +40 -0
  44. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/main.m +16 -0
  45. data/spec/fixtures/LibraryConsumerDemo/Podfile +5 -0
  46. data/spec/fixtures/LibraryDemo.podspec +14 -0
  47. data/spec/fixtures/NikeKit.podspec +19 -0
  48. data/spec/fixtures/OpenSans.podspec +18 -0
  49. data/spec/fixtures/PackagerTest/.gitignore +21 -0
  50. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.pbxproj +536 -0
  51. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  52. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/xcshareddata/xcschemes/PackagerTest.xcscheme +110 -0
  53. data/spec/fixtures/PackagerTest/PackagerTest.xcworkspace/contents.xcworkspacedata +1 -0
  54. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.h +15 -0
  55. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.m +49 -0
  56. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  57. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  58. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Info.plist +38 -0
  59. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Prefix.pch +16 -0
  60. data/spec/fixtures/PackagerTest/PackagerTest/en.lproj/InfoPlist.strings +2 -0
  61. data/spec/fixtures/PackagerTest/PackagerTest/main.m +18 -0
  62. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests-Info.plist +22 -0
  63. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests.m +34 -0
  64. data/spec/fixtures/PackagerTest/PackagerTestTests/en.lproj/InfoPlist.strings +2 -0
  65. data/spec/fixtures/PackagerTest/Podfile +10 -0
  66. data/spec/fixtures/PackagerTest/Podfile.lock +32 -0
  67. data/spec/fixtures/Weakly.podspec +13 -0
  68. data/spec/fixtures/a.podspec +19 -0
  69. data/spec/fixtures/foo-bar.podspec +19 -0
  70. data/spec/fixtures/layer-client-messaging-schema.podspec +13 -0
  71. data/spec/integration/project_spec.rb +70 -0
  72. data/spec/pod/utils_spec.rb +58 -0
  73. data/spec/spec_helper.rb +50 -0
  74. data/spec/specification/builder_spec.rb +40 -0
  75. data/spec/specification/spec_builder_spec.rb +61 -0
  76. data/spec/user_interface/build_failed_report_spec.rb +11 -0
  77. metadata +232 -0
@@ -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,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
@@ -0,0 +1,265 @@
1
+ module Pod
2
+ class Command
3
+ class Package < Command
4
+ private
5
+
6
+ def build_static_sandbox(dynamic)
7
+ static_sandbox_root = if dynamic
8
+ Pathname.new(config.sandbox_root + '/Static')
9
+ else
10
+ Pathname.new(config.sandbox_root)
11
+ end
12
+ Sandbox.new(static_sandbox_root)
13
+ end
14
+
15
+ def install_pod(platform_name, sandbox)
16
+ podfile = podfile_from_spec(
17
+ File.basename(@path),
18
+ @spec.name,
19
+ platform_name,
20
+ @spec.deployment_target(platform_name),
21
+ @subspecs,
22
+ @spec_sources
23
+ )
24
+
25
+ static_installer = Installer.new(sandbox, podfile)
26
+ static_installer.install!
27
+
28
+ unless static_installer.nil?
29
+ static_installer.pods_project.targets.each do |target|
30
+ target.build_configurations.each do |config|
31
+ config.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
32
+ config.build_settings['GCC_GENERATE_DEBUGGING_SYMBOLS'] = 'NO'
33
+ end
34
+ end
35
+ static_installer.pods_project.save
36
+ end
37
+
38
+ static_installer
39
+ end
40
+
41
+ def podfile_from_spec(path, spec_name, platform_name, deployment_target, subspecs, sources)
42
+ options = {}
43
+ spec_path = @path
44
+ if spec_path
45
+ options[:podspec] = spec_path
46
+ else
47
+ options[:path] = '.'
48
+ end
49
+ puts "path is #{@path}"
50
+ options[:subspecs] = subspecs if subspecs
51
+ dependencies = @allLocalDependencies
52
+ Pod::Podfile.new do
53
+ sources.each { |s| source s }
54
+ platform(platform_name, deployment_target)
55
+ pod(spec_name, options)
56
+
57
+ install!('cocoapods',
58
+ :integrate_targets => false,
59
+ :deterministic_uuids => false)
60
+
61
+ if not dependencies.nil?
62
+ for dep in dependencies
63
+ pod dep.name , path:dep.path
64
+ puts "pod #{dep.name} #{dep.path}"
65
+ end
66
+ else
67
+ puts "depencies is nil"
68
+ end
69
+ target('packager') do
70
+ if spec_path
71
+ if subspecs
72
+ subspecs.each do |subspec|
73
+ pod spec_name + '/' + subspec, :podspec => spec_path
74
+ end
75
+ else
76
+ pod spec_name, :podspec => spec_path
77
+ end
78
+ elsif subspecs
79
+ subspecs.each do |subspec|
80
+ pod spec_name + '/' + subspec, :path => '.'
81
+ end
82
+ else
83
+ pod spec_name, :path => '.'
84
+ end
85
+ end
86
+
87
+
88
+ end
89
+ end
90
+
91
+ def binary_only?(spec)
92
+ deps = spec.dependencies.map { |dep| spec_with_name(dep.name) }
93
+ [spec, *deps].each do |specification|
94
+ %w(vendored_frameworks vendored_libraries).each do |attrib|
95
+ if specification.attributes_hash[attrib]
96
+ return true
97
+ end
98
+ end
99
+ end
100
+
101
+ false
102
+ end
103
+
104
+ def spec_with_name(name)
105
+ return if name.nil?
106
+
107
+ set = Pod::Config.instance.sources_manager.search(Dependency.new(name))
108
+ return nil if set.nil?
109
+
110
+ set.specification.root
111
+ end
112
+
113
+ def spec_with_path(path)
114
+ return if path.nil? || !Pathname.new(path).exist?
115
+ @path = Pathname(path).realpath.to_path
116
+ puts "path is #{@path}"
117
+
118
+ if Pathname.new(path).directory?
119
+ help! path + ': is a directory.'
120
+ return
121
+ end
122
+
123
+ unless ['.podspec', '.json'].include? Pathname.new(path).extname
124
+ help! path + ': is not a podspec.'
125
+ return
126
+ end
127
+
128
+ Specification.from_file(path)
129
+ end
130
+
131
+ #----------------------
132
+ # Dynamic Project Setup
133
+ #----------------------
134
+
135
+ def build_dynamic_sandbox(_static_sandbox, _static_installer)
136
+ dynamic_sandbox_root = Pathname.new(config.sandbox_root + '/Dynamic')
137
+ dynamic_sandbox = Sandbox.new(dynamic_sandbox_root)
138
+
139
+ dynamic_sandbox
140
+ end
141
+
142
+ def install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer)
143
+ # 1 Create a dynamic target for only the spec pod.
144
+ dynamic_target = build_dynamic_target(dynamic_sandbox, static_installer)
145
+
146
+ # 2. Build a new xcodeproj in the dynamic_sandbox with only the spec pod as a target.
147
+ project = prepare_pods_project(dynamic_sandbox, dynamic_target.name, static_installer)
148
+
149
+ # 3. Copy the source directory for the dynamic framework from the static sandbox.
150
+ copy_dynamic_target(static_sandbox, dynamic_target, dynamic_sandbox)
151
+
152
+ # 4. Copy the supporting files for the dynamic framework from the static sandbox.
153
+ copy_dynamic_supporting_files(static_sandbox, dynamic_target, dynamic_sandbox)
154
+
155
+ # 5. Update the file accecssors.
156
+ dynamic_target = update_file_accessors(dynamic_target, dynamic_sandbox)
157
+
158
+ # 6. Create the file references.
159
+ install_file_references(dynamic_sandbox, [dynamic_target], project)
160
+
161
+ # 7. Install the target.
162
+ install_library(dynamic_sandbox, dynamic_target)
163
+
164
+ # 9. Write the actual Xcodeproject to the dynamic sandbox.
165
+ write_pod_project(project, dynamic_sandbox)
166
+ end
167
+
168
+ def build_dynamic_target(dynamic_sandbox, static_installer)
169
+ spec_targets = static_installer.pod_targets.select do |target|
170
+ target.name == @spec.name
171
+ end
172
+ static_target = spec_targets[0]
173
+
174
+ dynamic_target = Pod::PodTarget.new(static_target.specs, static_target.target_definitions, dynamic_sandbox)
175
+ dynamic_target.host_requires_frameworks = true
176
+ dynamic_target.user_build_configurations = static_target.user_build_configurations
177
+ dynamic_target
178
+ end
179
+
180
+ def prepare_pods_project(dynamic_sandbox, spec_name, installer)
181
+ # Create a new pods project
182
+ pods_project = Pod::Project.new(dynamic_sandbox.project_path)
183
+
184
+ # Update build configurations
185
+ installer.analysis_result.all_user_build_configurations.each do |name, type|
186
+ pods_project.add_build_configuration(name, type)
187
+ end
188
+
189
+ # Add the pod group for only the dynamic framework
190
+ local = dynamic_sandbox.local?(spec_name)
191
+ path = dynamic_sandbox.pod_dir(spec_name)
192
+ was_absolute = dynamic_sandbox.local_path_was_absolute?(spec_name)
193
+ pods_project.add_pod_group(spec_name, path, local, was_absolute)
194
+
195
+ dynamic_sandbox.project = pods_project
196
+ pods_project
197
+ end
198
+
199
+ def copy_dynamic_target(static_sandbox, _dynamic_target, dynamic_sandbox)
200
+ command = "cp -a #{static_sandbox.root}/#{@spec.name} #{dynamic_sandbox.root}"
201
+ `#{command}`
202
+ end
203
+
204
+ def copy_dynamic_supporting_files(_static_sandbox, dynamic_target, _dynamic_sandbox)
205
+ support_dir = Pathname.new(dynamic_target.support_files_dir.to_s.chomp("/#{dynamic_target.name}"))
206
+ support_dir.mkdir
207
+ end
208
+
209
+ def update_file_accessors(dynamic_target, dynamic_sandbox)
210
+ pod_root = dynamic_sandbox.pod_dir(dynamic_target.root_spec.name)
211
+
212
+ path_list = Sandbox::PathList.new(pod_root)
213
+ file_accessors = dynamic_target.specs.map do |spec|
214
+ Sandbox::FileAccessor.new(path_list, spec.consumer(dynamic_target.platform))
215
+ end
216
+
217
+ dynamic_target.file_accessors = file_accessors
218
+ dynamic_target
219
+ end
220
+
221
+ def install_file_references(dynamic_sandbox, pod_targets, pods_project)
222
+ installer = Pod::Installer::Xcode::PodsProjectGenerator::FileReferencesInstaller.new(dynamic_sandbox, pod_targets, pods_project)
223
+ installer.install!
224
+ end
225
+
226
+ def install_library(dynamic_sandbox, dynamic_target)
227
+ return if dynamic_target.target_definitions.flat_map(&:dependencies).empty?
228
+ target_installer = Pod::Installer::Xcode::PodsProjectGenerator::PodTargetInstaller.new(dynamic_sandbox, dynamic_target)
229
+ target_installer.install!
230
+
231
+ # Installs System Frameworks
232
+ dynamic_target.file_accessors.each do |file_accessor|
233
+ file_accessor.spec_consumer.frameworks.each do |framework|
234
+ if dynamic_target.should_build?
235
+ dynamic_target.native_target.add_system_framework(framework)
236
+ end
237
+ end
238
+
239
+ file_accessor.spec_consumer.libraries.each do |library|
240
+ if dynamic_target.should_build?
241
+ dynamic_target.native_target.add_system_library(library)
242
+ end
243
+ end
244
+ end
245
+ end
246
+
247
+ def write_pod_project(dynamic_project, dynamic_sandbox)
248
+ UI.message "- Writing Xcode project file to #{UI.path dynamic_sandbox.project_path}" do
249
+ dynamic_project.pods.remove_from_project if dynamic_project.pods.empty?
250
+ dynamic_project.development_pods.remove_from_project if dynamic_project.development_pods.empty?
251
+ dynamic_project.sort(:groups_position => :below)
252
+ dynamic_project.recreate_user_schemes(false)
253
+
254
+ # Edit search paths so that we can find our dependency headers
255
+ dynamic_project.targets.first.build_configuration_list.build_configurations.each do |config|
256
+ config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
257
+ config.build_settings['USER_HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
258
+ config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -ObjC'
259
+ end
260
+ dynamic_project.save
261
+ end
262
+ end
263
+ end
264
+ end
265
+ end
@@ -0,0 +1,63 @@
1
+ module Pod
2
+ class SpecBuilder
3
+ def initialize(spec, source, embedded, dynamic)
4
+ @spec = spec
5
+ @source = source.nil? ? '{ :path => \'.\' }' : source
6
+ @embedded = embedded
7
+ @dynamic = dynamic
8
+ end
9
+
10
+ def framework_path
11
+ if @embedded
12
+ @spec.name + '.embeddedframework' + '/' + @spec.name + '.framework'
13
+ else
14
+ @spec.name + '.framework'
15
+ end
16
+ end
17
+
18
+ def spec_platform(platform)
19
+ fwk_base = platform.name.to_s + '/' + framework_path
20
+ spec = <<RB
21
+ s.#{platform.name}.deployment_target = '#{platform.deployment_target}'
22
+ s.#{platform.name}.vendored_framework = '#{fwk_base}'
23
+ RB
24
+
25
+ %w(frameworks weak_frameworks libraries requires_arc xcconfig).each do |attribute|
26
+ attributes_hash = @spec.attributes_hash[platform.name.to_s]
27
+ next if attributes_hash.nil?
28
+ value = attributes_hash[attribute]
29
+ next if value.nil?
30
+
31
+ value = "'#{value}'" if value.class == String
32
+ spec += " s.#{platform.name}.#{attribute} = #{value}\n"
33
+ end
34
+ spec
35
+ end
36
+
37
+ def spec_metadata
38
+ spec = spec_header
39
+ spec
40
+ end
41
+
42
+ def spec_close
43
+ "end\n"
44
+ end
45
+
46
+ private
47
+
48
+ def spec_header
49
+ spec = "Pod::Spec.new do |s|\n"
50
+
51
+ %w(name version summary license authors homepage description social_media_url
52
+ docset_url documentation_url screenshots frameworks weak_frameworks libraries requires_arc
53
+ deployment_target xcconfig).each do |attribute|
54
+ value = @spec.attributes_hash[attribute]
55
+ next if value.nil?
56
+ value = value.dump if value.class == String
57
+ spec += " s.#{attribute} = #{value}\n"
58
+ end
59
+
60
+ spec + " s.source = #{@source}\n\n"
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,35 @@
1
+ module Symbols
2
+ def symbols_from_library(library)
3
+ syms = `nm -gU #{library}`.split("\n")
4
+ result = classes_from_symbols(syms)
5
+ result += constants_from_symbols(syms)
6
+
7
+ result.reject { |e| e == 'llvm.cmdline' || e == 'llvm.embedded.module' }
8
+ end
9
+
10
+ module_function :symbols_from_library
11
+
12
+ private
13
+
14
+ def classes_from_symbols(syms)
15
+ classes = syms.select { |klass| klass[/OBJC_CLASS_\$_/] }
16
+ classes = classes.uniq
17
+ classes.map! { |klass| klass.gsub(/^.*\$_/, '') }
18
+ end
19
+
20
+ def constants_from_symbols(syms)
21
+ consts = syms.select { |const| const[/ S /] }
22
+ consts = consts.select { |const| const !~ /OBJC|\.eh/ }
23
+ consts = consts.uniq
24
+ consts = consts.map! { |const| const.gsub(/^.* _/, '') }
25
+
26
+ other_consts = syms.select { |const| const[/ T /] }
27
+ other_consts = other_consts.uniq
28
+ other_consts = other_consts.map! { |const| const.gsub(/^.* _/, '') }
29
+
30
+ consts + other_consts
31
+ end
32
+
33
+ module_function :classes_from_symbols
34
+ module_function :constants_from_symbols
35
+ end