cocoapods-hmap-simple 1.0.1 → 1.0.2
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 +4 -4
- data/lib/hmap_optimize.rb +76 -89
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 533c0f5130721d03cd3f2faf06d940caa8b82e60015eb76c35a4ce2f108d1389
|
4
|
+
data.tar.gz: 1d39859b22204520e9a18c78154c4a560fa831b0d7bc0bfe2303ab36d4c20cd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfbcb9cf8fad7c176e82fbbf03f9213ce25f146e0429989979baf9e61d71f71f81006a2ee0985dc0b7228ba26accb76988224fe65012404851220b2f2f998daf
|
7
|
+
data.tar.gz: 4f4281be9706877de371d7aca837f5a6521863b090a6ea2d741ac9deebe4a1a48c6040b5369f947cf03657218a6fdc03b107d2ec2ad03e58742d24b5e910a257
|
data/lib/hmap_optimize.rb
CHANGED
@@ -4,132 +4,119 @@ combining "${PODS_ROOT}/Headers/Public/*" to a single hmap. (not including ${POD
|
|
4
4
|
=end
|
5
5
|
|
6
6
|
module Pod
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
sub_header_hash = {}
|
35
|
-
sub_header_hash['suffix'] = File.basename(header)
|
36
|
-
sub_header_hash['prefix'] = prefix + "/"
|
37
|
-
|
38
|
-
[file_name, sub_header_hash]
|
7
|
+
class HmapHelper
|
8
|
+
def self.post_install(installer)
|
9
|
+
to_remove = -> path { path.include?("${PODS_ROOT}/Headers/Public/") }
|
10
|
+
|
11
|
+
headers_for_path = -> path do
|
12
|
+
@cached_headers ||= {}
|
13
|
+
cached = @cached_headers.fetch(path, {})
|
14
|
+
return cached unless cached.blank?
|
15
|
+
|
16
|
+
full_path = path.sub(/^\$\{PODS_ROOT\}/, installer.sandbox.root.to_s)
|
17
|
+
headers = Dir.glob("#{full_path}/**/{*.h,*.hpp}")
|
18
|
+
return {} if headers.blank?
|
19
|
+
|
20
|
+
target_headers_hash = headers.to_h do |header|
|
21
|
+
prefix = File.dirname(header)
|
22
|
+
relative_dir = prefix.sub(/^#{full_path}/, '').sub(/^\//, '')
|
23
|
+
file_name = File.basename(header)
|
24
|
+
file_name = File.join(relative_dir, file_name) unless relative_dir.blank?
|
25
|
+
|
26
|
+
sub_header_hash = {}
|
27
|
+
sub_header_hash['suffix'] = File.basename(header)
|
28
|
+
sub_header_hash['prefix'] = prefix + "/"
|
29
|
+
|
30
|
+
[file_name, sub_header_hash]
|
31
|
+
end
|
32
|
+
@cached_headers[path] = target_headers_hash
|
33
|
+
target_headers_hash
|
39
34
|
end
|
40
|
-
@cached_headers[path] = target_headers_hash
|
41
|
-
target_headers_hash
|
42
|
-
end
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
create_hmap = -> build_settings do
|
37
|
+
header_search_paths = build_settings.header_search_paths
|
38
|
+
return if header_search_paths.blank?
|
47
39
|
|
48
|
-
|
49
|
-
|
40
|
+
convert_paths = header_search_paths.select { |p| to_remove.call(p) }
|
41
|
+
return if convert_paths.blank?
|
50
42
|
|
51
|
-
|
52
|
-
|
43
|
+
convert_paths_string = convert_paths.join(" ")&.strip
|
44
|
+
md5_string = Digest::MD5.hexdigest(convert_paths_string)
|
53
45
|
|
54
|
-
|
46
|
+
UI.message "md5(#{convert_paths_string})=#{md5_string}"
|
55
47
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
48
|
+
hmap_dir = File.expand_path("Headers/hmap", installer.sandbox.root.to_s)
|
49
|
+
hmap_path = File.expand_path("#{md5_string}.hmap", hmap_dir)
|
50
|
+
if File.exist?(hmap_path)
|
51
|
+
return md5_string
|
52
|
+
end
|
62
53
|
|
63
|
-
|
64
|
-
|
54
|
+
header_path_hash = convert_paths.map { |x| headers_for_path.call(x) }.inject(:merge)
|
55
|
+
return if header_path_hash.blank?
|
65
56
|
|
66
|
-
begin
|
67
57
|
FileUtils.mkdir_p(hmap_dir) unless File.directory?(hmap_dir)
|
68
58
|
json_path = File.expand_path("#{md5_string}.json", hmap_dir)
|
69
59
|
File.open(json_path, 'w') do |file|
|
70
60
|
file << header_path_hash.to_json
|
71
61
|
end
|
72
62
|
|
73
|
-
|
63
|
+
hmap = File.expand_path("hmap", File.dirname(__FILE__ ))
|
64
|
+
`#{hmap} convert '#{json_path}' '#{hmap_path}' `
|
74
65
|
File.delete(json_path)
|
75
66
|
|
76
|
-
build_settings.hmap_md5 = md5_string
|
77
67
|
UI.message "created hmap #{hmap_path}"
|
78
|
-
|
79
|
-
UI.warn "create hmap error: #{e.inspect}"
|
68
|
+
return md5_string
|
80
69
|
end
|
81
|
-
end
|
82
70
|
|
83
|
-
|
84
|
-
|
85
|
-
`#{hmap} convert '#{public_json}' '#{public_hmap}' `
|
86
|
-
end
|
71
|
+
handle_target_with_settings = -> hmap_md5, target, config do
|
72
|
+
return if hmap_md5.blank?
|
87
73
|
|
88
|
-
|
89
|
-
|
74
|
+
xcconfig_path = target.xcconfig_path(config)
|
75
|
+
xcconfig = Xcodeproj::Config.new(xcconfig_path)
|
90
76
|
|
91
|
-
|
92
|
-
|
77
|
+
hmap_path = File.expand_path("Headers/hmap/#{hmap_md5}.hmap", installer.sandbox.root.to_s)
|
78
|
+
return unless File.exist?(hmap_path)
|
93
79
|
|
94
|
-
|
80
|
+
hmap_item = "\"${PODS_ROOT}/Headers/hmap/#{hmap_md5}.hmap\""
|
95
81
|
|
96
|
-
|
97
|
-
|
82
|
+
header_search_paths = xcconfig.to_hash['HEADER_SEARCH_PATHS']
|
83
|
+
path_items = header_search_paths.split(/\s+/)
|
98
84
|
|
99
|
-
|
100
|
-
|
85
|
+
keep_paths = path_items.reject { |p| to_remove.call(p) }
|
86
|
+
keep_paths << hmap_item
|
101
87
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
88
|
+
new_header_search_paths = keep_paths.join(" ")
|
89
|
+
xcconfig.attributes['HEADER_SEARCH_PATHS'] = new_header_search_paths
|
90
|
+
xcconfig.save_as(xcconfig_path)
|
91
|
+
end
|
106
92
|
|
107
|
-
# hook point
|
108
|
-
alias_method :_old_run_podfile_post_install_hook, :run_podfile_post_install_hook
|
109
|
-
def run_podfile_post_install_hook
|
110
93
|
# 生成 hmap file,然后修改 xcconfig 文件
|
111
|
-
aggregate_targets.each do |aggregate_target|
|
94
|
+
installer.aggregate_targets.each do |aggregate_target|
|
112
95
|
UI.message "convert hmap for aggregate_target #{aggregate_target}"
|
113
96
|
aggregate_target.user_build_configurations.each_key do |config| # "Debug" => :debug
|
114
97
|
build_settings = aggregate_target.build_settings(config) # AggregateTargetSettings
|
115
|
-
create_hmap(build_settings)
|
116
|
-
|
117
|
-
xcconfig_path = aggregate_target.xcconfig_path(config)
|
118
|
-
xcconfig = aggregate_target.xcconfigs[config]
|
119
|
-
handle_target_with_settings(build_settings, xcconfig, xcconfig_path)
|
98
|
+
hmap_md5 = create_hmap.call(build_settings)
|
99
|
+
handle_target_with_settings.call(hmap_md5, aggregate_target, config)
|
120
100
|
end
|
121
101
|
end
|
122
102
|
|
123
|
-
pod_targets.each do |pod_target|
|
103
|
+
installer.pod_targets.each do |pod_target|
|
124
104
|
UI.message "convert hmap for pod_target #{pod_target}"
|
125
105
|
pod_target.build_settings.each do |config, build_settings| # "Debug" => PodTargetSettings
|
126
|
-
create_hmap(build_settings)
|
127
|
-
|
128
|
-
xcconfig_path = pod_target.xcconfig_path(config)
|
129
|
-
xcconfig = Xcodeproj::Config.new(xcconfig_path)
|
130
|
-
handle_target_with_settings(build_settings, xcconfig, xcconfig_path)
|
106
|
+
hmap_md5 = create_hmap.call(build_settings)
|
107
|
+
handle_target_with_settings.call(hmap_md5, pod_target, config)
|
131
108
|
end
|
132
109
|
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# hook point
|
115
|
+
module Pod
|
116
|
+
class Installer
|
117
|
+
alias_method :_old_run_podfile_post_install_hook, :run_podfile_post_install_hook
|
118
|
+
def run_podfile_post_install_hook
|
119
|
+
HmapHelper.post_install(self)
|
133
120
|
|
134
121
|
_old_run_podfile_post_install_hook
|
135
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-hmap-simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shyang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
This plugin modifies HEADER_SEARCH_PATHS in Pods/Target Support Files/*/*.xcconfig
|
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
43
|
requirements: []
|
44
|
-
rubygems_version: 3.
|
44
|
+
rubygems_version: 3.0.3
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: A simple hmap generating plugin for cocoapods.
|