class CBin::Config::Builder

Public Class Methods

instance() click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 9
def self.instance
  @instance ||= new
end
new() click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 13
def initialize
  load_build_config
  # clean
end

Public Instance Methods

binary_json_dir() click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 127
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() click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 123
def binary_json_dir_name
  "bin-json"
end
build_pod_list() click to toggle source

需要制作二进制名单,为空默认为全部

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 218
def build_pod_list
  @build_pod_list
end
clean() click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 49
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) click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 83
def framework_file(spec)
  File.join(zip_dir_name, framework_name(spec))
end
framework_name(spec) click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 71
def framework_name(spec)
  "#{spec.name}.framework"
end
framework_name_version(spec) click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 75
def framework_name_version(spec)
  "#{spec.name}.framework_#{spec.version}"
end
framework_zip_file(spec) click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 79
def framework_zip_file(spec)
  File.join(zip_dir_name, framework_name_version(spec))
end
gen_dir() click to toggle source

制作二进制打包 工程目录

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 62
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() click to toggle source

制作二进制打包 工程目录

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 57
def gen_name
  'bin-archive'
end
ignore_git_list() click to toggle source

忽略制作二进制组件的 git

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 228
def ignore_git_list
  @ignore_git_list
end
ignore_http_list() click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 232
def ignore_http_list
  @ignore_http_list
end
library_file(spec) click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 94
def library_file(spec)
  File.join(zip_dir_name, library_name(spec))
end
library_name(spec) click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 87
def library_name(spec)
  library_name_version(spec.name, spec.version)
end
library_name_version(name,version) click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 91
def library_name_version(name,version)
  "bin_#{name}_#{version}"
end
load_build_config() click to toggle source

加载配置项

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 19
def load_build_config
  @white_pod_list = []
  @build_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))
    if config['archive-white-pod-list']
      @white_pod_list = config['archive-white-pod-list']
    end

    if config['archive-build-pod-list']
      @build_pod_list = config['archive-build-pod-list']
    end

    UI.warn "====== archive-build-pod-list = #{@build_pod_list}" if @build_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() click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 115
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() click to toggle source

本地

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 111
def local_spec_dir_name
  "bin-spec"
end
root_dir() click to toggle source

处理编译产物后存储根目录,会存放spec、 json、zip的父目录,默认是工程的同级目录下,“#{basename}-build-temp”

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 206
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() click to toggle source

编译target名,如 seeyou

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 138
def target_name
  # podfile_path = Pod::Config.instance.installation_root.to_s + "/Example/podfile"
  # begin
  #   podfile = Pod::Podfile.from_file(podfile_path)
  # rescue
  #   podfile = Pod::Config.instance.podfile
  # end
  @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() click to toggle source

制作二进制 白名单

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 223
def white_pod_list
  @white_pod_list
end
xcode_BuildProductsPath_dir() click to toggle source

完整的xcodebuild BuildProductsPath输出路径,

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 185
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
xcode_build_dir() click to toggle source

完整的xcodebuild 输出路径

# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 173
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() click to toggle source

编译缓存文件目录,如Xcodebuild的编译缓存目录

如果有配置, 配置完整路径,会使用
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 153
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
zip_dir() click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 102
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() click to toggle source
# File lib/cocoapods-tdf-bin/config/config_builder.rb, line 98
def zip_dir_name
  "bin-zip"
end