cocoapods-mapfile 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -22
- data/bin/{hmap_writer → hmapfile} +2 -2
- data/lib/cocoapods_plugin.rb +18 -4
- data/lib/{cocoapods-hmap → hmap}/command/hmap_gen.rb +16 -8
- data/lib/{cocoapods-hmap → hmap}/command/hmap_reader.rb +12 -9
- data/lib/hmap/command/hmap_writer.rb +53 -0
- data/lib/hmap/command.rb +26 -0
- data/lib/{cocoapods-hmap → hmap}/exceptions.rb +0 -0
- data/lib/{cocoapods-hmap → hmap}/executable.rb +0 -0
- data/lib/{cocoapods-hmap → hmap}/framework/framework_vfs.rb +12 -13
- data/lib/hmap/helper/build_setting_constants.rb +13 -0
- data/lib/hmap/helper/hmap_helper.rb +212 -0
- data/lib/hmap/helper/pods_helper.rb +98 -0
- data/lib/{cocoapods-hmap → hmap/helper}/utils.rb +0 -4
- data/lib/hmap/helper/xcconfig_helper.rb +105 -0
- data/lib/{cocoapods-hmap → hmap}/hmap_reader.rb +1 -0
- data/lib/{cocoapods-hmap/hmap_save.rb → hmap/hmap_saver.rb} +11 -1
- data/lib/{cocoapods-hmap → hmap}/hmap_struct.rb +5 -4
- data/lib/hmap/hmap_writer.rb +99 -0
- data/lib/{cocoapods-hmap → hmap}/mapfile.rb +0 -0
- data/lib/hmap/pods_specification.rb +65 -0
- data/lib/hmap/version.rb +5 -0
- data/lib/hmap.rb +22 -0
- metadata +34 -34
- data/bin/hmap_reader +0 -12
- data/lib/cocoapods-hmap/helper/build_setting_helper.rb +0 -40
- data/lib/cocoapods-hmap/helper/pods_helper.rb +0 -104
- data/lib/cocoapods-hmap/helper/xcconfig_helper.rb +0 -82
- data/lib/cocoapods-hmap/hmap_writer.rb +0 -107
- data/lib/cocoapods-hmap/pods_specification.rb +0 -60
- data/lib/cocoapods-hmap/version.rb +0 -5
- data/lib/cocoapods-hmap/view.rb +0 -34
- data/lib/cocoapods_hmap.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7638b72b3d9fe0246d6dd7a06aba65b29ad95ccc30fdf7567626141f90c58d43
|
4
|
+
data.tar.gz: 62b76aa9a97ada6c2e0e187092c2c8ad669e1d55bd07e6efe0f95f00cc0ba5a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 723055fb0d1a47079499121296b2c0236f007a96a6cc023f6518a1888a3cb0d87e09de92dc6a820193187e1b9e3e8cdfc5d7c4d6fa2820942768b4972ddde1a7
|
7
|
+
data.tar.gz: 05d078150dca66846048b6dc73b29e2c6dd8d8e182bf1504dd3a17b973cd5101c2429d8c63cbd0d4d886ef92d920116481415c56542f1ae4adeda7574b48691d
|
data/README.md
CHANGED
@@ -7,11 +7,13 @@ A CocoaPods plugin which can gen/read header map file.
|
|
7
7
|
**hmap-gen** is able to scan the header files of the target referenced components in the specified Cocoapods project, and generates a header map file that public to all the components
|
8
8
|
as well as generates a public and private header map file for each referenced component.
|
9
9
|
|
10
|
-
-
|
11
|
-
-
|
10
|
+
- <header.h> : -I<hmap file path>
|
11
|
+
- "header.h" : -iquote <hmap file path>
|
12
12
|
|
13
13
|
For framework, use [yaml-vfs](https://github.com/Cat1237/yaml-vfs) create VFS file to map framework Headers and Modules dir and pass VFS file to `-ivfsoverlay` parameter.
|
14
14
|
|
15
|
+
- vfs : -ivfsoverlay <all-product-headers.yaml>
|
16
|
+
|
15
17
|
A hmap file includes four types of headers:
|
16
18
|
|
17
19
|
- header.h
|
@@ -19,12 +21,6 @@ A hmap file includes four types of headers:
|
|
19
21
|
- <project_name/header.h> **based on podspec**
|
20
22
|
- <podspec source header/**/header.h> **based on podspec**
|
21
23
|
|
22
|
-
At the same time, **hmap-reader** can read the header, bucktes, string_table information saved in the header map file.
|
23
|
-
|
24
|
-
- ✅ It can read hmap file.
|
25
|
-
|
26
|
-
- ✅ It can generate header map file.
|
27
|
-
|
28
24
|
## Installation
|
29
25
|
|
30
26
|
Add this line to your application's Gemfile:
|
@@ -64,39 +60,73 @@ $ pod hmap-gen --project-directory=/project/dir/ --nosave-origin-header-search-p
|
|
64
60
|
# cleanup the hmap file
|
65
61
|
$ pod hmap-gen --clean-hmap
|
66
62
|
|
63
|
+
# no keep xcconfig file [HEADER_SEARCH_PATHS] and [USER_HEADER_SEARCH_PATHS] value
|
64
|
+
$ pod hmap-gen --fno-save-origin
|
65
|
+
|
66
|
+
# ⚠️no keep xcconfig file [HEADER_SEARCH_PATHS] and [USER_HEADER_SEARCH_PATHS] value, except for the values set by[--allow-targets]
|
67
|
+
$ pod hmap-gen --fno-save-origin --allow-targets=Realm, YYKit
|
68
|
+
|
69
|
+
# not use automatically generated hmap file from Xcode, use [hmap-gen]
|
70
|
+
$ pod hmap-gen --fno-use-origin-headermap
|
71
|
+
|
67
72
|
# read the hmap file from /hmap/dir/file
|
68
73
|
$ pod hmap-reader --hmap-path=/hmap/dir/file
|
69
74
|
```
|
70
75
|
|
71
|
-
At same time, you can put this line in your podfile:
|
72
|
-
|
73
76
|
```rb
|
74
77
|
plugin 'cocoapods-mapfile'
|
75
78
|
```
|
76
79
|
This was equl:
|
77
80
|
```rb
|
78
|
-
pod hmap-gen --project-directory=/project/dir/
|
81
|
+
$ pod hmap-gen --project-directory=/project/dir/
|
79
82
|
```
|
83
|
+
or, you can set some value:
|
80
84
|
|
81
|
-
|
85
|
+
```rb
|
86
|
+
plugin('cocoapods-mapfile', allow_targets: ['Realm', 'YYKit'], save_origin: false, use_origin_headermap: false)
|
87
|
+
```
|
88
|
+
This was equl:
|
89
|
+
```rb
|
90
|
+
$ pod hmap-gen --fno-save-origin --fno-use-origin-headermap --allow-targets=Realm, YYKit
|
91
|
+
```
|
82
92
|
|
83
|
-
|
93
|
+
Every time you execute pod install or pod update, `cocoapods-mapfile` will automatically generate a `header map file` for you and modify:
|
94
|
+
- `OTHER_CPLUSPLUSFLAGS`
|
95
|
+
- `OTHER_CFLAGS`
|
96
|
+
- `USE_HEADERMAP`
|
97
|
+
- `USER_HEADER_SEARCH_PATHS`
|
98
|
+
- `HEAD_SEARCH_PATHS`
|
84
99
|
|
85
|
-
|
100
|
+
## Command Line Tool
|
86
101
|
|
87
|
-
-
|
88
|
-
- `--nosave-origin-header-search-paths`: This option will not save xcconfig origin [HEADER_SEARCH_PATHS] and put `hmap file path` first.
|
89
|
-
- `--clean-hmap`: This option will clean up all `hmap-gen/hmap-writer` setup for hmap.
|
102
|
+
Installing the `cocoapods-mapfile` gem will also install two command-line tool `hmapfile reader` and `hmapfile writer` which you can use to generate header map file and read hmap file.
|
90
103
|
|
91
|
-
|
104
|
+
For more information consult
|
105
|
+
- `hmapfile --help`,
|
106
|
+
- `hmapfile reader --help`
|
107
|
+
- `hmapfile writer --help`
|
92
108
|
|
93
|
-
|
109
|
+
### Usage
|
94
110
|
|
95
|
-
|
111
|
+
```shell
|
112
|
+
# Read or write header map file.
|
113
|
+
$ hmapfile COMMAND
|
114
|
+
```
|
115
|
+
#### Commands
|
116
|
+
`hmapfile reader`:
|
117
|
+
- `--hmap-path=/hmap/dir/file`: Read this path of the hmap file.
|
118
|
+
|
119
|
+
`hmapfile writer`:
|
120
|
+
- `--json-path=/project/dir/json`: The path to the hmap json data.
|
121
|
+
- `--output-path=/project/dir/hmap file`: The path json data to the hmap file.
|
96
122
|
|
97
|
-
|
123
|
+
example:
|
98
124
|
|
99
|
-
|
125
|
+
```shell
|
126
|
+
hmapfile writer --json-path=../cat.json --output-path=../cat.hmap
|
127
|
+
|
128
|
+
hmapfile reader --hmap-path=../cat.hmap
|
129
|
+
```
|
100
130
|
|
101
131
|
## Contributing
|
102
132
|
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,13 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'cocoapods-hmap/command/hmap_reader'
|
3
|
+
require 'hmap/command/hmap_gen'
|
5
4
|
|
6
5
|
module Pod
|
7
6
|
# hook
|
8
7
|
module CocoaPodsHMapHook
|
9
|
-
HooksManager
|
10
|
-
|
8
|
+
@HooksManager = HooksManager
|
9
|
+
@HooksManager.register('cocoapods-mapfile', :post_install) do |_, options|
|
10
|
+
args = ["--project-directory=#{Config.instance.installation_root}"]
|
11
|
+
allow_targets = options['allow_targets']
|
12
|
+
unless allow_targets.nil?
|
13
|
+
if allow_targets.is_a?(Array)
|
14
|
+
args << "--allow-targets=#{allow_targets.join(', ')}" unless allow_targets.empty?
|
15
|
+
else
|
16
|
+
print 'waring:'.yellow, \
|
17
|
+
'plugin cocoapods-mapfile args allow_targets must be a array, like ## allow_targets: [target1, targte2] ##'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
save_origin = options['save_oripodgin'].nil? ? true : options['save_origin']
|
21
|
+
use_origin_headermap = options['use_origin_headermap'].nil? ? true : options['use_origin_headermap']
|
22
|
+
args << '--fno-save-origin' unless save_origin
|
23
|
+
args << '--fno-use-origin-headermap' unless use_origin_headermap
|
24
|
+
Command::HMapGen.run(args)
|
11
25
|
end
|
12
26
|
end
|
13
27
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'cocoapods'
|
3
|
+
require 'hmap'
|
5
4
|
|
6
5
|
module Pod
|
7
6
|
class Command
|
@@ -17,9 +16,11 @@ module Pod
|
|
17
16
|
def initialize(argv)
|
18
17
|
super
|
19
18
|
project_directory = argv.option('project-directory')
|
20
|
-
|
19
|
+
targets = argv.option('allow-targets') || ''
|
20
|
+
@allow_targets = targets.split(%r{,\s*})
|
21
|
+
@no_use_build_in_headermap = !argv.flag?('fno-use-origin-headermap', false)
|
22
|
+
@save_origin_build_setting = !argv.flag?('fno-save-origin', false)
|
21
23
|
@clean_hmap = argv.flag?('clean-hmap', false)
|
22
|
-
|
23
24
|
return if project_directory.nil?
|
24
25
|
|
25
26
|
@project_directory = Pathname.new(project_directory).expand_path
|
@@ -34,16 +35,23 @@ module Pod
|
|
34
35
|
# help
|
35
36
|
def self.options
|
36
37
|
[
|
37
|
-
['--project-directory=/project/dir/', 'The path to the root of the project
|
38
|
-
|
39
|
-
|
38
|
+
['--project-directory=/project/dir/', 'The path to the root of the project directory'],
|
39
|
+
['--allow-targets=target, target1, target2', 'If we set --fno-use-origin-headermap and ' \
|
40
|
+
'--fno-save-origin, we can use this option to decide which targets to use hmap file while keeping the initial settings'],
|
41
|
+
['--fno-save-origin',
|
42
|
+
'This option will not save xcconfig origin [HEADER_SEARCH_PATHS] and put hmap file first'],
|
43
|
+
['--fno-use-origin-headermap',
|
44
|
+
'This option will use Xcode built-in options Use Header Maps and not use this code gen hmap file'],
|
40
45
|
['--clean-hmap', 'This option will clean up all hmap-gen setup for hmap.']
|
41
46
|
].concat(super)
|
42
47
|
end
|
43
48
|
|
44
49
|
def run
|
45
50
|
UI.section "\n[hmap-gen] start.............." do
|
46
|
-
HMap::MapFileWriter.new(@
|
51
|
+
HMap::MapFileWriter.new(@save_origin_build_setting,
|
52
|
+
@clean_hmap,
|
53
|
+
@allow_targets,
|
54
|
+
use_build_in_headermap: @no_use_build_in_headermap)
|
47
55
|
end
|
48
56
|
UI.puts('[hmap-gen] finish..............')
|
49
57
|
end
|
@@ -1,18 +1,22 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'cocoapods'
|
3
|
+
require 'hmap'
|
5
4
|
|
6
|
-
module
|
5
|
+
module HMap
|
7
6
|
class Command
|
8
7
|
# hmap file reader cmd
|
9
|
-
class
|
8
|
+
class Reader < Command
|
10
9
|
self.summary = 'Read mapfile and puts result.'
|
11
10
|
|
12
11
|
self.description = <<-DESC
|
13
12
|
Read mapfile and puts result, header, buckets, string_table.
|
14
13
|
DESC
|
15
14
|
|
15
|
+
self.arguments = [
|
16
|
+
# framework_p, r_header, r_m
|
17
|
+
CLAide::Argument.new('--hmap-path', true)
|
18
|
+
]
|
19
|
+
|
16
20
|
def initialize(argv)
|
17
21
|
super
|
18
22
|
mapfile_path = argv.option('hmap-path')
|
@@ -21,7 +25,7 @@ module Pod
|
|
21
25
|
|
22
26
|
def validate!
|
23
27
|
super
|
24
|
-
banner! if help?
|
28
|
+
# banner! if help?
|
25
29
|
raise '[ERROR]: --hmap-path no set'.red unless File.exist?(@mapfile_path)
|
26
30
|
end
|
27
31
|
|
@@ -32,10 +36,9 @@ module Pod
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def run
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
UI.puts("\n[hmap-reader] finish..............\n".yellow)
|
39
|
+
puts "\n[hmap-reader] start..............\n".yellow
|
40
|
+
HMap::MapFileReader.new(@mapfile_path)
|
41
|
+
puts "\n[hmap-reader] finish..............\n".yellow
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HMap
|
4
|
+
class Command
|
5
|
+
# hmap file gen cmd
|
6
|
+
class Writer < Command
|
7
|
+
# summary
|
8
|
+
self.summary = 'Analyzes the input json and gen each dependencie mapfile.'
|
9
|
+
|
10
|
+
self.description = <<-DESC
|
11
|
+
Analyzes the input json and gen each dependencie mapfile.
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
# framework_p, r_header, r_m
|
16
|
+
CLAide::Argument.new('--json-path', true),
|
17
|
+
CLAide::Argument.new('--output-path', false)
|
18
|
+
]
|
19
|
+
|
20
|
+
def initialize(argv)
|
21
|
+
super
|
22
|
+
json_path = argv.option('json-path')
|
23
|
+
@json_path = json_path unless json_path.nil?
|
24
|
+
output_path = argv.option('output-path')
|
25
|
+
@output_path = output_path.nil? ? Pathname('.') : Pathname(output_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate!
|
29
|
+
super
|
30
|
+
help! 'error: no input json files which to use with the `--json-path` option.' if @json_path.nil?
|
31
|
+
help! "error: Input json file #{@json_path}: no such file" unless File.exist?(@json_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
# help
|
35
|
+
def self.options
|
36
|
+
[
|
37
|
+
['--json-path=/project/dir/json', 'The path to the hmap json data.'],
|
38
|
+
['--output-path=/project/dir/hmap file', 'The path json data to the hmap file.']
|
39
|
+
].concat(super)
|
40
|
+
end
|
41
|
+
|
42
|
+
def run
|
43
|
+
puts "\n[hmap-gen-from-json] start..............".yellow
|
44
|
+
json_file = File.read(@json_path)
|
45
|
+
json = JSON.parse(json_file)
|
46
|
+
path = @output_path
|
47
|
+
path = path.join("#{File.basename(@json_path, '.*')}.hmap") if path.directory?
|
48
|
+
HMapSaver.new_from_buckets(json).write_to(path)
|
49
|
+
puts '[hmap-gen-from-json] finish..............'.yellow
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/hmap/command.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The primary namespace for VFS.
|
4
|
+
module HMap
|
5
|
+
require 'colored2'
|
6
|
+
require 'claide'
|
7
|
+
# The primary Command for VFS.
|
8
|
+
class Command < CLAide::Command
|
9
|
+
require 'hmap/command/hmap_writer'
|
10
|
+
require 'hmap/command/hmap_reader'
|
11
|
+
|
12
|
+
self.abstract_command = false
|
13
|
+
self.command = 'hmapfile'
|
14
|
+
self.version = VERSION
|
15
|
+
self.description = 'Read or write header map file.'
|
16
|
+
self.plugin_prefixes = %w[claide writer reader]
|
17
|
+
|
18
|
+
def initialize(argv)
|
19
|
+
super
|
20
|
+
return if ansi_output?
|
21
|
+
|
22
|
+
Colored2.disable!
|
23
|
+
String.send(:define_method, :colorize) { |string, _| string }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
File without changes
|
File without changes
|
@@ -1,5 +1,8 @@
|
|
1
|
+
require 'yaml_vfs'
|
2
|
+
|
1
3
|
module HMap
|
2
4
|
module Target
|
5
|
+
# Each fremaework vfs informations
|
3
6
|
class FrameworkEntry
|
4
7
|
attr_reader :configuration, :platform, :app_build_dir, :project_temp_dir
|
5
8
|
attr_accessor :headers_real_paths, :modules_real_paths
|
@@ -40,16 +43,15 @@ module HMap
|
|
40
43
|
has_private_module = module_path.glob('module*.modulemap').length > 1
|
41
44
|
e_headers = ->(path, *names) { names.inject(Pathname(path)) { |e, n| e.join(n) } }
|
42
45
|
@headers_real_paths += headers
|
43
|
-
@headers_real_paths << e_headers.call(app_build_dir, 'Headers',
|
44
|
-
"#{framework_name}-Swift.h")
|
46
|
+
@headers_real_paths << e_headers.call(app_build_dir, 'Headers', "#{framework_name}-Swift.h")
|
45
47
|
@modules_real_paths << e_headers.call(project_temp_dir, 'module.modulemap')
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
48
|
+
return unless has_private_module
|
49
|
+
|
50
|
+
@modules_real_paths << e_headers.call(entry.project_temp_dir, 'module.private.modulemap')
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
54
|
+
# A collection of Each FrameworkEntrys
|
53
55
|
class FrameworkVFS
|
54
56
|
attr_reader :entrys
|
55
57
|
|
@@ -75,17 +77,14 @@ module HMap
|
|
75
77
|
vfs_path.select { |k, _| k.include?(key) }
|
76
78
|
end
|
77
79
|
|
78
|
-
def write(path
|
80
|
+
def write(path)
|
79
81
|
vfs_path.each do |key, values|
|
80
82
|
es = values.map do |value|
|
81
|
-
|
82
|
-
|
83
|
-
VFS::FileCollectorEntry.new(Pathname(value.app_build_dir), modules_real_paths, headers_real_paths)
|
83
|
+
VFS::FileCollectorEntry.new(Pathname(value.app_build_dir), value.modules_real_paths,
|
84
|
+
value.headers_real_paths)
|
84
85
|
end
|
85
86
|
fc = VFS::FileCollector.new(es)
|
86
|
-
pa =
|
87
|
-
pa = File.join(path, key) unless path.nil?
|
88
|
-
pa = Pathname(pa)
|
87
|
+
pa = path.join(key)
|
89
88
|
pa.mkpath unless pa.exist?
|
90
89
|
fc.write_mapping(pa)
|
91
90
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HMap
|
4
|
+
# A collection of build settings key.
|
5
|
+
module BuildSettingConstants
|
6
|
+
OTHER_CFLAGS = 'OTHER_CFLAGS'
|
7
|
+
OTHER_CPLUSPLUSFLAGS = 'OTHER_CPLUSPLUSFLAGS'
|
8
|
+
HEAD_SEARCH_PATHS = 'HEADER_SEARCH_PATHS'
|
9
|
+
USER_HEADER_SEARCH_PATHS = 'USER_HEADER_SEARCH_PATHS'
|
10
|
+
USE_HEADERMAP = 'USE_HEADERMAP'
|
11
|
+
INGERITED = '$(inherited)'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
module HMap
|
6
|
+
# HMap file information
|
7
|
+
class HMapHeaderEntry
|
8
|
+
attr_reader :type, :headers
|
9
|
+
|
10
|
+
def initialize(type)
|
11
|
+
@type = type
|
12
|
+
@headers = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_header(header)
|
16
|
+
headers << header
|
17
|
+
end
|
18
|
+
|
19
|
+
def file_name(name)
|
20
|
+
name = 'hmap' if name.nil?
|
21
|
+
[name, '-', type, '.hmap'].join
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_setting_key
|
25
|
+
case type
|
26
|
+
when :i_headers, :iextra_headers
|
27
|
+
yield('-I', :HEADER_SEARCH_PATHS) if block_given?
|
28
|
+
when :iquote_headers, :extra_headers
|
29
|
+
yield('-iquote', :USER_HEADER_SEARCH_PATHS) if block_given?
|
30
|
+
else
|
31
|
+
raise Informative, "Error: header type not expect#{type}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_setting(path, name)
|
36
|
+
full_path = File.join(path, file_name(name))
|
37
|
+
build_setting_key do |key|
|
38
|
+
[key, "\"#{full_path}\""]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_setting_xcconfig(path, name)
|
43
|
+
full_path = File.join(path, file_name(name))
|
44
|
+
build_setting_key do |_, xc|
|
45
|
+
[xc, "\"#{full_path}\""]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# A collection of Each HMapHeaderEntry
|
51
|
+
class HMapHeaders
|
52
|
+
def initialize
|
53
|
+
@public_headers = HMapHeaderEntry.new(:i_headers)
|
54
|
+
@public_headers_e = HMapHeaderEntry.new(:iextra_headers)
|
55
|
+
@private_headers = HMapHeaderEntry.new(:iquote_headers)
|
56
|
+
@private_headers_e = HMapHeaderEntry.new(:extra_headers)
|
57
|
+
@unqi_headers = Set.new
|
58
|
+
end
|
59
|
+
|
60
|
+
def headers
|
61
|
+
public_headers + private_headers
|
62
|
+
end
|
63
|
+
|
64
|
+
def public_headers
|
65
|
+
[@public_headers, @public_headers_e]
|
66
|
+
end
|
67
|
+
|
68
|
+
def private_headers
|
69
|
+
[@private_headers, @private_headers_e]
|
70
|
+
end
|
71
|
+
|
72
|
+
def private_setting_for_reference(path, name)
|
73
|
+
headers_build_settings_for_reference(private_headers, path, name)
|
74
|
+
end
|
75
|
+
|
76
|
+
def public_setting_for_reference(path, name)
|
77
|
+
headers_build_settings_for_reference(public_headers, path, name)
|
78
|
+
end
|
79
|
+
|
80
|
+
def private_setting_for_options(path, name)
|
81
|
+
headers_build_settings_for_options(private_headers, path, name, ' ').join(' ')
|
82
|
+
end
|
83
|
+
|
84
|
+
def public_setting_for_options(path, name)
|
85
|
+
headers_build_settings_for_options(public_headers, path, name).join(' ')
|
86
|
+
end
|
87
|
+
|
88
|
+
def headers_build_settings_for_reference(headers, path, name)
|
89
|
+
headers.each_with_object({}) do |header, setting|
|
90
|
+
se = header.build_setting_xcconfig(path, name)
|
91
|
+
setting.merge!(Hash[*se]) { |_, oldval, newval| [oldval, newval].join(' ') }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def headers_build_settings_for_options(headers, path, name, key = '')
|
96
|
+
headers.each_with_object([]) do |header, setting|
|
97
|
+
setting << header.build_setting(path, name).join(key)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_headers(type, headers, module_name, headers_sandbox)
|
102
|
+
headers.each do |header|
|
103
|
+
next unless @unqi_headers.add?(header)
|
104
|
+
|
105
|
+
header_name = header.basename.to_s
|
106
|
+
header_dir = "#{header.dirname}/"
|
107
|
+
header_module_path = "#{module_name}/#{header_name}"
|
108
|
+
header_module_name = "#{module_name}/"
|
109
|
+
header_relative_path = header.relative_path_from(headers_sandbox).to_s
|
110
|
+
header_last_dir_name = "#{header.dirname.basename}/#{header_name}"
|
111
|
+
case type
|
112
|
+
when :private_header_files, :public_header_files
|
113
|
+
@public_headers.add_header([header_name, header_module_name, header_name]) if type == :public_header_files
|
114
|
+
@public_headers_e.add_header([header_module_path, header_dir, header_name])
|
115
|
+
@private_headers.add_header([header_name, header_module_name, header_name])
|
116
|
+
unless header_relative_path == header_module_path || header_relative_path == header_name
|
117
|
+
@private_headers_e.add_header([header_relative_path, header_dir, header_name])
|
118
|
+
end
|
119
|
+
unless header_last_dir_name == header_module_path
|
120
|
+
@private_headers_e.add_header([header_last_dir_name, header_dir, header_name])
|
121
|
+
end
|
122
|
+
when :source_files
|
123
|
+
@private_headers_e.add_header([header_name, header_dir, header_name])
|
124
|
+
@private_headers_e.add_header([header_last_dir_name, header_dir, header_name])
|
125
|
+
@private_headers_e.add_header([header_relative_path, header_dir, header_name])
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Gen hmap file and vfs file
|
132
|
+
class HMapHelper
|
133
|
+
attr_reader :i_headers, :iquote_headers, :directory, :framework_entrys, :headers
|
134
|
+
|
135
|
+
def initialize(directory)
|
136
|
+
puts "Current hmap files dir: #{directory}"
|
137
|
+
@directory = Pathname(directory)
|
138
|
+
@framework_entrys = []
|
139
|
+
@headers = HMapHeaders.new
|
140
|
+
end
|
141
|
+
|
142
|
+
def write_hmapfile(name = nil)
|
143
|
+
return if directory.nil?
|
144
|
+
|
145
|
+
@headers.headers.each do |entry|
|
146
|
+
path = directory.join(entry.file_name(name))
|
147
|
+
hmap_write_headers_to_path(path, entry.headers)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def write_vfsfiles(name = '')
|
152
|
+
return if framework_entrys.empty?
|
153
|
+
|
154
|
+
vfs_directory = directory.join(name).join('vfs')
|
155
|
+
puts "Current vfs files dir: #{vfs_directory}"
|
156
|
+
Target::FrameworkVFS.new(framework_entrys).write(vfs_directory)
|
157
|
+
puts 'vfs files write finish.'
|
158
|
+
end
|
159
|
+
|
160
|
+
def write_hmap_vfs_to_paths(hmap_name = nil, vfs_name = '')
|
161
|
+
write_vfsfiles(vfs_name)
|
162
|
+
write_hmapfile(hmap_name)
|
163
|
+
end
|
164
|
+
|
165
|
+
def add_framework_entry(configurations, platforms,
|
166
|
+
name, framework_name, module_path, headers)
|
167
|
+
entry = Target::FrameworkEntry.new_entrys_from_configurations_platforms(configurations, platforms, name,
|
168
|
+
framework_name, module_path, headers)
|
169
|
+
@framework_entrys += entry
|
170
|
+
end
|
171
|
+
|
172
|
+
def header_mappings(headers, headers_sandbox, module_name, type)
|
173
|
+
@headers.add_headers(type, headers, module_name, headers_sandbox)
|
174
|
+
end
|
175
|
+
|
176
|
+
def xcconfig_header_setting(is_framework, path = nil, name = nil)
|
177
|
+
i_s = @headers.public_setting_for_options(path, name)
|
178
|
+
setting_values = [[BuildSettingConstants::INGERITED, i_s].join(' ')]
|
179
|
+
setting_values << xcconfig_vfs_setting(path) if is_framework
|
180
|
+
setting_values << @headers.private_setting_for_options(path, name)
|
181
|
+
setting_values.each_with_object({}) do |value, setting|
|
182
|
+
setting.merge!({
|
183
|
+
BuildSettingConstants::OTHER_CFLAGS => value,
|
184
|
+
BuildSettingConstants::OTHER_CPLUSPLUSFLAGS => value
|
185
|
+
}) { |_, oldval, newval| [oldval, newval].join(' ') }
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
private
|
190
|
+
|
191
|
+
def xcconfig_vfs_setting(path)
|
192
|
+
path = directory if path.nil?
|
193
|
+
"-ivfsoverlay \"#{path}/vfs/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/all-product-headers.yaml\""
|
194
|
+
end
|
195
|
+
|
196
|
+
def i_headers_name(name)
|
197
|
+
directory.join("#{name}.hmap")
|
198
|
+
end
|
199
|
+
|
200
|
+
def iquote_headers_name
|
201
|
+
directory.join("#{name}-iquote.hmap")
|
202
|
+
end
|
203
|
+
|
204
|
+
def hmap_write_headers_to_path(path, headers)
|
205
|
+
return if headers.empty?
|
206
|
+
|
207
|
+
print "\t - Save hmap file to path: "
|
208
|
+
puts path.to_s.yellow
|
209
|
+
HMapSaver.new_from_buckets(headers).write_to(path)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|