cocoapods-hmap-prebuilt 0.0.2 → 0.0.7

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: d189ef8201c8798107aea9e91ed335cc4aeea99814cc78cfe053b89c97259ebf
4
- data.tar.gz: e99400f4e44fe8ac3e64167493eb62d71826d5fdb1e58e89948c43dcd82bcfb2
3
+ metadata.gz: fe4c3bd3405bef59144321942032ab36d23823c8e2f504da5734464c01d6deb8
4
+ data.tar.gz: 5b7236e35e1f8e783a2907abd218f090fb0fdb9652e4b9b050665492528372fb
5
5
  SHA512:
6
- metadata.gz: a70c5f2440ffb93a27c6706b997067111ab6a16598e751354653d53c49dce4219a6e19a846ac3b54c0a22ceb84360a2830c7d98d35ae0b38d2dacb0dc5e3c103
7
- data.tar.gz: 76b7ed93626493ca1385034f271bbfdcc4e98b3e700e09a0e708b9253bb56c6889c0f44f03f09ae535452127752b3a4855a924f5646765a93c64e19656761425
6
+ metadata.gz: fafbb86fe22016979fd023261779b69e5a02d0b9bb8f502bfb11c069fd1aa2438e9251628699bb5a5c09bec4ce3853082e9b7be794673fdeb01077862c4fc49c
7
+ data.tar.gz: 5e50af503a030938dc92ca43b618788a3e3fd944b9a9477187c8fb99e69997488936b175fead468fa709a44eb50b60f5ef2d76f7efe6313d086e008a7a9d4dbd
@@ -1,13 +1 @@
1
- # The primary namespace for cocoapods-hmap-prebuilt.
2
- module HMap
3
- require_relative 'cocoapods-hmap-prebuilt/hmap_version'
4
- require_relative 'cocoapods-hmap-prebuilt/hmap_view'
5
- require_relative 'cocoapods-hmap-prebuilt/hmap_struct'
6
- require_relative 'cocoapods-hmap-prebuilt/hmap_utils'
7
- require_relative 'cocoapods-hmap-prebuilt/hmap_helper'
8
- require_relative 'cocoapods-hmap-prebuilt/hmap_exceptions'
9
-
10
- autoload :HMapFileReader, 'cocoapods-hmap-prebuilt/hmap_file_reader'
11
- autoload :HMapFileWriter, 'cocoapods-hmap-prebuilt/hmap_file_writer'
12
- autoload :HMapFile, 'cocoapods-hmap-prebuilt/hmap_file'
13
- end
1
+ require_relative 'cocoapods-hmap-prebuilt/hmap_version'
@@ -0,0 +1,48 @@
1
+ # !/usr/bin/env ruby
2
+
3
+ module HMap
4
+ class HMapConstructor
5
+ def initialize
6
+ @bucket = Hash.new
7
+ end
8
+
9
+ # header_mapping : [Hash{FileAccessor => Hash}] Hash of file accessors by header mappings.
10
+ def add_hmap_with_header_mapping(header_mapping, target_name = nil)
11
+ header_mapping.each do |accessor, headers|
12
+ headers.each do |key, paths|
13
+ paths.each do |path|
14
+ pn = Pathname.new(path)
15
+ basename = pn.basename.to_s
16
+ dirname = pn.dirname.to_s + '/'
17
+ # construct hmap hash info
18
+ bucket = Hash['suffix' => basename, 'prefix' => dirname]
19
+ if $use_strict_mode == false
20
+ @bucket[basename] = bucket
21
+ end
22
+ if target_name != nil
23
+ @bucket["#{target_name}/#{basename}"] = bucket
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ # @path : path/to/xxx.hmap
31
+ # @return : success
32
+ def save_to(path)
33
+ if path != nil && @bucket.empty? == false
34
+ pn = Pathname(path)
35
+ json_path = pn.dirname.to_s + '/temp.json'
36
+ # write hmap json to file
37
+ File.open(json_path, 'w') { |file| file << @bucket.to_json }
38
+ # json to hmap
39
+ success = system("hmap convert #{json_path} #{path}")
40
+ # delete json file
41
+ File.delete(json_path)
42
+ success
43
+ else
44
+ false
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsHmapPrebuilt
2
- VERSION = "0.0.2"
3
- end
2
+ VERSION = "0.0.7"
3
+ end
@@ -0,0 +1,68 @@
1
+ require 'cocoapods'
2
+ require_relative 'hmap_constructor'
3
+ require_relative 'pod_xcconfig'
4
+ require_relative 'pod_target'
5
+ require_relative 'podfile_dsl'
6
+ require_relative 'pod_context_hook'
7
+
8
+ module HMap
9
+ class HMapFileWriter
10
+ def initialize(context)
11
+ hmap_dir = context.sandbox_root + '/Headers/HMap'
12
+ aggregate_targets = context.aggregate_targets
13
+ FileUtils.rm_rf(hmap_dir) if File.exist?(hmap_dir)
14
+ Dir.mkdir(hmap_dir)
15
+ gen_hmapfile(aggregate_targets, hmap_dir)
16
+ end
17
+
18
+ def gen_hmapfile(aggregate_targets, hmap_dir)
19
+ aggregate_targets.each do |aggregate_target|
20
+ pods_hmap = HMap::HMapConstructor.new
21
+
22
+ aggregate_target.pod_targets.each do |target|
23
+ pods_hmap.add_hmap_with_header_mapping(target.public_header_mappings_by_file_accessor, target.name)
24
+ unless $skip_hmap_for_pods.include?(target.name)
25
+ target_hmap = HMap::HMapConstructor.new
26
+ dependent_target_header_search_path_setting = Array.new
27
+ target_hmap.add_hmap_with_header_mapping(target.header_mappings_by_file_accessor, target.name)
28
+
29
+ target.dependent_targets.each do |dependent_target|
30
+ target_hmap.add_hmap_with_header_mapping(dependent_target.public_header_mappings_by_file_accessor, dependent_target.name)
31
+
32
+ dependent_target.build_settings.each do |config, setting|
33
+ dependent_target_xcconfig = setting.xcconfig
34
+ dependent_target_header_search_paths = dependent_target_xcconfig.attributes['HEADER_SEARCH_PATHS']
35
+ dependent_target_header_search_paths.split(' ').each do |path|
36
+ unless (path.include?('${PODS_ROOT}/Headers') || path.include?('$(inherited)'))
37
+ dependent_target_header_search_path_setting << path
38
+ end
39
+ end
40
+ end
41
+ target.dependent_target_header_search_path_setting = dependent_target_header_search_path_setting.uniq
42
+ end
43
+
44
+ target_hmap_name = "#{target.name}-prebuilt.hmap"
45
+ target_hmap_path = hmap_dir + "/#{target_hmap_name}"
46
+ relative_hmap_path = "Headers/HMap/#{target_hmap_name}"
47
+ if target_hmap.save_to(target_hmap_path)
48
+ puts "- hmapfile of target :#{target.name} save to :#{target_hmap_path}".yellow
49
+ target.reset_header_search_with_relative_hmap_path(relative_hmap_path)
50
+ else
51
+ $fail_generate_hmap_pods << target.name
52
+ end
53
+ else
54
+ puts "- skip generate hmapfile of target :#{target.name}"
55
+ end
56
+ end
57
+
58
+ pods_hmap_name = "#{aggregate_target.name}-prebuilt.hmap"
59
+ pods_hmap_path = hmap_dir + "/#{pods_hmap_name}"
60
+ relative_hmap_path = "Headers/HMap/#{pods_hmap_name}"
61
+ if pods_hmap.save_to(pods_hmap_path)
62
+ puts "- hmapfile of target :#{aggregate_target.name} save to :#{pods_hmap_path}".green
63
+ aggregate_target.reset_header_search_with_relative_hmap_path(relative_hmap_path)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,42 @@
1
+ # !/usr/bin/env ruby
2
+
3
+ module Pod
4
+ class Installer
5
+ class PostInstallHooksContext
6
+ attr_accessor :aggregate_targets
7
+
8
+ version = Gem::Version.new(Pod::VERSION)
9
+ if version < Gem::Version.new('1.7.0')
10
+ # Method `generate` has two args
11
+ class << self
12
+ alias old_generate generate
13
+ def generate(sandbox, aggregate_targets)
14
+ context = old_generate(sandbox, aggregate_targets)
15
+ UI.info "- generate method of post install hook context hooked"
16
+ context.aggregate_targets = aggregate_targets
17
+ context
18
+ end
19
+ end
20
+ elsif version < Gem::Version.new('1.10.0')
21
+ # Method `generate` has three args
22
+ class << self
23
+ alias old_generate generate
24
+ def generate(sandbox, pods_project, aggregate_targets)
25
+ context = old_generate(sandbox, pods_project, aggregate_targets)
26
+ UI.info "- generate method of post install hook context hooked"
27
+ context.aggregate_targets = aggregate_targets
28
+ context
29
+ end
30
+ end
31
+ else
32
+ # PostInstallHooksContext inherit BaseContext, just override `generate`
33
+ def self.generate(sandbox, pods_project, aggregate_targets)
34
+ context = super
35
+ UI.info "- generate method of post install hook context override"
36
+ context.aggregate_targets = aggregate_targets
37
+ context
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,65 @@
1
+ # !/usr/bin/env ruby
2
+
3
+ require_relative 'pod_xcconfig'
4
+ require_relative 'podfile_dsl'
5
+
6
+ $fail_generate_hmap_pods = []
7
+
8
+ module Pod
9
+ class PodTarget
10
+ attr_accessor :dependent_target_header_search_path_setting
11
+
12
+ def reset_header_search_with_relative_hmap_path(hmap_path)
13
+ if build_settings.instance_of?(Hash)
14
+ build_settings.each do |config_name, setting|
15
+ config_file = setting.xcconfig
16
+ config_file.reset_header_search_with_relative_hmap_path(hmap_path, @dependent_target_header_search_path_setting)
17
+ config_file.set_use_hmap(false)
18
+ config_path = xcconfig_path(config_name)
19
+ config_file.save_as(config_path)
20
+ end
21
+ elsif build_settings.instance_of?(BuildSettings::PodTargetSettings)
22
+ config_file = build_settings.xcconfig
23
+ config_file.reset_header_search_with_relative_hmap_path(hmap_path, @dependent_target_header_search_path_setting)
24
+ config_file.set_use_hmap(false)
25
+ config_path = xcconfig_path
26
+ config_file.save_as(config_path)
27
+ else
28
+ puts 'Unknown build settings'.red
29
+ end
30
+ end
31
+
32
+ def addition_aggregate_hmapfile_to_pod_target(hmap_path)
33
+ if build_settings.instance_of?(Hash)
34
+ build_settings.each do |name, setting|
35
+ config_file = setting.xcconfig
36
+ config_file.addition_aggregate_hmapfile_to_pod_target(hmap_path)
37
+ config_file.save_as(xcconfig_path(name))
38
+ end
39
+ elsif build_settings.instance_of?(BuildSettings::PodTargetSettings)
40
+ config_file = build_settings.xcconfig
41
+ config_file.addition_aggregate_hmapfile_to_pod_target(hmap_path)
42
+ config_file.save_as(xcconfig_path)
43
+ else
44
+ puts 'Unknown build settings'.red
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+ class AggregateTarget
51
+ def reset_header_search_with_relative_hmap_path(hmap_path)
52
+ xcconfigs.each do |config_name, config_file|
53
+ config_file.reset_header_search_with_relative_hmap_path(hmap_path)
54
+ config_path = xcconfig_path(config_name)
55
+ config_file.save_as(config_path)
56
+ end
57
+
58
+ pod_targets.each do |target|
59
+ unless ($skip_hmap_for_pods.include?(target.name) || $fail_generate_hmap_pods.include?(target.name))
60
+ target.addition_aggregate_hmapfile_to_pod_target(hmap_path)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,83 @@
1
+ # !/usr/bin/env ruby
2
+
3
+ module Xcodeproj
4
+ class Config
5
+ def remove_attr_with_key(key)
6
+ if key != nil
7
+ @attributes.delete(key)
8
+ end
9
+ end
10
+
11
+ def remove_header_search_path
12
+ header_search_paths = @attributes['HEADER_SEARCH_PATHS']
13
+ if header_search_paths
14
+ new_paths = Array.new
15
+ header_search_paths.split(' ').each do |path|
16
+ unless (path.include?('${PODS_ROOT}/Headers/Public') || path.include?('${PODS_ROOT}/Headers/Private') || path.include?('$(inherited)'))
17
+ new_paths << path
18
+ end
19
+ end
20
+ if new_paths.size > 0
21
+ @attributes['HEADER_SEARCH_PATHS'] = new_paths.join(' ')
22
+ else
23
+ remove_attr_with_key('HEADER_SEARCH_PATHS')
24
+ end
25
+ end
26
+ remove_system_options_in_other_cflags
27
+ end
28
+
29
+ def remove_system_options_in_other_cflags
30
+ flags = @attributes['OTHER_CFLAGS']
31
+ if flags
32
+ new_flags = ''
33
+ skip = false
34
+ flags.split(' ').each do |substr|
35
+ if skip
36
+ skip = false
37
+ next
38
+ end
39
+ if substr == '-isystem'
40
+ skip = true
41
+ next
42
+ end
43
+ if new_flags.length > 0
44
+ new_flags += ' '
45
+ end
46
+ new_flags += substr
47
+ end
48
+ if new_flags.length > 0
49
+ @attributes['OTHER_CFLAGS'] = new_flags
50
+ else
51
+ remove_attr_with_key('OTHER_CFLAGS')
52
+ end
53
+ end
54
+ end
55
+
56
+ def reset_header_search_with_relative_hmap_path(hmap_path, dependent_header_search_path_setting = nil)
57
+ remove_header_search_path
58
+ # add build flags
59
+ new_paths = Array.new
60
+ new_paths << "${PODS_ROOT}/#{hmap_path}"
61
+ header_search_paths = @attributes['HEADER_SEARCH_PATHS']
62
+ if header_search_paths
63
+ new_paths.concat(header_search_paths.split(' '))
64
+ end
65
+ new_paths.concat(dependent_header_search_path_setting) if dependent_header_search_path_setting
66
+ @attributes['HEADER_SEARCH_PATHS'] = new_paths.join(' ')
67
+ end
68
+
69
+ def addition_aggregate_hmapfile_to_pod_target(hmap_path)
70
+ new_paths = Array.new
71
+ header_search_paths = @attributes['HEADER_SEARCH_PATHS']
72
+ if header_search_paths
73
+ new_paths.concat(header_search_paths.split(' '))
74
+ end
75
+ new_paths << "${PODS_ROOT}/#{hmap_path}"
76
+ @attributes['HEADER_SEARCH_PATHS'] = new_paths.join(' ')
77
+ end
78
+
79
+ def set_use_hmap(use_hmap = false)
80
+ @attributes['USE_HEADERMAP'] = (use_hmap ? 'YES' : 'NO')
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,22 @@
1
+ # !/usr/bin/env ruby
2
+
3
+ $skip_hmap_for_pods = []
4
+ $use_strict_mode = false
5
+
6
+ module Pod
7
+ class Podfile
8
+ module DSL
9
+ def skip_hmap_for_pods(pods)
10
+ if pods != nil && pods.size() > 0
11
+ $skip_hmap_for_pods.concat(pods)
12
+ end
13
+ end
14
+
15
+ # if use strict mode, main project can only use `#import <PodA/HeaderA.h>`
16
+ # `#import <HeaderA.h>` will get 'file not found' error
17
+ def use_strict_mode!
18
+ $use_strict_mode = true
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,13 +1,12 @@
1
- require 'cocoapods-hmap-prebuilt/command/hmap_writer'
2
- require 'cocoapods-hmap-prebuilt/command/hmap_reader'
3
1
 
4
- module Pod
5
- module CocoapodsHmapPrebuiltHook
6
- Pod::HooksManager.register('cocoapods-hmap-prebuilt', :post_install) do
7
- Command::HMapWriter.run(["--project-directory=#{Config.instance.installation_root}", "--nosave-origin-header-search-paths"])
8
- end
9
- Pod::HooksManager.register('cocoapods-hmap-prebuilt', :post_update) do
10
- Command::HMapWriter.run(["--project-directory=#{Config.instance.installation_root}", "--nosave-origin-header-search-paths"])
11
- end
2
+ require 'cocoapods-hmap-prebuilt/hmap_writer'
3
+ require 'cocoapods-hmap-prebuilt/pod_context_hook'
4
+
5
+ module HMapPrebuiltHook
6
+ Pod::HooksManager.register('cocoapods-hmap-prebuilt', :post_install) do |context|
7
+ HMap::HMapFileWriter.new(context)
8
+ end
9
+ Pod::HooksManager.register('cocoapods-hmap-prebuilt', :post_update) do |context|
10
+ HMap::HMapFileWriter.new(context)
12
11
  end
13
- end
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-hmap-prebuilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - EricLou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-03 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.1'
27
- - !ruby/object:Gem::Dependency
28
- name: coveralls
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,45 +52,22 @@ dependencies:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: '3.0'
69
- - !ruby/object:Gem::Dependency
70
- name: cocoapods
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '1.6'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '1.6'
83
55
  description: A short description of cocoapods-hmap-prebuilt.
84
56
  email:
85
57
  - 499304609@qq.com
86
- executables:
87
- - hmap-prebuilt-read
88
- - hmap-prebuilt-write
58
+ executables: []
89
59
  extensions: []
90
60
  extra_rdoc_files: []
91
61
  files:
92
62
  - LICENSE
93
- - README.md
94
- - bin/hmap-prebuilt-read
95
- - bin/hmap-prebuilt-write
96
63
  - lib/cocoapods-hmap-prebuilt.rb
97
- - lib/cocoapods-hmap-prebuilt/command/hmap_reader.rb
98
- - lib/cocoapods-hmap-prebuilt/command/hmap_writer.rb
99
- - lib/cocoapods-hmap-prebuilt/hmap_exceptions.rb
100
- - lib/cocoapods-hmap-prebuilt/hmap_file.rb
101
- - lib/cocoapods-hmap-prebuilt/hmap_file_reader.rb
102
- - lib/cocoapods-hmap-prebuilt/hmap_file_writer.rb
103
- - lib/cocoapods-hmap-prebuilt/hmap_helper.rb
104
- - lib/cocoapods-hmap-prebuilt/hmap_struct.rb
105
- - lib/cocoapods-hmap-prebuilt/hmap_utils.rb
64
+ - lib/cocoapods-hmap-prebuilt/hmap_constructor.rb
106
65
  - lib/cocoapods-hmap-prebuilt/hmap_version.rb
107
- - lib/cocoapods-hmap-prebuilt/hmap_view.rb
66
+ - lib/cocoapods-hmap-prebuilt/hmap_writer.rb
67
+ - lib/cocoapods-hmap-prebuilt/pod_context_hook.rb
68
+ - lib/cocoapods-hmap-prebuilt/pod_target.rb
69
+ - lib/cocoapods-hmap-prebuilt/pod_xcconfig.rb
70
+ - lib/cocoapods-hmap-prebuilt/podfile_dsl.rb
108
71
  - lib/cocoapods_plugin.rb
109
72
  homepage: http://gitlab.webuy.ai/iOS/cocoapod-hamp-prebuilt.git
110
73
  licenses:
@@ -118,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
81
  requirements:
119
82
  - - ">="
120
83
  - !ruby/object:Gem::Version
121
- version: '2.5'
84
+ version: '0'
122
85
  required_rubygems_version: !ruby/object:Gem::Requirement
123
86
  requirements:
124
87
  - - ">="