cocoapods-hd 0.0.7 → 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 +1 -2
- 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 +0 -4
- 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 +46 -2
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
|
@@ -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
|
@@ -0,0 +1,130 @@
|
|
1
|
+
module Pod
|
2
|
+
|
3
|
+
class Prebuild
|
4
|
+
def self.keyword
|
5
|
+
:binary
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class Podfile
|
10
|
+
class TargetDefinition
|
11
|
+
|
12
|
+
## --- option for setting using prebuild framework ---
|
13
|
+
def parse_prebuild_framework(name, requirements)
|
14
|
+
should_prebuild = Pod::Podfile::DSL.is_all_binary
|
15
|
+
|
16
|
+
options = requirements.last
|
17
|
+
if options.is_a?(Hash) && options[Pod::Prebuild.keyword] != nil
|
18
|
+
should_prebuild = options.delete(Pod::Prebuild.keyword)
|
19
|
+
requirements.pop if options.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
pod_name = Specification.root_name(name)
|
23
|
+
set_prebuild_for_pod(pod_name, should_prebuild)
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_prebuild_for_pod(pod_name, should_prebuild)
|
27
|
+
|
28
|
+
if should_prebuild == true
|
29
|
+
@prebuild_framework_pod_names ||= []
|
30
|
+
Pod::UI.puts "prebuild_framework_pod_names -------- :#{@prebuild_framework_pod_names}"
|
31
|
+
@prebuild_framework_pod_names.push pod_name
|
32
|
+
else
|
33
|
+
@should_not_prebuild_framework_pod_names ||= []
|
34
|
+
@should_not_prebuild_framework_pod_names.push pod_name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def prebuild_framework_pod_names
|
39
|
+
names = @prebuild_framework_pod_names || []
|
40
|
+
if parent != nil and parent.kind_of? TargetDefinition
|
41
|
+
names += parent.prebuild_framework_pod_names
|
42
|
+
end
|
43
|
+
names
|
44
|
+
end
|
45
|
+
def should_not_prebuild_framework_pod_names
|
46
|
+
names = @should_not_prebuild_framework_pod_names || []
|
47
|
+
if parent != nil and parent.kind_of? TargetDefinition
|
48
|
+
names += parent.should_not_prebuild_framework_pod_names
|
49
|
+
end
|
50
|
+
names
|
51
|
+
end
|
52
|
+
|
53
|
+
# ---- patch method ----
|
54
|
+
# We want modify `store_pod` method, but it's hard to insert a line in the
|
55
|
+
# implementation. So we patch a method called in `store_pod`.
|
56
|
+
# old_method = instance_method(:parse_inhibit_warnings)
|
57
|
+
#
|
58
|
+
# define_method(:parse_inhibit_warnings) do |name, requirements|
|
59
|
+
# parse_prebuild_framework(name, requirements)
|
60
|
+
# old_method.bind(self).(name, requirements)
|
61
|
+
# end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
module Pod
|
69
|
+
class Installer
|
70
|
+
|
71
|
+
def prebuild_pod_targets
|
72
|
+
@prebuild_pod_targets ||= (
|
73
|
+
all = []
|
74
|
+
|
75
|
+
aggregate_targets = self.aggregate_targets
|
76
|
+
aggregate_targets.each do |aggregate_target|
|
77
|
+
target_definition = aggregate_target.target_definition
|
78
|
+
targets = aggregate_target.pod_targets || []
|
79
|
+
|
80
|
+
# filter prebuild
|
81
|
+
prebuild_names = target_definition.prebuild_framework_pod_names
|
82
|
+
if not Podfile::DSL.is_all_binary
|
83
|
+
targets = targets.select { |pod_target| prebuild_names.include?(pod_target.pod_name) }
|
84
|
+
end
|
85
|
+
dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
|
86
|
+
targets = (targets + dependency_targets).uniq
|
87
|
+
|
88
|
+
# filter should not prebuild
|
89
|
+
explict_should_not_names = target_definition.should_not_prebuild_framework_pod_names
|
90
|
+
targets = targets.reject { |pod_target| explict_should_not_names.include?(pod_target.pod_name) }
|
91
|
+
|
92
|
+
all += targets
|
93
|
+
end
|
94
|
+
|
95
|
+
all = all.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
|
96
|
+
all.uniq
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
# the root names who needs prebuild, including dependency pods.
|
101
|
+
def prebuild_pod_names
|
102
|
+
@prebuild_pod_names ||= self.prebuild_pod_targets.map(&:pod_name)
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def validate_every_pod_only_have_one_form
|
107
|
+
|
108
|
+
multi_targets_pods = self.pod_targets.group_by do |t|
|
109
|
+
t.pod_name
|
110
|
+
end.select do |k, v|
|
111
|
+
v.map{|t| t.platform.name }.count > 1
|
112
|
+
end
|
113
|
+
|
114
|
+
multi_targets_pods = multi_targets_pods.reject do |name, targets|
|
115
|
+
contained = targets.map{|t| self.prebuild_pod_targets.include? t }
|
116
|
+
contained.uniq.count == 1 # all equal
|
117
|
+
end
|
118
|
+
|
119
|
+
return if multi_targets_pods.empty?
|
120
|
+
|
121
|
+
warnings = "One pod can only be prebuilt or not prebuilt. These pod have different forms in multiple targets:\n"
|
122
|
+
warnings += multi_targets_pods.map{|name, targets| " #{name}: #{targets.map{|t|t.platform.name}}"}.join("\n")
|
123
|
+
raise Informative, warnings
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
|