Class: Teapot::Target
Instance Attribute Summary
Attributes inherited from Definition
#context, #description, #name, #package
Instance Method Summary
collapse
Methods included from Dependency
chain, #dependencies, #depends, #depends?, #provides, #provides?, #provisions
Methods inherited from Definition
#path, #to_s
Constructor Details
#initialize(context, package, name) ⇒ Target
Returns a new instance of Target.
33
34
35
36
37
|
# File 'lib/teapot/target.rb', line 33
def initialize(context, package, name)
super context, package, name
@build = nil
end
|
Instance Method Details
#build(&block) ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/teapot/target.rb', line 72
def build(&block)
if block_given?
@build = Proc.new(&block)
end
return @build
end
|
#build!(configuration) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/teapot/target.rb', line 80
def build!(configuration)
return unless @build
local_environment = environment_for_configuration(configuration)
@build.call(local_environment)
end
|
#builder ⇒ Object
39
40
41
|
# File 'lib/teapot/target.rb', line 39
def builder
Build.top(@path)
end
|
#environment_for_configuration(configuration) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/teapot/target.rb', line 43
def environment_for_configuration(configuration)
context = configuration.context
chain = Dependency::chain(context.selection, dependencies, context.targets.values)
environments = []
environments += chain.provisions.collect do |provision|
Environment.new(&provision.value)
end
environments << @package.options[:environment]
environment = Environment.combine(*environments)
environment.merge do
default platforms_path configuration.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
end
|
#run(&block) ⇒ Object
Specify a default block which is used to run the configuration.
89
90
91
92
93
94
95
|
# File 'lib/teapot/target.rb', line 89
def run(&block)
if block_given?
@run = block
end
return @run
end
|
#run!(configuration) ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'lib/teapot/target.rb', line 97
def run!(configuration)
return unless @run
local_environment = environment_for_configuration(configuration)
if @run
@run.call(local_environment)
end
end
|