cocoapods-hmap-simple 1.0.1 → 1.0.4
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 +77 -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: 2a3b893c05e8ef2c396266909325327cbe743f58aaef2273ae2c68c73908b98a
|
4
|
+
data.tar.gz: 858a3e1164807760c20e02315a4da1808cdbf80e1266e2409dddfa0ed1bd3aa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a21d12e5951be1ad6b712df56278ddbbddaafa80b57826f036fe720ac388f50b9a8c8b3eab7d6ce2e9a96457fb28bf6096455738c459912809c5c54e1cd08bed
|
7
|
+
data.tar.gz: dd2187bdd5c9a93ea2a0d7ab485759e47c4203b2f214d10a9badf66d4979e304a497633ca7445678e4d7bf1b0e86c46e599f46c83061ae026169eacb44cf8ef4
|
data/lib/hmap_optimize.rb
CHANGED
@@ -4,132 +4,120 @@ 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/") || path.include?("${PODS_ROOT}/Headers/hmap/") }
|
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
|
+
return unless File.exist?(xcconfig_path)
|
76
|
+
xcconfig = Xcodeproj::Config.new(xcconfig_path)
|
90
77
|
|
91
|
-
|
92
|
-
|
78
|
+
hmap_path = File.expand_path("Headers/hmap/#{hmap_md5}.hmap", installer.sandbox.root.to_s)
|
79
|
+
return unless File.exist?(hmap_path)
|
93
80
|
|
94
|
-
|
81
|
+
hmap_item = "\"${PODS_ROOT}/Headers/hmap/#{hmap_md5}.hmap\""
|
95
82
|
|
96
|
-
|
97
|
-
|
83
|
+
header_search_paths = xcconfig.to_hash['HEADER_SEARCH_PATHS']
|
84
|
+
path_items = header_search_paths.split(/\s+/)
|
98
85
|
|
99
|
-
|
100
|
-
|
86
|
+
keep_paths = path_items.reject { |p| to_remove.call(p) }
|
87
|
+
keep_paths << hmap_item
|
101
88
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
89
|
+
new_header_search_paths = keep_paths.join(" ")
|
90
|
+
xcconfig.attributes['HEADER_SEARCH_PATHS'] = new_header_search_paths
|
91
|
+
xcconfig.save_as(xcconfig_path)
|
92
|
+
end
|
106
93
|
|
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
94
|
# 生成 hmap file,然后修改 xcconfig 文件
|
111
|
-
aggregate_targets.each do |aggregate_target|
|
95
|
+
installer.aggregate_targets.each do |aggregate_target|
|
112
96
|
UI.message "convert hmap for aggregate_target #{aggregate_target}"
|
113
97
|
aggregate_target.user_build_configurations.each_key do |config| # "Debug" => :debug
|
114
98
|
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)
|
99
|
+
hmap_md5 = create_hmap.call(build_settings)
|
100
|
+
handle_target_with_settings.call(hmap_md5, aggregate_target, config)
|
120
101
|
end
|
121
102
|
end
|
122
103
|
|
123
|
-
pod_targets.each do |pod_target|
|
104
|
+
installer.pod_targets.each do |pod_target|
|
124
105
|
UI.message "convert hmap for pod_target #{pod_target}"
|
125
106
|
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)
|
107
|
+
hmap_md5 = create_hmap.call(build_settings)
|
108
|
+
handle_target_with_settings.call(hmap_md5, pod_target, config)
|
131
109
|
end
|
132
110
|
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# hook point
|
116
|
+
module Pod
|
117
|
+
class Installer
|
118
|
+
alias_method :_old_run_podfile_post_install_hook, :run_podfile_post_install_hook
|
119
|
+
def run_podfile_post_install_hook
|
120
|
+
HmapHelper.post_install(self)
|
133
121
|
|
134
122
|
_old_run_podfile_post_install_hook
|
135
123
|
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.4
|
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.
|