cocoapods-project-hmap 0.0.4 → 0.0.6
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/README.md +25 -56
- data/README_en.md +9 -51
- data/lib/cocoapods-project-hmap/gem_version.rb +1 -1
- data/lib/cocoapods-project-hmap/hmap_generator.rb +3 -0
- data/lib/cocoapods-project-hmap/pod_target.rb +50 -6
- data/lib/cocoapods-project-hmap/podfile_dsl.rb +2 -12
- data/lib/cocoapods-project-hmap/post_install_hook_context.rb +8 -1
- data/lib/cocoapods-project-hmap/xcconfig.rb +46 -15
- data/lib/cocoapods_plugin.rb +7 -40
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76aafc1a72adea3d0470980e1ab52c0c5f47e837d276504182c447096669b0b6
|
4
|
+
data.tar.gz: 2db9c4c2e8ecf5f779b8bffea1c1f45de8903630aeb6c2beb1b62c6c95fd7ccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60509c81ad64b51dbc6e0db6f0b017ef18703a9802b1b85344fb2b9736bd078a6e2558daf6741b96991d1f9ef2facb71bf17e31be7b02bc5c22f1654b754e754
|
7
|
+
data.tar.gz: cc92de52b40cded06bc1970b65ebef988f9ffab233edc13d051715e173682521629d54ca835263225909fef4077f234d705a1f97299960f942cde9f2cc9ad8f7
|
data/README.md
CHANGED
@@ -1,57 +1,22 @@
|
|
1
1
|
# cocoapods-project-hmap
|
2
2
|
|
3
|
-
此插件思路来源于[《一款可以让大型iOS工程编译速度提升50%的工具》](https://tech.meituan.com/2021/02/25/cocoapods-hmap-prebuilt.html)。通过使用hmap代替文件路径搜索优化预处理阶段中头文件搜索的性能实现编译速度提升。
|
4
|
-
|
5
|
-
[English](./README_en.md)
|
6
|
-
|
7
|
-
##
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
| 100 source files & 125 pods (plugin) | 165.76690363883972 | [166.8555600643158, 165.40182876586914, 165.04332208633423] |
|
21
|
-
| > optimization (speed) | 16.09% | |
|
22
|
-
| > optimization (time cost) | 13.86% | |
|
23
|
-
| 1 source files & 125 pods (origin) | 170.00553512573242 | [175.31463813781738, 173.79285717010498, 160.9091100692749] |
|
24
|
-
| 1 source files & 125 pods (plugin) | 124.49473492304485 | [123.54309391975403, 124.4949209690094, 125.4461898803711] |
|
25
|
-
| > optimization (speed) | 36.56% | |
|
26
|
-
| > optimization (time cost) | 26.77% | |
|
27
|
-
| Total (origin) | 181.22080246607462 | [218.57447242736816, 178.7542200088501, 179.97951698303223, 175.31463813781738, 173.79285717010498, 160.9091100692749] |
|
28
|
-
| Total (plugin) | 145.1308192809423 | [166.8555600643158, 165.40182876586914, 165.04332208633423, 123.54309391975403, 124.4949209690094, 125.4461898803711] |
|
29
|
-
| > optimization (speed) | 24.87% | |
|
30
|
-
| > optimization (time cost) | 19.91% | |
|
31
|
-
+--------------------------------------+--------------------+------------------------------------------------------------------------------------------------------------------------+
|
32
|
-
```
|
33
|
-
- Mac air (Apple M1/16g) :
|
34
|
-
|
35
|
-
```
|
36
|
-
+--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------------------+
|
37
|
-
| Case | Average(s) | Detail(s) |
|
38
|
-
+--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------------------+
|
39
|
-
| 100 source files & 125 pods (origin) | 95.07198365529378 | [91.36949586868286, 96.10968923568726, 97.73676586151123] |
|
40
|
-
| 100 source files & 125 pods (plugin) | 91.2074584166289 | [90.87663986448735, 90.77357686752014, 91.97326111793518] |
|
41
|
-
| > optimization (speed) | 4.24% | |
|
42
|
-
| > optimization (time cost) | 4.06% | |
|
43
|
-
| 1 source files & 125 pods (origin) | 81.564133644104 | [80.95829105377197, 82.07278513988386, 81.66132473945618] |
|
44
|
-
| 1 source files & 125 pods (plugin) | 79.28314812668217 | [78.21958923339844, 80.21097787748413, 79.17887886892395] |
|
45
|
-
| > optimization (speed) | 2.98% | |
|
46
|
-
| > optimization (time cost) | 2.89% | |
|
47
|
-
| Total (origin) | 88.3180586496989 | [91.36949586868286, 96.10968923568726, 97.73676586151123, 80.95829105377197, 82.07278513988386, 81.66132473945618] |
|
48
|
-
| Total (plugin) | 85.2053037/161153 | [90.87663986448735, 90.77357686752014, 91.97326111793518, 78.21958923339844, 80.21097787748413, 79.17887886892395] |
|
49
|
-
| > optimization (speed) | 3.65% | |
|
50
|
-
| > optimization (time cost) | 3.52% | |
|
51
|
-
+--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------------------+
|
52
|
-
```
|
53
|
-
|
54
|
-
从上面的输出日志可以看出,插件可以带来3%-36%的编译速度提升,在使用Intel芯片的机器上优化效果还是挺好的,但是在使用Apple M1芯片的机器上效果就约等于没有了,只能说是M1的性能实在牛批。**如果你用的是M1,这里建议直接 `return`**
|
3
|
+
此插件思路来源于[《一款可以让大型iOS工程编译速度提升50%的工具》](https://tech.meituan.com/2021/02/25/cocoapods-hmap-prebuilt.html)。通过使用 header map (以下简称 hmap ) 代替文件路径搜索优化预处理阶段中头文件搜索的性能实现编译速度提升。
|
4
|
+
|
5
|
+
[English Version](./README_en.md)
|
6
|
+
|
7
|
+
## 首先,什么样的项目适合使用这个插件?
|
8
|
+
|
9
|
+
- **仅适合使用 objective-c 作为主要开发语言项目**,因为 swift 没有头文件的概念,从其编译原理上看并没有什么帮助;
|
10
|
+
|
11
|
+
- **不适合 Podfile 中 开启了 `use_frameworks!` or `use_modular_headers!` 的项目使用**;为了兼容 clang module 特性,采取的策略是不对开启了 DEFINES_MODULE 的项目生成 hmap;
|
12
|
+
|
13
|
+
- **不适用于 CPU 为 M1 以及后续 M 系列芯片的 Mac**;因为使用之后提升也很小;
|
14
|
+
|
15
|
+
综上,比较适合 old school 的项目使用此插件,如果你的项目满足以上条件推荐使用此插件,不然可能收效甚微,不建议继续往下看了。
|
16
|
+
|
17
|
+
## 插件名的由来
|
18
|
+
|
19
|
+
最初版本的插件仅仅为了给 Pod Project 和 Host Project 提供一个可行的跨项目 hmap 方案,填补 Xcode 自带的仅支持 Project 内部的 hmap 的空白,由此得名:cocoapods-project-hmap.
|
55
20
|
|
56
21
|
## 环境要求
|
57
22
|
|
@@ -65,15 +30,15 @@
|
|
65
30
|
|
66
31
|
## 使用
|
67
32
|
|
68
|
-
只需要在你的`Podfile
|
33
|
+
只需要在你的`Podfile`中添加如下行:`plugin 'cocoapods-project-hmap'` 声明使用该插件。
|
69
34
|
|
70
35
|
同时插件还为`Podfile`提供了一下几个可选的方法调用:
|
71
36
|
|
72
|
-
- **
|
37
|
+
- **set\_hmap\_black\_pod\_list:** 如果你有第三方库在使用插件后编译失败,可以尝试把它添加到黑名单中
|
73
38
|
|
74
|
-
- **
|
39
|
+
- **turn\_prebuilt\_hmap\_off\_for\_pod\_targets:** 如果你发现有太多的三方库需要添加到黑名单,你可以直接通过调用这个方法开启“纯净模式”,关闭插件对 Pod Project 内部所有 target 的 header 处理,仅仅对提供给主项目使用的 target 处理 hmap
|
75
40
|
|
76
|
-
- **
|
41
|
+
- **set\_hmap\_use\_strict\_mode:** 在一个 target 中引用另一个 target 的 header,严格意义上来说应该使用`#import <PodA/Header.h>`的方式,但是有些是通过`#import "Header.h"`,这种情况如果设置了对应的 header search path 编译是可以成功的,比如使用原生的 cocoapods 情况下,在项目中使用`#import "Masonry.h"`、`#import <Mansory.h>`和`#import <Masonry/Mansory.h>`三种方式引入都是可以成功的,如果你使用这个插件并且开启这个选项后只有`#import <Masonry/Mansory.h>`可以编译成功。默认为关闭。
|
77
42
|
|
78
43
|
|
79
44
|
最终你的Podfile看起来会是这样的 :
|
@@ -92,6 +57,10 @@ target 'app' do
|
|
92
57
|
end
|
93
58
|
```
|
94
59
|
|
60
|
+
## 联系方式
|
61
|
+
|
62
|
+
QQ: 930565063
|
63
|
+
|
95
64
|
## License
|
96
65
|
|
97
66
|
cocoapods-project-hmap is released under the MIT license. See LICENSE for details.
|
data/README_en.md
CHANGED
@@ -2,56 +2,14 @@
|
|
2
2
|
|
3
3
|
A cocoapods plugin to improve compilation speed at preprosessor phase by using hmap instead of file paths for header searching. The idea comes from [《一款可以让大型iOS工程编译速度提升50%的工具》](https://tech.meituan.com/2021/02/25/cocoapods-hmap-prebuilt.html)
|
4
4
|
|
5
|
-
##
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
```
|
14
|
-
+--------------------------------------+--------------------+------------------------------------------------------------------------------------------------------------------------+
|
15
|
-
| Case | Average(s) | Detail(s) |
|
16
|
-
+--------------------------------------+--------------------+------------------------------------------------------------------------------------------------------------------------+
|
17
|
-
| 100 source files & 125 pods (origin) | 192.43606980641684 | [218.57447242736816, 178.7542200088501, 179.97951698303223] |
|
18
|
-
| 100 source files & 125 pods (plugin) | 165.76690363883972 | [166.8555600643158, 165.40182876586914, 165.04332208633423] |
|
19
|
-
| > optimization (speed) | 16.09% | |
|
20
|
-
| > optimization (time cost) | 13.86% | |
|
21
|
-
| 1 source files & 125 pods (origin) | 170.00553512573242 | [175.31463813781738, 173.79285717010498, 160.9091100692749] |
|
22
|
-
| 1 source files & 125 pods (plugin) | 124.49473492304485 | [123.54309391975403, 124.4949209690094, 125.4461898803711] |
|
23
|
-
| > optimization (speed) | 36.56% | |
|
24
|
-
| > optimization (time cost) | 26.77% | |
|
25
|
-
| Total (origin) | 181.22080246607462 | [218.57447242736816, 178.7542200088501, 179.97951698303223, 175.31463813781738, 173.79285717010498, 160.9091100692749] |
|
26
|
-
| Total (plugin) | 145.1308192809423 | [166.8555600643158, 165.40182876586914, 165.04332208633423, 123.54309391975403, 124.4949209690094, 125.4461898803711] |
|
27
|
-
| > optimization (speed) | 24.87% | |
|
28
|
-
| > optimization (time cost) | 19.91% | |
|
29
|
-
+--------------------------------------+--------------------+------------------------------------------------------------------------------------------------------------------------+
|
30
|
-
```
|
31
|
-
- Mac air (Apple M1/16g) :
|
32
|
-
|
33
|
-
```
|
34
|
-
+--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------------------+
|
35
|
-
| Case | Average(s) | Detail(s) |
|
36
|
-
+--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------------------+
|
37
|
-
| 100 source files & 125 pods (origin) | 95.07198365529378 | [91.36949586868286, 96.10968923568726, 97.73676586151123] |
|
38
|
-
| 100 source files & 125 pods (plugin) | 91.2074584166289 | [90.87663986448735, 90.77357686752014, 91.97326111793518] |
|
39
|
-
| > optimization (speed) | 4.24% | |
|
40
|
-
| > optimization (time cost) | 4.06% | |
|
41
|
-
| 1 source files & 125 pods (origin) | 81.564133644104 | [80.95829105377197, 82.07278513988386, 81.66132473945618] |
|
42
|
-
| 1 source files & 125 pods (plugin) | 79.28314812668217 | [78.21958923339844, 80.21097787748413, 79.17887886892395] |
|
43
|
-
| > optimization (speed) | 2.98% | |
|
44
|
-
| > optimization (time cost) | 2.89% | |
|
45
|
-
| Total (origin) | 88.3180586496989 | [91.36949586868286, 96.10968923568726, 97.73676586151123, 80.95829105377197, 82.07278513988386, 81.66132473945618] |
|
46
|
-
| Total (plugin) | 85.2053037/161153 | [90.87663986448735, 90.77357686752014, 91.97326111793518, 78.21958923339844, 80.21097787748413, 79.17887886892395] |
|
47
|
-
| > optimization (speed) | 3.65% | |
|
48
|
-
| > optimization (time cost) | 3.52% | |
|
49
|
-
+--------------------------------------+-------------------+--------------------------------------------------------------------------------------------------------------------+
|
50
|
-
```
|
51
|
-
|
52
|
-
The outputs indicate that this plugin has about 3%-36% build speed improvement, the improvement is not significant on mac using M1 processor because of Apple M1 processor's high IO performance (I GUESS...).
|
53
|
-
|
54
|
-
**So if you are using Mac with Apple M1 processor, There may be no need to use this plugin.**
|
5
|
+
## First
|
6
|
+
|
7
|
+
What kind of projects are recommended to use this plugin?
|
8
|
+
|
9
|
+
- **Project using objective-c as their main develop language**
|
10
|
+
- **Project not using `use_frameworks!` and `use_modular_headers!` in their Podfile**
|
11
|
+
|
12
|
+
and Developer not using Mac with M series CPU.
|
55
13
|
|
56
14
|
## Requirement
|
57
15
|
|
@@ -69,7 +27,7 @@ In your `Podfile`, add this line : `plugin 'cocoapods-project-hmap'`
|
|
69
27
|
|
70
28
|
And this plugin also provides Podfile DSL bellow:
|
71
29
|
|
72
|
-
- `set_hmap_black_pod_list`:
|
30
|
+
- `set_hmap_black_pod_list`: If you have some compilation error for pod targets because of this plugin, adding the target name to black list...
|
73
31
|
- `turn_prebuilt_hmap_off_for_pod_targets`: If you have to many build error after using this plugin, or have to add to many 'pod' to black list, I provides a most non-intrusive way to use, call this method `turn_prebuilt_hmap_off_for_pod_targets` to ignore hmap prebuilt for most of the pod target (excepting the 'main' pods, named `Pods-${YOUR SCHEME}`).
|
74
32
|
- `set_hmap_use_strict_mode`: Import a header in other library(PodA), strictly speaking, we should use `#import <PodA/Header.h>`, but not all library developer do like that, if you turn it on, you can find then.
|
75
33
|
|
@@ -1,14 +1,43 @@
|
|
1
1
|
# !/usr/bin/env ruby
|
2
2
|
require 'cocoapods-project-hmap/xcconfig'
|
3
3
|
require 'cocoapods-project-hmap/hmap_generator'
|
4
|
+
require 'cocoapods-project-hmap/podfile_dsl'
|
5
|
+
|
6
|
+
SAVED_HMAP_DIR='prebuilt-hmaps'
|
4
7
|
|
5
8
|
module Pod
|
9
|
+
class Target
|
10
|
+
attr_accessor :prebuilt_hmap_target_names
|
11
|
+
def save_hmap(hmap)
|
12
|
+
if hmap.empty? == false
|
13
|
+
target_hmap_name="#{name}.hmap"
|
14
|
+
relative_hmap_path = "#{SAVED_HMAP_DIR}/#{target_hmap_name}"
|
15
|
+
target_hmap_path = sandbox.root.to_s + "/#{relative_hmap_path}"
|
16
|
+
hmaps_dir = sandbox.root.to_s + "/#{SAVED_HMAP_DIR}"
|
17
|
+
unless File.exist?(hmaps_dir)
|
18
|
+
Dir.mkdir(hmaps_dir)
|
19
|
+
end
|
20
|
+
if hmap.save_to(target_hmap_path)
|
21
|
+
reset_header_search_with_relative_hmap_path(relative_hmap_path)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
def add_prebuilt_hmap_target(name)
|
26
|
+
@prebuilt_hmap_target_names = Array.new if @prebuilt_hmap_target_names == nil
|
27
|
+
@prebuilt_hmap_target_names << name
|
28
|
+
end
|
29
|
+
def concat_prebuilt_hmap_targets(names)
|
30
|
+
@prebuilt_hmap_target_names = Array.new if @prebuilt_hmap_target_names == nil
|
31
|
+
@prebuilt_hmap_target_names.concat(names) if names
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
6
35
|
class PodTarget
|
7
36
|
def reset_header_search_with_relative_hmap_path(hmap_path)
|
8
37
|
if build_settings.instance_of?(Hash)
|
9
38
|
build_settings.each do |config_name, setting|
|
10
39
|
config_file = setting.xcconfig
|
11
|
-
config_file.reset_header_search_with_relative_hmap_path(hmap_path)
|
40
|
+
config_file.reset_header_search_with_relative_hmap_path(hmap_path, @prebuilt_hmap_target_names.uniq)
|
12
41
|
# https://github.com/CocoaPods/CocoaPods/issues/1216
|
13
42
|
# just turn off private xcconfig's USE_HEADERMAP flag
|
14
43
|
config_file.set_use_hmap(false)
|
@@ -17,21 +46,36 @@ module Pod
|
|
17
46
|
end
|
18
47
|
elsif build_settings.instance_of?(BuildSettings::PodTargetSettings)
|
19
48
|
config_file = build_settings.xcconfig
|
20
|
-
config_file.reset_header_search_with_relative_hmap_path(hmap_path)
|
49
|
+
config_file.reset_header_search_with_relative_hmap_path(hmap_path, @prebuilt_hmap_target_names.uniq)
|
21
50
|
# https://github.com/CocoaPods/CocoaPods/issues/1216
|
22
51
|
# just turn off private xcconfig's USE_HEADERMAP flag
|
23
52
|
config_file.set_use_hmap(false)
|
24
53
|
config_path = xcconfig_path
|
25
54
|
config_file.save_as(config_path)
|
26
55
|
else
|
27
|
-
|
56
|
+
Pod::UI.notice 'Unknown build settings'
|
28
57
|
end
|
29
58
|
end
|
30
59
|
def recursively_add_dependent_headers_to_hmap(hmap, generate_type)
|
31
60
|
dependent_targets.each do |depend_target|
|
32
61
|
# set public header for dependent target
|
33
|
-
|
34
|
-
depend_target.
|
62
|
+
depend_target.generate_hmap(hmap, generate_type, true, true) if depend_target.respond_to?(:generate_hmap)
|
63
|
+
concat_prebuilt_hmap_targets(depend_target.prebuilt_hmap_target_names) if depend_target.prebuilt_hmap_target_names
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def generate_hmap(hmap, generate_type, only_public_headers=true, add_dependency=false)
|
68
|
+
# There is no need to add headers of target defines module to hmap.
|
69
|
+
unless defines_module?
|
70
|
+
unless $hmap_black_pod_list.include?(name)
|
71
|
+
add_prebuilt_hmap_target(name)
|
72
|
+
# Create hmap for current target if not in black list.
|
73
|
+
hmap.add_hmap_with_header_mapping(only_public_headers ? public_header_mappings_by_file_accessor : header_mappings_by_file_accessor, generate_type, name, product_module_name)
|
74
|
+
# Recursively add dependent targets if needed.
|
75
|
+
recursively_add_dependent_headers_to_hmap(hmap, generate_type) if add_dependency
|
76
|
+
else
|
77
|
+
Pod::UI.message "- skip target in black list :#{name}"
|
78
|
+
end
|
35
79
|
end
|
36
80
|
end
|
37
81
|
end
|
@@ -39,7 +83,7 @@ module Pod
|
|
39
83
|
def reset_header_search_with_relative_hmap_path(hmap_path)
|
40
84
|
# override xcconfig
|
41
85
|
xcconfigs.each do |config_name, config_file|
|
42
|
-
config_file.reset_header_search_with_relative_hmap_path(hmap_path)
|
86
|
+
config_file.reset_header_search_with_relative_hmap_path(hmap_path, @prebuilt_hmap_target_names.uniq)
|
43
87
|
config_path = xcconfig_path(config_name)
|
44
88
|
config_file.save_as(config_path)
|
45
89
|
end
|
@@ -1,17 +1,7 @@
|
|
1
1
|
# !/usr/bin/env ruby
|
2
|
-
# built-in black list pods
|
2
|
+
# built-in black list pods
|
3
3
|
# you can use hmap_black_pod_list to add other pods
|
4
|
-
$hmap_black_pod_list = [
|
5
|
-
'GoogleUtilities',
|
6
|
-
'MeshPipe',
|
7
|
-
'GoogleDataTransport',
|
8
|
-
'FirebaseCoreDiagnostics',
|
9
|
-
'FirebaseCore',
|
10
|
-
'FirebaseCrashlytics',
|
11
|
-
'FirebaseInstallations',
|
12
|
-
'CoreDragon',
|
13
|
-
'Objective-LevelDB'
|
14
|
-
]
|
4
|
+
$hmap_black_pod_list = []
|
15
5
|
|
16
6
|
$strict_mode = false
|
17
7
|
$prebuilt_hmap_for_pod_targets = true
|
@@ -27,13 +27,20 @@ module Pod
|
|
27
27
|
context
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
elsif version < Gem::Version.new('1.12.0')
|
31
31
|
# PostInstallHooksContext inherited from BaseContext, just override `generate`
|
32
32
|
def self.generate(sandbox, pods_project, aggregate_targets)
|
33
33
|
context = super
|
34
34
|
UI.info "- generate method of post install hook context override"
|
35
35
|
context.aggregate_targets = aggregate_targets
|
36
36
|
context
|
37
|
+
end
|
38
|
+
else
|
39
|
+
def self.generate(sandbox, pods_project, pod_target_subprojects, aggregate_targets)
|
40
|
+
context = super
|
41
|
+
UI.info "- generate method of post install hook context override"
|
42
|
+
context.aggregate_targets = aggregate_targets
|
43
|
+
context
|
37
44
|
end
|
38
45
|
end
|
39
46
|
end
|
@@ -7,12 +7,12 @@ module Xcodeproj
|
|
7
7
|
@attributes.delete(key)
|
8
8
|
end
|
9
9
|
end
|
10
|
-
def remove_header_search_path
|
10
|
+
def remove_header_search_path(prebuilt_hmap_target_names=nil)
|
11
11
|
header_search_paths = @attributes['HEADER_SEARCH_PATHS']
|
12
12
|
if header_search_paths
|
13
13
|
new_paths = Array.new
|
14
14
|
header_search_paths.split(' ').each do |p|
|
15
|
-
unless
|
15
|
+
unless search_path_should_be_deleted?(p, prebuilt_hmap_target_names)
|
16
16
|
new_paths << p
|
17
17
|
end
|
18
18
|
end
|
@@ -22,27 +22,58 @@ module Xcodeproj
|
|
22
22
|
remove_attr_with_key('HEADER_SEARCH_PATHS')
|
23
23
|
end
|
24
24
|
end
|
25
|
-
remove_system_option_in_other_cflags
|
25
|
+
remove_system_option_in_other_cflags(prebuilt_hmap_target_names)
|
26
26
|
end
|
27
|
-
def
|
27
|
+
def search_path_should_be_deleted?(search_path, prebuilt_hmap_target_names=nil)
|
28
|
+
# Check if the path should be deleted from search list
|
29
|
+
# 1. It must be at the ${PODS_ROOT} directory
|
30
|
+
# 2. It has generated hmap
|
31
|
+
ret = false
|
32
|
+
if search_path.include?('${PODS_ROOT}/Headers')
|
33
|
+
if prebuilt_hmap_target_names
|
34
|
+
ret = prebuilt_hmap_target_names.select { |name| search_path.include?(name) }.empty? == false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
ret
|
38
|
+
end
|
39
|
+
def remove_system_option_in_other_cflags(prebuilt_hmap_target_names=nil)
|
40
|
+
# ----------------------------------------------
|
41
|
+
# -I<dir>, --include-directory <arg>, --include-directory=<arg>
|
42
|
+
# Add directory to include search path. For C++ inputs, if there are multiple -I options,
|
43
|
+
# these directories are searched in the order they are given before the standard system directories are searched.
|
44
|
+
# If the same directory is in the SYSTEM include search paths, for example if also specified with -isystem, the -I option will be ignored
|
45
|
+
#
|
46
|
+
# -isystem<directory>
|
47
|
+
# Add directory to SYSTEM include search path
|
48
|
+
# ----------------------------------------------
|
28
49
|
flags = @attributes['OTHER_CFLAGS']
|
29
50
|
if flags
|
30
51
|
new_flags = ''
|
31
|
-
|
52
|
+
is_isystem_flag = false
|
32
53
|
flags.split(' ').each do |substr|
|
33
|
-
|
34
|
-
|
35
|
-
|
54
|
+
append_str = substr
|
55
|
+
# Previous flag is `isystem`
|
56
|
+
if is_isystem_flag
|
57
|
+
is_isystem_flag = false
|
58
|
+
if search_path_should_be_deleted?(append_str, prebuilt_hmap_target_names)
|
59
|
+
next
|
60
|
+
else
|
61
|
+
# recover
|
62
|
+
append_str = "-isystem #{append_str}"
|
63
|
+
end
|
36
64
|
end
|
37
|
-
|
38
|
-
|
65
|
+
|
66
|
+
if append_str == '-isystem'
|
67
|
+
is_isystem_flag = true
|
39
68
|
next
|
40
69
|
end
|
70
|
+
|
41
71
|
if new_flags.length > 0
|
42
72
|
new_flags += ' '
|
43
73
|
end
|
44
|
-
new_flags +=
|
74
|
+
new_flags += append_str
|
45
75
|
end
|
76
|
+
|
46
77
|
if new_flags.length > 0
|
47
78
|
@attributes['OTHER_CFLAGS'] = new_flags
|
48
79
|
else
|
@@ -50,10 +81,10 @@ module Xcodeproj
|
|
50
81
|
end
|
51
82
|
end
|
52
83
|
end
|
53
|
-
def reset_header_search_with_relative_hmap_path(hmap_path)
|
54
|
-
#
|
55
|
-
remove_header_search_path
|
56
|
-
#
|
84
|
+
def reset_header_search_with_relative_hmap_path(hmap_path, prebuilt_hmap_target_names=nil)
|
85
|
+
# Delete associate search paths
|
86
|
+
remove_header_search_path(prebuilt_hmap_target_names)
|
87
|
+
# Add hmap file to search path
|
57
88
|
new_paths = Array["${PODS_ROOT}/#{hmap_path}"]
|
58
89
|
header_search_paths = @attributes['HEADER_SEARCH_PATHS']
|
59
90
|
if header_search_paths
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,55 +1,22 @@
|
|
1
1
|
# !/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'cocoapods-project-hmap/podfile_dsl'
|
4
3
|
require 'cocoapods-project-hmap/pod_target'
|
5
4
|
require 'cocoapods-project-hmap/post_install_hook_context'
|
6
5
|
|
7
6
|
module ProjectHeaderMap
|
8
7
|
Pod::HooksManager.register('cocoapods-project-hmap', :post_install) do |post_context|
|
9
8
|
generate_type = $strict_mode ? HmapGenerator::ANGLE_BRACKET : HmapGenerator::BOTH
|
10
|
-
hmaps_dir=post_context.sandbox_root + '/prebuilt-hmaps'
|
11
|
-
unless File.exist?(hmaps_dir)
|
12
|
-
Dir.mkdir(hmaps_dir)
|
13
|
-
end
|
14
|
-
|
15
9
|
post_context.aggregate_targets.each do |one|
|
16
10
|
pods_hmap = HmapGenerator.new
|
17
|
-
Pod::UI.message "- hanlding headers of aggregate target :#{one.name}"
|
11
|
+
Pod::UI.message "- hanlding headers of aggregate target :#{one.name}"
|
18
12
|
one.pod_targets.each do |target|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
Pod::UI.message "- skip dynamic framework: #{target.name}"
|
25
|
-
end
|
26
|
-
|
27
|
-
unless $hmap_black_pod_list.include?(target.name) || $prebuilt_hmap_for_pod_targets == false
|
28
|
-
target_hmap = HmapGenerator.new
|
29
|
-
# set project header for current target
|
30
|
-
target_hmap.add_hmap_with_header_mapping(target.header_mappings_by_file_accessor, HmapGenerator::BOTH, target.name, target.product_module_name)
|
31
|
-
if target.respond_to?(:recursively_add_dependent_headers_to_hmap)
|
32
|
-
target.recursively_add_dependent_headers_to_hmap(target_hmap, generate_type)
|
33
|
-
end
|
34
|
-
|
35
|
-
target_hmap_name="#{target.name}.hmap"
|
36
|
-
target_hmap_path = hmaps_dir + "/#{target_hmap_name}"
|
37
|
-
relative_hmap_path = "prebuilt-hmaps/#{target_hmap_name}"
|
38
|
-
if target_hmap.save_to(target_hmap_path)
|
39
|
-
target.reset_header_search_with_relative_hmap_path(relative_hmap_path)
|
40
|
-
end
|
41
|
-
else
|
42
|
-
Pod::UI.message "- skip handling headers of target :#{target.name}"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
pods_hmap_name = "#{one.name}.hmap"
|
47
|
-
pods_hmap_path = hmaps_dir + "/#{pods_hmap_name}"
|
48
|
-
relative_hmap_path = "prebuilt-hmaps/#{pods_hmap_name}"
|
49
|
-
if pods_hmap.save_to(pods_hmap_path)
|
50
|
-
# override xcconfig
|
51
|
-
one.reset_header_search_with_relative_hmap_path(relative_hmap_path)
|
13
|
+
target.generate_hmap(pods_hmap, generate_type, true, false)
|
14
|
+
target_hmap = HmapGenerator.new
|
15
|
+
target.generate_hmap(target_hmap, HmapGenerator::BOTH, false, true)
|
16
|
+
target.save_hmap(target_hmap)
|
17
|
+
one.concat_prebuilt_hmap_targets(target.prebuilt_hmap_target_names)
|
52
18
|
end
|
19
|
+
one.save_hmap(pods_hmap)
|
53
20
|
end
|
54
21
|
end
|
55
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-project-hmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chenxGen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|