Class: Teapot::Build::Targets::Library
Instance Attribute Summary collapse
#parent
Instance Method Summary
collapse
#install_prefix!
Methods included from Compiler
#build_prefix!, #compile, #compile!, #link_prefix!
#configure, #execute, #root, target
Constructor Details
#initialize(parent, name, options = {}) ⇒ Library
Returns a new instance of Library.
38
39
40
41
42
43
|
# File 'lib/teapot/build/targets/library.rb', line 38
def initialize(parent, name, options = {})
super parent
@name = name
@options = options
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
45
46
47
|
# File 'lib/teapot/build/targets/library.rb', line 45
def options
@options
end
|
Instance Method Details
#build(environment) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/teapot/build/targets/library.rb', line 93
def build(environment)
prefix = install_prefix!(environment)
compile_and_link(environment).each do |path|
destination_path = prefix + subdirectory + path.basename
destination_path.dirname.mkpath
FileUtils.cp(path, destination_path, :preserve => true)
end
if self.respond_to? :headers
install_file_list(self.(environment), prefix + "include")
end
end
|
#compile_and_link(environment) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/teapot/build/targets/library.rb', line 67
def compile_and_link(environment)
file_list = self.source_files(environment)
pool = Commands::Pool.new
objects = file_list.collect do |source_file|
relative_path = source_file.relative_path_from(file_list.root)
compile(environment, file_list.root, relative_path, pool)
end
pool.wait
return Array link(environment, objects)
end
|
#dependent_libraries(environment) ⇒ Object
#install_file_list(file_list, prefix) ⇒ Object
83
84
85
86
87
88
89
90
91
|
# File 'lib/teapot/build/targets/library.rb', line 83
def install_file_list(file_list, prefix)
file_list.each do |path|
relative_path = path.relative_path_from(file_list.root)
destination_path = prefix + file_list.prefix + relative_path
destination_path.dirname.mkpath
FileUtils.cp(path, destination_path, :preserve => true)
end
end
|
#link(environment, objects) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/teapot/build/targets/library.rb', line 55
def link(environment, objects)
library_file = link_prefix!(environment) + "lib#{@name}.a"
graph = Build::dependency_graph(environment)
if graph.regenerate?(library_file, objects + dependent_libraries(environment))
Linker.link_static(environment, library_file, objects)
end
return library_file
end
|
#subdirectory ⇒ Object
47
48
49
|
# File 'lib/teapot/build/targets/library.rb', line 47
def subdirectory
options[:subdirectory] || "lib"
end
|