cocoapods-hmap-simple 1.0.0 → 1.0.3
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 +0 -0
- data/lib/hmap_optimize.rb +125 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25a712f2bbda85f5c9c28c4d34c1d48666d9f6485fe688533d6ba028b6d78b1a
|
4
|
+
data.tar.gz: 1d2086d27a19d1d8872924be8161dafd8e7da37b01cc1caba337ed5fae9dde29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ee2903119b65f1c552671e9d19b40e8fdbb477e8bc065a48fbe2aa64c6f19f78e44b206c5cb9f4f8e6035d8358ebf48188d3913df827ce79b6b580fe97b8eee
|
7
|
+
data.tar.gz: 956a599aec20ec0af62992b9127a794fe3b4d8253d645d83c0800ca36de889f1b0420be7f8dcbe57eb9a8e48ab0d438e054830cf754d6db894019de6c4939257
|
data/lib/hmap
ADDED
Binary file
|
@@ -0,0 +1,125 @@
|
|
1
|
+
=begin
|
2
|
+
This plugin modifies HEADER_SEARCH_PATHS in Pods/Target Support Files/*/*.xcconfig
|
3
|
+
combining "${PODS_ROOT}/Headers/Public/*" to a single hmap. (not including ${PODS_ROOT}/Headers/Public itself)
|
4
|
+
=end
|
5
|
+
|
6
|
+
module Pod
|
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
|
34
|
+
end
|
35
|
+
|
36
|
+
create_hmap = -> build_settings do
|
37
|
+
header_search_paths = build_settings.header_search_paths
|
38
|
+
return if header_search_paths.blank?
|
39
|
+
|
40
|
+
convert_paths = header_search_paths.select { |p| to_remove.call(p) }
|
41
|
+
return if convert_paths.blank?
|
42
|
+
|
43
|
+
convert_paths_string = convert_paths.join(" ")&.strip
|
44
|
+
md5_string = Digest::MD5.hexdigest(convert_paths_string)
|
45
|
+
|
46
|
+
UI.message "md5(#{convert_paths_string})=#{md5_string}"
|
47
|
+
|
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
|
53
|
+
|
54
|
+
header_path_hash = convert_paths.map { |x| headers_for_path.call(x) }.inject(:merge)
|
55
|
+
return if header_path_hash.blank?
|
56
|
+
|
57
|
+
FileUtils.mkdir_p(hmap_dir) unless File.directory?(hmap_dir)
|
58
|
+
json_path = File.expand_path("#{md5_string}.json", hmap_dir)
|
59
|
+
File.open(json_path, 'w') do |file|
|
60
|
+
file << header_path_hash.to_json
|
61
|
+
end
|
62
|
+
|
63
|
+
hmap = File.expand_path("hmap", File.dirname(__FILE__ ))
|
64
|
+
`#{hmap} convert '#{json_path}' '#{hmap_path}' `
|
65
|
+
File.delete(json_path)
|
66
|
+
|
67
|
+
UI.message "created hmap #{hmap_path}"
|
68
|
+
return md5_string
|
69
|
+
end
|
70
|
+
|
71
|
+
handle_target_with_settings = -> hmap_md5, target, config do
|
72
|
+
return if hmap_md5.blank?
|
73
|
+
|
74
|
+
xcconfig_path = target.xcconfig_path(config)
|
75
|
+
xcconfig = File.exist?(xcconfig_path) ? Xcodeproj::Config.new(xcconfig_path) : target.xcconfigs[config]
|
76
|
+
|
77
|
+
hmap_path = File.expand_path("Headers/hmap/#{hmap_md5}.hmap", installer.sandbox.root.to_s)
|
78
|
+
return unless File.exist?(hmap_path)
|
79
|
+
|
80
|
+
hmap_item = "\"${PODS_ROOT}/Headers/hmap/#{hmap_md5}.hmap\""
|
81
|
+
|
82
|
+
header_search_paths = xcconfig.to_hash['HEADER_SEARCH_PATHS']
|
83
|
+
path_items = header_search_paths.split(/\s+/)
|
84
|
+
|
85
|
+
keep_paths = path_items.reject { |p| to_remove.call(p) }
|
86
|
+
keep_paths << hmap_item
|
87
|
+
|
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
|
92
|
+
|
93
|
+
# 生成 hmap file,然后修改 xcconfig 文件
|
94
|
+
installer.aggregate_targets.each do |aggregate_target|
|
95
|
+
UI.message "convert hmap for aggregate_target #{aggregate_target}"
|
96
|
+
aggregate_target.user_build_configurations.each_key do |config| # "Debug" => :debug
|
97
|
+
build_settings = aggregate_target.build_settings(config) # AggregateTargetSettings
|
98
|
+
hmap_md5 = create_hmap.call(build_settings)
|
99
|
+
handle_target_with_settings.call(hmap_md5, aggregate_target, config)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
installer.pod_targets.each do |pod_target|
|
104
|
+
UI.message "convert hmap for pod_target #{pod_target}"
|
105
|
+
pod_target.build_settings.each do |config, build_settings| # "Debug" => PodTargetSettings
|
106
|
+
hmap_md5 = create_hmap.call(build_settings)
|
107
|
+
handle_target_with_settings.call(hmap_md5, pod_target, config)
|
108
|
+
end
|
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)
|
120
|
+
|
121
|
+
_old_run_podfile_post_install_hook
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
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.3
|
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
|
@@ -20,6 +20,8 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- lib/cocoapods_plugin.rb
|
23
|
+
- lib/hmap
|
24
|
+
- lib/hmap_optimize.rb
|
23
25
|
homepage: https://github.com/shyang/cocoapods-hmap
|
24
26
|
licenses:
|
25
27
|
- MIT
|
@@ -39,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
41
|
- !ruby/object:Gem::Version
|
40
42
|
version: '0'
|
41
43
|
requirements: []
|
42
|
-
rubygems_version: 3.
|
44
|
+
rubygems_version: 3.0.3
|
43
45
|
signing_key:
|
44
46
|
specification_version: 4
|
45
47
|
summary: A simple hmap generating plugin for cocoapods.
|