cocoapods-mapfile 0.2.6.1 → 0.2.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 638ba36cc9be5ecffeed1c7b02cb466b173b3a74fe3b2903d049450e07a4fd18
4
- data.tar.gz: 959264f5b51c9c9e0d1543306a381ca61021f2e92038300d257b3dcc0a72d4af
3
+ metadata.gz: aaaa78e71fbc30aa040f8a0ad7d14ad0af6691a406e40a1002119c8b39a06f7c
4
+ data.tar.gz: 790ac93ec756eb422472df923f99d4d706638b69141ccd43e84a515cac42cdad
5
5
  SHA512:
6
- metadata.gz: f96fd831a0215bb118c568a4a03a10ef3f039f5a1f51d9edb34d8a4ca3b8a44ec9071ef5f87aeed69833fc2cb7b6d175b0e4461a06bff8b9f6247c4bb26d0719
7
- data.tar.gz: 55ba2200d4aca7fe0549a4fe79ad067b2b7aec25fa4c5beccbad06cccb4d296aabdcd7fdbebe3344032ff5d72d7e03b71667536799eb43a6aadfdd81f35d2f96
6
+ metadata.gz: 4bca57920f0d2ef6bc29aa611c221c1e1b1f86e95abf4ac2225fa160dd44a51456a3ba4044202dde4088994d663bb30c2ed02f640947e8e825cc7e7264de63d7
7
+ data.tar.gz: eb3623e1250bbf2d1ae177aaf819735cd410fb43eba476727350fc0ed6d662bd8e6bc03b51e38b4377f45c665d953622fc6bf04aff9d091b92274bbf1ebe309d
@@ -40,7 +40,7 @@ module HMap
40
40
 
41
41
  def run
42
42
  UserInterface.puts "\n[hmapfile-from-json] start"
43
- if File.exist?(@json_path) && File.exist?(@output_path)
43
+ if File.exist?(@json_path)
44
44
  require 'json'
45
45
  json_file = File.read(@json_path)
46
46
  json = JSON.parse(json_file)
@@ -39,8 +39,8 @@ module HMap
39
39
  # PROJECT_TEMP_DIR, CONFIGURATION_EFFECTIVE_PLATFORM,
40
40
  # TARGET_TEMP_DIR].join('/')
41
41
  HMAP_TARGET_ROOT = [SRCROOT, HMAP_DIR,
42
- PROJECT_TEMP_DIR, CONFIGURATION_EFFECTIVE_PLATFORM,
43
- TARGET_TEMP_DIR].join('/')
42
+ PROJECT_TEMP_DIR, CONFIGURATION_EFFECTIVE_PLATFORM,
43
+ TARGET_TEMP_DIR].join('/')
44
44
 
45
45
  HMAP_GEN_DIR_ATTRIBUTE = { HMAP_GEN_DIR => HMAP_TARGET_ROOT }
46
46
 
@@ -101,23 +101,23 @@ module HMap
101
101
  xc_filenames[type]
102
102
  end
103
103
 
104
- def hmap_build_settings(build_as_framework)
105
- build_settings(build_as_framework)
104
+ def hmap_build_settings
105
+ build_settings
106
106
  end
107
107
 
108
108
  private
109
109
 
110
- def build_settings(build_as_framework)
111
- return @build_as_framework[build_as_framework] unless @build_as_framework[build_as_framework].nil?
110
+ def build_settings
111
+ return @build_settings if defined? @build_settings
112
112
 
113
113
  attributes = HMAP_GEN_DIR_ATTRIBUTE
114
- attributes[HEADER_SEARCH_PATHS] = build_setting_values_i(build_as_framework)
114
+ attributes[HEADER_SEARCH_PATHS] = build_setting_values_i
115
115
  attributes[OTHER_CFLAGS] = build_setting_values_c
116
116
  attributes[OTHER_CPLUSPLUSFLAGS] = build_setting_values_c
117
117
  attributes[OTHER_SWIFT_FLAGS] = build_setting_values_s
118
- attributes[USER_HEADER_SEARCH_PATHS] = build_setting_values_iquote
118
+ # attributes[USER_HEADER_SEARCH_PATHS] = build_setting_values_iquote
119
119
  attributes[USE_HEADERMAP] = 'NO'
120
- @build_as_framework[build_as_framework] = attributes
120
+ @build_settings = attributes
121
121
  end
122
122
 
123
123
  def filenames
@@ -137,14 +137,16 @@ module HMap
137
137
  %i[all_non_framework_target_headers own_target_headers all_product_headers project_headers].map do |type|
138
138
  key = build_setting_keys[type]
139
139
  value = xc_filenames[type]
140
- ["-Xcc -#{key}", "-Xcc \"#{HMAP_GEN_DIR_VALUE}/#{value}\""].join(' ')
140
+ if key == :I
141
+ "-Xcc -#{key}\"#{HMAP_GEN_DIR_VALUE}/#{value}\""
142
+ else
143
+ "-Xcc -#{key} -Xcc \"#{HMAP_GEN_DIR_VALUE}/#{value}\""
144
+ end
141
145
  end.join(' ')
142
146
  end
143
147
 
144
- def build_setting_values_i(build_as_framework)
145
- a = %i[all_non_framework_target_headers own_target_headers]
146
- a << :all_target_headers unless build_as_framework
147
- a.map do |type|
148
+ def build_setting_values_i
149
+ %i[all_non_framework_target_headers own_target_headers project_headers].map do |type|
148
150
  value = xc_filenames[type]
149
151
  "\"#{HMAP_GEN_DIR_VALUE}/#{value}\""
150
152
  end.join(' ')
@@ -201,6 +203,7 @@ module HMap
201
203
  [type, case type
202
204
  when :all_product_headers then file_name
203
205
  else
206
+ # file_name.to_s
204
207
  "#{Constants::PRODUCT_NAME_VALUE}-#{file_name}"
205
208
  end]
206
209
  end]
@@ -1,5 +1,5 @@
1
1
  module HMap
2
2
  # The version of the hmapfile command line tool.
3
3
  #
4
- VERSION = '0.2.6.1'.freeze unless defined? HMap::VERSION
4
+ VERSION = '0.2.7.1'.freeze unless defined? HMap::VERSION
5
5
  end
@@ -9,11 +9,13 @@ module HMap
9
9
  include HMap::Target::Helper
10
10
 
11
11
  attr_reader :entrys, :target, :project
12
+ attr_accessor :xcconfig_paths
12
13
 
13
14
  def initialize(entrys, target, project)
14
15
  @entrys = entrys || []
15
16
  @target = target
16
17
  @project = project
18
+ @xcconfig_paths = []
17
19
  end
18
20
 
19
21
  def platforms
@@ -27,39 +29,63 @@ module HMap
27
29
  end
28
30
 
29
31
  def save_hmap_settings!
30
- xcconfig_paths.each do |path|
31
- settings = Constants.instance.hmap_build_settings(build_as_framework?)
32
+ build_setting_paths.each do |path|
33
+ settings = Constants.instance.hmap_build_settings
32
34
  XcodeprojHelper.new(path).add_build_settings_and_save(settings, use_origin: Resolver.instance.use_origin)
33
35
  end
34
36
  end
35
37
 
36
38
  def remove_hmap_settings!
37
- xcconfig_paths.each { |path| HMap::XcodeprojHelper.new(path).remove_build_settings_and_save }
39
+ build_setting_paths.each { |path| HMap::XcodeprojHelper.new(path).remove_build_settings_and_save }
38
40
  end
39
41
 
40
42
  private
41
43
 
42
- def xcconfig_paths
43
- return @xcconfig_paths if defined?(@xcconfig_paths)
44
+ def build_setting_paths
45
+ return @build_setting_paths if defined?(@build_setting_paths)
44
46
 
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
- # if bcr.nil?
49
- # ab_path = Pathname(project.project_dir + "hmap-#{target_name}.#{configuration.name}.xcconfig")
50
- # File.new(ab_path, 'w') unless ab_path.exist?
51
- # xc_ref = target.project.new_file(ab_path)
52
- # configuration.base_configuration_reference = xc_ref
53
- # target.project.save
54
- # ab_path
55
- # else
56
- unless bcr.nil?
57
- s_path = PBXHelper.group_paths(bcr)
58
- x = bcr.instance_variable_get('@simple_attributes_hash')['path'] || ''
59
- File.expand_path File.join(project.project_dir, s_path, x)
60
- end
61
- end
47
+ @build_setting_paths = xcconfig_paths.map do |path|
48
+ xc = XCConfig.new(path)
49
+ inc = xc.includes_paths
50
+ path if inc.empty? || project.workspace.xcconfig_paths.none? { |pa| inc.include?(pa) }
62
51
  end.compact
63
52
  end
53
+
54
+ # def xcconfig_paths
55
+ # return @xcconfig_paths if defined?(@xcconfig_paths)
56
+
57
+ # @xcconfig_paths = target.build_configurations.flat_map do |configuration|
58
+ # if configuration.is_a?(Constants::XCBuildConfiguration)
59
+ # bcr = configuration.base_configuration_reference
60
+ # unless bcr.nil?
61
+ # s_path = PBXHelper.group_paths(bcr)
62
+ # x = bcr.instance_variable_get('@simple_attributes_hash')['path'] || ''
63
+ # path = File.expand_path(File.join(project.project_dir, s_path, x))
64
+ # xc = XCConfig.new(path)
65
+ # inc = xc.includes_paths
66
+ # path if inc.empty? || project.workspace.xcconfig_paths.none? { |pa| inc.include?(pa) }
67
+ # end
68
+ # end
69
+ # end.compact
70
+
71
+ # @xcconfig_paths = target.build_configuration_list.build_configurations.flat_map do |configuration|
72
+ # if configuration.is_a?(Constants::XCBuildConfiguration)
73
+ # bcr = configuration.base_configuration_reference
74
+ # # if bcr.nil?
75
+ # # ab_path = Pathname(project.project_dir + "hmap-#{target_name}.#{configuration.name}.xcconfig")
76
+ # # File.new(ab_path, 'w') unless ab_path.exist?
77
+ # # xc_ref = target.project.new_file(ab_path)
78
+ # # configuration.base_configuration_reference = xc_ref
79
+ # # target.project.save
80
+ # # ab_path
81
+ # # else
82
+ # unless bcr.nil?
83
+ # s_path = PBXHelper.group_paths(bcr)
84
+ # x = bcr.instance_variable_get('@simple_attributes_hash')['path'] || ''
85
+ # File.expand_path File.join(project.project_dir, s_path, x)
86
+ # end
87
+ # end
88
+ # end.compact
89
+ # end
64
90
  end
65
91
  end
@@ -16,37 +16,45 @@ module HMap
16
16
  define_method(:all_non_framework_target_headers) do
17
17
  return if build_as_framework?
18
18
 
19
+ return @all_non_framework_target_headers if defined? @all_non_framework_target_headers
20
+
19
21
  p_h = public_entrys + private_entrys
20
- p_h.inject({}) do |sum, entry|
22
+ @all_non_framework_target_headers = p_h.inject({}) do |sum, entry|
21
23
  sum.merge!(entry.full_module_buckets(product_name)) { |_, v1, _| v1 }
22
24
  end
23
25
  end
24
26
 
25
27
  # all_targets include header full module path
26
28
  define_method(:all_target_headers) do
29
+ return @all_target_headers if defined? @all_target_headers
30
+
27
31
  p_h = public_entrys + private_entrys
28
- p_h.inject({}) do |sum, entry|
32
+ @all_target_headers = p_h.inject({}) do |sum, entry|
29
33
  sum.merge!(entry.module_buckets(product_name)) { |_, v1, _| v1 }
30
34
  sum.merge!(entry.full_module_buckets(product_name)) { |_, v1, _| v1 }
31
35
  end
32
36
  end
33
37
 
34
38
  define_method(:project_headers) do
39
+ return @project_headers if defined? @project_headers
40
+
35
41
  p_h = public_entrys + private_entrys
36
42
  hs = p_h.inject({}) do |sum, entry|
37
43
  sum.merge!(entry.module_buckets(product_name)) { |_, v1, _| v1 }
38
44
  end
39
- project_entrys.inject(hs) do |sum, entry|
45
+ @project_headers = project_entrys.inject(hs) do |sum, entry|
40
46
  sum.merge!(entry.project_buckets_extra) { |_, v1, _| v1 }
41
47
  end
42
48
  end
43
49
 
44
50
  define_method(:own_target_headers) do
51
+ return @own_target_headers if defined? @own_target_headers
52
+
45
53
  headers = public_entrys + private_entrys
46
54
  hs = headers.inject({}) do |sum, entry|
47
55
  sum.merge!(entry.module_buckets(product_name)) { |_, v1, _| v1 }
48
56
  end
49
- project_entrys.inject(hs) do |sum, entry|
57
+ @own_target_headers = project_entrys.inject(hs) do |sum, entry|
50
58
  sum.merge!(entry.project_buckets) { |_, v1, _| v1 }
51
59
  sum.merge!(entry.full_module_buckets(product_name)) { |_, v1, _| v1 }
52
60
  end
@@ -65,7 +73,10 @@ module HMap
65
73
  end
66
74
 
67
75
  def product_name
68
- target.product_name.gsub(/[-]/, '_')
76
+ product_name = target.build_settings(target.build_configurations.first.name)['PRODUCT_NAME']
77
+ return target_name.gsub(/-/, '_') if product_name.nil? || product_name.include?('TARGET_NAME')
78
+
79
+ product_name
69
80
  end
70
81
 
71
82
  def full_product_name
@@ -83,13 +94,14 @@ module HMap
83
94
  def build_dir
84
95
  return @build_dir if defined?(@build_dir)
85
96
 
86
- b_d = xcconfig_paths.any? do |path|
87
- xc = XCConfig.new(path)
88
- !xc.attributes[Constants::CONFIGURATION_BUILD_DIR].nil?
89
- end
97
+ b_d = build_setting_paths.none? { |path| XCConfig.new(path).attributes[Constants::CONFIGURATION_BUILD_DIR].nil? }
90
98
  @build_dir = target_name if b_d
91
99
  end
92
100
 
101
+ def app_target?
102
+ Xcodeproj::Constants::PRODUCT_UTI_EXTENSIONS[target.symbol_type] == 'app'
103
+ end
104
+
93
105
  def build_as_framework?
94
106
  PBXHelper.build_as_framework?(target)
95
107
  end
@@ -10,6 +10,10 @@ module HMap
10
10
  @real_path = file
11
11
  @virtual_path = File.join(build_dir, File.basename(file))
12
12
  end
13
+
14
+ def eql?(other)
15
+ other.real_path == real_path && other.virtual_path == virtual_path
16
+ end
13
17
  end
14
18
 
15
19
  class TargetPlatformVFS
@@ -37,6 +37,11 @@ module HMap
37
37
  #
38
38
  attr_accessor :attributes
39
39
 
40
+ # @return [Array] The list of the configuration files included by this
41
+ # configuration file (`#include "SomeConfig"`).
42
+ #
43
+ attr_accessor :includes_paths
44
+
40
45
  # @return [Hash{Symbol => Set<String>}] The other linker flags by key.
41
46
  # Xcodeproj handles them in a dedicated way to prevent duplication
42
47
  # of the libraries and of the frameworks.
@@ -44,7 +49,9 @@ module HMap
44
49
  def initialize(xcconfig_hash_or_file = {})
45
50
  @attributes = {}
46
51
  @includes = []
52
+ @include_attributes = {}
47
53
  merge!(extract_hash(xcconfig_hash_or_file))
54
+ @includes_paths = @includes.map { |i| File.expand_path(i, @filepath.dirname) }
48
55
  end
49
56
 
50
57
  def inspect
@@ -52,7 +59,7 @@ module HMap
52
59
  end
53
60
 
54
61
  def ==(other)
55
- other.attributes == attributes
62
+ other.attributes == attributes && other.includes_paths = @includes_paths
56
63
  end
57
64
 
58
65
  # @!group Serialization
@@ -98,8 +105,6 @@ module HMap
98
105
  # @return [Hash] The hash representation
99
106
  #
100
107
  def to_hash(prefix = nil)
101
- list = []
102
-
103
108
  result = attributes.dup
104
109
  result.reject! { |_, v| INHERITED.any? { |i| i == v.to_s.strip } }
105
110
  if prefix
@@ -191,14 +196,14 @@ module HMap
191
196
  hash = {}
192
197
  string.split("\n").each do |line|
193
198
  uncommented_line = strip_comment(line)
194
- if include = extract_include(uncommented_line)
195
- @includes.push normalized_xcconfig_path(include)
196
- else
199
+ e = extract_include(uncommented_line)
200
+ if e.nil?
197
201
  key, value = extract_key_value(uncommented_line)
198
202
  next unless key
199
-
200
203
  value.gsub!(INHERITED_REGEXP) { |m| hash.fetch(key, m) }
201
204
  hash[key] = value
205
+ else
206
+ @includes.push normalized_xcconfig_path(e)
202
207
  end
203
208
  end
204
209
  hash
@@ -40,10 +40,11 @@ module HMap
40
40
  @xcconfig.attributes[key] = value
41
41
  else
42
42
  save_origin = save_build_setting(key)
43
- e_value = value
44
- e_value = "${#{save_xckey(key)}} #{e_value} " if use_origin && !save_origin.nil?
45
- @xcconfig.attributes[hmap_xckey(key)] = e_value
46
- @xcconfig.attributes[key] = "${#{hmap_xckey(key)}}"
43
+ value = "#{value} ${#{save_xckey(key)}} " if use_origin && !save_origin.nil?
44
+ @xcconfig.attributes[hmap_xckey(key)] = value
45
+ h_value = "${#{hmap_xckey(key)}}"
46
+ h_value += ' $(inherited)' unless key == Constants::USE_HEADERMAP
47
+ @xcconfig.attributes[key] = h_value
47
48
  end
48
49
  end
49
50
 
@@ -9,11 +9,20 @@ module HMap
9
9
  define_method(:all_product_headers) do
10
10
  return @all_product_headers if defined? @all_product_headers
11
11
 
12
- @all_product_headers = targets.each_with_object({}) do |target, sum|
12
+ hs = targets.each_with_object({}) do |target, sum|
13
13
  next if target.all_product_headers.nil?
14
14
 
15
15
  sum.merge!(target.all_product_headers) { |_, oldval, newval| newval + oldval }
16
16
  end
17
+
18
+ if targets.any?(&:app_target?)
19
+ workspace.projects.each do |pr|
20
+ next if pr == self
21
+
22
+ hs.merge!(pr.all_product_headers) { |_, v1, v2| v1 + v2 }
23
+ end
24
+ end
25
+ @all_product_headers = hs
17
26
  end
18
27
 
19
28
  define_method(:all_non_framework_target_headers) do
@@ -37,6 +46,13 @@ module HMap
37
46
  hs = targets.inject({}) do |sum, entry|
38
47
  sum.merge!(entry.project_headers) { |_, v1, _| v1 }
39
48
  end
49
+ if targets.any?(&:app_target?)
50
+ workspace.projects.each do |pr|
51
+ next if pr == self
52
+
53
+ hs.merge!(pr.project_headers) { |_, v1, _| v1 }
54
+ end
55
+ end
40
56
  @project_headers = project_entrys.inject(hs) do |sum, entry|
41
57
  sum.merge!(entry.project_buckets_extra) { |_, v1, _| v1 }
42
58
  end
@@ -82,5 +82,26 @@ module HMap
82
82
  sum.merge!(entry.all_target_headers) { |_, v1, _| v1 }
83
83
  end
84
84
  end
85
+
86
+ def xcconfig_paths
87
+ return @xcconfig_paths if defined?(@xcconfig_paths)
88
+
89
+ @xcconfig_paths = projects.flat_map do |project|
90
+ project.targets.flat_map do |target|
91
+ target.target.build_configurations.map do |configuration|
92
+ next unless configuration.is_a?(Constants::XCBuildConfiguration)
93
+
94
+ bcr = configuration.base_configuration_reference
95
+ next if bcr.nil?
96
+
97
+ s_path = PBXHelper.group_paths(bcr)
98
+ x = bcr.instance_variable_get('@simple_attributes_hash')['path'] || ''
99
+ path = File.expand_path(File.join(project.project_dir, s_path, x))
100
+ target.xcconfig_paths << path
101
+ path
102
+ end.compact
103
+ end
104
+ end.uniq
105
+ end
85
106
  end
86
107
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-mapfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6.1
4
+ version: 0.2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cat1237
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-02 00:00:00.000000000 Z
11
+ date: 2022-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler