cocoapods-mapfile 0.2.6.2 → 0.2.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3413fccd914b1bc1a758ef738dc08b60601ec6070f9559789489434d7f28922f
4
- data.tar.gz: 1d8f09ac5c6d105fa64c9b15e7a634106fd640795752911781930bec64965ce0
3
+ metadata.gz: 65bdc2c48951cb24058ac1f84069c3d45ae4f675a1c1668ee794a8c1f49b5219
4
+ data.tar.gz: ea6f67b75799e12c0d9cdc973c23e1259de900d7452e7515783a5ebcffdb74f7
5
5
  SHA512:
6
- metadata.gz: 92916dac70c8cc47fb01673cecaab625a34c59a395f52c136d124a4de3cd3e89f81489797680da8bbc05ded32883f6f89eb3a565e92fc9fa06de814e9306d434
7
- data.tar.gz: ef1fe10382fd8522fd96da6cd9dce26e6590f2348ef3b7ab178b4e6989d76b9e8481208ad1694899da7deb30d5967903ce1223e86b579d5d51da02069f170d17
6
+ metadata.gz: cb0e16716cdd01a364909d5f452e6a00545b0c8096a812159140b443811fd18c02455838c36f0f1b821d565044cfe6a00f84d471fef8fa648e6657295b6dcaa5
7
+ data.tar.gz: 02d64062414b7bb872fc06f39b7d4272a1c687b214672a5e9d8c53a8464d53895557023938cedab5b02e84b5308575d1fc97bb7f7d94032b0e07e57f9790923f
@@ -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)
@@ -57,6 +57,8 @@ module HMap
57
57
  end
58
58
  end
59
59
  UserInterface.puts "\n[hmapfile-from-json] finish"
60
+ rescue Object => exception
61
+ UserInterface.puts "#{exception}".red
60
62
  end
61
63
  end
62
64
  end
@@ -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,12 +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
- %i[all_non_framework_target_headers own_target_headers].map do |type|
148
+ def build_setting_values_i
149
+ %i[all_non_framework_target_headers own_target_headers project_headers].map do |type|
146
150
  value = xc_filenames[type]
147
151
  "\"#{HMAP_GEN_DIR_VALUE}/#{value}\""
148
152
  end.join(' ')
@@ -199,8 +203,8 @@ module HMap
199
203
  [type, case type
200
204
  when :all_product_headers then file_name
201
205
  else
202
- "#{file_name}"
203
- # "#{Constants::PRODUCT_NAME_VALUE}-#{file_name}"
206
+ # file_name.to_s
207
+ "#{Constants::PRODUCT_NAME_VALUE}-#{file_name}"
204
208
  end]
205
209
  end]
206
210
  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.2'.freeze unless defined? HMap::VERSION
4
+ VERSION = '0.2.7.2'.freeze unless defined? HMap::VERSION
5
5
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
-
2
+ require 'stringio'
3
+ require 'fileutils'
3
4
  module HMap
4
5
  # A collection of utility functions used throughout cocoapods-hmap.
5
6
  module Utils
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  require 'hmap/xc/workspace/workspace'
4
3
 
5
4
  module HMap
@@ -53,7 +53,7 @@ module HMap
53
53
  return @file_name if defined? @file_name
54
54
 
55
55
  product_name = @context.product_name if @context.respond_to? :product_name
56
- @file_name = Constants.instance.full_hmap_filename(type)
56
+ @file_name = Constants.instance.full_hmap_filename(type, product_name)
57
57
  end
58
58
 
59
59
  def hmap_filepath(need_platform)
@@ -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 = "#{e_value} ${#{save_xckey(key)}} " if use_origin && !save_origin.nil?
45
- @xcconfig.attributes[hmap_xckey(key)] = e_value
46
- @xcconfig.attributes[key] = "$(inherited) ${#{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.2
4
+ version: 0.2.7.2
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-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler