Skip to content

Commit 051843f

Browse files
committed
Merge branch feature/0.0.4 into main
2 parents 76fdf48 + 4cba284 commit 051843f

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module CocoapodsProjectHmap
2-
VERSION = "0.0.3"
2+
VERSION = "0.0.4"
33
end

lib/cocoapods-project-hmap/hmap_generator.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def initialize
99
@hmap = Hash.new
1010
end
1111
# header_mapping : [Hash{FileAccessor => Hash}] Hash of file accessors by header mappings.
12-
def add_hmap_with_header_mapping(header_mapping, type, target_name=nil)
12+
def add_hmap_with_header_mapping(header_mapping, type, target_name=nil, module_name=nil)
1313
header_mapping.each do |facc, headers|
1414
headers.each do |key, value|
1515
value.each do |path|
@@ -22,9 +22,14 @@ def add_hmap_with_header_mapping(header_mapping, type, target_name=nil)
2222
# import with quote
2323
@hmap[name] = path_info
2424
end
25-
if type & ANGLE_BRACKET > 0 && target_name != nil
26-
# import with angle bracket
27-
@hmap["#{target_name}/#{name}"] = path_info
25+
if type & ANGLE_BRACKET > 0
26+
if target_name != nil
27+
# import with angle bracket
28+
@hmap["#{target_name}/#{name}"] = path_info
29+
end
30+
if module_name != nil && module_name != target_name
31+
@hmap["#{module_name}/#{name}"] = path_info
32+
end
2833
end
2934
end
3035
end

lib/cocoapods-project-hmap/pod_target.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# !/usr/bin/env ruby
22
require 'cocoapods-project-hmap/xcconfig'
3+
require 'cocoapods-project-hmap/hmap_generator'
34

45
module Pod
56
class PodTarget
@@ -26,6 +27,13 @@ def reset_header_search_with_relative_hmap_path(hmap_path)
2627
puts 'Unknown build settings'.red
2728
end
2829
end
30+
def recursively_add_dependent_headers_to_hmap(hmap, generate_type)
31+
dependent_targets.each do |depend_target|
32+
# set public header for dependent target
33+
hmap.add_hmap_with_header_mapping(depend_target.public_header_mappings_by_file_accessor, generate_type, depend_target.name, depend_target.product_module_name)
34+
depend_target.recursively_add_dependent_headers_to_hmap(hmap, generate_type)
35+
end
36+
end
2937
end
3038
class AggregateTarget
3139
def reset_header_search_with_relative_hmap_path(hmap_path)

lib/cocoapods-project-hmap/post_install_hook_context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def generate(sandbox, pods_project, aggregate_targets)
2828
end
2929
end
3030
else
31-
# PostInstallHooksContext inherit BaseContext, just override `generate`
31+
# PostInstallHooksContext inherited from BaseContext, just override `generate`
3232
def self.generate(sandbox, pods_project, aggregate_targets)
3333
context = super
3434
UI.info "- generate method of post install hook context override"

lib/cocoapods_plugin.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require 'cocoapods-project-hmap/podfile_dsl'
44
require 'cocoapods-project-hmap/pod_target'
55
require 'cocoapods-project-hmap/post_install_hook_context'
6-
require 'cocoapods-project-hmap/hmap_generator'
76

87
module ProjectHeaderMap
98
Pod::HooksManager.register('cocoapods-project-hmap', :post_install) do |post_context|
@@ -18,14 +17,19 @@ module ProjectHeaderMap
1817
Pod::UI.message "- hanlding headers of aggregate target :#{one.name}".green
1918
one.pod_targets.each do |target|
2019
Pod::UI.message "- hanlding headers of target :#{target.name}"
21-
pods_hmap.add_hmap_with_header_mapping(target.public_header_mappings_by_file_accessor, generate_type, target.name)
20+
# There is no need to add headers of dynamic framework to hmap.
21+
unless target.defines_module? && target.requires_frameworks?
22+
pods_hmap.add_hmap_with_header_mapping(target.public_header_mappings_by_file_accessor, generate_type, target.name, target.product_module_name)
23+
else
24+
Pod::UI.message "- skip dynamic framework: #{target.name}"
25+
end
26+
2227
unless $hmap_black_pod_list.include?(target.name) || $prebuilt_hmap_for_pod_targets == false
2328
target_hmap = HmapGenerator.new
2429
# set project header for current target
25-
target_hmap.add_hmap_with_header_mapping(target.header_mappings_by_file_accessor, HmapGenerator::BOTH, target.name)
26-
target.dependent_targets.each do |depend_target|
27-
# set public header for dependent target
28-
target_hmap.add_hmap_with_header_mapping(depend_target.public_header_mappings_by_file_accessor, generate_type, depend_target.name)
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)
2933
end
3034

3135
target_hmap_name="#{target.name}.hmap"

0 commit comments

Comments
 (0)