Class: Pod::Builder
- Inherits:
-
Object
- Object
- Pod::Builder
- Defined in:
- lib/cocoapods-util/command/package/helper/builder.rb,
lib/cocoapods-util/command/package/helper/library_builder.rb,
lib/cocoapods-util/command/package/helper/framework_builder.rb
Instance Method Summary collapse
- #build(package_type) ⇒ Object
- #build_options ⇒ Object
- #build_sim_libraries(defines) ⇒ Object
- #build_static_framework ⇒ Object
- #build_static_library ⇒ Object
- #build_static_xcframework ⇒ Object
- #compile ⇒ Object
- #expand_paths(path_specs) ⇒ Object
-
#initialize(platform, static_installer, source_dir, static_sandbox_root, public_headers_root, spec, config, exclude_sim, framework_contains_resources, verbose) ⇒ Builder
constructor
A new instance of Builder.
- #os_build_name(build_root) ⇒ Object
- #static_libs_in_sandbox(build_dir = 'build') ⇒ Object
- #vendored_libraries ⇒ Object
- #xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-packager', project_root = @static_sandbox_root, config = @config) ⇒ Object
Constructor Details
#initialize(platform, static_installer, source_dir, static_sandbox_root, public_headers_root, spec, config, exclude_sim, framework_contains_resources, verbose) ⇒ Builder
Returns a new instance of Builder.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 3 def initialize(platform, static_installer, source_dir, static_sandbox_root, public_headers_root, spec, config, exclude_sim, framework_contains_resources, verbose) @platform = platform @static_installer = static_installer @source_dir = source_dir @static_sandbox_root = static_sandbox_root @public_headers_root = public_headers_root @spec = spec @config = config @exclude_sim = exclude_sim || @platform.name.to_s == 'osx' @framework_contains_resources = framework_contains_resources @verbose = verbose @file_accessors = @static_installer.pod_targets.select { |t| t.pod_name == @spec.name }.flat_map(&:file_accessors) end |
Instance Method Details
#build(package_type) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 18 def build(package_type) require_relative 'framework_builder.rb' require_relative 'library_builder.rb' case package_type when :static_library build_static_library when :static_framework build_static_framework when :static_xcframework build_static_xcframework end end |
#build_options ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 113 def vendored_archs = [] vendored_libraries.each do |library| vendored_archs = vendored_archs | `lipo -archs #{library}`.split UI.puts "library at #{library}, archs: #{vendored_archs}" if @verbose end = ("ARCHS=\'#{vendored_archs.join(' ')}\'" unless vendored_archs.empty?) || "" end |
#build_sim_libraries(defines) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 79 def build_sim_libraries(defines) = case @platform.name when :ios << ' -sdk iphonesimulator' when :watchos << ' -sdk watchsimulator' when :tvos << ' -sdk appletvsimulator' else return end xcodebuild(defines, , 'build-sim') end |
#build_static_framework ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 42 def build_static_framework UI.puts("Building #{@platform.name.to_s} static framework #{@spec} with configuration #{@config}") defines = compile build_sim_libraries(defines) unless @exclude_sim frameworks = generate_frameworks combine_frameworks(frameworks) # delete framework framework_paths = frameworks.map {|fwk| fwk.fwk_path } framework_paths.each { |path| FileUtils.rm_rf(File.dirname(path)) } UI.puts("Building #{@platform.name.to_s} static framework #{@spec} with configuration #{@config} success") end |
#build_static_library ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 32 def build_static_library UI.puts("Building #{@platform.name.to_s} static library #{@spec} with configuration #{@config}") defines = compile build_sim_libraries(defines) unless @exclude_sim create_library UI.puts("Building #{@platform.name.to_s} static library #{@spec} with configuration #{@config} success") end |
#build_static_xcframework ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 58 def build_static_xcframework require_relative '../../xcframework/xcframework_build.rb' UI.puts("Building #{@platform.name.to_s} static framework #{@spec} with configuration #{@config}") defines = compile build_sim_libraries(defines) unless @exclude_sim frameworks = generate_frameworks framework_paths = frameworks.map {|fwk| fwk.fwk_path } # gemerate xcframework xcbuilder = XCFrameworkBuilder.new( @spec.name, @platform.name.to_s, true ) xcbuilder.generate_xcframework(framework_paths) # delete framework framework_paths.each { |path| FileUtils.rm_rf(File.dirname(path)) } end |
#compile ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 94 def compile defines = ("" << @spec.consumer(@platform).compiler_flags.join(' ')) = case @platform.name when :ios << ' -sdk iphoneos' when :osx << ' -sdk macosx' when :watchos << ' -sdk watchos' when :tvos << ' -sdk appletvos' end xcodebuild(defines, ) defines end |
#expand_paths(path_specs) ⇒ Object
142 143 144 145 146 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 142 def (path_specs) path_specs.map do |path_spec| Dir.glob(File.join(@source_dir, path_spec)) end end |
#os_build_name(build_root) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 148 def os_build_name(build_root) build_name = "#{@config}" case build_root when 'build' case @platform.name when :ios build_name += "-iphoneos" when :watchos build_name += '-watchos' when :tvos build_name += '-appletvos' end else case @platform.name when :ios build_name += "-iphonesimulator" when :watchos build_name += '-watchsimulator' when :tvos build_name += '-appletvsimulator' end end build_name end |
#static_libs_in_sandbox(build_dir = 'build') ⇒ Object
123 124 125 126 127 128 129 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 123 def static_libs_in_sandbox(build_dir = 'build') if build_dir == 'build' Dir.glob("#{@static_sandbox_root}/#{build_dir}/**/#{@spec.name}/lib#{@spec.name}.a") else Dir.glob("#{@static_sandbox_root}/#{build_dir}/**/#{@spec.name}/lib#{@spec.name}.a") end end |
#vendored_libraries ⇒ Object
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 131 def vendored_libraries if @vendored_libraries @vendored_libraries end file_accessors = @file_accessors libs = file_accessors.flat_map(&:vendored_static_frameworks).map { |f| f + f.basename('.*') } || [] libs += file_accessors.flat_map(&:vendored_static_libraries) @vendored_libraries = libs.compact.map(&:to_s) @vendored_libraries end |
#xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-packager', project_root = @static_sandbox_root, config = @config) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/cocoapods-util/command/package/helper/builder.rb', line 173 def xcodebuild(defines = '', args = '', build_dir = 'build', target = 'Pods-packager', project_root = @static_sandbox_root, config = @config) if defined?(Pod::DONT_CODESIGN) args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO" end command = "xcodebuild #{defines} #{args} BUILD_DIR=#{build_dir} clean build -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj 2>&1".gsub!(/\s+/, ' ') UI.puts "#{command}" if @verbose output = `#{command}`.lines.to_a if $?.exitstatus != 0 puts UI::BuildFailedReport.report(command, output) # Note: We use `Process.exit` here because it fires a `SystemExit` # exception, which gives the caller a chance to clean up before the # process terminates. # # See http://ruby-doc.org/core-1.9.3/Process.html#method-c-exit Process.exit end end |