Class: CBin::LocalBuild::Helper
- Inherits:
-
Object
- Object
- CBin::LocalBuild::Helper
- Includes:
- Pod
- Defined in:
- lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb
Constant Summary collapse
- @@build_defines =
class var
""
Instance Method Summary collapse
- #build ⇒ Object
- #build_static_framework ⇒ Object
- #build_static_library ⇒ Object
- #clean_workspace ⇒ Object
- #framework_name ⇒ Object
- #gen_name ⇒ Object
-
#initialize(spec, platform, framework_output, zip, clean, target_name, local_build_dir_name, local_build_dir) ⇒ Helper
constructor
Debug下还待完成.
- #library_name ⇒ Object
- #spec_file ⇒ Object
- #workspace_directory ⇒ Object
- #zip_dir ⇒ Object
- #zip_static_framework ⇒ Object
- #zip_static_library ⇒ Object
Methods included from Pod
Constructor Details
#initialize(spec, platform, framework_output, zip, clean, target_name, local_build_dir_name, local_build_dir) ⇒ Helper
Debug下还待完成
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 19 def initialize(spec, platform, framework_output, zip, clean, target_name, local_build_dir_name, local_build_dir) @spec = spec @target_name = target_name @platform = platform @framework_output = framework_output @zip = zip @local_build_dir_name = local_build_dir_name @local_build_dir = local_build_dir @clean = clean @framework_path end |
Instance Method Details
#build ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 39 def build UI.section("Building static framework #{@spec}") do build_static_framework build_static_library zip_static_framework if @zip &&= @framework_output zip_static_library clean_workspace if @clean end end |
#build_static_framework ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 52 def build_static_framework file_accessor = Sandbox::FileAccessor.new(Pathname.new('.')., @spec.consumer(@platform)) Dir.chdir(workspace_directory) do builder = CBin::LocalFramework::Builder.new(@spec, file_accessor, @platform, @local_build_dir_name,@local_build_dir) @framework_path = builder.create end end |
#build_static_library ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 60 def build_static_library source_dir = zip_dir file_accessor = Sandbox::FileAccessor.new(Pathname.new('.')., @spec.consumer(@platform)) Dir.chdir(workspace_directory) do builder = CBin::LocalLibrary::Builder.new(@spec, file_accessor, @platform, source_dir,@framework_path) builder.build end end |
#clean_workspace ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 97 def clean_workspace UI.puts 'Cleaning workspace' FileUtils.rm_rf(gen_name) Dir.chdir(zip_dir) do FileUtils.rm_rf(framework_name) if @zip FileUtils.rm_rf(library_name) FileUtils.rm_rf(framework_name) unless @framework_output FileUtils.rm_rf("#{framework_name}.zip") unless @framework_output end end |
#framework_name ⇒ Object
109 110 111 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 109 def framework_name CBin::Config::Builder.instance.framework_name(@spec) end |
#gen_name ⇒ Object
125 126 127 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 125 def gen_name CBin::Config::Builder.instance.gen_name end |
#library_name ⇒ Object
113 114 115 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 113 def library_name CBin::Config::Builder.instance.library_name(@spec) end |
#spec_file ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 129 def spec_file @spec_file ||= begin if @podspec find_spec_file(@podspec) else if code_spec_files.empty? raise Informative, '当前目录下没有找到可用源码 podspec.' end spec_file = code_spec_files.first spec_file end end end |
#workspace_directory ⇒ Object
117 118 119 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 117 def workspace_directory @local_build_dir end |
#zip_dir ⇒ Object
121 122 123 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 121 def zip_dir CBin::Config::Builder.instance.zip_dir end |
#zip_static_framework ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 69 def zip_static_framework Dir.chdir(zip_dir) do output_name = "#{framework_name}.zip" unless File.exist?(framework_name) raise Informative, "没有需要压缩的 framework 文件:#{framework_name}" end UI.puts "Compressing #{framework_name} into #{output_name}" `zip --symlinks -r #{output_name} #{framework_name}` end end |
#zip_static_library ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 82 def zip_static_library Dir.chdir(zip_dir) do output_library = "#{library_name}.zip" unless File.exist?(library_name) raise Informative, "没有需要压缩的 library 文件:#{library_name}" end UI.puts "Compressing #{library_name} into #{output_library}" `zip --symlinks -r #{output_library} #{library_name}` end end |