cocoapods-hmap-simple 1.0.0 → 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 +4 -4
- data/lib/hmap +0 -0
- data/lib/hmap_optimize.rb +138 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 250c86d07ab698229d2c1683751d8de2505af1e5438c55e8b3b186aa20f4dc36
|
4
|
+
data.tar.gz: cb0a9e02ed361ca71e6e8c04f1d58f0a05f9635bb6d7a44dc270c1f0b116c9c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76b7e5bf4fdd3591f3e865a2094771bddc58cb320bad99047fab61c112eb19ea8b9dcda5a8da5b136c793296eec29fe83660e48cb552c2195ff63c673029671a
|
7
|
+
data.tar.gz: abc8efb050e94118684bb9241504d5d0cc69826007b4f3c3251be574fa72f8ad01e13ba254f0da8e250f6ead2d23539b3064eaae87f49406931ebc706ede5872
|
data/lib/hmap
ADDED
Binary file
|
@@ -0,0 +1,138 @@
|
|
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 Target
|
8
|
+
class BuildSettings
|
9
|
+
attr_accessor :hmap_md5
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Installer
|
14
|
+
# helper functions
|
15
|
+
def to_remove?(header_search_path)
|
16
|
+
header_search_path.include?("${PODS_ROOT}/Headers/Public/")
|
17
|
+
end
|
18
|
+
|
19
|
+
def headers_for_path(path)
|
20
|
+
@cached_headers ||= {}
|
21
|
+
cached = @cached_headers.fetch(path, {})
|
22
|
+
return cached unless cached.blank?
|
23
|
+
|
24
|
+
full_path = path.sub(/^\$\{PODS_ROOT\}/, sandbox.root.to_s)
|
25
|
+
headers = Dir.glob("#{full_path}/**/{*.h,*.hpp}")
|
26
|
+
return {} if headers.blank?
|
27
|
+
|
28
|
+
target_headers_hash = headers.to_h do |header|
|
29
|
+
prefix = File.dirname(header)
|
30
|
+
relative_dir = prefix.sub(/^#{full_path}/, '').sub(/^\//, '')
|
31
|
+
file_name = File.basename(header)
|
32
|
+
file_name = File.join(relative_dir, file_name) unless relative_dir.blank?
|
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]
|
39
|
+
end
|
40
|
+
@cached_headers[path] = target_headers_hash
|
41
|
+
target_headers_hash
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_hmap(build_settings)
|
45
|
+
header_search_paths = build_settings.header_search_paths
|
46
|
+
return if header_search_paths.blank?
|
47
|
+
|
48
|
+
convert_paths = header_search_paths.select { |p| to_remove?(p) }
|
49
|
+
return if convert_paths.blank?
|
50
|
+
|
51
|
+
convert_paths_string = convert_paths.join(" ")&.strip
|
52
|
+
md5_string = Digest::MD5.hexdigest(convert_paths_string)
|
53
|
+
|
54
|
+
UI.message "md5(#{convert_paths_string})=#{md5_string}"
|
55
|
+
|
56
|
+
hmap_dir = File.expand_path("Headers/hmap", sandbox.root.to_s)
|
57
|
+
hmap_path = File.expand_path("#{md5_string}.hmap", hmap_dir)
|
58
|
+
if File.exist?(hmap_path)
|
59
|
+
build_settings.hmap_md5 = md5_string
|
60
|
+
return
|
61
|
+
end
|
62
|
+
|
63
|
+
header_path_hash = convert_paths.map { |x| headers_for_path(x) }.inject(:merge)
|
64
|
+
return if header_path_hash.blank?
|
65
|
+
|
66
|
+
begin
|
67
|
+
FileUtils.mkdir_p(hmap_dir) unless File.directory?(hmap_dir)
|
68
|
+
json_path = File.expand_path("#{md5_string}.json", hmap_dir)
|
69
|
+
File.open(json_path, 'w') do |file|
|
70
|
+
file << header_path_hash.to_json
|
71
|
+
end
|
72
|
+
|
73
|
+
convert_json_to_hmap(json_path, hmap_path)
|
74
|
+
File.delete(json_path)
|
75
|
+
|
76
|
+
build_settings.hmap_md5 = md5_string
|
77
|
+
UI.message "created hmap #{hmap_path}"
|
78
|
+
rescue => e
|
79
|
+
UI.warn "create hmap error: #{e.inspect}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def convert_json_to_hmap(public_json, public_hmap)
|
84
|
+
hmap = File.expand_path("hmap", File.dirname(__FILE__ ))
|
85
|
+
`#{hmap} convert '#{public_json}' '#{public_hmap}' `
|
86
|
+
end
|
87
|
+
|
88
|
+
def handle_target_with_settings(build_settings, xcconfig, xcconfig_path)
|
89
|
+
return if build_settings.blank? || build_settings.hmap_md5.blank?
|
90
|
+
|
91
|
+
hmap_path = File.expand_path("Headers/hmap/#{build_settings.hmap_md5}.hmap", sandbox.root.to_s)
|
92
|
+
return unless File.exist?(hmap_path)
|
93
|
+
|
94
|
+
hmap_item = "\"${PODS_ROOT}/Headers/hmap/#{build_settings.hmap_md5}.hmap\""
|
95
|
+
|
96
|
+
header_search_paths = xcconfig.to_hash['HEADER_SEARCH_PATHS']
|
97
|
+
path_items = header_search_paths.split(/\s+/)
|
98
|
+
|
99
|
+
keep_paths = path_items.reject { |p| to_remove?(p) }
|
100
|
+
keep_paths << hmap_item
|
101
|
+
|
102
|
+
new_header_search_paths = keep_paths.join(" ")
|
103
|
+
xcconfig.attributes['HEADER_SEARCH_PATHS'] = new_header_search_paths
|
104
|
+
xcconfig.save_as(xcconfig_path)
|
105
|
+
end
|
106
|
+
|
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
|
+
# 生成 hmap file,然后修改 xcconfig 文件
|
111
|
+
aggregate_targets.each do |aggregate_target|
|
112
|
+
UI.message "convert hmap for aggregate_target #{aggregate_target}"
|
113
|
+
aggregate_target.user_build_configurations.each_key do |config| # "Debug" => :debug
|
114
|
+
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)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
pod_targets.each do |pod_target|
|
124
|
+
UI.message "convert hmap for pod_target #{pod_target}"
|
125
|
+
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)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
_old_run_podfile_post_install_hook
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shyang
|
@@ -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
|