cocoapods-mapfile 0.2.0 → 0.2.5

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +80 -43
  3. data/bin/{hmap_writer → hmapfile} +2 -2
  4. data/lib/cocoapods_plugin.rb +18 -6
  5. data/lib/hmap/command/hmap_gen.rb +52 -0
  6. data/lib/{cocoapods-hmap → hmap}/command/hmap_reader.rb +14 -11
  7. data/lib/hmap/command/hmap_writer.rb +55 -0
  8. data/lib/hmap/command.rb +28 -0
  9. data/lib/hmap/constants.rb +198 -0
  10. data/lib/{cocoapods-hmap → hmap}/exceptions.rb +0 -0
  11. data/lib/{cocoapods-hmap → hmap/helper}/executable.rb +5 -6
  12. data/lib/{cocoapods-hmap → hmap/helper}/utils.rb +0 -4
  13. data/lib/hmap/hmap/hmap_bucketstr.rb +20 -0
  14. data/lib/{cocoapods-hmap → hmap/hmap}/hmap_reader.rb +4 -19
  15. data/lib/{cocoapods-hmap/hmap_save.rb → hmap/hmap/hmap_saver.rb} +21 -6
  16. data/lib/{cocoapods-hmap → hmap/hmap}/hmap_struct.rb +5 -4
  17. data/lib/hmap/hmap/hmap_writer.rb +52 -0
  18. data/lib/{cocoapods-hmap → hmap/hmap}/mapfile.rb +1 -1
  19. data/lib/hmap/user_interface.rb +22 -0
  20. data/lib/hmap/version.rb +5 -0
  21. data/lib/hmap/xc/context.rb +23 -0
  22. data/lib/hmap/xc/header_entry.rb +55 -0
  23. data/lib/hmap/xc/header_type.rb +32 -0
  24. data/lib/hmap/xc/pbx_helper.rb +68 -0
  25. data/lib/hmap/xc/product_helper.rb +36 -0
  26. data/lib/hmap/xc/resolver.rb +129 -0
  27. data/lib/hmap/xc/target/build_setting.rb +126 -0
  28. data/lib/hmap/xc/target/target.rb +76 -0
  29. data/lib/hmap/xc/target/target_context.rb +29 -0
  30. data/lib/hmap/xc/target/target_helper.rb +114 -0
  31. data/lib/hmap/xc/target/target_vfs.rb +122 -0
  32. data/lib/hmap/xc/target/xcconfig_helper.rb +109 -0
  33. data/lib/hmap/xc/workspace/project.rb +120 -0
  34. data/lib/hmap/xc/workspace/project_helper.rb +92 -0
  35. data/lib/hmap/xc/workspace/workspace.rb +83 -0
  36. data/lib/hmap.rb +24 -0
  37. metadata +76 -38
  38. data/bin/hmap_reader +0 -12
  39. data/lib/cocoapods-hmap/command/hmap_gen.rb +0 -52
  40. data/lib/cocoapods-hmap/framework/framework_vfs.rb +0 -95
  41. data/lib/cocoapods-hmap/helper/build_setting_helper.rb +0 -40
  42. data/lib/cocoapods-hmap/helper/pods_helper.rb +0 -104
  43. data/lib/cocoapods-hmap/helper/xcconfig_helper.rb +0 -82
  44. data/lib/cocoapods-hmap/hmap_writer.rb +0 -107
  45. data/lib/cocoapods-hmap/pods_specification.rb +0 -60
  46. data/lib/cocoapods-hmap/version.rb +0 -5
  47. data/lib/cocoapods-hmap/view.rb +0 -34
  48. data/lib/cocoapods_hmap.rb +0 -21
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+ require 'hmap/xc/target/target_vfs'
3
+
4
+ module HMap
5
+ class Platform
6
+ attr_reader :configuration, :platform
7
+
8
+ def self.new_from_platforms(configuration, platforms)
9
+ Utils.effective_platforms_names(platforms).map { |pl| new(configuration, pl) }
10
+ end
11
+
12
+ def initialize(configuration, platform)
13
+ @configuration = configuration
14
+ @platform = platform
15
+ end
16
+
17
+ def to_s
18
+ "#{configuration}-#{platform}"
19
+ end
20
+ end
21
+ end
22
+
23
+ module HMap
24
+ class BuildSettings
25
+ attr_reader :type, :platform
26
+
27
+ def self.new_from_platforms(type, platforms, context)
28
+ platforms.map { |platform| new(type, platform.to_s, context) }
29
+ end
30
+
31
+ def initialize(type, platform, context)
32
+ @type = type
33
+ @platform = platform.to_s || ''
34
+ @context = context
35
+ end
36
+
37
+ def write_or_symlink(path, data, need_platform)
38
+ return if data.nil? && path.nil?
39
+
40
+ if data.nil?
41
+ dir = platform if type == :all_product_headers
42
+ path = Constants.instance.full_hmap_filepath(type, path, dir)
43
+ symlink_to(path, need_platform)
44
+ else
45
+ write(data, need_platform)
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def file_name
52
+ return @file_name if defined? @file_name
53
+
54
+ product_name = @context.product_name if @context.respond_to? :product_name
55
+ @file_name = Constants.instance.full_hmap_filename(type, product_name)
56
+ end
57
+
58
+ def hmap_filepath(need_platform)
59
+ platform = ''
60
+ platform = @platform if need_platform
61
+ hmap_root = File.join(@context.hmap_root, platform, @context.temp_name)
62
+ File.join(hmap_root, file_name)
63
+ end
64
+
65
+ def symlink_to(path, need_platform)
66
+ return unless path.exist?
67
+
68
+ filepath = Pathname.new(hmap_filepath(need_platform))
69
+ filepath.dirname.mkpath unless filepath.exist?
70
+ return if File.identical?(filepath, path)
71
+
72
+ filepath.make_symlink(path)
73
+ end
74
+
75
+ def write(data, need_platform)
76
+ path = Constants.instance.full_hmap_filepath(type, hmap_filepath(need_platform))
77
+ if type == :all_product_headers
78
+ da = data[platform] || []
79
+ TargetVFSWriter.new(da).write!(path)
80
+ else
81
+ HMapSaver.new_from_buckets(data).write_to(path)
82
+ end
83
+ end
84
+ end
85
+
86
+ class BuildSettingsWriter
87
+ attr_reader :platforms
88
+
89
+ # Initialize a new instance
90
+ #
91
+ # @param [Array<HMap::Platform>] platforms
92
+ # the platforms to lint.
93
+ #
94
+ # @param [HMap::Context] context
95
+ # the Project or target information.
96
+ #
97
+ def initialize(platforms, context)
98
+ @platforms = platforms
99
+ @context = context
100
+ end
101
+
102
+ def write_or_symlink(path, data, platforms = [])
103
+ build_settings.each do |setting|
104
+ type_data = data[setting.type] unless data.nil?
105
+ next if type_data.nil? && path.nil?
106
+
107
+ need_platform = platforms.include?(setting.type)
108
+ setting.write_or_symlink(path, type_data, need_platform)
109
+ end
110
+ end
111
+
112
+ private
113
+
114
+ def build_settings
115
+ return @build_settings if defined? @build_settings
116
+
117
+ @build_settings = Constants::HMAP_FILE_TYPE.flat_map do |type|
118
+ if @platforms.empty?
119
+ BuildSettings.new(type, nil, @context)
120
+ else
121
+ BuildSettings.new_from_platforms(type, @platforms, @context)
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'hmap/xc/target/build_setting'
4
+ require 'hmap/xc/target/target_helper'
5
+ require 'hmap/xc/target/xcconfig_helper'
6
+
7
+ module HMap
8
+ class Target
9
+ include HMap::Target::Helper
10
+
11
+ attr_reader :entrys, :target, :project
12
+
13
+ def initialize(entrys, target, project)
14
+ @entrys = entrys || []
15
+ @target = target
16
+ @project = project
17
+ end
18
+
19
+ def platforms
20
+ project.platforms
21
+ end
22
+
23
+ def write_hmapfile!
24
+ datas = headers_hash(:own_target_headers)
25
+ build_settings = BuildSettingsWriter.new(platforms, context)
26
+ build_settings.write_or_symlink(project.context.hmap_root, datas, Constants::HMAP_FILE_TYPE)
27
+ end
28
+
29
+ def save_hmap_settings!
30
+ xcconfig_paths.each do |path|
31
+ settings = Constants.instance.hmap_build_settings
32
+ XcodeprojHelper.new(path).add_build_settings_and_save(settings, use_origin: Resolver.instance.use_origin)
33
+ end
34
+ end
35
+
36
+ def remove_hmap_settings!
37
+ xcconfig_paths.each { |path| HMap::XcodeprojHelper.new(path).remove_build_settings_and_save }
38
+ end
39
+
40
+ private
41
+
42
+ def xcconfig_paths
43
+ return @xcconfig_paths if defined?(@xcconfig_paths)
44
+
45
+ @xcconfig_paths = target.build_configuration_list.build_configurations.flat_map do |configuration|
46
+ if configuration.is_a?(Constants::XCBuildConfiguration)
47
+ bcr = configuration.base_configuration_reference
48
+ unless bcr.nil?
49
+ s_path = PBXHelper.group_paths(bcr)
50
+ x = bcr.instance_variable_get('@simple_attributes_hash')['path'] || ''
51
+ File.expand_path File.join(project.project_dir, s_path, x)
52
+ end
53
+ end
54
+ end.compact
55
+ # @xcconfig_paths = TargetConfiguration.new_from_xc(target, project.project_dir).map do |c|
56
+ # c.xcconfig_path unless c.xcconfig_path.nil?
57
+ # end.compact
58
+ # @xcconfig_paths = bc.map(&:xcconfig_path).compact
59
+ # xc_type = 'XCConfigurationList'
60
+ # xcs = target.build_configuration_list.build_configurations
61
+ # @xcconfig_paths = xcs.map do |xc|
62
+ # if xc.isa == xc_type
63
+ # xc_path = xc.instance_variable_get('@simple_attributes_hash')['path'] || ''
64
+ # { xc => File.join(project.project_dir, xc_path) }
65
+ # else
66
+ # # ab_path = Pathname(project.project_dir + "hmap-#{name}.#{xc.name}.xcconfig")
67
+ # # File.new(ab_path, 'w') unless ab_path.exist?
68
+ # # xc_ref = target.project.new_file(ab_path)
69
+ # # xc.base_configuration_reference = xc_ref
70
+ # # target.project.save
71
+ # # ab_path
72
+ # end
73
+ # end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HMap
4
+ class Target
5
+ class TargetContext < Context
6
+ attr_reader :product_name
7
+ def initialize(build_root, temp_dir, hmap_root, temp_name, build_dir, product_name, full_product_name, defines_modules, build_as_framework_swift)
8
+ super(build_root, temp_dir, hmap_root, temp_name, build_dir)
9
+ @full_product_name = full_product_name
10
+ @product_name = product_name
11
+ @defines_modules = defines_modules
12
+ @build_as_framework_swift = build_as_framework_swift
13
+ end
14
+
15
+ def build_as_framework_swift?
16
+ @build_as_framework_swift
17
+ end
18
+
19
+ def defines_modules?
20
+ @defines_modules
21
+ end
22
+
23
+ def build_path(platform)
24
+ path = super(platform)
25
+ File.join(path, @full_product_name)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,114 @@
1
+ require 'hmap/xc/target/target_context'
2
+
3
+ module HMap
4
+ class Target
5
+ module Helper
6
+ include HMap::HeaderType
7
+
8
+ define_method(:all_product_headers) do
9
+ return @all_product_headers if defined? @all_product_headers
10
+
11
+ public_headers = public_entrys.map(&:path)
12
+ private_headers = private_entrys.map(&:path)
13
+ @all_product_headers = TargetVFS.new(public_headers, private_headers, platforms, context).vfs_entrys
14
+ end
15
+
16
+ define_method(:all_non_framework_target_headers) do
17
+ return if build_as_framework?
18
+
19
+ p_h = public_entrys + private_entrys
20
+ p_h.flat_map { |entry| entry.full_module_buckets(product_name) }
21
+ end
22
+
23
+ # all_targets include header full module path
24
+ define_method(:all_target_headers) do
25
+ p_h = public_entrys + private_entrys
26
+ p_h.flat_map do |entry|
27
+ entry.full_module_buckets_extra(product_name) + entry.module_buckets(product_name)
28
+ end
29
+ end
30
+
31
+ define_method(:project_headers) do
32
+ all_target_headers + project_entrys.flat_map(&:project_buckets_extra)
33
+ end
34
+
35
+ define_method(:own_target_headers) do
36
+ headers = public_entrys + private_entrys
37
+ headers = headers.flat_map { |entry| entry.module_buckets(product_name) }
38
+ headers + project_entrys.flat_map do |entry|
39
+ entry.project_buckets + entry.full_module_buckets(product_name)
40
+ end
41
+ end
42
+ def build_root
43
+ project.build_root
44
+ end
45
+
46
+ def hmap_root
47
+ project.hmap_root
48
+ end
49
+
50
+ def target_name
51
+ target.name
52
+ end
53
+
54
+ def product_name
55
+ target.product_name.gsub(/[-]/, '_')
56
+ end
57
+
58
+ def full_product_name
59
+ target.product_reference.instance_variable_get('@simple_attributes_hash')['path'] || ''
60
+ end
61
+
62
+ def temp_name
63
+ "#{target_name}.build"
64
+ end
65
+
66
+ def temp_dir
67
+ project.temp_dir
68
+ end
69
+
70
+ def build_dir
71
+ return @build_dir if defined?(@build_dir)
72
+
73
+ b_d = xcconfig_paths.any? do |path|
74
+ xc = Xcodeproj::Config.new(path)
75
+ !xc.attributes[Constants::CONFIGURATION_BUILD_DIR].nil?
76
+ end
77
+ @build_dir = target_name if b_d
78
+ end
79
+
80
+ def build_as_framework?
81
+ PBXHelper.build_as_framework?(target)
82
+ end
83
+
84
+ def build_as_framework_swift?
85
+ uses_swift? && build_as_framework?
86
+ end
87
+
88
+ def uses_swift?
89
+ return @uses_swift if defined?(@uses_swift)
90
+
91
+ @uses_swift = PBXHelper.uses_swift?(target)
92
+ end
93
+
94
+ def defines_module?
95
+ return @defines_module if defined?(@defines_module)
96
+ return @defines_module = true if build_as_framework?
97
+
98
+ @defines_module = PBXHelper.defines_module?(target)
99
+ end
100
+
101
+ def context
102
+ TargetContext.new(build_root,
103
+ temp_dir,
104
+ hmap_root,
105
+ temp_name,
106
+ build_dir,
107
+ product_name,
108
+ full_product_name,
109
+ defines_module?,
110
+ build_as_framework_swift?)
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml_vfs'
4
+
5
+ module HMap
6
+ class TargetVFSEntry
7
+ attr_reader :real_path, :virtual_path
8
+
9
+ def initialize(build_dir, file)
10
+ @real_path = file
11
+ @virtual_path = File.join(build_dir, File.basename(file))
12
+ end
13
+ end
14
+
15
+ class TargetPlatformVFS
16
+ def initialize(platform, setting)
17
+ @platform = platform
18
+ @setting = setting
19
+ end
20
+
21
+ def product_name
22
+ File.basename(build_dir, '.*')
23
+ end
24
+
25
+ def build_dir
26
+ @setting.build_path(@platform)
27
+ end
28
+
29
+ def temp_dir
30
+ @setting.temp_path(@platform)
31
+ end
32
+
33
+ def defines_modules?
34
+ @setting.defines_modules?
35
+ end
36
+
37
+ def module_path
38
+ File.join(temp_dir, 'module.modulemap') if defines_modules?
39
+ end
40
+
41
+ def private_module_path
42
+ File.join(temp_dir, 'module.private.modulemap') if defines_modules?
43
+ end
44
+
45
+ def swift_header_path
46
+ File.join(build_dir, 'Headers', "#{product_name}-Swift.h") if @setting.build_as_framework_swift?
47
+ end
48
+
49
+ def public_headers_dir
50
+ File.join(build_dir, 'Headers')
51
+ end
52
+
53
+ def private_headers_dir
54
+ File.join(build_dir, 'PrivateHeaders')
55
+ end
56
+
57
+ def module_dir
58
+ File.join(build_dir, 'Modules')
59
+ end
60
+ end
61
+
62
+
63
+ # A collection of Each TargetVFSEntry
64
+ class TargetVFS
65
+ def initialize(public_headers, private_headers, platforms, setting)
66
+ @setting = setting
67
+ @platforms = platforms
68
+ @public_headers = public_headers
69
+ @private_headers = private_headers
70
+ end
71
+
72
+ def add_headers_modules(config)
73
+ r_public_paths = []
74
+ r_public_paths += @public_headers
75
+ s_h = config.swift_header_path
76
+ r_public_paths << s_h unless s_h.nil?
77
+ r_private_paths = []
78
+ r_private_paths += @private_headers
79
+ headers = []
80
+ headers += add_files(r_public_paths, config.public_headers_dir)
81
+ headers += add_files(r_private_paths, config.private_headers_dir)
82
+ modules_real_paths = []
83
+ if config.defines_modules?
84
+ modules_real_paths << config.module_path
85
+ modules_real_paths << config.private_module_path unless r_private_paths.empty?
86
+ end
87
+ headers += add_files(modules_real_paths, config.module_dir) || []
88
+ headers
89
+ end
90
+
91
+ def add_files(files, virtual_dir)
92
+ return if files.nil?
93
+
94
+ files.map { |file| TargetVFSEntry.new(virtual_dir, file) }
95
+ end
96
+
97
+ def vfs_entrys
98
+ Hash[@platforms.map do |platform|
99
+ config = TargetPlatformVFS.new(platform, @setting)
100
+ [platform.to_s, add_headers_modules(config)]
101
+ end]
102
+ end
103
+ end
104
+
105
+ class TargetVFSWriter
106
+ attr_reader :entrys
107
+
108
+ def initialize(entrys)
109
+ @entrys = entrys
110
+ end
111
+
112
+ def write!(path)
113
+ es = @entrys.map do |entry|
114
+ VFS::FileCollectorEntry.new(entry.real_path, entry.virtual_path)
115
+ end.uniq
116
+ fc = VFS::FileCollector.new(es)
117
+ pa = Pathname.new(path)
118
+ pa.dirname.mkpath unless pa.exist?
119
+ fc.write_mapping(pa)
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HMap
4
+ # A collection of xcodeproj Helper functions used throughout hmap.
5
+ class XcodeprojHelper
6
+ HMAP_XCKEY_START = 'HMAP_'
7
+ SAVE_XCKEY_START = 'SAVE_'
8
+ private_constant :HMAP_XCKEY_START, :SAVE_XCKEY_START
9
+
10
+ attr_reader :xcconfig_path
11
+
12
+ def initialize(path)
13
+ xc = Pathname(path)
14
+ @xcconfig_path = xc
15
+ @xcconfig = Xcodeproj::Config.new(xc)
16
+ end
17
+
18
+ def add_build_settings_and_save(settings, use_origin: true)
19
+ add_build_settings(settings, use_origin)
20
+ build_settings = [Constants::HEADER_SEARCH_PATHS, Constants::USER_HEADER_SEARCH_PATHS]
21
+ if use_origin
22
+ remove_build_settings(settings)
23
+ else
24
+ save_build_settings(settings)
25
+ end
26
+ save_as
27
+ end
28
+
29
+ def add_build_settings(settings, use_origin)
30
+ settings.each do |key, value|
31
+ add_build_setting(key.to_s, value, use_origin)
32
+ end
33
+ end
34
+
35
+ def add_build_setting(key, value, use_origin)
36
+ return if value.nil?
37
+
38
+ if key.start_with?(HMAP_XCKEY_START)
39
+ @xcconfig.attributes[key] = value
40
+ else
41
+ save_origin = save_build_setting(key)
42
+ e_value = value
43
+ e_value = "#{e_value} ${#{save_xckey(key)}}" if use_origin && !save_origin.nil?
44
+ @xcconfig.attributes[hmap_xckey(key)] = e_value
45
+ @xcconfig.attributes[key] = "${#{hmap_xckey(key)}}"
46
+ end
47
+ end
48
+
49
+ def save_build_settings(settings)
50
+ settings ||= []
51
+ settings.each { |key| save_build_setting(key) }
52
+ end
53
+
54
+ def save_build_setting(key)
55
+ origin = @xcconfig.attributes[key]
56
+ if origin.nil? || !origin.include?(hmap_xckey(key))
57
+ @xcconfig.attributes[save_xckey(key)] = origin unless origin.nil?
58
+ @xcconfig.attributes.delete(key)
59
+ end
60
+ @xcconfig.attributes[save_xckey(key)]
61
+ end
62
+
63
+ def remove_build_settings_and_save
64
+
65
+ hmap_ks = @xcconfig.attributes.keys.each_with_object([]) do |key, sum|
66
+ sum << key[HMAP_XCKEY_START.length..-1] if key.start_with?(HMAP_XCKEY_START)
67
+ sum << key[SAVE_XCKEY_START.length..-1] if key.start_with?(SAVE_XCKEY_START)
68
+ end.compact
69
+ remove_build_settings(hmap_ks)
70
+ save_as
71
+ end
72
+
73
+ def remove_build_settings(settings)
74
+ settings ||= []
75
+ settings.each { |setting| remove_build_setting(setting) }
76
+ end
77
+
78
+ def remove_build_setting(setting)
79
+ save_origin = @xcconfig.attributes[save_xckey(setting)]
80
+ origin = @xcconfig.attributes[setting]
81
+ if save_origin.nil? && !origin.nil? && origin.include?(hmap_xckey(setting))
82
+ @xcconfig.attributes.delete(setting)
83
+ end
84
+ @xcconfig.attributes[setting] = save_origin unless save_origin.nil?
85
+ @xcconfig.attributes.delete(hmap_xckey(setting))
86
+ @xcconfig.attributes.delete(save_xckey(setting))
87
+ end
88
+
89
+ def save_as(path = nil)
90
+ path = xcconfig_path if path.nil?
91
+ @xcconfig.save_as(path)
92
+ end
93
+
94
+ private
95
+
96
+ def build_setting?(key)
97
+ !@xcconfig.attributes[key].nil?
98
+ end
99
+
100
+
101
+ def hmap_xckey(key)
102
+ "#{HMAP_XCKEY_START}#{key}"
103
+ end
104
+
105
+ def save_xckey(key)
106
+ "#{SAVE_XCKEY_START}#{key}"
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'hmap/xc/workspace/project_helper'
4
+ require 'hmap/xc/target/target'
5
+
6
+ module HMap
7
+ HEADER_FILES_EXTENSIONS = %w[.h .hh .hpp .ipp .tpp .hxx .def .inl .inc .pch]
8
+
9
+ class Project
10
+ include HMap::Project::Helper
11
+
12
+ attr_reader :project, :workspace
13
+
14
+ def initialize(project, workspace)
15
+ @project = project
16
+ @workspace = workspace
17
+ end
18
+
19
+ def platforms
20
+ return @platforms if defined? @platforms
21
+
22
+ build_configurations = project.build_configuration_list.build_configurations
23
+ build_configurations += project.targets.flat_map do |target|
24
+ target.build_configuration_list.build_configurations
25
+ end
26
+
27
+ ps = build_configurations.flatten.each_with_object({}) do |configuration, sum|
28
+ bs = configuration.build_settings
29
+ d_t = []
30
+ d_t << :osx unless bs['MACOSX_DEPLOYMENT_TARGET'].nil?
31
+ d_t << :ios unless bs['IPHONEOS_DEPLOYMENT_TARGET'].nil?
32
+ d_t << :watchos unless bs['WATCHOS_DEPLOYMENT_TARGET'].nil?
33
+ d_t << :tvos unless bs['TVOS_DEPLOYMENT_TARGET'].nil?
34
+ sum[configuration.name] ||= []
35
+ sum[configuration.name] += d_t unless d_t.empty?
36
+ end
37
+
38
+ @platforms = ps.flat_map do |key, value|
39
+ Platform.new_from_platforms(key, value.uniq)
40
+ end
41
+ end
42
+
43
+ def targets
44
+ return @targets if defined?(@targets)
45
+
46
+ project_dir = project.project_dir
47
+
48
+ h_ts = project.targets.map do |target|
49
+ next if target.is_a?(Constants::PBXAggregateTarget)
50
+
51
+ name = target.name
52
+ headers = target.build_phases.flat_map do |phase|
53
+ next unless phase.is_a?(Constants::PBXHeadersBuildPhase)
54
+
55
+ phase.files.flat_map do |file|
56
+ ff = file.file_ref
57
+ f_path = ff.instance_variable_get('@simple_attributes_hash')['path'] || ''
58
+ g_path = PBXHelper.group_paths(ff)
59
+ header_entry(project_dir, g_path, f_path, file)
60
+ end
61
+ end.compact
62
+ Target.new(headers, target, self)
63
+ end.compact
64
+ @targets = h_ts || []
65
+ end
66
+
67
+ def write_hmapfile!
68
+ hmap_writer = BuildSettingsWriter.new(platforms, context)
69
+ types = %i[all_non_framework_target_headers project_headers all_target_headers all_product_headers]
70
+ datas = headers_hash(*types)
71
+ hmap_writer.write_or_symlink(nil, datas, %i[all_product_headers])
72
+ targets.each(&:write_hmapfile!)
73
+ end
74
+
75
+ def save_hmap_settings!
76
+ targets.each(&:save_hmap_settings!)
77
+ end
78
+
79
+ def remove_hmap_settings!
80
+ targets.each(&:remove_hmap_settings!)
81
+ end
82
+
83
+ private
84
+
85
+ def header_entry(project_dir, group, file, xc)
86
+ settings_h = xc.instance_variable_get('@simple_attributes_hash') || {}
87
+ settings = settings_h['settings'] || {}
88
+ attributes = settings['ATTRIBUTES']
89
+ full_path = File.expand_path(File.join(project_dir, group, file))
90
+ extra_headers = []
91
+ extra_headers << File.join(group, file)
92
+ extra_headers << File.join(file)
93
+ extra_headers.uniq!
94
+ types = %i[Public Private Project]
95
+ attributes = 'Project' if attributes.nil?
96
+ ts = types.select { |type| attributes.include?(type.to_s) }
97
+ ts.map { |t| HeaderEntry.new(full_path, extra_headers, t) }
98
+ end
99
+
100
+ def entrys
101
+ return @entrys if defined?(@entrys)
102
+
103
+ project_dir = project.project_dir
104
+ @entrys = project.objects_by_uuid.flat_map do |_uuid, ff|
105
+ next unless ff.is_a?(Constants::PBXFileReference)
106
+
107
+ f_path = ff.instance_variable_get('@simple_attributes_hash')['path'] || ''
108
+ next unless HEADER_FILES_EXTENSIONS.include?(File.extname(f_path))
109
+
110
+ builds = ff.referrers.select { |e| e.is_a?(Constants::PBXBuildFile) } || []
111
+ g_path = PBXHelper.group_paths(ff)
112
+ if builds.empty?
113
+ header_entry(project_dir, g_path, f_path, nil)
114
+ else
115
+ builds.flat_map { |bf| header_entry(project_dir, g_path, f_path, bf) }
116
+ end
117
+ end.compact
118
+ end
119
+ end
120
+ end