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_dir ⇒ Object
- #framework_name ⇒ Object
- #framework_name_zip ⇒ Object
- #gen_name ⇒ Object
-
#initialize(spec, platform, framework_output, zip, clean, target_name, local_build_dir_name, local_build_dir) ⇒ Helper
constructor
Debug下还待完成.
-
#is_framework ⇒ Object
使用了user_framework 会有#@[email protected] 未使用的 需要判断文件.
- #is_library ⇒ Object
- #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 38 |
# 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 @is_library = !is_framework end |
Instance Method Details
#build ⇒ Object
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/helpers/local/local_build_helper.rb', line 40 def build UI.section("Building static framework #{@spec}") do begin build_static_framework if @is_library build_static_library zip_static_framework if @zip &&= @framework_output zip_static_library else zip_static_framework end clean_workspace if @clean rescue Exception => e puts e. puts e.backtrace.inspect return false end end return true end |
#build_static_framework ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 62 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, @is_library, frameWork_dir) @framework_path = builder.create end end |
#build_static_library ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 70 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
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 108 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_dir ⇒ Object
158 159 160 161 162 163 164 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 158 def frameWork_dir dir = File.join(@local_build_dir, "#{@spec.name}.framework") unless File.exist?(dir) dir = File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}") end dir end |
#framework_name ⇒ Object
120 121 122 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 120 def framework_name CBin::Config::Builder.instance.framework_name(@spec) end |
#framework_name_zip ⇒ Object
124 125 126 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 124 def framework_name_zip CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip" end |
#gen_name ⇒ Object
140 141 142 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 140 def gen_name CBin::Config::Builder.instance.gen_name end |
#is_framework ⇒ Object
使用了user_framework 会有#CBin::LocalBuild::Helper.@[email protected] 未使用的 需要判断文件
150 151 152 153 154 155 156 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 150 def is_framework res = File.exist?(File.join(@local_build_dir, "#{@spec.name}.framework")) unless res res = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{@spec.name}","Swift Compatibility Header")) end res end |
#is_library ⇒ Object
144 145 146 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 144 def is_library File.exist?(File.join(@local_build_dir, "lib#{@spec.name}.a")) end |
#library_name ⇒ Object
128 129 130 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 128 def library_name CBin::Config::Builder.instance.library_name(@spec) end |
#spec_file ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 166 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
132 133 134 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 132 def workspace_directory @local_build_dir end |
#zip_dir ⇒ Object
136 137 138 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 136 def zip_dir CBin::Config::Builder.instance.zip_dir end |
#zip_static_framework ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 79 def zip_static_framework Dir.chdir(zip_dir) do # output_name = "#{framework_name}.zip" output_name = File.join(zip_dir, framework_name_zip) unless File.exist?(framework_name) UI.warn "没有需要压缩的 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
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/cocoapods-imy-bin/helpers/local/local_build_helper.rb', line 93 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 |