Class: PPL::Command::Build
Class Method Summary
collapse
Instance Method Summary
collapse
#argv_extension, ensure_not_root_or_allowed!, git_version, options_extension, options_extension_hash, run, verify_minimum_git_version!, verify_xcode_license_approved!
Constructor Details
#initialize(argv) ⇒ Build
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/pod-pipeline/command/build.rb', line 30
def initialize(argv)
@path = argv.arguments!
@output = argv.option('output', '').split(',').first
@configuration = argv.option('configuration', '').split(',').first
@archs = argv.option('arch', '').split(',')
@combines = argv.option('combine', '').split(',')
@bundle_merge = argv.option('bundle-merge', '').split(',').first
@projectPath = @path.count.zero? ? Pathname.pwd.to_s : @path.first
@output = @output ? @output : @projectPath
super
end
|
Class Method Details
.options ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/pod-pipeline/command/build.rb', line 20
def self.options
[
['--output=./', '项目构建的输出目录。(默认使用项目根目录)'],
['--configuration=Release', '项目构建的环境。(默认为Release)'],
['--arch=arm64,armv7,x86_64', '项目构建的架构。(默认为 arm64,armv7,x86_64)'],
['--combine=local,pod', '项目构建后合并依赖库的二进制文件,local为本地依赖库,pod为CocoaPods依赖库。(默认为 local)'],
['--bundle-merge=merge', '是否合并所有资源包,参数为合并后的资源包名。(默认为 不合并)'],
].concat(super)
end
|
Instance Method Details
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/pod-pipeline/command/build.rb', line 96
def
header_stands = "#{@output}/Example/Pods/Headers/Public/#{@podspec.name}/*.h"
Dir[header_stands].each do |header_stand|
if File.ftype(header_stand).eql? 'link'
= "#{File.dirname(header_stand)}/#{File.readlink(header_stand)}"
if File.ftype().eql? 'file'
= File.basename()
if !(File.exist? "#{@framework_headers_path}/#{}")
puts
FileUtils.cp(, @framework_headers_path)
end
end
end
end
= "#{@build_path}/**/#{@podspec.name}.framework/Headers/*.h"
Dir[].each do ||
if File.ftype().eql? 'file'
= File.basename()
if !(File.exist? "#{@framework_headers_path}/#{}")
puts
FileUtils.cp(, @framework_headers_path)
end
end
end
end
|
#combine_binarys(local_dependency, pod_dependency) ⇒ Object
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/pod-pipeline/command/build.rb', line 122
def combine_binarys(local_dependency, pod_dependency)
binary = "#{@framework_path}/#{@podspec.name}"
inputs = []
inputs << "#{@build_path}/**/lib#{@podspec.name}.a"
inputs << "#{@build_path}/**/*.framework/#{@podspec.name}"
if local_dependency
inputs << "#{@output}/#{@podspec.name}/Libraries/**/*.a"
inputs << "#{@output}/#{@podspec.name}/Frameworks/**/*.framework/*"
end
if pod_dependency
inputs << "#{@build_path}/**/lib*.a";
inputs << "#{@build_path}/**/*.framework/*";
inputs << "#{@output}/Example/Pods/**/*SDK/*.framework/*"
inputs << "#{@output}/Example/Pods/**/Libraries/**/*.a"
inputs << "#{@output}/Example/Pods/**/Frameworks/**/*.framework/*"
end
Binary.combine(binary, inputs)
Binary.thin(binary, @archs)
end
|
#copy_bundles(local_dependency, pod_dependency) ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/pod-pipeline/command/build.rb', line 148
def copy_bundles(local_dependency, pod_dependency)
inputs = ["#{@output}/**/#{@podspec.name}/*.bundle"]
if local_dependency
inputs << "#{@output}/#{@podspec.name}/Libraries/**/*.bundle"
inputs << "#{@output}/#{@podspec.name}/Frameworks/**/*.bundle"
end
if pod_dependency
inputs << "#{@build_path}/**/*.bundle"
inputs << "#{@output}/Example/Pods/**/*SDK/*.bundle"
inputs << "#{@output}/Example/Pods/**/Libraries/**/*.bundle"
inputs << "#{@output}/Example/Pods/**/Frameworks/**/*.bundle"
end
Bundle.cp(inputs, @build_path)
end
|
#merge_bundles ⇒ Object
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/pod-pipeline/command/build.rb', line 169
def merge_bundles
bundle_path = "#{@build_path}/#{@bundle_merge}"
Dir.reset(bundle_path)
Dir["#{@build_path}/*.bundle/*"].each do |asset|
`cp -fr "#{asset}" "#{bundle_path}"`
end
Dir["#{@build_path}/*.bundle/"].each do |bundle|
`rm -fr "#{bundle}"`
end
`mv "#{bundle_path}" "#{bundle_path}.bundle"`
end
|
#reset_dir ⇒ Object
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/pod-pipeline/command/build.rb', line 85
def reset_dir
@build_path = "#{@output}/#{@podspec.name}-#{@podspec.version}"
Dir.reset(@build_path)
@framework_path = "#{@build_path}/#{@podspec.name}.framework"
Dir.reset(@framework_path)
@framework_headers_path = "#{@framework_path}/Headers"
Dir.reset(@framework_headers_path)
end
|
#run ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/pod-pipeline/command/build.rb', line 44
def run
PPL::Scanner.new(@projectPath, ["all"]).run
@podspec = PPL::Scanner.linter.spec
@workspace = PPL::Scanner.workspace
puts "Pod: #{@podspec}"
puts "Workspace: #{@workspace.path}"
if !@archs
puts "无需构建"
return
end
reset_dir
puts "\n[构建 #{@configuration} 环境的 #{@archs.join(", ")} 架构项目]"
@archs.each do |arch|
XCodebuild.build(@workspace.path, @podspec.name, arch, @configuration, @build_path)
end
puts "\n[添加Framework头文件]"
puts "\n[合并 #{@combines.join(", ")} 的二进制文件]"
combine_binarys(@combines.include?('local'), @combines.include?('pod'))
puts "\n[拷贝 #{@combines.join(", ")} 的资源包 到输出目录]"
copy_bundles(@combines.include?('local'), @combines.include?('pod'))
if @bundle_merge
puts "\n[合并的资源包内容 到 #{@bundle_merge}.bundle]"
merge_bundles
end
end
|