Class: CBin::Config::Builder
- Inherits:
-
Object
- Object
- CBin::Config::Builder
- Includes:
- Pod
- Defined in:
- lib/cocoapods-imy-bin/config/config_builder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #binary_json_dir ⇒ Object
- #binary_json_dir_name ⇒ Object
- #clean ⇒ Object
- #framework_file(spec) ⇒ Object
- #framework_name(spec) ⇒ Object
- #framework_name_version(spec) ⇒ Object
- #framework_zip_file(spec) ⇒ Object
-
#gen_dir ⇒ Object
制作二进制打包 工程目录.
-
#gen_name ⇒ Object
制作二进制打包 工程目录.
-
#ignore_git_list ⇒ Object
忽略制作二进制组件的 git.
- #ignore_http_list ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #library_file(spec) ⇒ Object
- #library_name(spec) ⇒ Object
- #library_name_version(name, version) ⇒ Object
-
#load_build_config ⇒ Object
加载配置项.
- #local_psec_dir ⇒ Object
-
#local_spec_dir_name ⇒ Object
本地.
-
#root_dir ⇒ Object
处理编译产物后存储根目录,会存放spec、 json、zip的父目录,默认是工程的同级目录下,“#basename-build-temp”.
-
#target_name ⇒ Object
编译target名,如 seeyou.
-
#white_pod_list ⇒ Object
制作二进制 白名单.
-
#xcode_build_dir ⇒ Object
完整的xcodebuild 输出路径.
-
#xcode_build_name ⇒ Object
编译缓存文件目录,如Xcodebuild的编译缓存目录 如果有配置, 配置完整路径,会使用.
-
#xcode_BuildProductsPath_dir ⇒ Object
完整的xcodebuild BuildProductsPath输出路径,.
- #zip_dir ⇒ Object
- #zip_dir_name ⇒ Object
Methods included from Pod
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
13 14 15 16 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 13 def initialize load_build_config # clean end |
Class Method Details
.instance ⇒ Object
9 10 11 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 9 def self.instance @instance ||= new end |
Instance Method Details
#binary_json_dir ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 119 def binary_json_dir @binary_json_dir ||= begin dir = File.join(root_dir,binary_json_dir_name) Dir.mkdir(dir) unless File.exist?dir Pathname.new(dir) end end |
#binary_json_dir_name ⇒ Object
115 116 117 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 115 def binary_json_dir_name "bin-json" end |
#clean ⇒ Object
39 40 41 42 43 44 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 39 def clean #清除之前的缓存 FileUtils.rm_rf(Dir.glob("#{zip_dir}/*")) if File.exist?(zip_dir) FileUtils.rm_rf(Dir.glob("#{binary_json_dir}/*")) if File.exist?(binary_json_dir) FileUtils.rm_rf(Dir.glob("#{local_psec_dir}/*")) if File.exist?(local_psec_dir) end |
#framework_file(spec) ⇒ Object
75 76 77 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 75 def framework_file(spec) File.join(zip_dir_name, framework_name(spec)) end |
#framework_name(spec) ⇒ Object
61 62 63 64 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 61 def framework_name(spec) custom_name = spec.module_name.nil? ? spec.name : spec.module_name "#{custom_name}.framework" end |
#framework_name_version(spec) ⇒ Object
66 67 68 69 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 66 def framework_name_version(spec) custom_name = spec.module_name.nil? ? spec.name : spec.module_name "#{custom_name}.framework_#{spec.version}" end |
#framework_zip_file(spec) ⇒ Object
71 72 73 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 71 def framework_zip_file(spec) File.join(zip_dir_name, framework_name_version(spec)) end |
#gen_dir ⇒ Object
制作二进制打包 工程目录
52 53 54 55 56 57 58 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 52 def gen_dir @gen_dir ||= begin dir = File.join(root_dir,gen_name) Dir.mkdir(dir) unless File.exist?dir Pathname.new(dir) end end |
#gen_name ⇒ Object
制作二进制打包 工程目录
47 48 49 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 47 def gen_name 'bin-archive' end |
#ignore_git_list ⇒ Object
忽略制作二进制组件的 git
208 209 210 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 208 def ignore_git_list @ignore_git_list end |
#ignore_http_list ⇒ Object
212 213 214 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 212 def ignore_http_list @ignore_http_list end |
#library_file(spec) ⇒ Object
86 87 88 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 86 def library_file(spec) File.join(zip_dir_name, library_name(spec)) end |
#library_name(spec) ⇒ Object
79 80 81 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 79 def library_name(spec) library_name_version(spec.name, spec.version) end |
#library_name_version(name, version) ⇒ Object
83 84 85 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 83 def library_name_version(name,version) "bin_#{name}_#{version}" end |
#load_build_config ⇒ Object
加载配置项
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 19 def load_build_config @white_pod_list = [] @ignore_git_list = [] project_root = Pod::Config.instance.project_root path = File.join(project_root.to_s, 'BinArchive.json') if File.exist?(path) config = JSON.parse(File.read(path)) @white_pod_list = config['archive-white-pod-list'] UI.warn "====== archive-white-pod-list = #{@white_pod_list}" if @white_pod_list @ignore_git_list = config['ignore-git-list'] UI.warn "====== ignore_git_list = #{@ignore_git_list}" if @ignore_git_list @ignore_http_list = config['ignore-http-list'] @xcode_build_name = config['xcode_build_path'] @root_dir = config['root_dir'] unless config['root_dir'].nil? end end |
#local_psec_dir ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 107 def local_psec_dir @local_psec_dir ||= begin dir = File.join(root_dir,local_spec_dir_name) Dir.mkdir(dir) unless File.exist?dir Pathname.new(dir) end end |
#local_spec_dir_name ⇒ Object
本地
103 104 105 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 103 def local_spec_dir_name "bin-spec" end |
#root_dir ⇒ Object
处理编译产物后存储根目录,会存放spec、 json、zip的父目录,默认是工程的同级目录下,“#basename-build-temp”
192 193 194 195 196 197 198 199 200 201 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 192 def root_dir @root_dir ||= begin basename = File.basename(Pod::Config.instance.installation_root) parent_dir = File.dirname(Pod::Config.instance.installation_root) root_name = File.join(parent_dir,"#{basename}-build-temp") Dir.mkdir(root_name) unless File.exist?root_name Pathname.new(root_name) end end |
#target_name ⇒ Object
编译target名,如 seeyou
130 131 132 133 134 135 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 130 def target_name @target_name ||= begin target_name_str = Pod::Config.instance.podfile.root_target_definitions.first.children.first.to_s target_name_str[5,target_name_str.length] end end |
#white_pod_list ⇒ Object
制作二进制 白名单
204 205 206 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 204 def white_pod_list @white_pod_list end |
#xcode_build_dir ⇒ Object
完整的xcodebuild 输出路径
159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 159 def xcode_build_dir @xcode_build_dir ||= begin temp_xcode_build_name = xcode_build_name if File.exist?(temp_xcode_build_name) Pathname.new(temp_xcode_build_name) else dir = File.join(root_dir,xcode_build_name) Pathname.new(dir) end end end |
#xcode_build_name ⇒ Object
编译缓存文件目录,如Xcodebuild的编译缓存目录 如果有配置, 配置完整路径,会使用
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 139 def xcode_build_name @xcode_build_name ||= begin project_root = Pod::Config.instance.project_root path = File.join(project_root.to_s, 'BinArchive.json') if File.exist?(path) config = JSON.parse(File.read(path)) @xcode_build_name = config['xcode_build_path'] end #默认值,在美柚上使用默认 if @xcode_build_name.nil? || Dir.exist?(@xcode_build_name) @xcode_build_name = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/" end puts @xcode_build_name @xcode_build_name end end |
#xcode_BuildProductsPath_dir ⇒ Object
完整的xcodebuild BuildProductsPath输出路径,
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 171 def xcode_BuildProductsPath_dir @xcode_BuildProductsPath_dir ||= begin temp_xcode_BuildProductsPath_dir = "xcode-build/Build/Intermediates.noindex/ArchiveIntermediates/#{target_name}/BuildProductsPath/" full_path = File.join(root_dir, temp_xcode_BuildProductsPath_dir) if (File.exist?(full_path)) Dir.chdir(full_path) do iphoneos = Dir.glob('*-iphoneos') if iphoneos.length > 0 full_path = File.join(full_path,iphoneos.first) else UI.warn "====== 找不到 *-iphoneos @xcode_BuildProductsPath_dir = #{@xcode_BuildProductsPath_dir}" end end end Pathname.new(full_path) end end |
#zip_dir ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 94 def zip_dir @zip_dir ||= begin dir = File.join(root_dir,zip_dir_name) Dir.mkdir(dir) unless File.exist?dir Pathname.new(dir) end end |
#zip_dir_name ⇒ Object
90 91 92 |
# File 'lib/cocoapods-imy-bin/config/config_builder.rb', line 90 def zip_dir_name "bin-zip" end |