Class: Pod::Command::Bin::Local
- Inherits:
-
Pod::Command::Bin
- Object
- Pod::Command
- Pod::Command::Bin
- Pod::Command::Bin::Local
- Defined in:
- lib/cocoapods-imy-bin/command/bin/local.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build(make_binary_specs) ⇒ Object
-
#initialize(argv) ⇒ Local
constructor
A new instance of Local.
- #run ⇒ Object
Methods inherited from Pod::Command::Bin
Methods included from CBin::SpecFilesHelper
#binary_spec, #binary_spec_files, #binary_template_spec, #binary_template_spec_file, #binary_template_spec_files, #clear_binary_spec_file_if_needed, #code_spec, #code_spec_files, #create_binary_spec_file, #find_spec_file, #spec_files
Methods included from CBin::SourcesHelper
#binary_source, #code_source, #sources_manager, #sources_option, #valid_sources
Constructor Details
#initialize(argv) ⇒ Local
Returns a new instance of Local.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cocoapods-imy-bin/command/bin/local.rb', line 40 def initialize(argv) @env = argv.option('env') || 'dev' CBin.config.set_configuration_env(@env) UI.warn "====== cocoapods-imy-bin #{CBin::VERSION} 版本 ======== \n " UI.warn "====== #{@env} 环境 ======== " @make_binary_specs = argv.option('make-binary-specs') || [] @framework_output = argv.flag?('framework-output', false) @clean = argv.flag?('no-clean', true) @zip = argv.flag?('zip', true) @sources = argv.option('sources') || [] @platform = Platform.new(:ios) @target_name = CBin::Config::Builder.instance.target_name @local_build_dir_name = CBin::Config::Builder.instance.xcode_build_name @local_build_dir = CBin::Config::Builder.instance.xcode_build_dir @framework_path super end |
Class Method Details
.options ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/cocoapods-imy-bin/command/bin/local.rb', line 30 def self. [ ['--no-clean', '保留构建中间产物'], ['--framework-output', '输出framework文件'], ['--no-zip', '不压缩静态 framework 为 zip'], ['--make-binary-specs', '需要制作spec集合'], ['--env', "该组件上传的环境 %w[dev debug_iphoneos release_iphoneos]"] ].concat(Pod::Command::Gen.).concat(super).uniq end |
Instance Method Details
#build(make_binary_specs) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 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 121 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 147 148 149 |
# File 'lib/cocoapods-imy-bin/command/bin/local.rb', line 82 def build(make_binary_specs) # 如果没要求,就清空依赖库数据 sources_sepc = [] make_binary_specs.uniq.each do |spec| next if spec.name.include?('/') next if spec.name == @target_name #过滤白名单 next if CBin::Config::Builder.instance.white_pod_list.include?(spec.name) #过滤 git ignore_git_list = CBin::Config::Builder.instance.ignore_git_list if spec.source[:git] && spec.source[:git] && ignore_git_list spec_git = spec.source[:git] spec_git_res = false ignore_git_list.each do |ignore_git| spec_git_res = spec_git.include?(ignore_git) break if spec_git_res end next if spec_git_res end UI.warn "#{spec.name}.podspec 带有 vendored_frameworks 字段,请检查是否有效!!!" if spec.attributes_hash['vendored_frameworks'] next if spec.attributes_hash['vendored_frameworks'] && @target_name != spec.name #过滤带有vendored_frameworks的 next if (spec.attributes_hash['ios'] && spec.attributes_hash['ios']['vendored_frameworks']) #过滤带有vendored_frameworks的 #获取没有制作二进制版本的spec集合 next unless library_exist(spec) # 获取没有制作二进制版本的spec集合 sources_sepc << spec end fail_build_specs = [] sources_sepc.uniq.each do |spec| begin builder = CBin::LocalBuild::Helper.new(spec, @platform, @framework_output, @zip, @clean, @target_name, @local_build_dir_name, @local_build_dir) if builder.build CBin::Upload::Helper.new(spec, @code_dependencies, @sources).upload else fail_build_specs << spec end rescue StandardError fail_build_specs << spec end end if fail_build_specs.any? fail_build_specs.uniq.each do |spec| UI.warn "【#{spec.name} | #{spec.version}】组件二进制版本编译失败 ." end end success_specs = sources_sepc - fail_build_specs if success_specs.any? success_specs.uniq.each do |spec| UI.warn " =======【 #{spec.name} | #{spec.version} 】二进制组件制作完成 !!!" end end # pod repo update UI.section("\nUpdating Spec Repositories\n".yellow) do Pod::Command::Bin::Repo::Update.new(CLAide::ARGV.new([])).run end end |
#run ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cocoapods-imy-bin/command/bin/local.rb', line 62 def run # 清除之前的缓存 # temp = File.join(@local_build_dir, @platform.to_s) # FileUtils.rm_r(temp) if File.exist? temp # if File.exist?(CBin::Config::Builder.instance.zip_dir) # FileUtils.rm_rf(Dir.glob("#{CBin::Config::Builder.instance.zip_dir}/*")) # end sources_spec = [] Dir.chdir(CBin::Config::Builder.instance.local_psec_dir) do spec_files = Dir.glob(%w[*.json *.podspec]) spec_files.each do |file| spec = Pod::Specification.from_file(file) sources_spec << spec end end build(sources_spec) end |