cocoapods-hd 0.0.3 → 0.1.0
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 +4 -4
- data/lib/cocoapods-hd/Integration.rb +283 -0
- data/lib/cocoapods-hd/build/build_framework.rb +205 -0
- data/lib/cocoapods-hd/command.rb +1 -0
- data/lib/cocoapods-hd/command/binary.rb +67 -0
- data/lib/cocoapods-hd/command/tag.rb +37 -44
- data/lib/cocoapods-hd/gem_version.rb +1 -1
- data/lib/cocoapods-hd/helper/feature_switches.rb +101 -0
- data/lib/cocoapods-hd/helper/names.rb +78 -0
- data/lib/cocoapods-hd/helper/passer.rb +46 -0
- data/lib/cocoapods-hd/helper/podfile_options.rb +130 -0
- data/lib/cocoapods-hd/helper/prebuild_sandbox.rb +73 -0
- data/lib/cocoapods-hd/helper/target_checker.rb +49 -0
- data/lib/cocoapods-hd/main.rb +226 -0
- data/lib/cocoapods-hd/prebuild.rb +333 -0
- data/lib/cocoapods-hd/resolver.rb +116 -0
- data/lib/cocoapods-hd/tag_util.rb +10 -6
- data/lib/cocoapods-hd/tool/tool.rb +12 -0
- data/lib/cocoapods-hd/upload/constant.rb +35 -0
- data/lib/cocoapods-hd/upload/spec_source_creator.rb +262 -0
- data/lib/cocoapods-hd/upload/upload_helper.rb +91 -0
- data/lib/cocoapods_plugin.rb +6 -6
- metadata +48 -4
data/lib/cocoapods-hd/command.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'cocoapods-hd/helper/feature_switches'
|
4
|
+
require 'cocoapods-hd/main'
|
5
|
+
require_relative '../../cocoapods-hd/helper/passer'
|
6
|
+
|
7
|
+
module Pod
|
8
|
+
class Command
|
9
|
+
class Binary < Command
|
10
|
+
|
11
|
+
self.summary = '指定源码二进制化'
|
12
|
+
self.description = <<-DESC
|
13
|
+
提升项目的整体编译速度,将代码二进制
|
14
|
+
DESC
|
15
|
+
|
16
|
+
def self.options
|
17
|
+
[
|
18
|
+
['--beta', 'beta tag'],
|
19
|
+
['--targets', 'specify targets for binary'],
|
20
|
+
['--delete', 'delete tag and remove pod repo source'],
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(argv)
|
25
|
+
@beta = argv.flag?('beta', false)
|
26
|
+
@delete = argv.flag?('delete', false)
|
27
|
+
# @tag_version = argv.shift_argument
|
28
|
+
@targets = argv.shift_argument
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
# 创建 binary tag
|
33
|
+
def binary_tag
|
34
|
+
UI.puts "binary targets: #{@targets}"
|
35
|
+
if @targets.nil?
|
36
|
+
Prebuild::Passer.target_names = []
|
37
|
+
else
|
38
|
+
Prebuild::Passer.target_names = @targets
|
39
|
+
end
|
40
|
+
Pod.is_ignore_hook_install = false
|
41
|
+
run_pod_install
|
42
|
+
Pod.is_ignore_hook_install = true
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# 移除tag
|
48
|
+
def delete_tag
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
# 获取tag名称
|
53
|
+
def get_tag
|
54
|
+
# @beta ? "#{@tag_version}-beta" : @tag_version
|
55
|
+
end
|
56
|
+
|
57
|
+
def run
|
58
|
+
if @delete
|
59
|
+
delete_tag
|
60
|
+
else
|
61
|
+
binary_tag
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -28,20 +28,8 @@ module Pod
|
|
28
28
|
super
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
unless TagUtil.exist_branch
|
35
|
-
UI.warn("当前分支名格式不正确,请修改为 release_x.x.x 格式")
|
36
|
-
return
|
37
|
-
end
|
38
|
-
unless TagUtil.check_branch_include_tag(@tag_version)
|
39
|
-
UI.warn("分支后缀版本号,必须跟tag保持一致")
|
40
|
-
return
|
41
|
-
end
|
42
|
-
|
43
|
-
UI.puts "🍉 开始创建tag: #{get_tag}"
|
44
|
-
|
31
|
+
def build_tag
|
32
|
+
UI.puts "🍉 开始创建tag : #{get_tag}"
|
45
33
|
if TagUtil.exist_tag(get_tag)
|
46
34
|
TagUtil.git_delete_tag(get_tag)
|
47
35
|
end
|
@@ -72,17 +60,15 @@ module Pod
|
|
72
60
|
`pod ipc spec #{pod_name}.podspec >>#{podspec_json_name}`
|
73
61
|
podspec_json_dir = File.join(Dir.pwd, podspec_json_name)
|
74
62
|
|
75
|
-
|
76
|
-
|
77
|
-
UI.puts("HDSourceSpecs目录: #{source_specs_dir}")
|
63
|
+
UI.puts("HDSourceSpecs目录: #{get_source_specs_dir}")
|
78
64
|
|
79
|
-
Dir.chdir(
|
65
|
+
Dir.chdir(get_source_specs_dir)
|
80
66
|
`git pull`
|
81
67
|
|
82
|
-
dest_dir = File.join(
|
68
|
+
dest_dir = File.join(get_source_specs_dir, pod_name, get_tag)
|
83
69
|
|
84
70
|
UI.section("创建目录: #{dest_dir}") do
|
85
|
-
FileUtils.
|
71
|
+
FileUtils.mkdir_p(dest_dir) unless File.directory?(dest_dir)
|
86
72
|
end
|
87
73
|
|
88
74
|
UI.section("move #{podspec_json_dir} to #{dest_dir}") do
|
@@ -90,18 +76,12 @@ module Pod
|
|
90
76
|
end
|
91
77
|
|
92
78
|
UI.section("✅ #{podspec_json_name} 上传成功") do
|
93
|
-
|
94
|
-
`git add .`
|
95
|
-
`git commit -m 'add #{pod_name} #{get_tag}'`
|
96
|
-
`git push origin master`
|
79
|
+
TagUtil.upload_origin_sources("添加 #{pod_name}/#{get_tag}")
|
97
80
|
end
|
98
|
-
|
99
81
|
Dir.chdir(module_dir)
|
100
82
|
end
|
101
|
-
unless
|
102
|
-
|
103
|
-
source_repo_path = File.join(module_parent_dir, "HDSourceSpecs")
|
104
|
-
FileUtils.rm_r(source_repo_path)
|
83
|
+
unless File.directory?(cocoapods_repos_dir)
|
84
|
+
remove_git_source_repo
|
105
85
|
end
|
106
86
|
|
107
87
|
unless @beta
|
@@ -111,8 +91,25 @@ module Pod
|
|
111
91
|
delete_tag(beta_tag)
|
112
92
|
end
|
113
93
|
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# 创建tag
|
98
|
+
def create_tag
|
114
99
|
|
100
|
+
unless TagUtil.check_master_branch
|
101
|
+
UI.warn("❌ 当前分支仅支持打 beta tag") unless @beta
|
102
|
+
build_tag if @beta
|
103
|
+
return
|
104
|
+
end
|
105
|
+
|
106
|
+
unless TagUtil.check_branch_include_tag(@tag_version)
|
107
|
+
UI.warn("❌ 分支后缀版本号,必须跟tag保持一致")
|
108
|
+
return
|
115
109
|
end
|
110
|
+
build_tag
|
111
|
+
|
112
|
+
|
116
113
|
end
|
117
114
|
|
118
115
|
# 获取 HDSourceSpecs 路径
|
@@ -136,6 +133,7 @@ module Pod
|
|
136
133
|
|
137
134
|
# 移除tag
|
138
135
|
def delete_tag(tag)
|
136
|
+
|
139
137
|
UI.puts "🍉 开始删除tag: #{tag}"
|
140
138
|
if TagUtil.exist_tag(tag)
|
141
139
|
TagUtil.git_delete_tag(tag)
|
@@ -157,25 +155,19 @@ module Pod
|
|
157
155
|
pod_name = rip.to_s.gsub(".podspec", "")
|
158
156
|
UI.puts "pod_name: #{pod_name}"
|
159
157
|
|
160
|
-
|
161
|
-
Pod::UI.puts "本地 HDSourceSpecs not found"
|
162
|
-
break
|
163
|
-
end
|
158
|
+
source_specs_dir = get_source_specs_dir
|
164
159
|
|
165
|
-
|
160
|
+
pod_tag_path = File.join(source_specs_dir, pod_name, tag_name)
|
166
161
|
|
167
|
-
unless File.exist?(
|
162
|
+
unless File.exist?(pod_tag_path)
|
168
163
|
UI.warn "❌ 本地HDSourceSpecs不包含#{pod_name}的#{tag_name}标签, 请先执行 pod repo update"
|
164
|
+
remove_git_source_repo
|
169
165
|
break
|
170
166
|
end
|
171
|
-
FileUtils.remove_dir(
|
172
|
-
Dir.chdir(
|
173
|
-
# UI.puts "切换到:#{Dir.pwd}"
|
167
|
+
FileUtils.remove_dir(pod_tag_path)
|
168
|
+
Dir.chdir(source_specs_dir)
|
174
169
|
UI.section("✅ #{pod_name} #{tag_name} 标签删除成功 !!!") do
|
175
|
-
|
176
|
-
`git add .`
|
177
|
-
`git commit -m '删除#{pod_name}/#{tag_name}'`
|
178
|
-
`git push origin master`
|
170
|
+
TagUtil.upload_origin_sources("删除 #{pod_name}/#{tag_name}")
|
179
171
|
end
|
180
172
|
|
181
173
|
end
|
@@ -185,8 +177,9 @@ module Pod
|
|
185
177
|
File.join(Dir.home, ".cocoapods/repos/HDSourceSpecs")
|
186
178
|
end
|
187
179
|
|
188
|
-
def
|
189
|
-
File.
|
180
|
+
def remove_git_source_repo
|
181
|
+
source_repo_path = File.join(File.dirname(Dir.pwd), "HDSourceSpecs")
|
182
|
+
FileUtils.rm_r(source_repo_path)
|
190
183
|
end
|
191
184
|
|
192
185
|
def run
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require_relative '../tool/tool'
|
2
|
+
require_relative 'prebuild_sandbox'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
|
6
|
+
# a flag that indicate stages
|
7
|
+
class_attr_accessor :is_prebuild_stage
|
8
|
+
|
9
|
+
# 是否忽略hook pre install
|
10
|
+
class_attr_accessor :is_ignore_hook_install
|
11
|
+
|
12
|
+
# a switch for the `pod` DSL to make it only valid for ':binary => true'
|
13
|
+
class Podfile
|
14
|
+
module DSL
|
15
|
+
|
16
|
+
@@enable_prebuild_patch = false
|
17
|
+
|
18
|
+
# when enable, `pod` function will skip all pods without 'prebuild => true'
|
19
|
+
def self.enable_prebuild_patch(value)
|
20
|
+
@@enable_prebuild_patch = value
|
21
|
+
end
|
22
|
+
|
23
|
+
# --- patch ---
|
24
|
+
old_method = instance_method(:pod)
|
25
|
+
|
26
|
+
define_method(:pod) do |name, *args|
|
27
|
+
if !@@enable_prebuild_patch
|
28
|
+
old_method.bind(self).(name, *args)
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
# patched content
|
33
|
+
should_prebuild = Pod::Podfile::DSL.is_all_binary
|
34
|
+
local = false
|
35
|
+
|
36
|
+
options = args.last
|
37
|
+
if options.is_a?(Hash) and options[Pod::Prebuild.keyword] != nil
|
38
|
+
should_prebuild = options[Pod::Prebuild.keyword]
|
39
|
+
local = (options[:path] != nil)
|
40
|
+
end
|
41
|
+
|
42
|
+
if should_prebuild and (not local)
|
43
|
+
old_method.bind(self).(name, *args)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# a force disable option for integral
|
50
|
+
class Installer
|
51
|
+
@@force_disable_integration = false
|
52
|
+
def self.force_disable_integration(value)
|
53
|
+
@@force_disable_integration = value
|
54
|
+
end
|
55
|
+
|
56
|
+
old_method = instance_method(:integrate_user_project)
|
57
|
+
define_method(:integrate_user_project) do
|
58
|
+
if @@force_disable_integration
|
59
|
+
return
|
60
|
+
end
|
61
|
+
old_method.bind(self).()
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# a option to disable install complete message
|
66
|
+
class Installer
|
67
|
+
@@disable_install_complete_message = false
|
68
|
+
def self.disable_install_complete_message(value)
|
69
|
+
@@disable_install_complete_message = value
|
70
|
+
end
|
71
|
+
|
72
|
+
old_method = instance_method(:print_post_install_message)
|
73
|
+
define_method(:print_post_install_message) do
|
74
|
+
if @@disable_install_complete_message
|
75
|
+
return
|
76
|
+
end
|
77
|
+
old_method.bind(self).()
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# option to disable write lockfiles
|
82
|
+
class Config
|
83
|
+
|
84
|
+
@@force_disable_write_lockfile = false
|
85
|
+
|
86
|
+
def self.force_disable_write_lockfile(value)
|
87
|
+
@@force_disable_write_lockfile = value
|
88
|
+
end
|
89
|
+
|
90
|
+
old_method = instance_method(:lockfile_path)
|
91
|
+
define_method(:lockfile_path) do
|
92
|
+
if @@force_disable_write_lockfile
|
93
|
+
# As config is a singleton, sandbox_root refer to the standard sandbox.
|
94
|
+
return PrebuildSandbox.from_standard_sanbox_path(sandbox_root).root + 'Manifest.lock.tmp'
|
95
|
+
else
|
96
|
+
return old_method.bind(self).()
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# ABOUT NAMES
|
2
|
+
#
|
3
|
+
# There are many kinds of name in cocoapods. Two main names are widely used in this plugin.
|
4
|
+
# - root_spec.name (spec.root_name, targe.pod_name):
|
5
|
+
# aka "pod_name"
|
6
|
+
# the name we use in podfile. the concept.
|
7
|
+
#
|
8
|
+
# - target.name:
|
9
|
+
# aka "target_name"
|
10
|
+
# the name of the final target in xcode project. the final real thing.
|
11
|
+
#
|
12
|
+
# One pod may have multiple targets in xcode project, due to one pod can be used in mutiple
|
13
|
+
# platform simultaneously. So one `root_spec.name` may have multiple coresponding `target.name`s.
|
14
|
+
# Therefore, map a spec to/from targets is a little complecated. It's one to many.
|
15
|
+
#
|
16
|
+
|
17
|
+
# Tool to transform Pod_name to target efficiently
|
18
|
+
module Pod
|
19
|
+
def self.fast_get_targets_for_pod_name(pod_name, targets, cache)
|
20
|
+
pod_name_to_targets_hash = nil
|
21
|
+
if cache.empty?
|
22
|
+
pod_name_to_targets_hash = targets.reduce({}) do |sum, target|
|
23
|
+
array = sum[target.pod_name] || []
|
24
|
+
array << target
|
25
|
+
sum[target.pod_name] = array
|
26
|
+
sum
|
27
|
+
end
|
28
|
+
cache << pod_name_to_targets_hash
|
29
|
+
else
|
30
|
+
pod_name_to_targets_hash = cache.first
|
31
|
+
end
|
32
|
+
|
33
|
+
pod_name_to_targets_hash[pod_name] || []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
# Target:
|
43
|
+
|
44
|
+
# def pod_name
|
45
|
+
# root_spec.name
|
46
|
+
# end
|
47
|
+
|
48
|
+
# def name
|
49
|
+
# pod_name + #{scope_suffix}
|
50
|
+
# end
|
51
|
+
|
52
|
+
# def product_module_name
|
53
|
+
# root_spec.module_name
|
54
|
+
# end
|
55
|
+
|
56
|
+
# def framework_name
|
57
|
+
# "#{product_module_name}.framework"
|
58
|
+
# end
|
59
|
+
|
60
|
+
# def product_name
|
61
|
+
# if requires_frameworks?
|
62
|
+
# framework_name
|
63
|
+
# else
|
64
|
+
# static_library_name
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
|
68
|
+
# def product_basename
|
69
|
+
# if requires_frameworks?
|
70
|
+
# product_module_name
|
71
|
+
# else
|
72
|
+
# label
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
|
76
|
+
# def framework_name
|
77
|
+
# "#{product_module_name}.framework"
|
78
|
+
# end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative '../tool/tool'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Prebuild
|
5
|
+
|
6
|
+
# Pass the data between the 2 steps
|
7
|
+
#
|
8
|
+
# At step 2, the normal pod install, it needs some info of the
|
9
|
+
# prebuilt step. So we store it here.
|
10
|
+
#
|
11
|
+
class Passer
|
12
|
+
|
13
|
+
# indicate the add/remove/update of prebuit pods
|
14
|
+
# @return [Analyzer::SpecsState]
|
15
|
+
#
|
16
|
+
class_attr_accessor :prebuild_pods_changes
|
17
|
+
|
18
|
+
|
19
|
+
# represent the path of resurces to copy
|
20
|
+
class ResourcePath
|
21
|
+
attr_accessor :real_file_path
|
22
|
+
attr_accessor :target_file_path
|
23
|
+
end
|
24
|
+
# Save the resoures for static framework, and used when installing the prebuild framework
|
25
|
+
# static framework needs copy the resurces mannully
|
26
|
+
#
|
27
|
+
# @return [Hash<String, [Passer::ResourcePath]>]
|
28
|
+
class_attr_accessor :resources_to_copy_for_static_framework
|
29
|
+
self.resources_to_copy_for_static_framework = {}
|
30
|
+
|
31
|
+
# Some pod won't be build in prebuild stage even if it have `binary=>true`.
|
32
|
+
# The targets of this pods have `oshould_build? == true`.
|
33
|
+
# We should skip integration (patch spec) for this pods
|
34
|
+
#
|
35
|
+
# @return [Array<String>]
|
36
|
+
class_attr_accessor :target_names_to_skip_integration_framework
|
37
|
+
self.target_names_to_skip_integration_framework = []
|
38
|
+
|
39
|
+
|
40
|
+
# 指定targets编译
|
41
|
+
class_attr_accessor :target_names
|
42
|
+
self.target_names = []
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|