cocoapods-mapfile 0.2.5 → 0.2.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'xcconfig'
4
+
3
5
  module HMap
4
6
  # A collection of xcodeproj Helper functions used throughout hmap.
5
7
  class XcodeprojHelper
@@ -12,12 +14,11 @@ module HMap
12
14
  def initialize(path)
13
15
  xc = Pathname(path)
14
16
  @xcconfig_path = xc
15
- @xcconfig = Xcodeproj::Config.new(xc)
17
+ @xcconfig = XCConfig.new(xc)
16
18
  end
17
19
 
18
20
  def add_build_settings_and_save(settings, use_origin: true)
19
21
  add_build_settings(settings, use_origin)
20
- build_settings = [Constants::HEADER_SEARCH_PATHS, Constants::USER_HEADER_SEARCH_PATHS]
21
22
  if use_origin
22
23
  remove_build_settings(settings)
23
24
  else
@@ -39,10 +40,11 @@ module HMap
39
40
  @xcconfig.attributes[key] = value
40
41
  else
41
42
  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)}}"
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
46
48
  end
47
49
  end
48
50
 
@@ -61,10 +63,9 @@ module HMap
61
63
  end
62
64
 
63
65
  def remove_build_settings_and_save
64
-
65
66
  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)
67
+ sum << key[HMAP_XCKEY_START.length..] if key.start_with?(HMAP_XCKEY_START)
68
+ sum << key[SAVE_XCKEY_START.length..] if key.start_with?(SAVE_XCKEY_START)
68
69
  end.compact
69
70
  remove_build_settings(hmap_ks)
70
71
  save_as
@@ -78,9 +79,7 @@ module HMap
78
79
  def remove_build_setting(setting)
79
80
  save_origin = @xcconfig.attributes[save_xckey(setting)]
80
81
  origin = @xcconfig.attributes[setting]
81
- if save_origin.nil? && !origin.nil? && origin.include?(hmap_xckey(setting))
82
- @xcconfig.attributes.delete(setting)
83
- end
82
+ @xcconfig.attributes.delete(setting) if save_origin.nil? && !origin.nil? && origin.include?(hmap_xckey(setting))
84
83
  @xcconfig.attributes[setting] = save_origin unless save_origin.nil?
85
84
  @xcconfig.attributes.delete(hmap_xckey(setting))
86
85
  @xcconfig.attributes.delete(save_xckey(setting))
@@ -97,7 +96,6 @@ module HMap
97
96
  !@xcconfig.attributes[key].nil?
98
97
  end
99
98
 
100
-
101
99
  def hmap_xckey(key)
102
100
  "#{HMAP_XCKEY_START}#{key}"
103
101
  end
@@ -22,7 +22,7 @@ module HMap
22
22
  build_configurations = project.build_configuration_list.build_configurations
23
23
  build_configurations += project.targets.flat_map do |target|
24
24
  target.build_configuration_list.build_configurations
25
- end
25
+ end
26
26
 
27
27
  ps = build_configurations.flatten.each_with_object({}) do |configuration, sum|
28
28
  bs = configuration.build_settings
@@ -39,16 +39,15 @@ module HMap
39
39
  Platform.new_from_platforms(key, value.uniq)
40
40
  end
41
41
  end
42
-
42
+
43
43
  def targets
44
44
  return @targets if defined?(@targets)
45
45
 
46
46
  project_dir = project.project_dir
47
-
47
+
48
48
  h_ts = project.targets.map do |target|
49
49
  next if target.is_a?(Constants::PBXAggregateTarget)
50
-
51
- name = target.name
50
+
52
51
  headers = target.build_phases.flat_map do |phase|
53
52
  next unless phase.is_a?(Constants::PBXHeadersBuildPhase)
54
53
 
@@ -69,7 +68,11 @@ module HMap
69
68
  types = %i[all_non_framework_target_headers project_headers all_target_headers all_product_headers]
70
69
  datas = headers_hash(*types)
71
70
  hmap_writer.write_or_symlink(nil, datas, %i[all_product_headers])
72
- targets.each(&:write_hmapfile!)
71
+ targets.each do |target|
72
+ target.write_hmapfile!
73
+ UserInterface.puts("[hmapfile] #{target.target_name} hmap files generated".green)
74
+ end
75
+ UserInterface.puts("[hmapfile] There are #{targets.length} targets hmap files generated")
73
76
  end
74
77
 
75
78
  def save_hmap_settings!
@@ -19,7 +19,9 @@ module HMap
19
19
  define_method(:all_non_framework_target_headers) do
20
20
  return @all_non_framework_target_headers if defined?(@all_non_framework_target_headers)
21
21
 
22
- @all_non_framework_target_headers = targets.flat_map(&:all_non_framework_target_headers).compact
22
+ @all_non_framework_target_headers = targets.inject({}) do |sum, entry|
23
+ sum.merge!(entry.all_non_framework_target_headers || {}) { |_, v1, _| v1 }
24
+ end
23
25
  end
24
26
 
25
27
  # all_targets include header full module path
@@ -32,12 +34,24 @@ module HMap
32
34
  define_method(:project_headers) do
33
35
  return @project_headers if defined?(@project_headers)
34
36
 
35
- @project_headers = all_target_headers + project_entrys.flat_map { |entry| entry.project_buckets_extra }
37
+ hs = targets.inject({}) do |sum, entry|
38
+ sum.merge!(entry.project_headers) { |_, v1, _| v1 }
39
+ end
40
+ # if targets.any?(&:app_target?)
41
+ # workspace.projects.each do |pr|
42
+ # next if pr == self
43
+
44
+ # hs.merge!(pr.project_headers) { |_, v1, _| v1 }
45
+ # end
46
+ # end
47
+ @project_headers = project_entrys.inject(hs) do |sum, entry|
48
+ sum.merge!(entry.project_buckets_extra) { |_, v1, _| v1 }
49
+ end
36
50
  end
37
51
 
38
52
  def project_references
39
53
  return @project_references if defined? @project_references
40
-
54
+
41
55
  project_references = PBXHelper.project_references(project)
42
56
  @project_references = project_references.map { |pr| Project.new(pr, workspace) }
43
57
  end
@@ -56,28 +70,21 @@ module HMap
56
70
  project.project_dir
57
71
  end
58
72
 
59
- def temp_name
60
- "#{project_name}.build"
61
- end
62
-
63
- def temp_root
64
- File.join(workspace.obj_root, temp_name)
65
- end
66
-
67
73
  def build_root
68
74
  workspace.build_root
69
75
  end
70
76
 
71
77
  def temp_dir
72
- workspace.obj_root
78
+ File.join(workspace.obj_root, temp_name)
73
79
  end
74
80
 
75
81
  def hmap_root
76
- File.join(workspace.hmap_root, temp_name)
82
+ # File.join(workspace.hmap_root, temp_name)
83
+ File.join(project_dir, Constants::HMAP_DIR, temp_name)
77
84
  end
78
85
 
79
86
  def build_data_dir
80
- Constants::XCBuildData
87
+ Constants::XC_BUILD_DATA
81
88
  end
82
89
 
83
90
  def context
@@ -48,36 +48,58 @@ module HMap
48
48
  end
49
49
 
50
50
  def hmap_root
51
- dir = build_root.dirname.dirname
51
+ # dir = build_root.dirname.dirname
52
+ dir = workspace_dir
52
53
  File.join(dir, Constants::HMAP_DIR)
53
54
  end
54
55
 
55
56
  def write_save!
56
- UserInterface.puts("[hmapfile] Got workspace/project build directory..............")
57
- UserInterface.puts("[hmapfile] #{name} Build directory: #{hmap_root} ..............")
57
+ UserInterface.puts('[hmapfile] Got workspace/project build directory')
58
+ UserInterface.puts("[hmapfile] #{name} hmapfile gen directory: #{hmap_root} ")
58
59
  write_hmapfile!
59
60
  save_hmap_settings!
60
61
  end
61
62
 
62
63
  def write_hmapfile!
63
- UserInterface.puts('[hmapfile] Starting generate hmap file..............')
64
+ UserInterface.puts('[hmapfile] Starting generate hmap file')
64
65
  projects.each(&:write_hmapfile!)
65
66
  end
66
67
 
67
68
  def save_hmap_settings!
68
- UserInterface.puts('[hmapfile] Saving hmap settings..............')
69
+ UserInterface.puts('[hmapfile] Saving hmap settings')
69
70
 
70
71
  projects.each(&:save_hmap_settings!)
71
72
  end
72
73
 
73
74
  def remove_hmap_settings!
74
- UserInterface.puts('[hmapfile] Cleanning hmap settings..............')
75
+ UserInterface.puts('[hmapfile] Cleanning hmap settings')
75
76
  FileUtils.rm_rf(hmap_root) if Dir.exist?(hmap_root)
76
77
  projects.each(&:remove_hmap_settings!)
77
78
  end
78
79
 
79
80
  def all_target_headers
80
- @projects.flat_map(&:targets).flat_map(&:all_target_headers)
81
+ @projects.flat_map(&:targets).inject({}) do |sum, entry|
82
+ sum.merge!(entry.all_target_headers) { |_, v1, _| v1 }
83
+ end
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
+ File.expand_path(File.join(project.project_dir, s_path, x))
100
+ end.compact
101
+ end
102
+ end.uniq
81
103
  end
82
104
  end
83
105
  end
data/lib/hmap.rb CHANGED
@@ -7,7 +7,7 @@ module HMap
7
7
  require 'pathname'
8
8
  require 'claide'
9
9
 
10
- require_relative 'hmap/version'
10
+ require 'hmap/gem_version'
11
11
  require_relative 'hmap/user_interface'
12
12
 
13
13
  # autoload registers a file path to be loaded the first time
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.5
4
+ version: 0.2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cat1237
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,6 +120,20 @@ dependencies:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: 0.0.4
123
+ - !ruby/object:Gem::Dependency
124
+ name: hashtable
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: 0.0.3
130
+ type: :runtime
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: 0.0.3
123
137
  description: header_reader lets your read Xcode header map file. header-writer lets
124
138
  your analyze the project pod dependencies and gen header map file for all pods.
125
139
  email:
@@ -140,6 +154,7 @@ files:
140
154
  - lib/hmap/command/hmap_writer.rb
141
155
  - lib/hmap/constants.rb
142
156
  - lib/hmap/exceptions.rb
157
+ - lib/hmap/gem_version.rb
143
158
  - lib/hmap/helper/executable.rb
144
159
  - lib/hmap/helper/utils.rb
145
160
  - lib/hmap/hmap/hmap_bucketstr.rb
@@ -149,7 +164,6 @@ files:
149
164
  - lib/hmap/hmap/hmap_writer.rb
150
165
  - lib/hmap/hmap/mapfile.rb
151
166
  - lib/hmap/user_interface.rb
152
- - lib/hmap/version.rb
153
167
  - lib/hmap/xc/context.rb
154
168
  - lib/hmap/xc/header_entry.rb
155
169
  - lib/hmap/xc/header_type.rb
@@ -161,6 +175,7 @@ files:
161
175
  - lib/hmap/xc/target/target_context.rb
162
176
  - lib/hmap/xc/target/target_helper.rb
163
177
  - lib/hmap/xc/target/target_vfs.rb
178
+ - lib/hmap/xc/target/xcconfig.rb
164
179
  - lib/hmap/xc/target/xcconfig_helper.rb
165
180
  - lib/hmap/xc/workspace/project.rb
166
181
  - lib/hmap/xc/workspace/project_helper.rb
@@ -177,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
192
  requirements:
178
193
  - - ">="
179
194
  - !ruby/object:Gem::Version
180
- version: '2.5'
195
+ version: '2.6'
181
196
  required_rubygems_version: !ruby/object:Gem::Requirement
182
197
  requirements:
183
198
  - - ">="
data/lib/hmap/version.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module HMap
4
- VERSION = '0.2.5'
5
- end