cocoapods-project-hmap 0.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 +7 -0
- data/.gitignore +4 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +13 -0
- data/cocoapods-project-hmap.gemspec +23 -0
- data/lib/cocoapods-project-hmap.rb +1 -0
- data/lib/cocoapods-project-hmap/gem_version.rb +3 -0
- data/lib/cocoapods_plugin.rb +93 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 68801210f55204e41af77674dc55ffbaf03feb46a204cae99447e4806d0792e2
|
4
|
+
data.tar.gz: ec5141459a5300d398ee9a21bd331345a2c1b0aad8c53e0fe83f73a9678bc82c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: decf080027a959c9593fc3b00affd3a634358faaaa2e0916667dcd239edf7253194e4be74aa01138b6ae355a99075145498d0796a81aa6495a06a1b8e601952c
|
7
|
+
data.tar.gz: 84f972b5c6374f08e59e0f15ffd81db646024aabdd35de07c979bbb763eee4250b7f20bc05b91d805887696f2e90362083999113927982838cf41d7ddd9af609
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2021 chenxGen <cxj83740@126.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
@@ -0,0 +1,43 @@
|
|
1
|
+
# cocoapods-project-hmap
|
2
|
+
|
3
|
+
此项目思路源自美团分享的文章:[《一款可以让大型iOS工程编译速度提升50%的工具》](https://tech.meituan.com/2021/02/25/cocoapods-hmap-prebuilt.html),由于该插件未开源,所以研究了下,通过hook post_install生成hmap文件保存到pod项目根目录,然后修改xcconfig文件,增加OTHER_CFLAGS,删除HEADER_SEARCH_PATHS,使得编译过程直接使用hmap文件。
|
4
|
+
|
5
|
+
## 效果
|
6
|
+
|
7
|
+
在我们自己的项目中测试一次全量编译数据为:
|
8
|
+
|
9
|
+
| before | hmap |
|
10
|
+
| ------ | ---- |
|
11
|
+
| 471s | 330s |
|
12
|
+
|
13
|
+
> 数据测试环境:
|
14
|
+
> - Mac:Mac mini (2018) / 3.2 GHz 六核Intel Core i7 / 16 GB 2667 MHz DDR4
|
15
|
+
> - Xcode: 12.4
|
16
|
+
> - ruby: 2.6.0
|
17
|
+
> - cocoapods: 1.10.1
|
18
|
+
|
19
|
+
从测试效果可以看出还是有较大提升的,所以开源出来给大家使用一下,可以在 issue 中反馈一下,也可以通过邮箱:chenxGen@outlook.com 联系我。
|
20
|
+
|
21
|
+
## 安装
|
22
|
+
|
23
|
+
由于hmap文件的生成借助于开源项目[hmap](https://github.com/milend/hmap),请先通过`brew install milend/taps/hmap`安装
|
24
|
+
|
25
|
+
### 使用Gemfile:
|
26
|
+
|
27
|
+
如果你的项目使用bundler管理gems,则在你的Gemfile中加入:
|
28
|
+
```ruby
|
29
|
+
gem 'cocoapods-project-hmap', :git=>'https://github.com/chenxGen/cocoapods-project-hmap.git', :branch=>'main'
|
30
|
+
```
|
31
|
+
|
32
|
+
### 源码编译:
|
33
|
+
|
34
|
+
```shell
|
35
|
+
$ git clone https://github.com/chenxGen/cocoapods-project-hmap.git
|
36
|
+
$ cd cocoapods-project-hmap
|
37
|
+
$ gem build cocoapods-project-hmap.gemspec
|
38
|
+
$ sudo gem install cocoapods-project-hmap-0.0.1.gem
|
39
|
+
```
|
40
|
+
|
41
|
+
## 使用
|
42
|
+
|
43
|
+
在你的Podfile中加入这一行: `plugin 'cocoapods-project-hmap'`
|
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-project-hmap/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-project-hmap'
|
8
|
+
spec.version = CocoapodsProjectHmap::VERSION
|
9
|
+
spec.authors = ['chenxGen']
|
10
|
+
spec.email = ['chenxGen@outlook.com']
|
11
|
+
spec.description = %q{A short description of cocoapods-project-hmap.}
|
12
|
+
spec.summary = %q{A longer description of cocoapods-project-hmap.}
|
13
|
+
spec.homepage = 'https://github.com/chenxGen/cocoapods-project-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-project-hmap/gem_version'
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Xcodeproj
|
2
|
+
class Config
|
3
|
+
def remove_attr_with_key(key)
|
4
|
+
unless key == nil
|
5
|
+
@attributes.delete(key)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
def remove_header_search_path
|
9
|
+
remove_attr_with_key('HEADER_SEARCH_PATHS')
|
10
|
+
flags = @attributes['OTHER_CFLAGS']
|
11
|
+
if flags
|
12
|
+
new_flags = ''
|
13
|
+
skip = false
|
14
|
+
flags.split(' ').each do |substr|
|
15
|
+
if skip
|
16
|
+
skip = false
|
17
|
+
next
|
18
|
+
end
|
19
|
+
if substr == '-isystem'
|
20
|
+
skip = true
|
21
|
+
next
|
22
|
+
end
|
23
|
+
if new_flags.length > 0
|
24
|
+
new_flags += ' '
|
25
|
+
end
|
26
|
+
new_flags += substr
|
27
|
+
end
|
28
|
+
if new_flags.length > 0
|
29
|
+
@attributes['OTHER_CFLAGS'] = new_flags
|
30
|
+
else
|
31
|
+
remove_attr_with_key('OTHER_CFLAGS')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Pod
|
39
|
+
class Installer
|
40
|
+
class PostInstallHooksContext
|
41
|
+
attr_accessor :aggregate_targets
|
42
|
+
def self.generate(sandbox, pods_project, aggregate_targets)
|
43
|
+
context = super
|
44
|
+
UI.info "[#] generate method of post install hook context override"
|
45
|
+
context.aggregate_targets = aggregate_targets
|
46
|
+
context
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
module ProjectHeaderMap
|
51
|
+
HooksManager.register('cocoapods-project-hmap', :post_install) do |post_context|
|
52
|
+
post_context.aggregate_targets.each do |one|
|
53
|
+
hmap = Hash.new
|
54
|
+
one.pod_targets.each do |target|
|
55
|
+
target.public_header_mappings_by_file_accessor.each do |facc, headers|
|
56
|
+
headers.each do |key, value|
|
57
|
+
value.each do |path|
|
58
|
+
pn = Pathname.new(path)
|
59
|
+
name = pn.basename.to_s
|
60
|
+
dirname = pn.dirname.to_s + '/'
|
61
|
+
# construct hmap hash info
|
62
|
+
path_info = Hash['suffix' => name, 'prefix' => dirname]
|
63
|
+
# import with quote
|
64
|
+
hmap[name] = path_info
|
65
|
+
# import with angle bracket
|
66
|
+
hmap["#{target.name}/#{name}"] = path_info
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
unless hmap.empty?
|
73
|
+
path = post_context.sandbox_root + "/#{one.name}-hmap.json"
|
74
|
+
path_hmap = post_context.sandbox_root + "/#{one.name}.hmap"
|
75
|
+
# write hmap json to file
|
76
|
+
File.open(path, 'w') { |file| file << hmap.to_json }
|
77
|
+
# json to hmap
|
78
|
+
system("hmap convert #{path} #{path_hmap}")
|
79
|
+
# delete json file
|
80
|
+
File.delete(path)
|
81
|
+
# override xcconfig
|
82
|
+
one.xcconfigs.each do |config_name, config_file|
|
83
|
+
config_file << Hash['OTHER_CFLAGS' => "-I ${PODS_ROOT}/#{one.name}.hmap"]
|
84
|
+
config_file << Hash['OTHER_SWIFT_FLAGS' => "-Xcc -I${PODS_ROOT}/#{one.name}.hmap"]
|
85
|
+
config_file.remove_header_search_path
|
86
|
+
xcconfig_path = one.xcconfig_path(config_name)
|
87
|
+
config_file.save_as(xcconfig_path)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-project-hmap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- chenxGen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-20 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-project-hmap.
|
42
|
+
email:
|
43
|
+
- chenxGen@outlook.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-project-hmap.gemspec
|
54
|
+
- lib/cocoapods-project-hmap.rb
|
55
|
+
- lib/cocoapods-project-hmap/gem_version.rb
|
56
|
+
- lib/cocoapods_plugin.rb
|
57
|
+
homepage: https://github.com/chenxGen/cocoapods-project-hmap
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubygems_version: 3.0.3
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: A longer description of cocoapods-project-hmap.
|
80
|
+
test_files: []
|