cocoapods-hmap 0.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 +7 -0
- data/.gitignore +3 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +11 -0
- data/Rakefile +13 -0
- data/cocoapods-hmap.gemspec +23 -0
- data/lib/cocoapods-hmap.rb +1 -0
- data/lib/cocoapods-hmap/aggregateconfig/modify_aggregate_config.rb +61 -0
- data/lib/cocoapods-hmap/command.rb +33 -0
- data/lib/cocoapods-hmap/command/hmap.rb +44 -0
- data/lib/cocoapods-hmap/gem_version.rb +3 -0
- data/lib/cocoapods-hmap/hmapcreate/hmap.rb +172 -0
- data/lib/cocoapods-hmap/hmapcreate/public_hmap.rb +111 -0
- data/lib/cocoapods-hmap/modifyconfig/modify_config.rb +74 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/spec/command/hmap_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e775725eeb6b202429a7cb51deeaa266067dafd5a15b445ff2e9a9b79afe888b
|
4
|
+
data.tar.gz: fb75d62cba49573da649d43d4ce6e73bcee0d088df211b835b792fbf2a1b6451
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b247ea8d9b4385c61cfd749f6fea7fa9a2bbfd513bc7760f76c785f428d0c0bae1d6af08be4bdcd6308f5b71e88194a716408c9da088c59be1a5deebcf7021d
|
7
|
+
data.tar.gz: 9b0216035fabdf2019a70a206129e57ee1389097d2c65dc207c7253b98d2764be464389e8923b9dfb060387daa0dc9f6bb02436d429e30225b8ca2a8599250fc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2021 常延广 <changyanguang@xiaomi.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods-hmap/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-hmap'
|
8
|
+
spec.version = CocoapodsHmap::VERSION
|
9
|
+
spec.authors = ['常延广']
|
10
|
+
spec.email = ['yanguang-chang@foxmail.com']
|
11
|
+
spec.description = %q{A short description of cocoapods-hmap.}
|
12
|
+
spec.summary = %q{A longer description of cocoapods-hmap.}
|
13
|
+
spec.homepage = 'https://github.com/EXAMPLE/cocoapods-hmap'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-hmap/gem_version'
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#---------------工具方法--------------#
|
2
|
+
|
3
|
+
def searchPodXcconfig(configname)
|
4
|
+
xcconfig_file = configname
|
5
|
+
unless File.exist?(xcconfig_file)
|
6
|
+
return ""
|
7
|
+
end
|
8
|
+
return xcconfig_file
|
9
|
+
end
|
10
|
+
|
11
|
+
def modifyPodXcconfig(xcconfig_file,modify_value)
|
12
|
+
text = File.read(xcconfig_file)
|
13
|
+
lines = text.lines
|
14
|
+
len = lines.size
|
15
|
+
for i in 0..(len -1) do
|
16
|
+
line = replace_xcconfig_headersearchpath(lines[i],modify_value)
|
17
|
+
lines[i] = line unless line.nil?
|
18
|
+
end
|
19
|
+
text = lines.join()
|
20
|
+
# text += "USE_HEADERMAP = false"
|
21
|
+
File.open(xcconfig_file,'w'){|f| f.puts text}
|
22
|
+
end
|
23
|
+
|
24
|
+
def replace_xcconfig_headersearchpath(line,modify_value)
|
25
|
+
return nil unless line.include?"HEADER_SEARCH_PATHS"
|
26
|
+
line = "#{modify_value}\n"
|
27
|
+
return line
|
28
|
+
end
|
29
|
+
|
30
|
+
#-----------修改的入口方法-------------#
|
31
|
+
def modify_aggregate_target_config(targets)
|
32
|
+
#targets为主工程的target
|
33
|
+
xcconfig_paths = []
|
34
|
+
default_target = ''
|
35
|
+
for target_name in targets do
|
36
|
+
if target_name.start_with? 'Default'
|
37
|
+
default_target = target_name
|
38
|
+
next
|
39
|
+
end
|
40
|
+
if default_target.empty?
|
41
|
+
target_name = "Pods-#{target_name}"
|
42
|
+
else
|
43
|
+
target_name = "Pods-#{default_target}-#{target_name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
outputpath = 'Pods' + '/Target Support Files'
|
47
|
+
outputpath = File.join(outputpath,target_name)
|
48
|
+
xcconfig_debug_path = File.join(outputpath,target_name + '.debug.xcconfig')
|
49
|
+
xcconfig_release_path = File.join(outputpath,target_name + '.release.xcconfig')
|
50
|
+
xcconfig_paths.append(xcconfig_debug_path)
|
51
|
+
xcconfig_paths.append(xcconfig_release_path)
|
52
|
+
end
|
53
|
+
|
54
|
+
for xcconfig_name in xcconfig_paths do
|
55
|
+
xcconfig_file = searchPodXcconfig(xcconfig_name)
|
56
|
+
public_hmap_path = File.join(Pathname.pwd,"Pods/Headers/headermap"+"/public_hmap.hmap")
|
57
|
+
modify_value = "HEADER_SEARCH_PATHS = \"#{public_hmap_path}\""
|
58
|
+
modifyPodXcconfig(xcconfig_file,modify_value)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# require 'cocoapods-hmap/command/hmap'
|
2
|
+
targets = []
|
3
|
+
Pod::HooksManager.register('cocoapods-hmap', :pre_install) do |installer|
|
4
|
+
|
5
|
+
# check user_framework is on
|
6
|
+
podfile = installer.podfile
|
7
|
+
podfile.target_definition_list.each do |target_definition|
|
8
|
+
next if target_definition.name == "Pods"
|
9
|
+
next if target_definition.name.include? "Tests"
|
10
|
+
targets.append(target_definition.name)
|
11
|
+
if target_definition.uses_frameworks?
|
12
|
+
STDERR.puts "插件暂不支持framework产物,只支持static library产物".red
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
headermap_path = File.join(Pathname.pwd,"Pods/Headers/headermap")
|
18
|
+
`rm -rf #{headermap_path}` if Dir.exist?(headermap_path)
|
19
|
+
require_relative 'hmapcreate/hmap'
|
20
|
+
end
|
21
|
+
|
22
|
+
Pod::HooksManager.register('cocoapods-hmap', :post_install) do |installer|
|
23
|
+
#------------生成public.hmap--------------#
|
24
|
+
require_relative 'hmapcreate/public_hmap'
|
25
|
+
#------------下面为修改xcconfig中的header_search_path及关闭hmap值为USE_HEADERMAP-----------#
|
26
|
+
require_relative 'modifyconfig/modify_config'
|
27
|
+
modify_all_target_config(installer)
|
28
|
+
|
29
|
+
#-------------修改aggregateconfig------------#
|
30
|
+
require_relative 'aggregateconfig/modify_aggregate_config'
|
31
|
+
modify_aggregate_target_config(targets)
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
4
|
+
# to the 'pod' command.
|
5
|
+
#
|
6
|
+
# You can also create subcommands of existing or new commands. Say you
|
7
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
8
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
9
|
+
# to change.
|
10
|
+
#
|
11
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
12
|
+
# the class to exist in the the Pod::Command::List namespace
|
13
|
+
# - change this class to extend from `List` instead of `Command`. This
|
14
|
+
# tells the plugin system that it is a subcommand of `list`.
|
15
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
16
|
+
#
|
17
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
18
|
+
# in the `plugins.json` file, once your plugin is released.
|
19
|
+
#
|
20
|
+
class Hmap < Command
|
21
|
+
self.summary = 'Short description of cocoapods-hmap.'
|
22
|
+
|
23
|
+
self.description = <<-DESC
|
24
|
+
Longer description of cocoapods-hmap.
|
25
|
+
DESC
|
26
|
+
|
27
|
+
self.arguments = 'NAME'
|
28
|
+
|
29
|
+
def initialize(argv)
|
30
|
+
@name = argv.shift_argument
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate!
|
35
|
+
super
|
36
|
+
help! 'A Pod name is required.' unless @name
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
UI.puts "Add your implementation for the cocoapods-hmap plugin in #{__FILE__}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
module Pod
|
2
|
+
class Installer
|
3
|
+
class Xcode
|
4
|
+
class PodsProjectGenerator
|
5
|
+
class FileReferencesInstaller
|
6
|
+
def link_headers
|
7
|
+
pod_targets.each do |pod_target|
|
8
|
+
# When integrating Pod as frameworks, built Pods are built into
|
9
|
+
# frameworks, whose headers are included inside the built
|
10
|
+
# framework. Those headers do not need to be linked from the
|
11
|
+
# sandbox.
|
12
|
+
next if pod_target.build_as_framework? && pod_target.should_build?
|
13
|
+
hmap_own_content = "" #双引号的引用
|
14
|
+
hmap_public_content = "" #<>的引用
|
15
|
+
pod_target_header_mappings = pod_target.header_mappings_by_file_accessor.values
|
16
|
+
pod_target_header_mappings.each do |header_mappings|
|
17
|
+
header_mappings.each do |namespaced_path, files|
|
18
|
+
# pod_target.build_headers.add_files(namespaced_path, files)
|
19
|
+
hmap_items = add_files(namespaced_path,files,pod_target.product_module_name)
|
20
|
+
hmap_own_item = hmap_items[0]
|
21
|
+
hmap_public_item = hmap_items[-1]
|
22
|
+
hmap_own_content = hmap_own_content + "#{hmap_own_item},\n"
|
23
|
+
hmap_public_content = hmap_public_content + "#{hmap_public_item},\n"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
#生成双引号的引用的hmap及json 只有双引号引用的key 里面加一个pch相关的key
|
28
|
+
hmap_own_content = hmap_own_content.chomp.chop
|
29
|
+
pch_item = generate_pch_hmap_item(pod_target)
|
30
|
+
hmap_own_content = hmap_own_content + ",\n#{pch_item}"
|
31
|
+
hmap_own_content = "{" + "\n #{hmap_own_content}\n" + "}"
|
32
|
+
generate_own_hmap_file(pod_target,hmap_own_content)
|
33
|
+
|
34
|
+
#生成<>引用的json 既有双引号的引用也有<>引用的Key
|
35
|
+
hmap_public_content = hmap_public_content.chomp.chop
|
36
|
+
if hmap_public_content.size == 0
|
37
|
+
hmap_public_content = ""
|
38
|
+
else
|
39
|
+
hmap_public_content = "{" + "\n #{hmap_public_content}\n" + "}"
|
40
|
+
end
|
41
|
+
|
42
|
+
generate_public_hmap_file(pod_target,hmap_public_content)
|
43
|
+
|
44
|
+
# public_header_mappings = pod_target.public_header_mappings_by_file_accessor.values
|
45
|
+
# public_header_mappings.each do |header_mappings|
|
46
|
+
# header_mappings.each do |namespaced_path, files|
|
47
|
+
# sandbox.public_headers.add_files(namespaced_path, files)
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_files(namespace, relative_header_paths,pod_module_name)
|
55
|
+
#要生成两个json 一个是给双引号的时候使用,一个是给<>的的使用
|
56
|
+
#双引号的Key只有 "ClassA.h"这种类型
|
57
|
+
#<>的key即有 “PodA/ClassA.h” 这种类型 也有"ClassA.h"这种类型 作为生成大的public时使用
|
58
|
+
hmap_own_content = ""
|
59
|
+
hmap_public_content = ""
|
60
|
+
relative_header_paths.map do |relative_header_path|
|
61
|
+
#own hmap的生成 只包含 ClassA这种类型
|
62
|
+
item = generate_own_hmap_item(namespace,relative_header_path)
|
63
|
+
hmap_own_content = hmap_own_content + "#{item},\n"
|
64
|
+
#public json生成 包含PodA/ClassA ClassA两种类型
|
65
|
+
public_item = generate_public_hmap_item(namespace,relative_header_path,pod_module_name)
|
66
|
+
hmap_public_content = hmap_public_content + "#{public_item},\n"
|
67
|
+
end
|
68
|
+
hmap_own_content = hmap_own_content.chomp.chop
|
69
|
+
hmap_public_content = hmap_public_content.chomp.chop
|
70
|
+
results = []
|
71
|
+
results.append(hmap_own_content)
|
72
|
+
results.append(hmap_public_content)
|
73
|
+
return results
|
74
|
+
# return hmap_content
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def generate_own_hmap_item(namespace,relative_header_path)
|
79
|
+
header_name = relative_header_path.basename
|
80
|
+
hmap_module_key = header_name.to_s
|
81
|
+
suffix = relative_header_path.basename.to_s
|
82
|
+
#prefix的计算
|
83
|
+
absolute_source = (@sandbox.root + relative_header_path)
|
84
|
+
prefix = File.join(absolute_source.dirname,'/')
|
85
|
+
value_item = Hash.new()
|
86
|
+
value_item["prefix"] = prefix
|
87
|
+
value_item["suffix"] = suffix
|
88
|
+
hmap_module_item = Hash.new()
|
89
|
+
hmap_module_item[hmap_module_key] = value_item
|
90
|
+
require 'json'
|
91
|
+
hmap_module_string = hmap_module_item.to_json
|
92
|
+
hmap_module_string = hmap_module_string.chop.reverse.chop.reverse
|
93
|
+
return hmap_module_string
|
94
|
+
end
|
95
|
+
|
96
|
+
def generate_public_hmap_item(namespace, relative_header_path,pod_module_name)
|
97
|
+
#----------下面面是通过尖括号引用<PodA/classA.h>----------------#
|
98
|
+
suffix = relative_header_path.basename.to_s
|
99
|
+
#prefix的计算
|
100
|
+
absolute_source = (@sandbox.root + relative_header_path)
|
101
|
+
prefix = File.join(absolute_source.dirname,'/')
|
102
|
+
|
103
|
+
value_item = Hash.new()
|
104
|
+
value_item["prefix"] = prefix
|
105
|
+
value_item["suffix"] = suffix
|
106
|
+
|
107
|
+
#如果有module_name这里的key要修改为对应的key 暂时修改这里改为module/class 或者直接添加module/key
|
108
|
+
module_header_name = namespace + relative_header_path.basename
|
109
|
+
module_header_name = File.join("#{pod_module_name}",relative_header_path.basename) unless pod_module_name.empty?
|
110
|
+
hmap_module_key = module_header_name.to_s
|
111
|
+
hmap_module_item = Hash.new()
|
112
|
+
hmap_module_item[hmap_module_key] = value_item
|
113
|
+
require 'json'
|
114
|
+
hmap_module_string = hmap_module_item.to_json
|
115
|
+
hmap_module_string = hmap_module_string.chop.reverse.chop.reverse
|
116
|
+
#----------下面是通过双引号引用classA.h 模块内部的使用方法----------------#
|
117
|
+
mark_value_item = Hash.new()
|
118
|
+
mark_value_item["suffix"] = suffix
|
119
|
+
mark_value_item["prefix"] = prefix
|
120
|
+
|
121
|
+
hmap_mark_key = relative_header_path.basename
|
122
|
+
hmap_mark_key = hmap_mark_key.to_s
|
123
|
+
hmap_mark_item = Hash.new()
|
124
|
+
hmap_mark_item[hmap_mark_key] = mark_value_item
|
125
|
+
hmap_mark_string = hmap_mark_item.to_json
|
126
|
+
hmap_mark_string = hmap_mark_string.chop.reverse.chop.reverse
|
127
|
+
|
128
|
+
hmap_string = "#{hmap_module_string}" + ",\n" + "#{hmap_mark_string}"
|
129
|
+
return hmap_string
|
130
|
+
end
|
131
|
+
|
132
|
+
def generate_own_hmap_file(namespace,hmap_content)
|
133
|
+
hmap_path = File.join(sandbox.headers_root,"headermap/#{namespace}")
|
134
|
+
`rm -rf #{hmap_path}` if Dir.exist?(hmap_path)
|
135
|
+
`mkdir -p #{hmap_path}`
|
136
|
+
hmap_json_file = File.join(hmap_path,"#{namespace}.json")
|
137
|
+
File.open(hmap_json_file, 'w'){|file| file.write(hmap_content)}
|
138
|
+
#创建hmap
|
139
|
+
hmap_file = File.join(hmap_path,"#{namespace}.hmap")
|
140
|
+
`hmap convert #{hmap_json_file} #{hmap_file}`
|
141
|
+
# `rm -rf #{hmap_json_file}`
|
142
|
+
end
|
143
|
+
|
144
|
+
def generate_public_hmap_file(namespace,hmap_public_content)
|
145
|
+
hmap_path = File.join(sandbox.headers_root,"headermap/#{namespace}")
|
146
|
+
hmap_json_file = File.join(hmap_path,"#{namespace}_public.json")
|
147
|
+
File.open(hmap_json_file, 'w'){|file| file.write(hmap_public_content)}
|
148
|
+
end
|
149
|
+
|
150
|
+
def generate_pch_hmap_item(namespace)
|
151
|
+
suffix = "#{namespace}-prefix.pch"
|
152
|
+
prefix_path = File.join(@sandbox.root,"Target Support Files")
|
153
|
+
prefix_path = File.join(prefix_path,"#{namespace}/")
|
154
|
+
prefix = prefix_path
|
155
|
+
value_item = Hash.new()
|
156
|
+
value_item['suffix'] = suffix
|
157
|
+
value_item['prefix'] = prefix
|
158
|
+
|
159
|
+
hmap_pch_item = Hash.new()
|
160
|
+
hmap_pch_key = "#{namespace}-prefix.pch"
|
161
|
+
hmap_pch_item[hmap_pch_key] = value_item
|
162
|
+
hmap_pch_string = hmap_pch_item.to_json
|
163
|
+
hmap_pch_string = hmap_pch_string.chop.reverse.chop.reverse
|
164
|
+
return hmap_pch_string
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
def readPodFile(podfileLock)
|
2
|
+
raise "#{podfileLock} is invalid" unless File.exist?(podfileLock)
|
3
|
+
file = open(podfileLock)
|
4
|
+
pod_names = []
|
5
|
+
begin
|
6
|
+
beginPodList = false
|
7
|
+
for line in file do
|
8
|
+
podline = line.strip()
|
9
|
+
if beginPodList == false and podline.start_with? 'SPEC CHECKSUMS'
|
10
|
+
beginPodList = true
|
11
|
+
next
|
12
|
+
end
|
13
|
+
if not beginPodList
|
14
|
+
next
|
15
|
+
end
|
16
|
+
if beginPodList and podline.size == 0
|
17
|
+
break
|
18
|
+
end
|
19
|
+
podline = podline.split(':')
|
20
|
+
podline = podline[0].gsub('"','')
|
21
|
+
if podline.start_with? '!'
|
22
|
+
next
|
23
|
+
end
|
24
|
+
pod_names.append(podline)
|
25
|
+
end
|
26
|
+
rescue
|
27
|
+
raise "读取过程失败"
|
28
|
+
ensure
|
29
|
+
file.close()
|
30
|
+
end
|
31
|
+
|
32
|
+
return pod_names
|
33
|
+
end
|
34
|
+
|
35
|
+
def searchPodHmapJson(podname)
|
36
|
+
outputpath = File.join(Pathname.pwd,"Pods/Headers/headermap")
|
37
|
+
unless Dir.exist?(outputpath)
|
38
|
+
return ""
|
39
|
+
end
|
40
|
+
outputpath = File.join(outputpath,podname)
|
41
|
+
unless Dir.exist?(outputpath)
|
42
|
+
return ""
|
43
|
+
end
|
44
|
+
jsonpath = File.join(outputpath,"#{podname}_public" + '.json')
|
45
|
+
unless File.exist?(jsonpath)
|
46
|
+
return ""
|
47
|
+
end
|
48
|
+
hmap_content = File.read(jsonpath)
|
49
|
+
hmap_content = hmap_content.chop.reverse.chop.reverse
|
50
|
+
if hmap_content.empty?
|
51
|
+
return ""
|
52
|
+
else
|
53
|
+
return hmap_content
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def generate_public_hmap_file(hmap_content)
|
58
|
+
outputpath = File.join(Pathname.pwd,"Pods/Headers/headermap")
|
59
|
+
unless Dir.exist?(outputpath)
|
60
|
+
raise "headermap 文件夹不存在"
|
61
|
+
end
|
62
|
+
hmap_json_file = File.join(outputpath,"public_hmap.json")
|
63
|
+
`rm -rf #{hmap_json_file}` unless File.exist?(hmap_json_file)
|
64
|
+
File.open(hmap_json_file, 'w'){|file| file.write(hmap_content)}
|
65
|
+
hmap_file = File.join(outputpath,"public_hmap.hmap")
|
66
|
+
`rm -rf #{hmap_file}` unless File.exist?(hmap_file)
|
67
|
+
`hmap convert #{hmap_json_file} #{hmap_file}`
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
#生成大的Public.json以后 可以删除每个target下小的Public.json了
|
72
|
+
def delete_target_public_json(podname)
|
73
|
+
|
74
|
+
outputpath = File.join(Pathname.pwd,"Pods/Headers/headermap")
|
75
|
+
unless Dir.exist?(outputpath)
|
76
|
+
return
|
77
|
+
end
|
78
|
+
outputpath = File.join(outputpath,podname)
|
79
|
+
unless Dir.exist?(outputpath)
|
80
|
+
return
|
81
|
+
end
|
82
|
+
jsonpath = File.join(outputpath,"#{podname}_public" + '.json')
|
83
|
+
unless File.exist?(jsonpath)
|
84
|
+
return
|
85
|
+
end
|
86
|
+
`rm -rf #{jsonpath}`
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
def collectHmapJson()
|
91
|
+
podfilelock = "./Podfile.lock"
|
92
|
+
podnames = readPodFile(podfilelock)
|
93
|
+
hmap_content = ""
|
94
|
+
for podname in podnames do
|
95
|
+
hmap_item = searchPodHmapJson(podname)
|
96
|
+
# delete_target_public_json(podname)
|
97
|
+
if hmap_item.size == 0
|
98
|
+
next
|
99
|
+
end
|
100
|
+
begin
|
101
|
+
hmap_content = hmap_content + "#{hmap_item},\n"
|
102
|
+
rescue
|
103
|
+
raise "json 解析失败"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
hmap_content = hmap_content.chomp.chop
|
107
|
+
hmap_content = "{" + "\n #{hmap_content} \n" + "}"
|
108
|
+
generate_public_hmap_file(hmap_content)
|
109
|
+
end
|
110
|
+
|
111
|
+
collectHmapJson()
|
@@ -0,0 +1,74 @@
|
|
1
|
+
def readPodFile(podfileLock)
|
2
|
+
raise "#{podfileLock} is invalid" unless File.exist?(podfileLock)
|
3
|
+
file = open(podfileLock)
|
4
|
+
pod_names = []
|
5
|
+
begin
|
6
|
+
beginPodList = false
|
7
|
+
for line in file do
|
8
|
+
podline = line.strip()
|
9
|
+
if beginPodList == false and podline.start_with? 'SPEC CHECKSUMS'
|
10
|
+
beginPodList = true
|
11
|
+
next
|
12
|
+
end
|
13
|
+
if not beginPodList
|
14
|
+
next
|
15
|
+
end
|
16
|
+
if beginPodList and podline.size == 0
|
17
|
+
break
|
18
|
+
end
|
19
|
+
podline = podline.split(':')
|
20
|
+
podline = podline[0].gsub('"','')
|
21
|
+
if podline.start_with? '!'
|
22
|
+
next
|
23
|
+
end
|
24
|
+
pod_names.append(podline)
|
25
|
+
end
|
26
|
+
rescue
|
27
|
+
raise "读取过程失败"
|
28
|
+
ensure
|
29
|
+
file.close()
|
30
|
+
end
|
31
|
+
|
32
|
+
return pod_names
|
33
|
+
end
|
34
|
+
|
35
|
+
def modifyPodXcconfig(xcconfig_file,modify_value)
|
36
|
+
text = File.read(xcconfig_file)
|
37
|
+
lines = text.lines
|
38
|
+
len = lines.size
|
39
|
+
for i in 0..(len -1) do
|
40
|
+
line = replace_xcconfig_headersearchpath(lines[i],modify_value)
|
41
|
+
lines[i] = line unless line.nil?
|
42
|
+
end
|
43
|
+
text = lines.join()
|
44
|
+
text += "USE_HEADERMAP = NO"
|
45
|
+
File.open(xcconfig_file,'w'){|f| f.puts text}
|
46
|
+
end
|
47
|
+
|
48
|
+
def replace_xcconfig_headersearchpath(line,modify_value)
|
49
|
+
return nil unless line.start_with? "HEADER_SEARCH_PATHS"
|
50
|
+
refine_modify_value = ""
|
51
|
+
if line.include?('Folly')
|
52
|
+
refine_modify_value = modify_value + " \"$(PODS_ROOT)/Folly\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/glog/glog\""
|
53
|
+
else
|
54
|
+
refine_modify_value = modify_value
|
55
|
+
end
|
56
|
+
line = "#{refine_modify_value}\n"
|
57
|
+
return line
|
58
|
+
end
|
59
|
+
|
60
|
+
def modify_all_target_config(installer)
|
61
|
+
#修改podsproject下的target
|
62
|
+
podfilelock = "./Podfile.lock"
|
63
|
+
target_names = readPodFile(podfilelock)
|
64
|
+
for target_name in target_names do
|
65
|
+
target_hmap_path = File.join(Pathname.pwd,"Pods/Headers/headermap"+"/#{target_name}/#{target_name}.hmap")
|
66
|
+
public_hmap_path = File.join(Pathname.pwd,"Pods/Headers/headermap"+"/public_hmap.hmap")
|
67
|
+
modify_value = "HEADER_SEARCH_PATHS = \"#{target_hmap_path}\" \"#{public_hmap_path}\""
|
68
|
+
|
69
|
+
outputpath = File.join(Pathname.pwd,'Pods' + '/Target Support Files')
|
70
|
+
outputpath = File.join(outputpath,target_name)
|
71
|
+
xcconfig_debug_file = File.join(outputpath,target_name + '.xcconfig')
|
72
|
+
modifyPodXcconfig(xcconfig_debug_file,modify_value)
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-hmap/command'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
4
|
+
$:.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'bacon'
|
8
|
+
require 'mocha-on-bacon'
|
9
|
+
require 'pretty_bacon'
|
10
|
+
require 'pathname'
|
11
|
+
require 'cocoapods'
|
12
|
+
|
13
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
14
|
+
|
15
|
+
require 'cocoapods_plugin'
|
16
|
+
|
17
|
+
#-----------------------------------------------------------------------------#
|
18
|
+
|
19
|
+
module Pod
|
20
|
+
|
21
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
22
|
+
#
|
23
|
+
UI.disable_wrap = true
|
24
|
+
|
25
|
+
# Redirects the messages to an internal store.
|
26
|
+
#
|
27
|
+
module UI
|
28
|
+
@output = ''
|
29
|
+
@warnings = ''
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :output
|
33
|
+
attr_accessor :warnings
|
34
|
+
|
35
|
+
def puts(message = '')
|
36
|
+
@output << "#{message}\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
def warn(message = '', actions = [])
|
40
|
+
@warnings << "#{message}\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def print(message)
|
44
|
+
@output << message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#-----------------------------------------------------------------------------#
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-hmap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 常延广
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A short description of cocoapods-hmap.
|
42
|
+
email:
|
43
|
+
- yanguang-chang@foxmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- cocoapods-hmap.gemspec
|
54
|
+
- lib/cocoapods-hmap.rb
|
55
|
+
- lib/cocoapods-hmap/aggregateconfig/modify_aggregate_config.rb
|
56
|
+
- lib/cocoapods-hmap/command.rb
|
57
|
+
- lib/cocoapods-hmap/command/hmap.rb
|
58
|
+
- lib/cocoapods-hmap/gem_version.rb
|
59
|
+
- lib/cocoapods-hmap/hmapcreate/hmap.rb
|
60
|
+
- lib/cocoapods-hmap/hmapcreate/public_hmap.rb
|
61
|
+
- lib/cocoapods-hmap/modifyconfig/modify_config.rb
|
62
|
+
- lib/cocoapods_plugin.rb
|
63
|
+
- spec/command/hmap_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: https://github.com/EXAMPLE/cocoapods-hmap
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubygems_version: 3.0.8
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: A longer description of cocoapods-hmap.
|
88
|
+
test_files:
|
89
|
+
- spec/command/hmap_spec.rb
|
90
|
+
- spec/spec_helper.rb
|