Class: Teapot::Target
- Inherits:
-
Object
- Object
- Teapot::Target
- Includes:
- Dependency
- Defined in:
- lib/teapot/target.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #builder ⇒ Object
-
#initialize(context, package, name) ⇒ Target
constructor
A new instance of Target.
- #install(&block) ⇒ Object
- #install!(context, config = {}) ⇒ Object
- #to_s ⇒ Object
Methods included from Dependency
chain, #dependencies, #depends, #depends?, #provides, #provides?, #provisions
Constructor Details
#initialize(context, package, name) ⇒ Target
Returns a new instance of Target.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/teapot/target.rb', line 32 def initialize(context, package, name) @context = context @package = package @name = name @install = nil @path = @package.path end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
43 44 45 |
# File 'lib/teapot/target.rb', line 43 def context @context end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
45 46 47 |
# File 'lib/teapot/target.rb', line 45 def name @name end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
44 45 46 |
# File 'lib/teapot/target.rb', line 44 def package @package end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
47 48 49 |
# File 'lib/teapot/target.rb', line 47 def path @path end |
Instance Method Details
#install(&block) ⇒ Object
53 54 55 |
# File 'lib/teapot/target.rb', line 53 def install(&block) @install = Proc.new(&block) end |
#install!(context, config = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/teapot/target.rb', line 57 def install!(context, config = {}) return unless @install chain = Dependency::chain(context.selection, dependencies, context.targets.values) environments = [] # The base configuration environment: environments << context.config.environment # Calculate the dependency chain's ordered environments: environments += chain.provisions.collect do |provision| Environment.new(&provision.value) end # Per-configuration package package environment: environments << @package.[:environment] # Merge all the environments together: environment = Environment.combine(*environments) local_build = environment.merge do default platforms_path context.config.platforms_path default build_prefix {platforms_path + "cache/#{platform_name}-#{variant}"} default install_prefix {platforms_path + "#{platform_name}-#{variant}"} append buildflags {"-I#{install_prefix + "include"}"} append linkflags {"-L#{install_prefix + "lib"}"} end @install.call(local_build) end |
#to_s ⇒ Object
90 91 92 |
# File 'lib/teapot/target.rb', line 90 def to_s "<Target: #{@name}>" end |