cocoapods-imy-bin 0.3.1.3 → 0.3.1.21

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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -0
  3. data/lib/cocoapods-imy-bin/command/bin/archive.rb +18 -20
  4. data/lib/cocoapods-imy-bin/command/bin/auto.rb +12 -9
  5. data/lib/cocoapods-imy-bin/command/bin/clean.rb +126 -0
  6. data/lib/cocoapods-imy-bin/command/bin/local.rb +169 -0
  7. data/lib/cocoapods-imy-bin/command/bin/update.rb +14 -3
  8. data/lib/cocoapods-imy-bin/command/bin.rb +2 -0
  9. data/lib/cocoapods-imy-bin/config/config.rb +8 -0
  10. data/lib/cocoapods-imy-bin/gem_version.rb +1 -1
  11. data/lib/cocoapods-imy-bin/helpers/build_utils.rb +40 -9
  12. data/lib/cocoapods-imy-bin/helpers/framework_builder.rb +1 -1
  13. data/lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb +57 -0
  14. data/lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb +183 -0
  15. data/lib/cocoapods-imy-bin/helpers/local/local_framework.rb +85 -0
  16. data/lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb +227 -0
  17. data/lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb +96 -0
  18. data/lib/cocoapods-imy-bin/helpers/spec_source_creator.rb +10 -4
  19. data/lib/cocoapods-imy-bin/helpers/upload_helper.rb +5 -3
  20. data/lib/cocoapods-imy-bin/native/Downloader.rb +68 -0
  21. data/lib/cocoapods-imy-bin/native/Lockfile.rb +36 -0
  22. data/lib/cocoapods-imy-bin/native/installer.rb +6 -0
  23. data/lib/cocoapods-imy-bin/native/podfile.rb +7 -0
  24. data/lib/cocoapods-imy-bin/native/podfile_env.rb +5 -0
  25. data/lib/cocoapods-imy-bin/native/resolver.rb +10 -5
  26. data/lib/cocoapods-imy-bin/native.rb +3 -1
  27. data/lib/cocoapods-imy-bin/post_install_hook.rb +110 -0
  28. data/lib/cocoapods-imy-bin/source_provider_hook.rb +3 -0
  29. data/lib/cocoapods_plugin.rb +1 -0
  30. metadata +16 -6
@@ -0,0 +1,68 @@
1
+ require 'cocoapods-downloader'
2
+ require 'claide/informative_error'
3
+ require 'fileutils'
4
+ require 'tmpdir'
5
+
6
+ module Pod
7
+ module Downloader
8
+ require 'cocoapods/downloader/cache'
9
+ require 'cocoapods/downloader/request'
10
+ require 'cocoapods/downloader/response'
11
+
12
+ # Downloads a pod from the given `request` to the given `target` location.
13
+ #
14
+ # @return [Response] The download response for this download.
15
+ #
16
+ # @param [Request] request
17
+ # the request that describes this pod download.
18
+ #
19
+ # @param [Pathname,Nil] target
20
+ # the location to which this pod should be downloaded. If `nil`,
21
+ # then the pod will only be cached.
22
+ #
23
+ # @param [Boolean] can_cache
24
+ # whether caching is allowed.
25
+ #
26
+ # @param [Pathname,Nil] cache_path
27
+ # the path used to cache pod downloads.
28
+ #
29
+ def self.download(
30
+ request,
31
+ target,
32
+ can_cache: true,
33
+ cache_path: Config.instance.cache_root + 'Pods'
34
+ )
35
+ can_cache &&= !Config.instance.skip_download_cache
36
+
37
+ request = preprocess_request(request)
38
+
39
+ if can_cache
40
+ raise ArgumentError, 'Must provide a `cache_path` when caching.' unless cache_path
41
+ cache = Cache.new(cache_path)
42
+ result = cache.download_pod(request)
43
+ else
44
+ raise ArgumentError, 'Must provide a `target` when caching is disabled.' unless target
45
+
46
+ require 'cocoapods/installer/pod_source_preparer'
47
+ result, = download_request(request, target)
48
+ Installer::PodSourcePreparer.new(result.spec, result.location).prepare!
49
+ end
50
+
51
+ if target && result.location && target != result.location
52
+ UI.message "Copying #{request.name} from `#{result.location}` to #{UI.path target}", '> ' do
53
+ FileUtils.rm_rf target
54
+ FileUtils.cp_r(result.location, target)
55
+ file_count = Dir.glob(File.join(target, '**', '*')).select { |file| File.file?(file) }.count
56
+ if file_count < 2
57
+ FileUtils.rm_rf target
58
+ FileUtils.cp_r(result.location, target)
59
+ UI.warn "======Copying #{request.name} ==== #{target} 为空,请注意 ======== "
60
+ end
61
+ end
62
+ end
63
+ result
64
+ end
65
+
66
+
67
+ end
68
+ end
@@ -0,0 +1,36 @@
1
+ require 'parallel'
2
+ require 'cocoapods'
3
+ require 'cocoapods-core/lockfile'
4
+ require 'fileutils'
5
+
6
+ module Pod
7
+ class Lockfile
8
+
9
+ # 处理 下载文件为空的情况
10
+ #交换 Lockfile 下的 detect_changes_with_podfile,拿到 result
11
+ #并且取出 result下的 unchanged下的列表,判断各个spec是否存在超过一个文件,
12
+ #如果不存在就删除该文件夹,移除result[:unchanged]中的值,并且加入result[:added],
13
+ alias old_detect_changes_with_podfile detect_changes_with_podfile
14
+ def detect_changes_with_podfile(podfile)
15
+ result = old_detect_changes_with_podfile(podfile)
16
+ result[:unchanged].each do |name|
17
+ spec_path = File.join(Pod::Config.instance.sandbox_root,name)
18
+
19
+ if File.directory?(spec_path)
20
+ #.头文件小于1个,认定是空的,需要重新下载podspec
21
+ file_count = Dir.glob(File.join(spec_path, '**', '*.h')).select { |file| File.file?(file) }.count
22
+ #用于判断是否文件,太少就认定是失败了
23
+ if file_count < 1
24
+ FileUtils.rm_rf(spec_path)
25
+ result[:added] << name
26
+ UI.warn "====== #{name} ==== #{spec_path} 为空,请注意 ======== "
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ result
33
+ end
34
+
35
+ end
36
+ end
@@ -105,6 +105,12 @@ module Pod
105
105
  group.set_source_tree('SOURCE_ROOT')
106
106
  #向group中添加 文件引用
107
107
  file_ref = group.new_reference(config.sandbox.root + '../Podfile_local')
108
+ file_ref.xc_language_specification_identifier = 'xcode.lang.ruby'
109
+ file_ref.explicit_file_type = 'text.script.ruby'
110
+ file_ref.last_known_file_type = 'text'
111
+ file_ref.tab_width = '2'
112
+ file_ref.indent_width = '2'
113
+
108
114
  #podfile_local排序
109
115
  podfile_local_group = group.children.last
110
116
  group.children.pop
@@ -15,6 +15,9 @@ module Pod
15
15
  def use_binaries!(flag = true)
16
16
  set_internal_hash_value(USE_BINARIES, flag)
17
17
  end
18
+ def use_hmap!(flag = true)
19
+ set_internal_hash_value(USE_HMAP, flag)
20
+ end
18
21
 
19
22
  def use_binaries_with_spec_selector!(&block)
20
23
  raise Informative, '必须提供选择需要二进制组件的 block !' unless block_given?
@@ -61,6 +64,10 @@ module Pod
61
64
  get_internal_hash_value(USE_BINARIES, false) || ENV[USE_BINARIES] == 'true'
62
65
  end
63
66
 
67
+ def use_hmap?
68
+ get_internal_hash_value(USE_HMAP, false) || ENV[USE_HMAP] == 'true'
69
+ end
70
+
64
71
  def use_source_pods
65
72
  get_internal_hash_value(USE_SOURCE_PODS, []) + String(ENV[USE_SOURCE_PODS]).split('|').uniq
66
73
  end
@@ -3,6 +3,7 @@
3
3
  module Pod
4
4
  class Podfile
5
5
  USE_BINARIES = 'use_binaries'
6
+ USE_HMAP = 'use_hmap'
6
7
  USE_SOURCE_PODS = 'use_source_pods'
7
8
  USE_BINARIES_SELECTOR = 'use_binaries_selector'
8
9
  ALLOW_PRERELEASE = 'allow_prerelease'
@@ -22,6 +23,10 @@ module Pod
22
23
  execute_with_key(USE_BINARIES, -> { use_binaries ? 'true' : 'false' }, &block)
23
24
  end
24
25
 
26
+ def execute_with_use_hmap(use_hmap, &block)
27
+ execute_with_key(USE_HMAP, -> { use_hmap ? 'true' : 'false' }, &block)
28
+ end
29
+
25
30
  def execute_with_key(key, value_returner)
26
31
  origin_value = ENV[key]
27
32
  ENV[key] = value_returner.call
@@ -184,12 +184,17 @@ module Pod
184
184
  missing_binary_specs.uniq.each do |spec|
185
185
  next if spec.name.include?('/')
186
186
 
187
- spec_git_res = false
188
- CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
189
- spec_git_res = spec.source[:git] && spec.source[:git].include?(ignore_git)
190
- break if spec_git_res
187
+ ignore_git_list = CBin::Config::Builder.instance.ignore_git_list
188
+ if ignore_git_list
189
+ spec_git_res = false
190
+ #这里会过滤 ignore_git 配置中的 仓库
191
+ ignore_git_list.each do |ignore_git|
192
+ spec_git_res = spec.source[:git] && spec.source[:git].include?(ignore_git)
193
+ break if spec_git_res
194
+ end
195
+ next if spec_git_res
191
196
  end
192
- next if spec_git_res
197
+
193
198
 
194
199
  #获取没有制作二进制版本的spec集合
195
200
  sources_sepc << spec
@@ -1,5 +1,5 @@
1
1
  require 'cocoapods'
2
-
2
+ require 'xcodeproj'
3
3
  if Pod.match_version?('~> 1.4')
4
4
  require 'cocoapods-imy-bin/native/podfile'
5
5
  require 'cocoapods-imy-bin/native/installation_options'
@@ -19,5 +19,7 @@ if Pod.match_version?('~> 1.4')
19
19
  require 'cocoapods-imy-bin/native/file_accessor'
20
20
  require 'cocoapods-imy-bin/native/pod_target_installer'
21
21
  require 'cocoapods-imy-bin/native/target_validator'
22
+ require 'cocoapods-imy-bin/native/Lockfile'
23
+ require 'cocoapods-imy-bin/native/Downloader'
22
24
 
23
25
  end
@@ -0,0 +1,110 @@
1
+ require 'cocoapods-imy-bin/native/sources_manager'
2
+ require 'cocoapods-imy-bin/command/bin/repo/update'
3
+ require 'cocoapods/user_interface'
4
+ require 'xcodeproj/config/other_linker_flags_parser'
5
+ require 'xcodeproj/config'
6
+
7
+ module Xcodeproj
8
+ class Config
9
+ def remove_attr_with_key(key)
10
+ unless key == nil
11
+ @attributes.delete(key)
12
+ end
13
+ end
14
+ def remove_header_search_path
15
+ remove_attr_with_key('HEADER_SEARCH_PATHS')
16
+ flags = @attributes['OTHER_CFLAGS']
17
+ if flags
18
+ new_flags = ''
19
+ skip = false
20
+ flags.split(' ').each do |substr|
21
+ if skip
22
+ skip = false
23
+ next
24
+ end
25
+ if substr == '-isystem'
26
+ skip = true
27
+ next
28
+ end
29
+ if new_flags.length > 0
30
+ new_flags += ' '
31
+ end
32
+ new_flags += substr
33
+ end
34
+ if new_flags.length > 0
35
+ @attributes['OTHER_CFLAGS'] = new_flags
36
+ else
37
+ remove_attr_with_key('OTHER_CFLAGS')
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ module Pod
45
+ class Installer
46
+ class PostInstallHooksContext
47
+ attr_accessor :aggregate_targets
48
+ def self.generate(sandbox, pods_project, aggregate_targets)
49
+ context = super
50
+ UI.info "[#] generate method of post install hook context override"
51
+ context.aggregate_targets = aggregate_targets
52
+ context
53
+ end
54
+ end
55
+ end
56
+ module ProjectHeaderMap
57
+ HooksManager.register('cocoapods-imy-bin', :post_install) do |post_context|
58
+
59
+ podfile = Pod::Config.instance.podfile
60
+
61
+
62
+ if podfile && podfile.use_hmap?
63
+ UI.info "[#] use hmap for this project"
64
+ post_context.aggregate_targets.each do |one|
65
+ hmap = Hash.new
66
+ one.pod_targets.each do |target|
67
+ target.public_header_mappings_by_file_accessor.each do |facc, headers|
68
+ headers.each do |key, value|
69
+ value.each do |path|
70
+ pn = Pathname.new(path)
71
+ name = pn.basename.to_s
72
+ dirname = pn.dirname.to_s + '/'
73
+ # construct hmap hash info
74
+ path_info = Hash['suffix' => name, 'prefix' => dirname]
75
+ # import with quote
76
+ hmap[name] = path_info
77
+ # import with angle bracket
78
+ hmap["#{target.name}/#{name}"] = path_info
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ unless hmap.empty?
85
+ path = "#{post_context.sandbox_root + "/#{one.name}-hmap.json"}"
86
+ path_hmap = "#{post_context.sandbox_root + "/#{one.name}.hmap"}"
87
+ # write hmap json to file
88
+ File.open(path, 'w') { |file| file << hmap.to_json }
89
+ # json to hmap
90
+ system("hmap convert #{path} #{path_hmap}")
91
+ # delete json file
92
+ File.delete(path)
93
+
94
+ # override xcconfig
95
+ one.xcconfigs.each do |config_name, config_file|
96
+ # puts "config_file == #{config_file} \n\r"
97
+ config_file << Hash['OTHER_CFLAGS' => "#{"-I ${PODS_ROOT}/#{one.name}.hmap"}"]
98
+ config_file << Hash['OTHER_SWIFT_FLAGS' => "#{"-Xcc -I${PODS_ROOT}/#{one.name}.hmap"}"]
99
+ config_file.remove_header_search_path
100
+ xcconfig_path = one.xcconfig_path(config_name)
101
+ config_file.save_as(xcconfig_path)
102
+ end
103
+
104
+ end
105
+ end
106
+ end
107
+
108
+ end
109
+ end
110
+ end
@@ -46,6 +46,7 @@ end
46
46
 
47
47
  Pod::HooksManager.register('cocoapods-imy-bin', :source_provider) do |context, _|
48
48
  #pod bin update || install 不走这里
49
+ puts "post_install================================="
49
50
  if $ARGV[1] == 'update' || $ARGV[1] != 'install'
50
51
 
51
52
  else
@@ -64,3 +65,5 @@ Pod::HooksManager.register('cocoapods-imy-bin', :source_provider) do |context, _
64
65
  end
65
66
 
66
67
  end
68
+
69
+
@@ -1,3 +1,4 @@
1
1
  require 'cocoapods-imy-bin/gem_version.rb'
2
2
  require 'cocoapods-imy-bin/command'
3
3
  require 'cocoapods-imy-bin/source_provider_hook'
4
+ require 'cocoapods-imy-bin/post_install_hook'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-imy-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1.3
4
+ version: 0.3.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - 苏良锦
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-12 00:00:00.000000000 Z
11
+ date: 2022-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: cocoapods-generate
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +95,7 @@ files:
95
95
  - lib/cocoapods-imy-bin/command/bin.rb
96
96
  - lib/cocoapods-imy-bin/command/bin/archive.rb
97
97
  - lib/cocoapods-imy-bin/command/bin/auto.rb
98
+ - lib/cocoapods-imy-bin/command/bin/clean.rb
98
99
  - lib/cocoapods-imy-bin/command/bin/code.rb
99
100
  - lib/cocoapods-imy-bin/command/bin/dup.rb
100
101
  - lib/cocoapods-imy-bin/command/bin/imy.rb
@@ -102,6 +103,7 @@ files:
102
103
  - lib/cocoapods-imy-bin/command/bin/initHotKey.rb
103
104
  - lib/cocoapods-imy-bin/command/bin/install.rb
104
105
  - lib/cocoapods-imy-bin/command/bin/lib/lint.rb
106
+ - lib/cocoapods-imy-bin/command/bin/local.rb
105
107
  - lib/cocoapods-imy-bin/command/bin/repo/update.rb
106
108
  - lib/cocoapods-imy-bin/command/bin/spec/create.rb
107
109
  - lib/cocoapods-imy-bin/command/bin/spec/push.rb
@@ -120,12 +122,19 @@ files:
120
122
  - lib/cocoapods-imy-bin/helpers/framework_builder.rb
121
123
  - lib/cocoapods-imy-bin/helpers/library.rb
122
124
  - lib/cocoapods-imy-bin/helpers/library_builder.rb
125
+ - lib/cocoapods-imy-bin/helpers/local/loca_llibrary.rb
126
+ - lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb
127
+ - lib/cocoapods-imy-bin/helpers/local/local_framework.rb
128
+ - lib/cocoapods-imy-bin/helpers/local/local_framework_builder.rb
129
+ - lib/cocoapods-imy-bin/helpers/local/local_library_builder.rb
123
130
  - lib/cocoapods-imy-bin/helpers/sources_helper.rb
124
131
  - lib/cocoapods-imy-bin/helpers/spec_creator.rb
125
132
  - lib/cocoapods-imy-bin/helpers/spec_files_helper.rb
126
133
  - lib/cocoapods-imy-bin/helpers/spec_source_creator.rb
127
134
  - lib/cocoapods-imy-bin/helpers/upload_helper.rb
128
135
  - lib/cocoapods-imy-bin/native.rb
136
+ - lib/cocoapods-imy-bin/native/Downloader.rb
137
+ - lib/cocoapods-imy-bin/native/Lockfile.rb
129
138
  - lib/cocoapods-imy-bin/native/acknowledgements.rb
130
139
  - lib/cocoapods-imy-bin/native/analyzer.rb
131
140
  - lib/cocoapods-imy-bin/native/file_accessor.rb
@@ -146,6 +155,7 @@ files:
146
155
  - lib/cocoapods-imy-bin/native/specification.rb
147
156
  - lib/cocoapods-imy-bin/native/target_validator.rb
148
157
  - lib/cocoapods-imy-bin/native/validator.rb
158
+ - lib/cocoapods-imy-bin/post_install_hook.rb
149
159
  - lib/cocoapods-imy-bin/source_provider_hook.rb
150
160
  - lib/cocoapods_plugin.rb
151
161
  - spec/command/bin_spec.rb