cocoapods-jxedt 0.0.9 → 0.0.12

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: c38c0828fdaf7acdd4f9aea09b68194af1d2e9e6117ca1c6156618e7b1bc8cd6
4
- data.tar.gz: 4d19e409eefaa4a2eac16c7c72e6874a2a626c49bf1a20cd216a7d5ef842395c
3
+ metadata.gz: ad01cd6bd2da4418b03764271caab2236a186ea81f3c9f77a885910d12263d78
4
+ data.tar.gz: aa9f410bbbea81420a9d04f01c379428aece86e8449c9ec10a461a79d03825fe
5
5
  SHA512:
6
- metadata.gz: 6587bbe4ed16a1a0f354b8bb07008399c2031ccf28544e4c75b8180005c5653670fa8d86c8868275fd389b700f8e6d8d18c4fea9c3061742f44e751f47fdcce3
7
- data.tar.gz: 3968415ded4a515d99569a2f060ae732055233c4c8703048346eaf52a2e0665dd659af92889b11cf959ce78f69d8b92719f68247fc4231133a04501d0ea7b933
6
+ metadata.gz: a0a5d962b702c2fde4f3ac10a81e027ba555f72310b31fee0530e94587eb7e56019ddf0d5e64951dd8f3c0e50626afbf286aa3c15b31a678bbb99413dcc5e8d1
7
+ data.tar.gz: 60e70a3f5be60178cf721b4d69b113d065275eb415f70655feb718279b9b2ad9de3bfb8a9ce0a01050b2972a7c2346ef7bbcd723849054d40bf79dc7b84db124
@@ -11,6 +11,7 @@ module Jxedt
11
11
  :binary_dir => "framework的保存路径,相对于'Pods/Pods.xcodeproj'的相对路径。默认为'../_Prebuild'",
12
12
  :binary_switch => "二进制开关,关闭则不hook pre_install过程。默认为true",
13
13
  :prebuild_job => "开启编译任务,设置为false则不触发编译。默认为true",
14
+ :keep_source_project => "保留源码的pods工程,默认保留,方便查看源码",
14
15
  :dev_pods_enabled => "Development Pods是否支持binary。默认为false",
15
16
  :excluded_pods => "排除binary的pods",
16
17
  :xcconfig_configuration_alias => "xcconfig文件中configuration的别名,configurations设置为多个值的时候会用到,用于搜索替换。一般不需要设置,有默认值为'cocoapods-jxedt-binary'",
@@ -59,6 +60,10 @@ module Jxedt
59
60
  @dsl_config[:prebuild_job] || @dsl_config[:prebuild_job].nil?
60
61
  end
61
62
 
63
+ def keep_source_project?
64
+ @dsl_config[:keep_source_project] || false
65
+ end
66
+
62
67
  def dev_pods_enabled?
63
68
  @dsl_config[:dev_pods_enabled] || false
64
69
  end
@@ -1,4 +1,46 @@
1
1
  module Pod
2
+ # The sandbox provides support for the directory that CocoaPods uses for an
3
+ # installation. In this directory the Pods projects, the support files and
4
+ # the sources of the Pods are stored.
5
+ #
6
+ # CocoaPods assumes to have control of the sandbox.
7
+ #
8
+ # Once completed the sandbox will have the following file structure:
9
+ #
10
+ # Pods
11
+ # |
12
+ # +-- Headers
13
+ # | +-- Private
14
+ # | | +-- [Pod Name]
15
+ # | +-- Public
16
+ # | +-- [Pod Name]
17
+ # |
18
+ # +-- Local Podspecs
19
+ # | +-- External Sources
20
+ # | +-- Normal Sources
21
+ # |
22
+ # +-- Target Support Files
23
+ # | +-- [Target Name]
24
+ # | +-- Pods-acknowledgements.markdown
25
+ # | +-- Pods-acknowledgements.plist
26
+ # | +-- Pods-dummy.m
27
+ # | +-- Pods-prefix.pch
28
+ # | +-- Pods.xcconfig
29
+ # |
30
+ # +-- [Pod Name]
31
+ # |
32
+ # +-- Manifest.lock
33
+ # |
34
+ # +-- Pods.xcodeproj
35
+ # (if installation option 'generate_multiple_pod_projects' is enabled)
36
+ # |
37
+ # +-- PodTarget1.xcodeproj
38
+ # |
39
+ # ...
40
+ # |
41
+ # +-- PodTargetN.xcodeproj
42
+ #
43
+ #
2
44
  class PrebuildSandbox < Sandbox
3
45
  # [String] standard_sandbox_path
4
46
  def self.from_standard_sandbox_path(path)
@@ -10,9 +52,77 @@ module Pod
10
52
  from_standard_sandbox_path(sandbox.root)
11
53
  end
12
54
 
55
+ def make_source_link(source, target)
56
+ source = Pathname.new(source)
57
+ target = Pathname.new(target)
58
+ target.parent.mkpath unless target.parent.exist?
59
+ target.rmtree if target.exist?
60
+ relative_source = source.relative_path_from(target.parent)
61
+ FileUtils.ln_sf(relative_source, target)
62
+ end
63
+
64
+ def source_path
65
+ '../Pods-Source'
66
+ end
67
+
68
+ def headers_root
69
+ root + source_path + 'Headers'
70
+ end
71
+
13
72
  def project_path
14
- super
15
- # root + 'Pods.xcodeproj'
73
+ root + source_path + 'Pods-Source.xcodeproj'
74
+ end
75
+
76
+ def specifications_root
77
+ # root + source_path + 'Local Podspecs'
78
+ super
79
+ end
80
+
81
+ def target_support_files_root
82
+ root + source_path + 'Target Support Files'
83
+ end
84
+
85
+ def link_source_project!
86
+ root.children.each do |child|
87
+ next if ['Headers', 'Local Podspecs', 'Target Support Files'].include? child.basename.to_s
88
+ next if ['.lock', '.xcodeproj'].include? child.extname.to_s
89
+ make_source_link(child, root + source_path + child.basename)
90
+ end
91
+ end
92
+
93
+ def clean_source_project!
94
+ return if Jxedt.config.keep_source_project?
95
+
96
+ source_project_path = root + source_path
97
+ source_project_path.rmtree if source_project_path.exist?
98
+ end
99
+ end
100
+ end
101
+
102
+ module Pod
103
+ class Installer
104
+ # The {UserProjectIntegrator} integrates the libraries generated by
105
+ # TargetDefinitions of the {Podfile} with their correspondent user
106
+ # projects.
107
+ #
108
+ class UserProjectIntegrator
109
+ alias_method :old_create_workspace, :create_workspace
110
+ def create_workspace
111
+ old_create_workspace unless sandbox.is_a?(Pod::PrebuildSandbox)
112
+ end
113
+ end
114
+ end
115
+ end
116
+
117
+ module Pod
118
+ class Installer
119
+ # Cleans up the sandbox directory by removing stale target support files and headers.
120
+ #
121
+ class SandboxDirCleaner
122
+ alias_method :old_clean!, :clean!
123
+ def clean!
124
+ old_clean! unless @sandbox.is_a?(Pod::PrebuildSandbox)
125
+ end
16
126
  end
17
127
  end
18
128
  end
@@ -44,8 +44,12 @@ module Jxedt
44
44
  require_relative '../prebuild'
45
45
 
46
46
  # prebuild_job
47
- log_section "🚀 Prebuild frameworks" if Jxedt.config.prebuild_job?
48
- Jxedt::Prebuild.new(source_installer).build if Jxedt.config.prebuild_job?
47
+ sandbox.link_source_project!
48
+ if Jxedt.config.prebuild_job?
49
+ log_section "🚀 Prebuild frameworks"
50
+ Jxedt::Prebuild.new(source_installer).build
51
+ end
52
+ sandbox.clean_source_project!
49
53
 
50
54
  log_section "🤖 Resume pod installation"
51
55
  require_relative '../targets/pod_target'
@@ -1,4 +1,54 @@
1
1
  module Pod
2
+ class PodTarget < Target
3
+ alias_method :old_resource_paths, :resource_paths
4
+ def resource_paths
5
+ resource_paths = old_resource_paths
6
+ # 没有使用二进制不处理
7
+ return resource_paths unless self.use_binary
8
+
9
+ # 遍历所有的resources
10
+ resource_paths.each do |name, resources|
11
+ resources.map! {|resource_file|
12
+ resource_extname = Pathname.new(resource_file).basename.extname
13
+ # 如果文件不需要编译,跳过
14
+ next resource_file unless self.class.resource_extension_compilable?(resource_extname)
15
+
16
+ # 确定编译后的文件名称
17
+ output_extname = self.class.output_extension_for_resource(resource_extname)
18
+ output_file_name = "#{Pathname.new(resource_file).basename.sub_ext('')}#{output_extname}"
19
+ # 从framework中查找编译后的文件
20
+ file_accessors.each do |file_accessor|
21
+ file_accessor.vendored_frameworks.each do |framework_file|
22
+ framework_name = Pathname.new(framework_file).basename.sub_ext('').to_s
23
+ # 只处理和当前target module_name相同的framework,否则跳过
24
+ next if self.product_module_name != framework_name
25
+
26
+ # xcframework和framework文件分别处理,而且只查找.framework根目录下的文件
27
+ if '.xcframework' == Pathname.new(framework_file).basename.extname
28
+ files = Dir.glob("#{framework_file}/**/#{framework_name}.framework/#{output_file_name}")
29
+ next if files.size == 0 # 没有查找到文件跳过
30
+
31
+ if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
32
+ resource_file = "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{self.name}/#{framework_name}.framework/#{output_file_name}"
33
+ else
34
+ resource_file = "${PODS_CONFIGURATION_BUILD_DIR}/#{framework_name}.framework/#{output_file_name}"
35
+ end
36
+ else
37
+ files = Dir.glob("#{framework_file}/#{output_file_name}")
38
+ next if files.size == 0 # 没有查找到文件跳过
39
+
40
+ resource_path = Pathname.new("#{framework_file}/#{output_file_name}") # 真实路径
41
+ resource_file = "${PODS_ROOT}/#{resource_path.relative_path_from(self.sandbox.root)}"
42
+ end
43
+ end
44
+ end
45
+ resource_file
46
+ }.reject!(&:nil?)
47
+ end
48
+ resource_paths
49
+ end
50
+ end
51
+
2
52
  class Target
3
53
  # @since 1.5.0
4
54
  class BuildSettings
@@ -2,9 +2,9 @@ module Pod
2
2
  class Command
3
3
  class JxedtCommand < Command
4
4
  class Header < JxedtCommand
5
- self.summary = 'header fix'
5
+ self.summary = '修改头文件引用问题'
6
6
  self.description = <<-DESC
7
- 修改头文件引用问题。\n
7
+ 修改头文件引用问题\n
8
8
  例如修改#import "AFNetworking.h"或#import <AFNetworking.h>这种头文件引用方式为#import <AFNetworking/AFNetworking.h>\n
9
9
  使用方式:\n
10
10
  到Podfile文件所在目录执行以下命令\n
@@ -23,6 +23,8 @@ module Pod
23
23
  ['--write', '修改命中的头文件引用,不写入则直接输出需要修改的文件和修改内容。默认false'],
24
24
  ['--suffix', '处理的文件后缀,默认处理\'h,m,mm,pch\'后缀的文件'],
25
25
  ['--header-regulation', 'header name的正则,默认为\'[\w+-]*\.h\',如果不满足也可以自定义'],
26
+ ['--verbose', '在屏幕上输出修改文件的详情'],
27
+ ['--log-path', '需要修改文件内容导出路径']
26
28
  ]
27
29
  end
28
30
  def initialize(argv)
@@ -31,6 +33,8 @@ module Pod
31
33
  @suffix = argv.option('suffix', 'h,m,mm,pch')
32
34
  @force_write = argv.flag?('write', false)
33
35
  @header_regulation = argv.option('header-regulation')
36
+ @verbose_flag = argv.flag?('verbose', false)
37
+ @log_path = argv.option('log-path')
34
38
  super
35
39
  end
36
40
 
@@ -65,7 +69,7 @@ module Pod
65
69
  }
66
70
 
67
71
  # 遍历需要处理的文件
68
- record = []
72
+ files, failed, record = [], [], []
69
73
  process_target_files.each {|file_path|
70
74
  changed = false
71
75
  lines = File.readlines(file_path)
@@ -77,16 +81,36 @@ module Pod
77
81
  header_name = line.match(/(?<=")#{header_name_regulation}(?=")/) || line.match(/(?<=<)#{header_name_regulation}(?=>)/)
78
82
  next unless public_header_mapping.include?("#{header_name}")
79
83
 
84
+ changed = true # 文件需要修改
80
85
  project_module_name = public_header_mapping["#{header_name}"]
81
86
  replace_line = "#import " << "<#{project_module_name}/#{header_name}>\n"
82
87
  lines[num] = replace_line
83
- changed = true
84
88
  record << "#{file_path} 第#{num}行,#{line} => #{replace_line}"
85
89
  }
86
- File.open(file_path, 'w') { |f| f.write(lines.join) } if changed && @force_write
90
+ files << file_path if changed
91
+ begin
92
+ File.open(file_path, 'w') { |f| f.write(lines.join) } if changed && @force_write
93
+ rescue
94
+ failed << file_path
95
+ ensure
96
+ help! "因权限问题文件修改失败:\n#{file_path}" if failed.size > 0
97
+ end
87
98
  }
88
- puts "需要修改的地方共有:#{record.size} 处"
89
- puts JSON.pretty_generate(record) if record.size > 0
99
+ puts "需要修改文件共有:#{files.size} 个,需要修改的头文件的地方共有:#{record.size} 处"
100
+ puts "已修改完成" if files.size > 0 && @force_write
101
+
102
+ if files.size > 0
103
+ logs = <<~LOGS
104
+ 需要修改的文件:
105
+ #{JSON.pretty_generate(files)}
106
+
107
+ 文件修改详情:
108
+ #{JSON.pretty_generate(record)}
109
+ LOGS
110
+ logs.gsub!('\\"', '"').gsub!('\\n', '') # 去除转义字符
111
+ puts logs if @verbose_flag
112
+ File.open(log_file_path, 'w') { |file| file.write("#{logs}") } unless log_file_path.nil?
113
+ end
90
114
  end
91
115
 
92
116
  def installer_for_config
@@ -151,6 +175,13 @@ module Pod
151
175
  end
152
176
  dependent_targets
153
177
  end
178
+
179
+ def log_file_path
180
+ log_path = @log_path
181
+ log_path << "/headerfix_output.txt" if log_path && File.directory?(log_path)
182
+ return if log_path && (!File.exist?(File.dirname(log_path)))
183
+ log_path
184
+ end
154
185
  end
155
186
  end
156
187
  end
@@ -1,5 +1,6 @@
1
1
  require_relative 'options/options'
2
2
  require_relative 'header/header'
3
+ require_relative 'statistics/statistics'
3
4
 
4
5
  module Pod
5
6
  class Command
@@ -0,0 +1,98 @@
1
+ module Pod
2
+ class Command
3
+ class JxedtCommand < Command
4
+ class Statistics < JxedtCommand
5
+ self.summary = '统计二进制使用情况'
6
+ self.description = <<-DESC
7
+ 统计二进制使用详情
8
+ DESC
9
+ self.command = 'statistics'
10
+ self.arguments = [
11
+ ]
12
+ def self.options
13
+ [
14
+ ['--failed', '统计校验失败的二进制'],
15
+ ]
16
+ end
17
+ def initialize(argv)
18
+ @check_failed = argv.flag?('failed')
19
+ super
20
+ end
21
+
22
+ def validate!
23
+ super
24
+ end
25
+
26
+ def run
27
+ podfile = Pod::Config.instance.podfile
28
+ lockfile = Pod::Config.instance.lockfile
29
+ help! '请检查命令执行路径,需要在Podfile文件所在目录执行' if podfile.nil? || lockfile.nil?
30
+
31
+ require 'cocoapods-jxedt/binary/config'
32
+ require 'cocoapods-jxedt/binary/helper/podfile_options'
33
+
34
+ pods_root = Pathname.new(File.dirname(podfile.defined_in_file)) + "Pods"
35
+ binary_dir = pods_root + Jxedt.config.binary_dir
36
+
37
+ used_binary = []
38
+ Dir.glob("#{pods_root}/*/_Prebuild") do |file_path|
39
+ next unless File.directory?(file_path)
40
+ dir_name = File.dirname(file_path)
41
+ name = File.basename(dir_name).to_s
42
+ target_path = binary_dir + name
43
+ next unless target_path.exist? # 路径不存在,跳过
44
+
45
+ new_hash = {}
46
+ # name
47
+ new_hash[:name] = name
48
+
49
+ # multiple_configuration
50
+ configuration_enable = target_path.children().select { |path| "#{path.basename}" == 'Debug' || "#{path.basename}" == 'Release' }.count == 2
51
+ new_hash[:multiple_configuration] = configuration_enable
52
+
53
+ # checksum validation
54
+ checksum_file = target_path.children().select { |path| path.extname == '.checksum' }.first
55
+ new_hash[:checksum] = checksum_file.basename.to_s.gsub('.checksum', '') unless checksum_file.nil?
56
+
57
+ used_binary << new_hash
58
+ end
59
+
60
+ # print
61
+ index, failed = 0, []
62
+ used_binary.sort_by {|hash| hash[:name].capitalize }.each do |hash|
63
+ name = hash[:name]
64
+
65
+ checksum = lockfile.spec_checksums_hash_key(name)
66
+ validation_passed = checksum && checksum == hash[:checksum]
67
+ failed << name unless validation_passed
68
+
69
+ # 校验和是否用的 git commitid
70
+ checkout_options = lockfile.internal_data["CHECKOUT OPTIONS"] || {}
71
+ is_git_commitid = checkout_options[name] && checkout_options[name][:commit]
72
+
73
+ if validation_passed
74
+ next if @check_failed
75
+ index += 1
76
+ log = <<~LOG
77
+ #{index}). #{name}:
78
+ multiple configuration: #{hash[:multiple_configuration]}
79
+ checksum#{"(git commitid)" if is_git_commitid}: #{hash[:checksum]}
80
+ LOG
81
+ Pod::UI.puts log
82
+ else
83
+ index += 1
84
+ log = <<~LOG
85
+ #{index}). #{name}:
86
+ multiple configuration: #{hash[:multiple_configuration]}
87
+ checksum: #{hash[:checksum]}
88
+ checksum in lockfile#{"(git commitid)" if is_git_commitid}: #{checksum}
89
+ LOG
90
+ Pod::UI.puts log.red
91
+ end
92
+ end
93
+ Pod::UI.puts "checksum校验失败的组件: #{failed}".red if failed.size > 0
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsJxedt
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-jxedt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - guojiashuang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-18 00:00:00.000000000 Z
11
+ date: 2023-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -90,6 +90,7 @@ files:
90
90
  - lib/cocoapods-jxedt/command/header/header.rb
91
91
  - lib/cocoapods-jxedt/command/jxedt.rb
92
92
  - lib/cocoapods-jxedt/command/options/options.rb
93
+ - lib/cocoapods-jxedt/command/statistics/statistics.rb
93
94
  - lib/cocoapods-jxedt/gem_version.rb
94
95
  - lib/cocoapods-jxedt/tool.rb
95
96
  - lib/cocoapods_plugin.rb