Class: Pod::Target::BuildType

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/target/build_type.rb

Constant Summary collapse

KNOWN_PACKAGING_OPTIONS =
i(library framework).freeze
KNOWN_LINKAGE_OPTIONS =
i(static dynamic).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(linkage: :static, packaging: :library) ⇒ BuildType

Returns a new instance of BuildType

Raises:

  • (ArgumentError)

22
23
24
25
26
27
28
29
# File 'lib/cocoapods/target/build_type.rb', line 22

def initialize(linkage: :static, packaging: :library)
  raise ArgumentError, "Invalid linkage option #{linkage.inspect}, valid options are #{KNOWN_LINKAGE_OPTIONS.inspect}" unless KNOWN_LINKAGE_OPTIONS.include?(linkage)
  raise ArgumentError, "Invalid packaging option #{packaging.inspect}, valid options are #{KNOWN_PACKAGING_OPTIONS.inspect}" unless KNOWN_PACKAGING_OPTIONS.include?(packaging)

  @packaging = packaging
  @linkage = linkage
  @hash = packaging.hash ^ linkage.hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash


20
21
22
# File 'lib/cocoapods/target/build_type.rb', line 20

def hash
  @hash
end

#linkageSymbol (readonly)


18
19
20
# File 'lib/cocoapods/target/build_type.rb', line 18

def linkage
  @linkage
end

#packagingSymbol (readonly)


14
15
16
# File 'lib/cocoapods/target/build_type.rb', line 14

def packaging
  @packaging
end

Class Method Details

.dynamic_frameworkBuildType


67
68
69
# File 'lib/cocoapods/target/build_type.rb', line 67

def self.dynamic_framework
  new(:linkage => :dynamic, :packaging => :framework)
end

.dynamic_libraryBuildType


55
56
57
# File 'lib/cocoapods/target/build_type.rb', line 55

def self.dynamic_library
  new(:linkage => :dynamic, :packaging => :library)
end

.infer_from_spec(spec, host_requires_frameworks: false) ⇒ BuildType


40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cocoapods/target/build_type.rb', line 40

def self.infer_from_spec(spec, host_requires_frameworks: false)
  if host_requires_frameworks
    root_spec = spec && spec.root
    if root_spec && root_spec.static_framework
      static_framework
    else
      dynamic_framework
    end
  else
    static_library
  end
end

.static_frameworkBuildType


73
74
75
# File 'lib/cocoapods/target/build_type.rb', line 73

def self.static_framework
  new(:linkage => :static, :packaging => :framework)
end

.static_libraryBuildType


61
62
63
# File 'lib/cocoapods/target/build_type.rb', line 61

def self.static_library
  new(:linkage => :static, :packaging => :library)
end

Instance Method Details

#==(other) ⇒ Object


133
134
135
136
# File 'lib/cocoapods/target/build_type.rb', line 133

def ==(other)
  linkage == other.linkage &&
      packaging == other.packaging
end

#dynamic?Boolean


79
80
81
# File 'lib/cocoapods/target/build_type.rb', line 79

def dynamic?
  linkage == :dynamic
end

#dynamic_framework?Boolean


103
104
105
# File 'lib/cocoapods/target/build_type.rb', line 103

def dynamic_framework?
  dynamic? && framework?
end

#dynamic_library?Boolean


109
110
111
# File 'lib/cocoapods/target/build_type.rb', line 109

def dynamic_library?
  dynamic? && library?
end

#framework?Boolean


91
92
93
# File 'lib/cocoapods/target/build_type.rb', line 91

def framework?
  packaging == :framework
end

#inspectObject


129
130
131
# File 'lib/cocoapods/target/build_type.rb', line 129

def inspect
  "#<#{self.class} linkage=#{linkage} packaging=#{packaging}>"
end

#library?Boolean


97
98
99
# File 'lib/cocoapods/target/build_type.rb', line 97

def library?
  packaging == :library
end

#static?Boolean


85
86
87
# File 'lib/cocoapods/target/build_type.rb', line 85

def static?
  linkage == :static
end

#static_framework?Boolean


115
116
117
# File 'lib/cocoapods/target/build_type.rb', line 115

def static_framework?
  static? && framework?
end

#static_library?Boolean


121
122
123
# File 'lib/cocoapods/target/build_type.rb', line 121

def static_library?
  static? && library?
end

#to_sObject


125
126
127
# File 'lib/cocoapods/target/build_type.rb', line 125

def to_s
  "#{linkage} #{packaging}"
end