Class: CBin::Build::Helper
- Inherits:
-
Object
- Object
- CBin::Build::Helper
- Includes:
- Pod
- Defined in:
- lib/cocoapods-mtxx-bin/helpers/build_helper.rb
Constant Summary collapse
- @@build_defines =
class var
""
Instance Method Summary collapse
-
#build ⇒ Object
构建.a或.framework.
-
#build_static_framework ⇒ Object
构建静态framework.
-
#build_static_library ⇒ Object
构建library.
-
#clean_workspace ⇒ Object
清理缓存.
- #framework_name ⇒ Object
- #framework_name_zip ⇒ Object
- #gen_name ⇒ Object
-
#initialize(spec, platform, framework_output, zip, rootSpec, skip_archive = false, build_model = "Release", installer = nil) ⇒ Helper
constructor
Debug下还待完成.
- #library_name ⇒ Object
- #spec_file ⇒ Object
-
#workspace_directory ⇒ Object
“PodA-build-temp/bin-archive/PodA”.
- #zip_dir ⇒ Object
-
#zip_static_framework ⇒ Object
压缩静态framework.
-
#zip_static_library ⇒ Object
压缩library.
Methods included from Pod
Constructor Details
#initialize(spec, platform, framework_output, zip, rootSpec, skip_archive = false, build_model = "Release", installer = nil) ⇒ Helper
Debug下还待完成
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 17 def initialize(spec, platform, framework_output, zip, rootSpec, skip_archive = false, build_model="Release", installer = nil) @spec = spec @platform = platform @build_model = build_model @rootSpec = rootSpec @isRootSpec = rootSpec.name == spec.name @skip_archive = skip_archive @framework_output = framework_output @zip = zip @installer = installer @framework_path end |
Instance Method Details
#build ⇒ Object
构建.a或.framework
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 39 def build unless @skip_archive unless CBin::Build::Utils.is_framework(@spec) build_static_library zip_static_library else build_static_framework zip_static_framework end end end |
#build_static_framework ⇒ Object
构建静态framework
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 52 def build_static_framework UI.title("Building static framework #{@spec}") do source_dir = Dir.pwd # file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform)) Dir.chdir(workspace_directory) do builder = CBin::Framework::Builder.new(@spec, @installer, @platform, source_dir, @isRootSpec, @build_model ) # 编译当前库 @@build_defines = builder.build if @isRootSpec begin @framework_path = builder.lipo_create(@@build_defines) unless @skip_archive rescue @skip_archive = true end end end end |
#build_static_library ⇒ Object
构建library
70 71 72 73 74 75 76 77 |
# File 'lib/cocoapods-mtxx-bin/helpers/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::Library::Builder.new(@spec, file_accessor, @platform, source_dir,@framework_path) builder.build end end |
#clean_workspace ⇒ Object
清理缓存
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 112 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
[View source]
124 125 126 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 124 def framework_name CBin::Config::Builder.instance.framework_name(@spec) end |
#framework_name_zip ⇒ Object
[View source]
128 129 130 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 128 def framework_name_zip CBin::Config::Builder.instance.framework_name_version(@spec) + ".zip" end |
#gen_name ⇒ Object
[View source]
145 146 147 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 145 def gen_name CBin::Config::Builder.instance.gen_dir end |
#library_name ⇒ Object
[View source]
132 133 134 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 132 def library_name CBin::Config::Builder.instance.library_name(@spec) end |
#spec_file ⇒ Object
[View source]
150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 150 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
“PodA-build-temp/bin-archive/PodA”
137 138 139 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 137 def workspace_directory File.("#{gen_name}/#{@rootSpec.name}") end |
#zip_dir ⇒ Object
[View source]
141 142 143 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 141 def zip_dir CBin::Config::Builder.instance.zip_dir end |
#zip_static_framework ⇒ Object
压缩静态framework
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 80 def zip_static_framework Dir.chdir(File.join(workspace_directory,@framework_path.root_path)) do output_name = File.join(zip_dir, framework_name_zip) unless File.exist?(framework_name) UI.info "没有需要压缩的 framework 文件:#{framework_name}" return end UI.title "Compressing #{framework_name} into #{output_name}" do Dir.mkdir(zip_dir) unless File.exist?(zip_dir) command = "zip --symlinks -r #{output_name} #{framework_name}" UI.info "#{command}" `#{command}` end end end |
#zip_static_library ⇒ Object
压缩library
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/cocoapods-mtxx-bin/helpers/build_helper.rb', line 98 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 |