cocoapods-hmap-prebuilt 0.0.2 → 0.0.3

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: 723e044d815f6fad29a5df76f527a938d172da2c530f0a1af71fa8af0e1b5e69
4
+ data.tar.gz: 81e969600276c30f6d23345ee3aa228b147756461268d81b4dbaf69d4f2f6c02
5
5
  SHA512:
6
- metadata.gz: a70c5f2440ffb93a27c6706b997067111ab6a16598e751354653d53c49dce4219a6e19a846ac3b54c0a22ceb84360a2830c7d98d35ae0b38d2dacb0dc5e3c103
7
- data.tar.gz: 76b7ed93626493ca1385034f271bbfdcc4e98b3e700e09a0e708b9253bb56c6889c0f44f03f09ae535452127752b3a4855a924f5646765a93c64e19656761425
6
+ metadata.gz: fe850c4aacb92d776ac2deb632206a057a134cc53b05c1551552b9ad903e80cb7265e1a96fdf50985014e51cd54cdf8affd5130f7b061ffbca7a7df3b2d6ed0c
7
+ data.tar.gz: c27233d8032b87602afa6c94f4e9b49b55032ccbdceab090f3c776d000faddeb728867a61f5d7dc98547ca88a952114900c35f072b500cd05c0338f767eeca5e
@@ -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.3"
3
+ end
@@ -0,0 +1,54 @@
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
+ Dir.mkdir(hmap_dir) if !File.exist?(hmap_dir)
14
+ gen_hmapfile(aggregate_targets, hmap_dir)
15
+ end
16
+
17
+ def gen_hmapfile(aggregate_targets, hmap_dir)
18
+ aggregate_targets.each do |aggregate_target|
19
+ pods_hmap = HMap::HMapConstructor.new
20
+ puts "- hanlding headers of aggregate target :#{aggregate_target.name}".green
21
+ aggregate_target.pod_targets.each do |target|
22
+ puts "- hanlding headers of target :#{target.name}".yellow
23
+ public_header_mapping = target.public_header_mappings_by_file_accessor
24
+ pods_hmap.add_hmap_with_header_mapping(public_header_mapping, target.name)
25
+
26
+ unless $skip_hmap_for_pods.include?(target.name)
27
+ target_hmap = HMap::HMapConstructor.new
28
+ header_mappings = target.header_mappings_by_file_accessor
29
+ target_hmap.add_hmap_with_header_mapping(header_mappings, target.name)
30
+ target.dependent_targets.each do |dependent_target|
31
+ target_hmap.add_hmap_with_header_mapping(dependent_target.public_header_mappings_by_file_accessor, dependent_target.name)
32
+ end
33
+
34
+ target_hmap_name = "#{target.name}-prebuilt.hmap"
35
+ target_hmap_path = hmap_dir + "/#{target_hmap_name}"
36
+ relative_hmap_path = "Headers/HMap/#{target_hmap_name}"
37
+ if target_hmap.save_to(target_hmap_path)
38
+ target.reset_header_search_with_relative_hmap_path(relative_hmap_path)
39
+ end
40
+ else
41
+ puts "- skip handling headers of target :#{target.name}"
42
+ end
43
+ end
44
+
45
+ pods_hmap_name = "#{aggregate_target.name}-prebuilt.hmap"
46
+ pods_hmap_path = hmap_dir + "/#{pods_hmap_name}"
47
+ relative_hmap_path = "Headers/HMap/#{pods_hmap_name}"
48
+ if pods_hmap.save_to(pods_hmap_path)
49
+ aggregate_target.reset_header_search_with_relative_hmap_path(relative_hmap_path)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ 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,40 @@
1
+ # !/usr/bin/env ruby
2
+
3
+ require_relative 'pod_xcconfig'
4
+
5
+ module Pod
6
+ class PodTarget
7
+ def reset_header_search_with_relative_hmap_path(hmap_path)
8
+ if build_settings.instance_of?(Hash)
9
+ build_settings.each do |config_name, setting|
10
+ config_file = setting.xcconfig
11
+ config_file.reset_header_search_with_relative_hmap_path(hmap_path)
12
+ # https://github.com/CocoaPods/CocoaPods/issues/1216
13
+ config_file.set_use_hmap(false)
14
+ config_path = xcconfig_path(config_name)
15
+ config_file.save_as(config_path)
16
+ end
17
+ elsif build_settings.instance_of?(BuildSettings::PodTargetSettings)
18
+ config_file = build_settings.xcconfig
19
+ config_file.reset_header_search_with_relative_hmap_path(hmap_path)
20
+ # https://github.com/CocoaPods/CocoaPods/issues/1216
21
+ config_file.set_use_hmap(false)
22
+ config_path = xcconfig_path
23
+ config_file.save_as(config_path)
24
+ else
25
+ puts 'Unknown build settings'.red
26
+ end
27
+ end
28
+ end
29
+
30
+ class AggregateTarget
31
+ def reset_header_search_with_relative_hmap_path(hmap_path)
32
+ # override xcconfig
33
+ xcconfigs.each do |config_name, config_file|
34
+ config_file.reset_header_search_with_relative_hmap_path(hmap_path)
35
+ config_path = xcconfig_path(config_name)
36
+ config_file.save_as(config_path)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,71 @@
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')
17
+ new_paths << p
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)
57
+ remove_header_search_path
58
+ # add build flags
59
+ new_paths = Array["${PODS_ROOT}/#{hmap_path}"]
60
+ header_search_paths = @attributes['HEADER_SEARCH_PATHS']
61
+ if header_search_paths
62
+ new_paths.concat(header_search_paths.split(' '))
63
+ end
64
+ @attributes['HEADER_SEARCH_PATHS'] = new_paths.join(' ')
65
+ end
66
+
67
+ def set_use_hmap(use_hmap = false)
68
+ @attributes['USE_HEADERMAP'] = (use_hmap ? 'YES' : 'NO')
69
+ end
70
+ end
71
+ 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.3
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-05 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
  - - ">="