cocoapods-mapfile 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -22
- data/bin/{hmap_writer → hmapfile} +2 -2
- data/lib/cocoapods_plugin.rb +18 -4
- data/lib/{cocoapods-hmap → hmap}/command/hmap_gen.rb +16 -8
- data/lib/{cocoapods-hmap → hmap}/command/hmap_reader.rb +12 -9
- data/lib/hmap/command/hmap_writer.rb +53 -0
- data/lib/hmap/command.rb +26 -0
- data/lib/{cocoapods-hmap → hmap}/exceptions.rb +0 -0
- data/lib/{cocoapods-hmap → hmap}/executable.rb +0 -0
- data/lib/{cocoapods-hmap → hmap}/framework/framework_vfs.rb +12 -13
- data/lib/hmap/helper/build_setting_constants.rb +13 -0
- data/lib/hmap/helper/hmap_helper.rb +212 -0
- data/lib/hmap/helper/pods_helper.rb +98 -0
- data/lib/{cocoapods-hmap → hmap/helper}/utils.rb +0 -4
- data/lib/hmap/helper/xcconfig_helper.rb +105 -0
- data/lib/{cocoapods-hmap → hmap}/hmap_reader.rb +1 -0
- data/lib/{cocoapods-hmap/hmap_save.rb → hmap/hmap_saver.rb} +11 -1
- data/lib/{cocoapods-hmap → hmap}/hmap_struct.rb +5 -4
- data/lib/hmap/hmap_writer.rb +99 -0
- data/lib/{cocoapods-hmap → hmap}/mapfile.rb +0 -0
- data/lib/hmap/pods_specification.rb +65 -0
- data/lib/hmap/version.rb +5 -0
- data/lib/hmap.rb +22 -0
- metadata +34 -34
- data/bin/hmap_reader +0 -12
- data/lib/cocoapods-hmap/helper/build_setting_helper.rb +0 -40
- data/lib/cocoapods-hmap/helper/pods_helper.rb +0 -104
- data/lib/cocoapods-hmap/helper/xcconfig_helper.rb +0 -82
- data/lib/cocoapods-hmap/hmap_writer.rb +0 -107
- data/lib/cocoapods-hmap/pods_specification.rb +0 -60
- data/lib/cocoapods-hmap/version.rb +0 -5
- data/lib/cocoapods-hmap/view.rb +0 -34
- data/lib/cocoapods_hmap.rb +0 -21
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
|
5
|
+
module HMap
|
6
|
+
# A collection of Pods Helper functions used throughout cocoapods-hmap.
|
7
|
+
module Pods
|
8
|
+
# mapfile dir name
|
9
|
+
# @api private
|
10
|
+
HMAP_DIR = 'HMap'
|
11
|
+
HEADER_EXTENSIONS = %w[h hh hpp ipp tpp hxx def inl inc].join(',')
|
12
|
+
def self.hmap_files_dir
|
13
|
+
Pathname(File.join(Pod::Config.instance.sandbox.headers_root, HMAP_DIR))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.pods_hmap_files_dir
|
17
|
+
"${PODS_ROOT}/Headers/#{HMAP_DIR}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.target_support_platforms(spec_path)
|
21
|
+
validator = Pod::Validator.new(spec_path, Pod::Config.instance.sources_manager.master.map(&:url))
|
22
|
+
validator.platforms_to_lint(validator.spec).map(&:name)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.paths_for_attribute(path)
|
26
|
+
return [] unless path.exist?
|
27
|
+
|
28
|
+
path_list = Pod::Sandbox::PathList.new(path)
|
29
|
+
path_list.glob("**/*.{#{HEADER_EXTENSIONS}}")
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.headers_mappings_by_file_accessor(target, type = :source_files)
|
33
|
+
valid_accessors = target.file_accessors.reject { |fa| fa.spec.non_library_specification? }
|
34
|
+
valid_accessors.each_with_object({}) do |file_accessor, sum|
|
35
|
+
sum[:private_header_files] ||= []
|
36
|
+
sum[:public_header_files] ||= []
|
37
|
+
sum[:source_files] ||= []
|
38
|
+
case type
|
39
|
+
when :private_header_files
|
40
|
+
sum[:private_header_files] += file_accessor.private_headers
|
41
|
+
when :source_files
|
42
|
+
header_mappings_dir = file_accessor.spec_consumer.header_mappings_dir
|
43
|
+
headers = paths_for_attribute(file_accessor.path_list.root)
|
44
|
+
unless header_mappings_dir.nil?
|
45
|
+
headers = paths_for_attribute(file_accessor.path_list.root + header_mappings_dir)
|
46
|
+
end
|
47
|
+
sum[:private_header_files] += file_accessor.private_headers
|
48
|
+
sum[:public_header_files] += file_accessor.public_headers
|
49
|
+
sum[:public_header_files] << target.umbrella_header_path if target.build_as_framework?
|
50
|
+
sum[:source_files] << target.prefix_header_path if target.build_as_framework?
|
51
|
+
sum[:source_files] += (headers - file_accessor.public_headers - file_accessor.private_headers)
|
52
|
+
when :public_header_files
|
53
|
+
sum[:public_header_files] += file_accessor.public_headers
|
54
|
+
sum[:public_header_files] << target.umbrella_header_path if target.build_as_framework?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.headers_mappings_by_file(target, type = :source_files)
|
60
|
+
valid_accessors = target.file_accessors.reject { |fa| fa.spec.non_library_specification? }
|
61
|
+
valid_accessors.each_with_object([]) do |file_accessor, sum|
|
62
|
+
sum << case type
|
63
|
+
when :private_header_files then file_accessor.headers - file_accessor.public_headers
|
64
|
+
when :source_files then file_accessor.headers
|
65
|
+
when :public_header_files then file_accessor.public_headers
|
66
|
+
end
|
67
|
+
end.flatten.compact
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.xcconfig_path_from(target)
|
71
|
+
raise ClassIncludedError.new(target.class, Pod::Target) unless target.is_a?(Pod::Target)
|
72
|
+
|
73
|
+
config_h = Pod::Target.instance_method(:build_settings).bind(target).call
|
74
|
+
config_h.each_key do |configuration_name|
|
75
|
+
xcconfig = target.xcconfig_path(configuration_name)
|
76
|
+
yield(xcconfig, target) if block_given?
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.clean_hmap_setting(clean_hmap, *targets)
|
81
|
+
return clean_hmap unless clean_hmap
|
82
|
+
|
83
|
+
FileUtils.rm_rf(Pods.hmap_files_dir)
|
84
|
+
targets.each { |target| clean_hmap_build_setting(target, log: true) }
|
85
|
+
clean_hmap
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.clean_hmap_build_setting(targets, log: false)
|
89
|
+
puts 'Clean build setting: '.blue if log
|
90
|
+
targets.each do |target|
|
91
|
+
xcconfig_path_from(target) do |xcconfig|
|
92
|
+
HMap::XcodeprojHelper.new(xcconfig).clean_hmap_build_setting_and_save
|
93
|
+
puts "\t -xcconfig path: #{xcconfig} clean finish." if log
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HMap
|
4
|
+
# A collection of xcodeproj Helper functions used throughout hmap.
|
5
|
+
class XcodeprojHelper
|
6
|
+
require 'xcodeproj'
|
7
|
+
|
8
|
+
attr_reader :xcconfig_path, :build_setting_key
|
9
|
+
|
10
|
+
def initialize(xcconfig)
|
11
|
+
@xcconfig_path = xcconfig
|
12
|
+
@xcconfig = Xcodeproj::Config.new(xcconfig_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def change_hmap_build_setting_and_save(values, use_headermap: false, save_origin: false)
|
16
|
+
ocf = values[BuildSettingConstants::OTHER_CFLAGS]
|
17
|
+
ocppf = values[BuildSettingConstants::OTHER_CPLUSPLUSFLAGS]
|
18
|
+
change_xcconfig_build_setting(BuildSettingConstants::OTHER_CFLAGS, ocf, true)
|
19
|
+
change_xcconfig_build_setting(BuildSettingConstants::OTHER_CPLUSPLUSFLAGS, ocppf, true) if build_setting?(BuildSettingConstants::OTHER_CPLUSPLUSFLAGS)
|
20
|
+
change_xcconfig_build_setting(BuildSettingConstants::USE_HEADERMAP, 'NO', false) unless use_headermap
|
21
|
+
build_settings = [BuildSettingConstants::HEAD_SEARCH_PATHS, BuildSettingConstants::USER_HEADER_SEARCH_PATHS]
|
22
|
+
if save_origin
|
23
|
+
clean_hmap_build_settings_to_xcconfig(build_settings)
|
24
|
+
else
|
25
|
+
save_build_settings_to_xcconfig(build_settings)
|
26
|
+
end
|
27
|
+
save_to_path
|
28
|
+
end
|
29
|
+
|
30
|
+
def change_xcconfig_build_settings(settings, save_origin)
|
31
|
+
settings.each do |key, value|
|
32
|
+
change_xcconfig_build_setting(key.to_s, value, save_origin)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def change_xcconfig_build_setting(build_setting_key, setting, save_origin)
|
37
|
+
return if setting.nil?
|
38
|
+
|
39
|
+
save_origin_build_setting = save_build_setting_to_xcconfig(build_setting_key)
|
40
|
+
value = setting
|
41
|
+
value = "#{value} ${#{save_key(build_setting_key)}}" if save_origin && !save_origin_build_setting.nil?
|
42
|
+
@xcconfig.attributes[hmap_key(build_setting_key)] = value
|
43
|
+
@xcconfig.attributes[build_setting_key] = "${#{hmap_key(build_setting_key)}}"
|
44
|
+
yield(@xcconfig) if block_given?
|
45
|
+
end
|
46
|
+
|
47
|
+
def save_build_settings_to_xcconfig(build_settings)
|
48
|
+
build_settings ||= []
|
49
|
+
build_settings.each { |key| save_build_setting_to_xcconfig(key) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def save_build_setting_to_xcconfig(key)
|
53
|
+
origin_build_setting = @xcconfig.attributes[key]
|
54
|
+
if origin_build_setting.nil? || !origin_build_setting.include?(hmap_key(key))
|
55
|
+
@xcconfig.attributes[save_key(key)] = origin_build_setting unless origin_build_setting.nil?
|
56
|
+
@xcconfig.attributes.delete(key)
|
57
|
+
end
|
58
|
+
@xcconfig.attributes[save_key(key)]
|
59
|
+
end
|
60
|
+
|
61
|
+
def clean_hmap_build_setting_and_save
|
62
|
+
clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::OTHER_CFLAGS)
|
63
|
+
clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::OTHER_CPLUSPLUSFLAGS)
|
64
|
+
clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::HEAD_SEARCH_PATHS)
|
65
|
+
clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::USER_HEADER_SEARCH_PATHS)
|
66
|
+
clean_hmap_build_setting_to_xcconfig(BuildSettingConstants::USE_HEADERMAP)
|
67
|
+
save_to_path
|
68
|
+
end
|
69
|
+
|
70
|
+
def clean_hmap_build_settings_to_xcconfig(build_settings)
|
71
|
+
build_settings ||= []
|
72
|
+
build_settings.each { |build_setting| clean_hmap_build_setting_to_xcconfig(build_setting) }
|
73
|
+
end
|
74
|
+
|
75
|
+
def clean_hmap_build_setting_to_xcconfig(build_setting)
|
76
|
+
save_origin_build_setting = @xcconfig.attributes[save_key(build_setting)]
|
77
|
+
origin_build_setting = @xcconfig.attributes[build_setting]
|
78
|
+
if save_origin_build_setting.nil? && !origin_build_setting.nil? && origin_build_setting.include?(hmap_key(build_setting))
|
79
|
+
@xcconfig.attributes.delete(build_setting)
|
80
|
+
end
|
81
|
+
@xcconfig.attributes[build_setting] = save_origin_build_setting unless save_origin_build_setting.nil?
|
82
|
+
@xcconfig.attributes.delete(hmap_key(build_setting))
|
83
|
+
@xcconfig.attributes.delete(save_key(build_setting))
|
84
|
+
end
|
85
|
+
|
86
|
+
def save_to_path(path = nil)
|
87
|
+
path = xcconfig_path if path.nil?
|
88
|
+
@xcconfig.save_as(path)
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def build_setting?(key)
|
94
|
+
!@xcconfig.attributes[key].nil?
|
95
|
+
end
|
96
|
+
|
97
|
+
def hmap_key(key)
|
98
|
+
"HMAP_PODS_#{key}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def save_key(key)
|
102
|
+
"SAVE_#{key}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -4,6 +4,12 @@ module HMap
|
|
4
4
|
class HMapSaver
|
5
5
|
attr_reader :string_table, :buckets, :headers
|
6
6
|
|
7
|
+
def self.new_from_buckets(buckets)
|
8
|
+
saver = new
|
9
|
+
saver.add_to_buckets(buckets)
|
10
|
+
saver
|
11
|
+
end
|
12
|
+
|
7
13
|
def initialize
|
8
14
|
@string_table = "\0"
|
9
15
|
@buckets = []
|
@@ -32,13 +38,17 @@ module HMap
|
|
32
38
|
headers[key]
|
33
39
|
end
|
34
40
|
|
35
|
-
def
|
41
|
+
def add_to_bucket(buckets)
|
36
42
|
values = buckets.map { |key| add_to_headers(key) }
|
37
43
|
bucket = HMapBucket.new(*values)
|
38
44
|
bucket.uuid = Utils.string_downcase_hash(buckets.first)
|
39
45
|
@buckets << bucket
|
40
46
|
end
|
41
47
|
|
48
|
+
def add_to_buckets(buckets)
|
49
|
+
buckets.each { |bucket| add_to_bucket(bucket) }
|
50
|
+
end
|
51
|
+
|
42
52
|
def write_to(path)
|
43
53
|
MapFile.new(@string_table, @buckets).write(path)
|
44
54
|
end
|
@@ -65,7 +65,7 @@ module HMap
|
|
65
65
|
# @see https://clang.llvm.org/doxygen/structclang_1_1HMapHeader.html
|
66
66
|
# @abstract
|
67
67
|
class HMapHeader < HMapStructure
|
68
|
-
# @return [HMap::
|
68
|
+
# @return [HMap::HMapHeader, nil] the raw view associated with the load command,
|
69
69
|
# or nil if the HMapHeader was created via {create}.
|
70
70
|
attr_reader :num_entries, :magic, :version, :reserved, :strings_offset, :num_buckets, :max_value_length
|
71
71
|
|
@@ -112,6 +112,7 @@ module HMap
|
|
112
112
|
}.merge super
|
113
113
|
end
|
114
114
|
end
|
115
|
+
|
115
116
|
# HMapBucket structure.
|
116
117
|
# @see https://clang.llvm.org/doxygen/structclang_1_1HMapHeader.html
|
117
118
|
# @abstract
|
@@ -157,7 +158,7 @@ module HMap
|
|
157
158
|
@header = populate_hmap_header(nums, entries)
|
158
159
|
@buckets = add_bucket(buckets, nums)
|
159
160
|
end
|
160
|
-
|
161
|
+
|
161
162
|
def num_buckets(count, pow2)
|
162
163
|
if count < 8
|
163
164
|
pow2 <<= 1 if count * 4 >= pow2 * 3
|
@@ -181,8 +182,8 @@ module HMap
|
|
181
182
|
def serialize
|
182
183
|
@header.serialize + @buckets.inject('') do |sum, bucket|
|
183
184
|
sum += if bucket.nil?
|
184
|
-
|
185
|
-
|
185
|
+
empty_b = [HEADER_CONST[:HMAP_EMPTY_BUCKT_KEY]] * 3
|
186
|
+
empty_b.pack('L<3')
|
186
187
|
else
|
187
188
|
bucket
|
188
189
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# require 'cocoapods'
|
4
|
+
|
5
|
+
module HMap
|
6
|
+
# Helper module which returns handle method from MapFileWriter.
|
7
|
+
class MapFileWriter
|
8
|
+
# @param save_origin_header_search_paths save_origin_header_search_paths
|
9
|
+
# @param clean_hmap clean up all hmap setup
|
10
|
+
# @param allow_targets this targets will save origin build setting
|
11
|
+
# @param use_build_in_headermap option use Xcode header map
|
12
|
+
def initialize(save_origin_build_setting, clean_hmap, allow_targets, use_build_in_headermap: true)
|
13
|
+
@allow_targets = allow_targets
|
14
|
+
puts "hmap allow targets: #{allow_targets}" unless allow_targets.empty?
|
15
|
+
@save_origin_build_setting = save_origin_build_setting
|
16
|
+
@use_build_in_headermap = use_build_in_headermap
|
17
|
+
create_mapfile(clean_hmap)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# Integrates the projects mapfile associated
|
23
|
+
# with the App project and Pods project.
|
24
|
+
#
|
25
|
+
# @param [clean] clean hmap dir @see #podfile
|
26
|
+
# @return [void]
|
27
|
+
#
|
28
|
+
def create_mapfile(clean)
|
29
|
+
analyze = PodsSpecification.instance.analyze
|
30
|
+
targets = analyze.targets
|
31
|
+
pod_targets = analyze.pod_targets
|
32
|
+
return if Pods.clean_hmap_setting(clean, targets, pod_targets)
|
33
|
+
|
34
|
+
merge_all_pods_target_headers_mapfile(pod_targets)
|
35
|
+
merge_all_target_public_headers_mapfile(targets)
|
36
|
+
end
|
37
|
+
|
38
|
+
def vfs_from_target(target, helper)
|
39
|
+
return unless target.build_as_framework?
|
40
|
+
|
41
|
+
spec_path = target.specs.map(&:defined_in_file).uniq.first
|
42
|
+
platforms = Pods.target_support_platforms(spec_path)
|
43
|
+
headers = Pods.headers_mappings_by_file(target).flat_map { |h| h }
|
44
|
+
helper.add_framework_entry(target.user_build_configurations.keys,
|
45
|
+
platforms, target.name, target.product_basename, target.support_files_dir, headers)
|
46
|
+
end
|
47
|
+
|
48
|
+
def hmap_from_header_mappings(target, helper, type = :source_files)
|
49
|
+
Pods.headers_mappings_by_file_accessor(target, type).each do |key, headers|
|
50
|
+
helper.header_mappings(headers, Pod::Config.instance.sandbox.root.join(target.headers_sandbox),
|
51
|
+
target.product_basename, key)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def hmap_vfs_from_target(target, helper, type = :source_files)
|
56
|
+
vfs_from_target(target, helper)
|
57
|
+
hmap_from_header_mappings(target, helper, type)
|
58
|
+
end
|
59
|
+
|
60
|
+
def merge_all_target_public_headers_mapfile(targets)
|
61
|
+
helper = HMapHelper.new(Pods.hmap_files_dir)
|
62
|
+
targets.each do |target|
|
63
|
+
hmap_name = target.name.to_s
|
64
|
+
target.pod_targets.each do |p_target|
|
65
|
+
hmap_from_header_mappings(p_target, helper, :public_header_files)
|
66
|
+
end
|
67
|
+
change_hmap_build_setting_and_save(target, false, helper, hmap_name, save_origin: @save_origin_build_setting)
|
68
|
+
helper.write_hmap_vfs_to_paths(hmap_name)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def merge_all_pods_target_headers_mapfile(pod_targets)
|
73
|
+
return Pods.clean_hmap_build_setting(pod_targets) if @use_build_in_headermap
|
74
|
+
|
75
|
+
helper = HMapHelper.new(Pods.hmap_files_dir)
|
76
|
+
hmap_name = 'all-pods'
|
77
|
+
pod_targets.each do |target|
|
78
|
+
hmap_vfs_from_target(target, helper)
|
79
|
+
change_hmap_build_setting_and_save(target, target.build_as_framework?, helper, hmap_name,
|
80
|
+
save_origin: @save_origin_build_setting)
|
81
|
+
end
|
82
|
+
helper.write_hmap_vfs_to_paths(hmap_name)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Cteate hmap files and vfs files
|
86
|
+
#
|
87
|
+
# @param [target] Pods project target @see Pod#PodTarget
|
88
|
+
# @param [hmap_helper] @see HMap#HMapHelper
|
89
|
+
# @param [hmap_name] hmap file contains pod targets header type
|
90
|
+
# @param [save_origin] save or not save origin build setting
|
91
|
+
def change_hmap_build_setting_and_save(target, build_as_framework, hmap_helper, hmap_name, save_origin: false)
|
92
|
+
save_origin = true if @allow_targets.include?(target.name)
|
93
|
+
setting = hmap_helper.xcconfig_header_setting(build_as_framework, Pods.pods_hmap_files_dir, hmap_name)
|
94
|
+
Pods.xcconfig_path_from(target) do |xcconfig|
|
95
|
+
XcodeprojHelper.new(xcconfig).change_hmap_build_setting_and_save(setting, save_origin: save_origin)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
File without changes
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HMap
|
4
|
+
class PodsSpecification
|
5
|
+
attr_reader :workspace_path, :analyze, :app_build_dir, :project_temp_dir
|
6
|
+
|
7
|
+
BUILD_DIR = 'BUILD_DIR'
|
8
|
+
PROJECT_TEMP_DIR = 'PROJECT_TEMP_DIR'
|
9
|
+
|
10
|
+
private_constant :BUILD_DIR
|
11
|
+
private_constant :PROJECT_TEMP_DIR
|
12
|
+
|
13
|
+
def self.instance
|
14
|
+
@instance ||= new
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@workspace_path = workspace
|
19
|
+
@analyze = pod_analyze
|
20
|
+
workspace_build_dir
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def workspace_build_dir
|
26
|
+
workspace_dic = xcodebuild('-list', workspace_path)['workspace']
|
27
|
+
scheme = workspace_dic['schemes'].first
|
28
|
+
build_settings = xcodebuild('analyze', workspace_path, scheme).first['buildSettings']
|
29
|
+
@app_build_dir = build_settings[BUILD_DIR]
|
30
|
+
@project_temp_dir = build_settings[PROJECT_TEMP_DIR]
|
31
|
+
end
|
32
|
+
|
33
|
+
def xcodebuild(action, workspace, scheme = nil)
|
34
|
+
command = %W[#{action} -workspace #{workspace} -json]
|
35
|
+
command += %W[-scheme #{scheme} -showBuildSettings] unless scheme.nil?
|
36
|
+
results = Executable.execute_command('xcodebuild', command, false)
|
37
|
+
JSON.parse(results) unless results.nil?
|
38
|
+
end
|
39
|
+
|
40
|
+
def pod_analyze
|
41
|
+
podfile = Pod::Podfile.from_file(Pod::Config.instance.podfile_path)
|
42
|
+
lockfile = Pod::Lockfile.from_file(Pod::Config.instance.lockfile_path)
|
43
|
+
Pod::Installer::Analyzer.new(Pod::Config.instance.sandbox, podfile, lockfile).analyze
|
44
|
+
end
|
45
|
+
|
46
|
+
def workspace
|
47
|
+
podfile = Pod::Podfile.from_file(Pod::Config.instance.podfile_path)
|
48
|
+
user_project_paths = pod_analyze.targets.map(&:user_project_path).compact.uniq
|
49
|
+
if podfile.workspace_path
|
50
|
+
declared_path = podfile.workspace_path
|
51
|
+
path_with_ext = File.extname(declared_path) == '.xcworkspace' ? declared_path : "#{declared_path}.xcworkspace"
|
52
|
+
podfile_dir = File.dirname(podfile.defined_in_file || '')
|
53
|
+
absolute_path = File.expand_path(path_with_ext, podfile_dir)
|
54
|
+
Pathname.new(absolute_path)
|
55
|
+
elsif user_project_paths.count == 1
|
56
|
+
project = user_project_paths.first.basename('.xcodeproj')
|
57
|
+
Pod::Config.instance.installation_root + "#{project}.xcworkspace"
|
58
|
+
else
|
59
|
+
raise Informative, 'Could not automatically select an Xcode ' \
|
60
|
+
"workspace. Specify one in your Podfile like so:\n\n" \
|
61
|
+
" workspace 'path/to/Workspace.xcworkspace'\n"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/hmap/version.rb
ADDED
data/lib/hmap.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The primary namespace for cocoapods-hmap.
|
4
|
+
module HMap
|
5
|
+
require_relative 'hmap/version'
|
6
|
+
require_relative 'hmap/hmap_struct'
|
7
|
+
require_relative 'hmap/helper/pods_helper'
|
8
|
+
require_relative 'hmap/exceptions'
|
9
|
+
require_relative 'hmap/framework/framework_vfs'
|
10
|
+
require_relative 'hmap/hmap_saver'
|
11
|
+
require_relative 'hmap/pods_specification'
|
12
|
+
require_relative 'hmap/helper/xcconfig_helper'
|
13
|
+
require_relative 'hmap/helper/utils'
|
14
|
+
require_relative 'hmap/helper/hmap_helper'
|
15
|
+
require_relative 'hmap/helper/build_setting_constants'
|
16
|
+
|
17
|
+
autoload :Command, 'hmap/command'
|
18
|
+
autoload :MapFileReader, 'hmap/hmap_reader'
|
19
|
+
autoload :MapFileWriter, 'hmap/hmap_writer'
|
20
|
+
autoload :MapFile, 'hmap/mapfile'
|
21
|
+
autoload :Executable, 'hmap/executable'
|
22
|
+
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-mapfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cat1237
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: coveralls
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -86,47 +86,47 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.0.
|
89
|
+
version: 0.0.3
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.0.
|
96
|
+
version: 0.0.3
|
97
97
|
description: header_reader lets your read Xcode header map file. header-writer lets
|
98
98
|
your analyze the project pod dependencies and gen header map file for all pods.
|
99
99
|
email:
|
100
100
|
- wangson1237@outlook.com
|
101
101
|
executables:
|
102
|
-
-
|
103
|
-
- hmap_writer
|
102
|
+
- hmapfile
|
104
103
|
extensions: []
|
105
104
|
extra_rdoc_files: []
|
106
105
|
files:
|
107
106
|
- LICENSE
|
108
107
|
- README.md
|
109
|
-
- bin/
|
110
|
-
- bin/hmap_writer
|
111
|
-
- lib/cocoapods-hmap/command/hmap_gen.rb
|
112
|
-
- lib/cocoapods-hmap/command/hmap_reader.rb
|
113
|
-
- lib/cocoapods-hmap/exceptions.rb
|
114
|
-
- lib/cocoapods-hmap/executable.rb
|
115
|
-
- lib/cocoapods-hmap/framework/framework_vfs.rb
|
116
|
-
- lib/cocoapods-hmap/helper/build_setting_helper.rb
|
117
|
-
- lib/cocoapods-hmap/helper/pods_helper.rb
|
118
|
-
- lib/cocoapods-hmap/helper/xcconfig_helper.rb
|
119
|
-
- lib/cocoapods-hmap/hmap_reader.rb
|
120
|
-
- lib/cocoapods-hmap/hmap_save.rb
|
121
|
-
- lib/cocoapods-hmap/hmap_struct.rb
|
122
|
-
- lib/cocoapods-hmap/hmap_writer.rb
|
123
|
-
- lib/cocoapods-hmap/mapfile.rb
|
124
|
-
- lib/cocoapods-hmap/pods_specification.rb
|
125
|
-
- lib/cocoapods-hmap/utils.rb
|
126
|
-
- lib/cocoapods-hmap/version.rb
|
127
|
-
- lib/cocoapods-hmap/view.rb
|
128
|
-
- lib/cocoapods_hmap.rb
|
108
|
+
- bin/hmapfile
|
129
109
|
- lib/cocoapods_plugin.rb
|
110
|
+
- lib/hmap.rb
|
111
|
+
- lib/hmap/command.rb
|
112
|
+
- lib/hmap/command/hmap_gen.rb
|
113
|
+
- lib/hmap/command/hmap_reader.rb
|
114
|
+
- lib/hmap/command/hmap_writer.rb
|
115
|
+
- lib/hmap/exceptions.rb
|
116
|
+
- lib/hmap/executable.rb
|
117
|
+
- lib/hmap/framework/framework_vfs.rb
|
118
|
+
- lib/hmap/helper/build_setting_constants.rb
|
119
|
+
- lib/hmap/helper/hmap_helper.rb
|
120
|
+
- lib/hmap/helper/pods_helper.rb
|
121
|
+
- lib/hmap/helper/utils.rb
|
122
|
+
- lib/hmap/helper/xcconfig_helper.rb
|
123
|
+
- lib/hmap/hmap_reader.rb
|
124
|
+
- lib/hmap/hmap_saver.rb
|
125
|
+
- lib/hmap/hmap_struct.rb
|
126
|
+
- lib/hmap/hmap_writer.rb
|
127
|
+
- lib/hmap/mapfile.rb
|
128
|
+
- lib/hmap/pods_specification.rb
|
129
|
+
- lib/hmap/version.rb
|
130
130
|
homepage: https://github.com/Cat1237/cocoapods-hmap.git
|
131
131
|
licenses:
|
132
132
|
- MIT
|
data/bin/hmap_reader
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
|
5
|
-
if $PROGRAM_NAME == __FILE__
|
6
|
-
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', __dir__)
|
7
|
-
require 'bundler/setup'
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'cocoapods-hmap/command/hmap_reader'
|
11
|
-
|
12
|
-
Pod::Command::HMapReader.run(ARGV)
|