Class: PodBuilder::PodfileItem
- Inherits:
-
Object
- Object
- PodBuilder::PodfileItem
- Defined in:
- lib/pod_builder/podfile_item.rb
Instance Attribute Summary collapse
-
#available_versions ⇒ Object
readonly
Returns the value of attribute available_versions.
-
#branch ⇒ String
readonly
The git branch.
-
#build_configuration ⇒ String
The pod’s build configuration.
-
#commit ⇒ String
readonly
The pinned commit of the pod, if any.
-
#dependency_names ⇒ Array<String>
readonly
The pod’s dependency names, if any.
-
#frameworks ⇒ String
Framweworks the pod needs to link to.
-
#is_external ⇒ Bool
Is external pod.
-
#is_static ⇒ Bool
readonly
True if the pod is shipped as a static framework.
-
#libraries ⇒ String
Libraries the pod needs to link to.
-
#module_name ⇒ String
readonly
The module name.
-
#name ⇒ String
readonly
The name of the pod, which might be the subspec name if appicable.
-
#path ⇒ String
Local path, if any.
-
#repo ⇒ String
readonly
The git repo.
-
#root_name ⇒ String
readonly
Matches @name unless for subspecs were it stores the name of the root pod.
-
#source_files ⇒ String
Source_files.
-
#swift_version ⇒ String
readonly
The swift version if applicable.
-
#tag ⇒ String
readonly
The pinned tag of the pod, if any.
-
#vendored_items ⇒ String
The pod’s vendored items (frameworks and libraries).
-
#version ⇒ String
readonly
The pinned version of the pod, if any.
-
#weak_frameworks ⇒ String
Weak framweworks the pod needs to link to.
-
#xcconfig ⇒ Array<Hash>
readonly
The pod’s xcconfig configuration.
Instance Method Summary collapse
- #dependencies(available_pods) ⇒ Object
-
#entry(include_version = true, include_pb_entry = true) ⇒ String
The podfile entry.
- #git_hard_checkout ⇒ Object
- #has_common_spec(named) ⇒ Object
- #has_subspec(named) ⇒ Object
-
#initialize(spec, all_specs, checkout_options) ⇒ PodfileItem
constructor
Initialize a new instance.
- #inspect ⇒ Object
-
#is_prebuilt ⇒ Bool
True if it’s a pod that doesn’t provide source code (is already shipped as a prebuilt pod).
-
#is_subspec ⇒ Bool
True if it’s a subspec.
- #pod_specification(all_poditems, parent_spec = nil) ⇒ Object
- #podspec_name ⇒ Object
- #prebuilt_entry(include_pb_entry = true) ⇒ Object
- #prebuilt_rel_path ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(spec, all_specs, checkout_options) ⇒ PodfileItem
Initialize a new instance
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 150 151 152 153 154 155 |
# File 'lib/pod_builder/podfile_item.rb', line 95 def initialize(spec, all_specs, ) if overrides = Configuration.spec_overrides[spec.name] overrides.each do |k, v| spec.root.attributes_hash[k] = v if .has_key?(spec.name) [spec.name][k] = v end end end @name = spec.name @root_name = spec.name.split("/").first = [@root_name, @name] if opts_key = .detect { |x| .has_key?(x) } @repo = [opts_key][:git] @tag = [opts_key][:tag] @commit = [opts_key][:commit] @path = [opts_key][:path] @branch = [opts_key][:branch] @is_external = true else @repo = spec.root.source[:git] @tag = spec.root.source[:tag] @commit = spec.root.source[:commit] @is_external = false end @vendored_items = recursive_vendored_items(spec, all_specs) @frameworks = [] @weak_frameworks = [] @libraries = [] spec_and_dependencies(spec, all_specs).each do |spec| @frameworks += extract_array(spec, "framework") @frameworks += extract_array(spec, "frameworks") @weak_frameworks += extract_array(spec, "weak_framework") @weak_frameworks += extract_array(spec, "weak_frameworks") @libraries += extract_array(spec, "library") @libraries += extract_array(spec, "libraries") end @version = spec.root.version.version @available_versions = spec.respond_to?(:spec_source) ? spec.spec_source.versions(@root_name)&.map(&:to_s) : [@version] @swift_version = spec.root.swift_version&.to_s @module_name = spec.root.module_name @dependency_names = spec.recursive_dep_names(all_specs) @is_static = spec.root.attributes_hash["static_framework"] || false @xcconfig = spec.root.attributes_hash["xcconfig"] || {} @source_files = source_files_from(spec) @build_configuration = spec.root.attributes_hash.dig("pod_target_xcconfig", "prebuild_configuration") || "release" @build_configuration.downcase! end |
Instance Attribute Details
#available_versions ⇒ Object (readonly)
Returns the value of attribute available_versions.
31 32 33 |
# File 'lib/pod_builder/podfile_item.rb', line 31 def available_versions @available_versions end |
#branch ⇒ String (readonly)
Returns The git branch.
11 12 13 |
# File 'lib/pod_builder/podfile_item.rb', line 11 def branch @branch end |
#build_configuration ⇒ String
Returns The pod’s build configuration.
67 68 69 |
# File 'lib/pod_builder/podfile_item.rb', line 67 def build_configuration @build_configuration end |
#commit ⇒ String (readonly)
Returns The pinned commit of the pod, if any.
39 40 41 |
# File 'lib/pod_builder/podfile_item.rb', line 39 def commit @commit end |
#dependency_names ⇒ Array<String> (readonly)
Returns The pod’s dependency names, if any. Use dependencies() to get the [Array<PodfileItem>].
51 52 53 |
# File 'lib/pod_builder/podfile_item.rb', line 51 def dependency_names @dependency_names end |
#frameworks ⇒ String
Returns Framweworks the pod needs to link to.
75 76 77 |
# File 'lib/pod_builder/podfile_item.rb', line 75 def frameworks @frameworks end |
#is_external ⇒ Bool
Returns Is external pod.
63 64 65 |
# File 'lib/pod_builder/podfile_item.rb', line 63 def is_external @is_external end |
#is_static ⇒ Bool (readonly)
Returns True if the pod is shipped as a static framework.
55 56 57 |
# File 'lib/pod_builder/podfile_item.rb', line 55 def is_static @is_static end |
#libraries ⇒ String
Returns Libraries the pod needs to link to.
83 84 85 |
# File 'lib/pod_builder/podfile_item.rb', line 83 def libraries @libraries end |
#module_name ⇒ String (readonly)
Returns The module name.
43 44 45 |
# File 'lib/pod_builder/podfile_item.rb', line 43 def module_name @module_name end |
#name ⇒ String (readonly)
Returns The name of the pod, which might be the subspec name if appicable.
19 20 21 |
# File 'lib/pod_builder/podfile_item.rb', line 19 def name @name end |
#path ⇒ String
Returns Local path, if any.
35 36 37 |
# File 'lib/pod_builder/podfile_item.rb', line 35 def path @path end |
#repo ⇒ String (readonly)
Returns The git repo.
7 8 9 |
# File 'lib/pod_builder/podfile_item.rb', line 7 def repo @repo end |
#root_name ⇒ String (readonly)
Returns Matches @name unless for subspecs were it stores the name of the root pod.
15 16 17 |
# File 'lib/pod_builder/podfile_item.rb', line 15 def root_name @root_name end |
#source_files ⇒ String
Returns source_files.
87 88 89 |
# File 'lib/pod_builder/podfile_item.rb', line 87 def source_files @source_files end |
#swift_version ⇒ String (readonly)
Returns The swift version if applicable.
47 48 49 |
# File 'lib/pod_builder/podfile_item.rb', line 47 def swift_version @swift_version end |
#tag ⇒ String (readonly)
Returns The pinned tag of the pod, if any.
23 24 25 |
# File 'lib/pod_builder/podfile_item.rb', line 23 def tag @tag end |
#vendored_items ⇒ String
Returns The pod’s vendored items (frameworks and libraries).
71 72 73 |
# File 'lib/pod_builder/podfile_item.rb', line 71 def vendored_items @vendored_items end |
#version ⇒ String (readonly)
Returns The pinned version of the pod, if any.
27 28 29 |
# File 'lib/pod_builder/podfile_item.rb', line 27 def version @version end |
#weak_frameworks ⇒ String
Returns Weak framweworks the pod needs to link to.
79 80 81 |
# File 'lib/pod_builder/podfile_item.rb', line 79 def weak_frameworks @weak_frameworks end |
#xcconfig ⇒ Array<Hash> (readonly)
Returns The pod’s xcconfig configuration.
59 60 61 |
# File 'lib/pod_builder/podfile_item.rb', line 59 def xcconfig @xcconfig end |
Instance Method Details
#dependencies(available_pods) ⇒ Object
203 204 205 |
# File 'lib/pod_builder/podfile_item.rb', line 203 def dependencies(available_pods) return available_pods.select { |x| @dependency_names.include?(x.name) } end |
#entry(include_version = true, include_pb_entry = true) ⇒ String
Returns The podfile entry.
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/pod_builder/podfile_item.rb', line 236 def entry(include_version = true, include_pb_entry = true) e = "pod '#{@name}'" unless include_version return e end if is_external if @path e += ", :path => '#{@path}'" else if @repo e += ", :git => '#{@repo}'" end if @tag e += ", :tag => '#{@tag}'" end if @commit e += ", :commit => '#{@commit}'" end if @branch e += ", :branch => '#{@branch}'" end end else e += ", '=#{@version}'" end if include_pb_entry && !is_prebuilt plists = Dir.glob(PodBuilder::basepath("Rome/**/#{module_name}.framework/#{Configuration::framework_plist_filename}")) if plists.count > 0 plist = CFPropertyList::List.new(:file => plists.first) data = CFPropertyList.native_types(plist.value) swift_version = data["swift_version"] is_static = data["is_static"] || false e += " # pb<#{name}> is<#{is_static}>" if swift_version e += " sv<#{swift_version}>" end else e += " # pb<#{name}>" end end return e end |
#git_hard_checkout ⇒ Object
324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/pod_builder/podfile_item.rb', line 324 def git_hard_checkout prefix = "git fetch --all --tags --prune; git reset --hard" if @tag return "#{prefix} tags/#{@tag}" end if @commit return "#{prefix} #{@commit}" end if @branch return "#{prefix} origin/#{@branch}" end return nil end |
#has_common_spec(named) ⇒ Object
320 321 322 |
# File 'lib/pod_builder/podfile_item.rb', line 320 def has_common_spec(named) return root_name == named.split("/").first end |
#has_subspec(named) ⇒ Object
312 313 314 315 316 317 318 |
# File 'lib/pod_builder/podfile_item.rb', line 312 def has_subspec(named) unless !is_subspec return false end return named.split("/").first == name end |
#inspect ⇒ Object
195 196 197 |
# File 'lib/pod_builder/podfile_item.rb', line 195 def inspect return "#{@name} repo=#{@repo} pinned=#{@tag || @commit} is_static=#{@is_static} deps=#{@dependencies || "[]"}" end |
#is_prebuilt ⇒ Bool
Returns True if it’s a pod that doesn’t provide source code (is already shipped as a prebuilt pod).
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/pod_builder/podfile_item.rb', line 209 def is_prebuilt # We treat pods to skip like prebuilt ones if Configuration.skip_pods.include?(@root_name) || Configuration.skip_pods.include?(@name) return true end # Podspecs aren't always properly written (source_file key is often used instead of header_files) # Therefore it can become tricky to understand which pods are already precompiled by boxing a .framework or .a vendored_items_paths = vendored_items.map { |x| File.basename(x) } = vendored_items_paths.include?("#{@module_name}.framework") = vendored_items_paths.any? { |x| x.match(/#{module_name}.*\\.a/) != nil } only_headers = @source_files.include?("*.h") only_headers |= (source_files.count > 0 && @source_files.all? { |x| x.end_with?(".h") }) no_sources = (@source_files.count == 0 || only_headers) && @vendored_items.count > 0 return || || only_headers || no_sources end |
#is_subspec ⇒ Bool
Returns True if it’s a subspec.
230 231 232 |
# File 'lib/pod_builder/podfile_item.rb', line 230 def is_subspec @root_name != @name end |
#pod_specification(all_poditems, parent_spec = nil) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/pod_builder/podfile_item.rb', line 157 def pod_specification(all_poditems, parent_spec = nil) spec_raw = {} spec_raw["name"] = @name spec_raw["module_name"] = @module_name spec_raw["source"] = {} if repo = @repo spec_raw["source"]["git"] = repo end if tag = @tag spec_raw["source"]["tag"] = tag end if commit = @commit spec_raw["source"]["commit"] = commit end spec_raw["version"] = @version if swift_version = @swift_version spec_raw["swift_version"] = swift_version end spec_raw["static_framework"] = is_static spec_raw["frameworks"] = @frameworks spec_raw["libraries"] = @libraries spec_raw["xcconfig"] = @xcconfig spec_raw["dependencies"] = @dependency_names.map { |x| [x, []] }.to_h spec = Pod::Specification.from_hash(spec_raw, parent_spec) all_subspec_items = all_poditems.select { |x| x.is_subspec && x.root_name == @name } spec.subspecs = all_subspec_items.map { |x| x.pod_specification(all_poditems, spec) } return spec end |
#podspec_name ⇒ Object
284 285 286 |
# File 'lib/pod_builder/podfile_item.rb', line 284 def podspec_name return name.gsub("/", "_") end |
#prebuilt_entry(include_pb_entry = true) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/pod_builder/podfile_item.rb', line 296 def prebuilt_entry(include_pb_entry = true) relative_path = Pathname.new(Configuration.base_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s if Configuration.subspecs_to_split.include?(name) entry = "pod 'PodBuilder/#{podspec_name}', :path => '#{relative_path}'" else entry = "pod 'PodBuilder/#{root_name}', :path => '#{relative_path}'" end if include_pb_entry && !is_prebuilt entry += " # pb<#{name}>" end return entry end |
#prebuilt_rel_path ⇒ Object
288 289 290 291 292 293 294 |
# File 'lib/pod_builder/podfile_item.rb', line 288 def prebuilt_rel_path if is_subspec && Configuration.subspecs_to_split.include?(name) return "#{name}/#{module_name}.framework" else return "#{module_name}.framework" end end |
#to_s ⇒ Object
199 200 201 |
# File 'lib/pod_builder/podfile_item.rb', line 199 def to_s return @name end |