cocoapods-link-filelist 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 92cf18ef391c7df06142c2147dd6716d32c26ef6683ebcb29e1f4237b790f28d
4
+ data.tar.gz: 3ef7eea18e4d5f266022e5cd61e708d3ef46154592efe32d1d98ab43ae6e7e4d
5
+ SHA512:
6
+ metadata.gz: 499f7776bfd166d434e12ccc841e141c35ca829c2b335e5a05024ce7569c502550bb19ed929e033c5359275c6da240c237af027022235843a77953a2ce86e0e5
7
+ data.tar.gz: cd9bad8ac7222d64ca03309483f9e94b7542ae41c91d054f43812976250f65717bb8695c2613cdf9d1785fc638a16b3330299cf8b95c33e9e3ec36ef80b9c6c0
@@ -0,0 +1,2 @@
1
+
2
+ require 'link_filelist_optimize'
@@ -0,0 +1,147 @@
1
+
2
+ module Pod
3
+ class Target
4
+ class BuildSettings
5
+ class AggregateTargetSettings
6
+
7
+ def device_sdk_path
8
+ @device_sdk_path ||= `xcrun --sdk iphoneos --show-sdk-path`.strip
9
+ end
10
+
11
+ def simulator_sdk_path
12
+ @simulator_sdk_path ||= `xcrun --sdk iphonesimulator --show-sdk-path`.strip
13
+ end
14
+
15
+ def find_path_of_lib(lib_name)
16
+ storage_lib_name = "lib" + lib_name + ".tbd"
17
+ library_path = File.expand_path(storage_lib_name, '/usr/lib')
18
+ return library_path if File.exist?(device_sdk_path + library_path)
19
+ end
20
+
21
+ def find_path_of_framework(framework_name)
22
+ storage_framework_path = framework_name + ".framework/" + framework_name + ".tbd"
23
+ framework_path = File.expand_path(storage_framework_path, '/System/Library/Frameworks')
24
+ return framework_path if File.exist?(device_sdk_path + framework_path)
25
+ end
26
+
27
+ # xcconfig 总所有配置的 key => value
28
+ def to_h
29
+ hash = super()
30
+ hash.delete('LIBRARY_SEARCH_PATHS')
31
+ hash.delete('FRAMEWORK_SEARCH_PATHS')
32
+
33
+ if defined?(@ld_flags_for_any_arch) && !@ld_flags_for_any_arch.blank?
34
+ hash['OTHER_LDFLAGS[arch=*]'] = @ld_flags_for_any_arch
35
+ end
36
+
37
+ if defined?(@ld_flags_for_device) && !@ld_flags_for_device.blank?
38
+ hash['OTHER_LDFLAGS[arch=armv7]'] = @ld_flags_for_device
39
+ hash['OTHER_LDFLAGS[arch=arm64]'] = @ld_flags_for_device
40
+ hash['OTHER_LDFLAGS[arch=i386]'] = @ld_flags_for_simulator
41
+ hash['OTHER_LDFLAGS[arch=x86_64]'] = @ld_flags_for_simulator
42
+ end
43
+ hash
44
+ end
45
+
46
+ def _raw_other_ldflags
47
+ # 每个 Pod 自带内部的 .a .framework
48
+ vendored_paths = {}
49
+ pod_targets.each do |pod_target|
50
+ pod_target.file_accessors.each do |acc|
51
+ (acc.vendored_dynamic_libraries + acc.vendored_static_libraries).each do |l|
52
+ library_name = File.basename(l, l.extname).sub(/^lib/, '')
53
+ vendored_paths[library_name] = l.to_s
54
+ end
55
+
56
+ (acc.vendored_dynamic_frameworks + acc.vendored_static_frameworks).each do |l|
57
+ framework_name = File.basename(l, l.extname)
58
+ vendored_paths[framework_name] = l.to_s
59
+ end
60
+ end
61
+ end
62
+
63
+ base_file_path = "#{target.name}.#{@configuration_name.to_s.downcase}"
64
+ xcconfig_dir = File.expand_path("Target Support Files/#{target.name}", self.target.sandbox.root.to_s)
65
+
66
+ vendored_file_path = File.expand_path("#{base_file_path}.vendored.filelist", xcconfig_dir)
67
+ vendored_files = []
68
+
69
+ intermediates_file_path = File.expand_path("#{base_file_path}.intermediates.filelist", xcconfig_dir)
70
+ intermediates_files = []
71
+
72
+ system_file_path = File.expand_path("#{base_file_path}.system.filelist", xcconfig_dir)
73
+ system_files = []
74
+
75
+ ld_flags = []
76
+ ld_flags << '-ObjC' if requires_objc_linker_flag?
77
+ if requires_fobjc_arc?
78
+ ld_flags << '-fobjc-arc'
79
+ end
80
+
81
+ libraries.each do |library_name|
82
+ library_path = vendored_paths[library_name]
83
+ if library_path
84
+ vendored_files << library_path
85
+ else
86
+ library_path = find_path_of_lib(library_name)
87
+ if library_path
88
+ system_files << library_path
89
+ else
90
+ intermediates_files << "#{library_name}/lib#{library_name}.a"
91
+ end
92
+ end
93
+ end
94
+
95
+ frameworks.each do |framework_name|
96
+ framework_path = nil
97
+ framework_path = vendored_paths[framework_name] + "/" + framework_name unless vendored_paths[framework_name].nil?
98
+ if framework_path
99
+ vendored_files << framework_path
100
+ else
101
+ framework_path = find_path_of_framework(framework_name)
102
+ if framework_path
103
+ system_files << framework_path
104
+ else
105
+ raise "Can't find framework #{framework_name}"
106
+ end
107
+ end
108
+ end
109
+
110
+ extra_ld_info = "$(inherited) "
111
+ if !intermediates_files.empty?
112
+ File.open(intermediates_file_path, 'w') do |f|
113
+ f.puts(intermediates_files)
114
+ end
115
+ extra_ld_info += "-filelist \"#{intermediates_file_path},${PODS_CONFIGURATION_BUILD_DIR}\" "
116
+ end
117
+
118
+ if !vendored_files.empty?
119
+ File.open(vendored_file_path, 'w') do |f|
120
+ f.puts(vendored_files)
121
+ end
122
+ extra_ld_info += "-filelist \"#{vendored_file_path}\""
123
+ end
124
+
125
+ if !intermediates_files.empty? || !vendored_files.empty?
126
+ @ld_flags_for_any_arch = extra_ld_info.strip
127
+ end
128
+
129
+ if !system_files.empty?
130
+ File.open(system_file_path, 'w') do |f|
131
+ f.puts(system_files)
132
+ end
133
+ @ld_flags_for_device = "$(inherited) -filelist \"#{system_file_path},#{device_sdk_path}\""
134
+ @ld_flags_for_simulator = "$(inherited) -filelist \"#{system_file_path},#{simulator_sdk_path}\""
135
+ end
136
+
137
+ weak_frameworks.each { |f| ld_flags << '-weak_framework' << %("#{f}") }
138
+ ld_flags
139
+ end
140
+
141
+ attr_accessor :ld_flags_for_any_arch
142
+ attr_accessor :ld_flags_for_device
143
+ attr_accessor :ld_flags_for_simulator
144
+ end
145
+ end
146
+ end
147
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-link-filelist
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - shyang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-03-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |-
14
+ This plugin modifies LD_FLAGS in Pods/Target Support Files/*/*.xcconfig
15
+ replacing multiple -l flags with a single filelist to speed up linking.
16
+ email:
17
+ - shaohua0110@yahoo.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/cocoapods_plugin.rb
23
+ - lib/link_filelist_optimize.rb
24
+ homepage: https://github.com/shyang/cocoapods-link-filelist
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 2.6.0
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.0.3
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: A filelist substitution plugin for cocoapods.
47
+ test_files: []