cocoapods-aomi-bin 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +11 -0
- data/lib/cocoapods-lhj-bin.rb +2 -0
- data/lib/cocoapods-lhj-bin/command.rb +1 -0
- data/lib/cocoapods-lhj-bin/command/bin.rb +58 -0
- data/lib/cocoapods-lhj-bin/command/bin/archive.rb +233 -0
- data/lib/cocoapods-lhj-bin/command/bin/auto.rb +200 -0
- data/lib/cocoapods-lhj-bin/command/bin/code.rb +232 -0
- data/lib/cocoapods-lhj-bin/command/bin/dup.rb +78 -0
- data/lib/cocoapods-lhj-bin/command/bin/import.rb +130 -0
- data/lib/cocoapods-lhj-bin/command/bin/init.rb +69 -0
- data/lib/cocoapods-lhj-bin/command/bin/initHotKey.rb +70 -0
- data/lib/cocoapods-lhj-bin/command/bin/install.rb +44 -0
- data/lib/cocoapods-lhj-bin/command/bin/lhj.rb +46 -0
- data/lib/cocoapods-lhj-bin/command/bin/lib/lint.rb +69 -0
- data/lib/cocoapods-lhj-bin/command/bin/repo/update.rb +43 -0
- data/lib/cocoapods-lhj-bin/command/bin/spec/create.rb +73 -0
- data/lib/cocoapods-lhj-bin/command/bin/spec/push.rb +115 -0
- data/lib/cocoapods-lhj-bin/command/bin/update.rb +153 -0
- data/lib/cocoapods-lhj-bin/config/config.rb +147 -0
- data/lib/cocoapods-lhj-bin/config/config_asker.rb +57 -0
- data/lib/cocoapods-lhj-bin/config/config_builder.rb +216 -0
- data/lib/cocoapods-lhj-bin/config/config_hot_key.rb +103 -0
- data/lib/cocoapods-lhj-bin/config/config_hot_key_asker.rb +57 -0
- data/lib/cocoapods-lhj-bin/gem_version.rb +9 -0
- data/lib/cocoapods-lhj-bin/helpers.rb +5 -0
- data/lib/cocoapods-lhj-bin/helpers/Info.plist +0 -0
- data/lib/cocoapods-lhj-bin/helpers/build_helper.rb +158 -0
- data/lib/cocoapods-lhj-bin/helpers/build_utils.rb +93 -0
- data/lib/cocoapods-lhj-bin/helpers/framework.rb +85 -0
- data/lib/cocoapods-lhj-bin/helpers/framework_builder.rb +444 -0
- data/lib/cocoapods-lhj-bin/helpers/library.rb +54 -0
- data/lib/cocoapods-lhj-bin/helpers/library_builder.rb +90 -0
- data/lib/cocoapods-lhj-bin/helpers/sources_helper.rb +34 -0
- data/lib/cocoapods-lhj-bin/helpers/spec_creator.rb +168 -0
- data/lib/cocoapods-lhj-bin/helpers/spec_files_helper.rb +75 -0
- data/lib/cocoapods-lhj-bin/helpers/spec_source_creator.rb +220 -0
- data/lib/cocoapods-lhj-bin/helpers/upload_helper.rb +105 -0
- data/lib/cocoapods-lhj-bin/native.rb +19 -0
- data/lib/cocoapods-lhj-bin/native/acknowledgements.rb +27 -0
- data/lib/cocoapods-lhj-bin/native/analyzer.rb +55 -0
- data/lib/cocoapods-lhj-bin/native/file_accessor.rb +28 -0
- data/lib/cocoapods-lhj-bin/native/installation_options.rb +25 -0
- data/lib/cocoapods-lhj-bin/native/installer.rb +135 -0
- data/lib/cocoapods-lhj-bin/native/linter.rb +26 -0
- data/lib/cocoapods-lhj-bin/native/path_source.rb +33 -0
- data/lib/cocoapods-lhj-bin/native/pod_source_installer.rb +19 -0
- data/lib/cocoapods-lhj-bin/native/pod_target_installer.rb +94 -0
- data/lib/cocoapods-lhj-bin/native/podfile.rb +91 -0
- data/lib/cocoapods-lhj-bin/native/podfile_env.rb +37 -0
- data/lib/cocoapods-lhj-bin/native/podfile_generator.rb +199 -0
- data/lib/cocoapods-lhj-bin/native/podspec_finder.rb +25 -0
- data/lib/cocoapods-lhj-bin/native/resolver.rb +230 -0
- data/lib/cocoapods-lhj-bin/native/sandbox_analyzer.rb +34 -0
- data/lib/cocoapods-lhj-bin/native/source.rb +35 -0
- data/lib/cocoapods-lhj-bin/native/sources_manager.rb +20 -0
- data/lib/cocoapods-lhj-bin/native/specification.rb +31 -0
- data/lib/cocoapods-lhj-bin/native/target_validator.rb +41 -0
- data/lib/cocoapods-lhj-bin/native/validator.rb +40 -0
- data/lib/cocoapods-lhj-bin/source_provider_hook.rb +66 -0
- data/lib/cocoapods_plugin.rb +2 -0
- data/spec/command/bin_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +178 -0
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'cocoapods-lhj-bin/native/podfile_env'
|
3
|
+
require 'cocoapods-lhj-bin/native/podfile'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Bin < Command
|
8
|
+
class Update < Bin
|
9
|
+
include Pod
|
10
|
+
include Pod::Podfile::DSL
|
11
|
+
|
12
|
+
self.summary = 'pod update 拦截器,会加载本地Podfile_local文件,DSL加载到原始Podfile文件中。'
|
13
|
+
|
14
|
+
self.description = <<-DESC
|
15
|
+
pod update 拦截器,会加载本地Podfile_local文件
|
16
|
+
会通过DSL加载到原始Podfile文件中
|
17
|
+
支持 pod 'xxx' 各种写法
|
18
|
+
支持 post_install/pre_install钩子,采用覆盖做法
|
19
|
+
DESC
|
20
|
+
def self.options
|
21
|
+
[
|
22
|
+
["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to update dependent pods. ' \
|
23
|
+
'Multiple sources must be comma-delimited'],
|
24
|
+
['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
|
25
|
+
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
26
|
+
'applies to projects that have enabled incremental installation'],
|
27
|
+
['--project-directory=/project/dir/', 'The path to the root of the project directory'],
|
28
|
+
['--no-repo-update', 'Skip running `pod repo update` before install']
|
29
|
+
].concat(super)
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(argv)
|
33
|
+
@update = argv.flag?('update')
|
34
|
+
super
|
35
|
+
@additional_args = argv.remainder!
|
36
|
+
end
|
37
|
+
|
38
|
+
def run
|
39
|
+
Update.load_local_podfile
|
40
|
+
|
41
|
+
argvs = [
|
42
|
+
*@additional_args
|
43
|
+
]
|
44
|
+
|
45
|
+
gen = Pod::Command::Update.new(CLAide::ARGV.new(argvs))
|
46
|
+
gen.validate!
|
47
|
+
gen.run
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.load_local_podfile
|
51
|
+
# 同步 Podfile_local 文件
|
52
|
+
project_root = Pod::Config.instance.project_root
|
53
|
+
path = File.join(project_root.to_s, 'Podfile_local')
|
54
|
+
unless File.exist?(path)
|
55
|
+
path = File.join(project_root.to_s, 'Podfile_local')
|
56
|
+
end
|
57
|
+
|
58
|
+
if File.exist?(path)
|
59
|
+
contents = File.open(path, 'r:utf-8', &:read)
|
60
|
+
|
61
|
+
podfile = Pod::Config.instance.podfile
|
62
|
+
local_podfile = Podfile.from_file(path)
|
63
|
+
|
64
|
+
if local_podfile
|
65
|
+
local_pre_install_callback = nil
|
66
|
+
local_post_install_callback = nil
|
67
|
+
local_podfile.instance_eval do
|
68
|
+
local_pre_install_callback = @pre_install_callback
|
69
|
+
local_post_install_callback = @post_install_callback
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
podfile.instance_eval do
|
74
|
+
begin
|
75
|
+
|
76
|
+
# podfile HASH_KEYS才有plugins字段,否则会被限制
|
77
|
+
if local_podfile.plugins.any?
|
78
|
+
hash_plugins = podfile.plugins || {}
|
79
|
+
hash_plugins = hash_plugins.merge(local_podfile.plugins)
|
80
|
+
set_hash_value(%w[plugins].first, hash_plugins)
|
81
|
+
|
82
|
+
# 加入源码白名单,避免本地库被二进制了
|
83
|
+
podfile.set_use_source_pods(local_podfile.use_source_pods) if local_podfile.use_source_pods
|
84
|
+
podfile.use_binaries!(local_podfile.use_binaries?)
|
85
|
+
end
|
86
|
+
|
87
|
+
# 在target把local-target中到dependencies值删除了,再设置
|
88
|
+
# 把本地和原始到dependencies 合并,设置dependencies
|
89
|
+
local_podfile&.target_definition_list&.each do |local_target|
|
90
|
+
next if local_target.name == 'Pods'
|
91
|
+
|
92
|
+
target_definition_list.each do |target|
|
93
|
+
|
94
|
+
unless target.name == local_target.name &&
|
95
|
+
(local_target.to_hash['dependencies'] &&local_target.to_hash['dependencies'].any?)
|
96
|
+
next
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
target.instance_exec do
|
102
|
+
# 在target把local-target中到dependencies值删除了,再设置
|
103
|
+
|
104
|
+
local_dependencies = local_target.to_hash['dependencies']
|
105
|
+
target_dependencies = target.to_hash['dependencies']
|
106
|
+
|
107
|
+
local_dependencies.each do |local_dependency|
|
108
|
+
unless local_dependency.is_a?(Hash) && local_dependency.keys.first
|
109
|
+
next
|
110
|
+
end
|
111
|
+
|
112
|
+
target_dependencies.each do |target_dependency|
|
113
|
+
next unless target_dependency.is_a?(Hash) &&
|
114
|
+
target_dependency.keys.first &&
|
115
|
+
target_dependency.keys.first == local_dependency.keys.first
|
116
|
+
|
117
|
+
target_dependencies.delete target_dependency
|
118
|
+
break
|
119
|
+
end
|
120
|
+
end
|
121
|
+
# 把本地和原始到dependencies 合并,设置dependencies
|
122
|
+
local_dependencies.each do |d|
|
123
|
+
UI.message "Development Pod #{d.to_yaml}"
|
124
|
+
if podfile.plugins.keys.include?('cocoapods-lhj-bin')
|
125
|
+
podfile.set_use_source_pods(d.keys.first) if (d.is_a?(Hash) && d.keys.first)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
new_dependencies = target_dependencies + local_dependencies
|
129
|
+
set_hash_value(%w[dependencies].first, new_dependencies)
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
if local_pre_install_callback
|
137
|
+
@pre_install_callback = local_pre_install_callback
|
138
|
+
end
|
139
|
+
if local_post_install_callback
|
140
|
+
@post_install_callback = local_post_install_callback
|
141
|
+
end
|
142
|
+
rescue Exception => e
|
143
|
+
message = "Invalid `#{path}` file: #{e.message}"
|
144
|
+
raise Pod::DSLError.new(message, path, e, contents)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'cocoapods-lhj-bin/native/podfile'
|
5
|
+
require 'cocoapods-lhj-bin/native/podfile_env'
|
6
|
+
require 'cocoapods/generate'
|
7
|
+
|
8
|
+
module CBin
|
9
|
+
class Config
|
10
|
+
def config_file
|
11
|
+
config_file_with_configuration_env(configuration_env)
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Hash{String->Hash{Symbol->String or Array<String>}}]
|
15
|
+
def template_hash
|
16
|
+
{
|
17
|
+
'configuration_env' => { description: '编译环境', default: 'dev',
|
18
|
+
selection: %w[dev debug_iphoneos release_iphoneos] },
|
19
|
+
'code_repo_url' => { description: '源码私有源 Git 地址',
|
20
|
+
default: 'git@github.com:su350380433/example_spec_source.git' },
|
21
|
+
'binary_repo_url' => { description: '二进制私有源 Git 地址',
|
22
|
+
default: 'git@github.com:su350380433/example_spec_bin_dev.git' },
|
23
|
+
'binary_download_url' => { description: '二进制下载地址,内部会依次传入组件名称与版本,替换字符串中的 %s ',
|
24
|
+
default: 'http://localhost:8080/frameworks/%s/%s/zip' },
|
25
|
+
# 'binary_type' => { description: '二进制打包类型', default: 'framework', selection: %w[framework library] },
|
26
|
+
'download_file_type' => { description: '下载二进制文件类型', default: 'zip', selection: %w[zip tgz tar tbz txz dmg] },
|
27
|
+
'oss_endpoint' => { description: 'oss_endpoint', default: 'oss-cn-shenzhen.aliyuncs.com' },
|
28
|
+
'oss_access_key_id' => { description: 'oss_access_key_id', default: 'xxxxxxx' },
|
29
|
+
'oss_access_key_secret' => { description: 'oss_access_key_secret', default: 'xxxxxxxxx' },
|
30
|
+
'oss_bucket' => { description: 'oss_bucket', default: 'oss_bucket' }
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def config_file_with_configuration_env(configuration_env)
|
35
|
+
file = config_dev_file
|
36
|
+
case configuration_env
|
37
|
+
when 'release_iphoneos'
|
38
|
+
file = config_release_iphoneos_file
|
39
|
+
puts "\n====== #{configuration_env} 环境 ========"
|
40
|
+
when 'debug_iphoneos'
|
41
|
+
file = config_debug_iphoneos_file
|
42
|
+
puts "\n====== #{configuration_env} 环境 ========"
|
43
|
+
when 'dev'
|
44
|
+
puts "\n====== #{configuration_env} 环境 ========"
|
45
|
+
else
|
46
|
+
raise "\n===== #{configuration_env} 参数有误,请检查%w[dev debug_iphoneos release_iphoneos]===="
|
47
|
+
end
|
48
|
+
|
49
|
+
File.expand_path("#{Pod::Config.instance.home_dir}/#{file}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def configuration_env
|
53
|
+
# 如果是dev 再去 podfile的配置文件中获取,确保是正确的, pod update时会用到
|
54
|
+
if @configuration_env == 'dev' || @configuration_env.nil?
|
55
|
+
configuration_env ||= Pod::Config.instance.podfile.configuration_env if Pod::Config.instance.podfile
|
56
|
+
configuration_env ||= 'dev'
|
57
|
+
@configuration_env = configuration_env
|
58
|
+
end
|
59
|
+
@configuration_env
|
60
|
+
end
|
61
|
+
|
62
|
+
# 上传的url
|
63
|
+
def binary_upload_url
|
64
|
+
cut_string = '/%s/%s/zip'
|
65
|
+
binary_download_url[0, binary_download_url.length - cut_string.length]
|
66
|
+
end
|
67
|
+
|
68
|
+
def set_configuration_env(env)
|
69
|
+
@configuration_env = env
|
70
|
+
end
|
71
|
+
|
72
|
+
# 包含arm64 armv7架构,xcodebuild 是Debug模式
|
73
|
+
def config_debug_iphoneos_file
|
74
|
+
'bin_debug_iphoneos.yml'
|
75
|
+
end
|
76
|
+
|
77
|
+
# 包含arm64 armv7架构,xcodebuild 是Release模式
|
78
|
+
def config_release_iphoneos_file
|
79
|
+
'bin_release_iphoneos.yml'
|
80
|
+
end
|
81
|
+
|
82
|
+
# 包含x86 arm64 armv7架构,xcodebuild 是Release模式
|
83
|
+
def config_dev_file
|
84
|
+
'bin_dev.yml'
|
85
|
+
end
|
86
|
+
|
87
|
+
def sync_config(config)
|
88
|
+
File.open(config_file_with_configuration_env(config['configuration_env']), 'w+') do |f|
|
89
|
+
f.write(config.to_yaml)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def default_config
|
94
|
+
@default_config ||= template_hash.transform_values { |v| v[:default] }
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def load_config
|
100
|
+
if File.exist?(config_file)
|
101
|
+
YAML.load_file(config_file)
|
102
|
+
else
|
103
|
+
default_config
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def config
|
108
|
+
@config ||= begin
|
109
|
+
# puts "====== cocoapods-lhj-bin #{CBin::VERSION} 版本 ======== \n"
|
110
|
+
@config = OpenStruct.new load_config
|
111
|
+
validate!
|
112
|
+
@config
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def validate!
|
117
|
+
template_hash.each do |k, v|
|
118
|
+
selection = v[:selection]
|
119
|
+
next if !selection || selection.empty?
|
120
|
+
|
121
|
+
config_value = @config.send(k)
|
122
|
+
next unless config_value
|
123
|
+
unless selection.include?(config_value)
|
124
|
+
raise Pod::Informative, "#{k} 字段的值必须限定在可选值 [ #{selection.join(' / ')} ] 内".red
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def respond_to_missing?(method, include_private = false)
|
130
|
+
config.respond_to?(method) || super
|
131
|
+
end
|
132
|
+
|
133
|
+
def method_missing(method, *args, &block)
|
134
|
+
if config.respond_to?(method)
|
135
|
+
config.send(method, *args)
|
136
|
+
elsif template_hash.keys.include?(method.to_s)
|
137
|
+
raise Pod::Informative, "#{method} 字段必须在配置文件 #{config_file} 中设置, 请执行 init 命令配置或手动修改配置文件".red
|
138
|
+
else
|
139
|
+
super
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.config
|
145
|
+
@config ||= Config.new
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'cocoapods-lhj-bin/config/config'
|
3
|
+
|
4
|
+
module CBin
|
5
|
+
class Config
|
6
|
+
class Asker
|
7
|
+
def show_prompt
|
8
|
+
print ' > '.green
|
9
|
+
end
|
10
|
+
|
11
|
+
def ask_with_answer(question, pre_answer, selection)
|
12
|
+
print "\n#{question}\n"
|
13
|
+
|
14
|
+
print_selection_info = lambda {
|
15
|
+
print "可选值:[ #{selection.join(' / ')} ]\n" if selection
|
16
|
+
}
|
17
|
+
print_selection_info.call
|
18
|
+
print "旧值:#{pre_answer}\n" unless pre_answer.nil?
|
19
|
+
|
20
|
+
answer = ''
|
21
|
+
loop do
|
22
|
+
show_prompt
|
23
|
+
answer = STDIN.gets.chomp.strip
|
24
|
+
|
25
|
+
if answer == '' && !pre_answer.nil?
|
26
|
+
answer = pre_answer
|
27
|
+
print answer.yellow
|
28
|
+
print "\n"
|
29
|
+
end
|
30
|
+
|
31
|
+
next if answer.empty?
|
32
|
+
break if !selection || selection.include?(answer)
|
33
|
+
|
34
|
+
print_selection_info.call
|
35
|
+
end
|
36
|
+
|
37
|
+
answer
|
38
|
+
end
|
39
|
+
|
40
|
+
def wellcome_message
|
41
|
+
print <<~EOF
|
42
|
+
|
43
|
+
开始设置二进制化初始信息.
|
44
|
+
所有的信息都会保存在 #{CBin.config.config_file} 文件中.
|
45
|
+
%w[bin_dev.yml bin_debug_iphoneos.yml bin_release_iphoneos.yml]
|
46
|
+
你可以在对应目录下手动添加编辑该文件. 文件包含的配置信息样式如下:
|
47
|
+
|
48
|
+
#{CBin.config.default_config.to_yaml}
|
49
|
+
EOF
|
50
|
+
end
|
51
|
+
|
52
|
+
def done_message
|
53
|
+
print "\n设置完成.\n".green
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module CBin
|
4
|
+
class Config
|
5
|
+
class Builder
|
6
|
+
|
7
|
+
include Pod
|
8
|
+
|
9
|
+
def self.instance
|
10
|
+
@instance ||= new
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
load_build_config
|
15
|
+
# clean
|
16
|
+
end
|
17
|
+
|
18
|
+
# 加载配置项
|
19
|
+
def load_build_config
|
20
|
+
@white_pod_list = []
|
21
|
+
@ignore_git_list = []
|
22
|
+
project_root = Pod::Config.instance.project_root
|
23
|
+
path = File.join(project_root.to_s, 'BinArchive.json')
|
24
|
+
|
25
|
+
if File.exist?(path)
|
26
|
+
config = JSON.parse(File.read(path))
|
27
|
+
@white_pod_list = config['archive-white-pod-list']
|
28
|
+
UI.warn "====== archive-white-pod-list = #{@white_pod_list}" if @white_pod_list
|
29
|
+
@ignore_git_list = config['ignore-git-list']
|
30
|
+
UI.warn "====== ignore_git_list = #{@ignore_git_list}" if @ignore_git_list
|
31
|
+
@ignore_http_list = config['ignore-http-list']
|
32
|
+
|
33
|
+
@xcode_build_name = config['xcode_build_path']
|
34
|
+
@root_dir = config['root_dir'] unless config['root_dir'].nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def clean
|
40
|
+
#清除之前的缓存
|
41
|
+
FileUtils.rm_rf(Dir.glob("#{zip_dir}/*")) if File.exist?(zip_dir)
|
42
|
+
FileUtils.rm_rf(Dir.glob("#{binary_json_dir}/*")) if File.exist?(binary_json_dir)
|
43
|
+
FileUtils.rm_rf(Dir.glob("#{local_psec_dir}/*")) if File.exist?(local_psec_dir)
|
44
|
+
end
|
45
|
+
|
46
|
+
# 制作二进制打包 工程目录
|
47
|
+
def gen_name
|
48
|
+
'bin-archive'
|
49
|
+
end
|
50
|
+
|
51
|
+
# 制作二进制打包 工程目录
|
52
|
+
def gen_dir
|
53
|
+
@gen_dir ||= begin
|
54
|
+
dir = File.join(root_dir, gen_name)
|
55
|
+
Dir.mkdir(dir) unless File.exist?dir
|
56
|
+
Pathname.new(dir)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def framework_name(spec)
|
62
|
+
"#{spec.name}.framework"
|
63
|
+
end
|
64
|
+
|
65
|
+
def framework_name_version(spec)
|
66
|
+
"#{spec.name}.framework_#{spec.version}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def framework_zip_file(spec)
|
70
|
+
File.join(zip_dir_name, framework_name_version(spec))
|
71
|
+
end
|
72
|
+
|
73
|
+
def framework_file(spec)
|
74
|
+
File.join(zip_dir_name, framework_name(spec))
|
75
|
+
end
|
76
|
+
|
77
|
+
def library_name(spec)
|
78
|
+
library_name_version(spec.name, spec.version)
|
79
|
+
end
|
80
|
+
|
81
|
+
def library_name_version(name,version)
|
82
|
+
"bin_#{name}_#{version}"
|
83
|
+
end
|
84
|
+
def library_file(spec)
|
85
|
+
File.join(zip_dir_name, library_name(spec))
|
86
|
+
end
|
87
|
+
|
88
|
+
def zip_dir_name
|
89
|
+
"bin-zip"
|
90
|
+
end
|
91
|
+
|
92
|
+
def zip_dir
|
93
|
+
@zip_dir ||= begin
|
94
|
+
dir = File.join(root_dir, zip_dir_name)
|
95
|
+
Dir.mkdir(dir) unless File.exist?dir
|
96
|
+
Pathname.new(dir)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
#本地
|
101
|
+
def local_spec_dir_name
|
102
|
+
"bin-spec"
|
103
|
+
end
|
104
|
+
|
105
|
+
def local_psec_dir
|
106
|
+
@local_psec_dir ||= begin
|
107
|
+
dir = File.join(root_dir, local_spec_dir_name)
|
108
|
+
Dir.mkdir(dir) unless File.exist?dir
|
109
|
+
Pathname.new(dir)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def binary_json_dir_name
|
114
|
+
"bin-json"
|
115
|
+
end
|
116
|
+
|
117
|
+
def binary_json_dir
|
118
|
+
@binary_json_dir ||= begin
|
119
|
+
dir = File.join(root_dir,binary_json_dir_name)
|
120
|
+
Dir.mkdir(dir) unless File.exist?dir
|
121
|
+
Pathname.new(dir)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
#编译target名,如 seeyou
|
128
|
+
def target_name
|
129
|
+
@target_name ||= begin
|
130
|
+
target_name_str = Pod::Config.instance.podfile.root_target_definitions.first.children.first.to_s
|
131
|
+
target_name_str[5,target_name_str.length]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
#编译缓存文件目录,如Xcodebuild的编译缓存目录
|
136
|
+
# 如果有配置, 配置完整路径,会使用
|
137
|
+
def xcode_build_name
|
138
|
+
@xcode_build_name ||= begin
|
139
|
+
project_root = Pod::Config.instance.project_root
|
140
|
+
path = File.join(project_root.to_s, 'BinArchive.json')
|
141
|
+
|
142
|
+
if File.exist?(path)
|
143
|
+
config = JSON.parse(File.read(path))
|
144
|
+
@xcode_build_name = config['xcode_build_path']
|
145
|
+
end
|
146
|
+
#默认值,在美柚上使用默认
|
147
|
+
if @xcode_build_name.nil? || Dir.exist?(@xcode_build_name)
|
148
|
+
@xcode_build_name = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/"
|
149
|
+
end
|
150
|
+
puts @xcode_build_name
|
151
|
+
@xcode_build_name
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
#完整的xcodebuild 输出路径
|
157
|
+
def xcode_build_dir
|
158
|
+
@xcode_build_dir ||= begin
|
159
|
+
temp_xcode_build_name = xcode_build_name
|
160
|
+
if File.exist?(temp_xcode_build_name)
|
161
|
+
Pathname.new(temp_xcode_build_name)
|
162
|
+
else
|
163
|
+
dir = File.join(root_dir, xcode_build_name)
|
164
|
+
Pathname.new(dir)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
#完整的xcodebuild BuildProductsPath输出路径,
|
169
|
+
def xcode_BuildProductsPath_dir
|
170
|
+
@xcode_BuildProductsPath_dir ||= begin
|
171
|
+
temp_xcode_BuildProductsPath_dir = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/BuildProductsPath/"
|
172
|
+
full_path = File.join(root_dir, temp_xcode_BuildProductsPath_dir)
|
173
|
+
|
174
|
+
if (File.exist?(full_path))
|
175
|
+
Dir.chdir(full_path) do
|
176
|
+
iphoneos = Dir.glob('*-iphoneos')
|
177
|
+
if iphoneos.length > 0
|
178
|
+
full_path = File.join(full_path,iphoneos.first)
|
179
|
+
else
|
180
|
+
UI.warn "====== 找不到 *-iphoneos @xcode_BuildProductsPath_dir = #{@xcode_BuildProductsPath_dir}"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
Pathname.new(full_path)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
#处理编译产物后存储根目录,会存放spec、 json、zip的父目录,默认是工程的同级目录下,"#{basename}-build-temp"
|
190
|
+
def root_dir
|
191
|
+
@root_dir ||= begin
|
192
|
+
basename = File.basename(Pod::Config.instance.installation_root)
|
193
|
+
parent_dir = File.dirname(Pod::Config.instance.installation_root)
|
194
|
+
root_name = File.join(parent_dir, "#{basename}-build-temp")
|
195
|
+
Dir.mkdir(root_name) unless File.exist? root_name
|
196
|
+
Pathname.new(root_name)
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
#制作二进制 白名单
|
202
|
+
def white_pod_list
|
203
|
+
@white_pod_list
|
204
|
+
end
|
205
|
+
#忽略制作二进制组件的 git
|
206
|
+
def ignore_git_list
|
207
|
+
@ignore_git_list
|
208
|
+
end
|
209
|
+
|
210
|
+
def ignore_http_list
|
211
|
+
@ignore_http_list
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|