2010-07-25 20:43:57 +00:00
|
|
|
class Library < Target
|
|
|
|
def initialize(name)
|
|
|
|
super name
|
|
|
|
@build_dll = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def build_dll(build_dll_as_well = true)
|
2018-04-08 10:09:30 +00:00
|
|
|
return self if !@only_if || (options.include?(:if) && !options[:if])
|
2010-07-25 20:43:57 +00:00
|
|
|
@build_dll = build_dll_as_well
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2018-04-08 10:09:30 +00:00
|
|
|
def create_specific_static
|
2010-07-25 20:43:57 +00:00
|
|
|
file "#{@target}.a" => @objects do |t|
|
2010-07-26 10:28:43 +00:00
|
|
|
FileUtils.rm_f t.name
|
2016-03-26 11:34:52 +00:00
|
|
|
runq "ar", t.name, "#{c(:AR)} rc #{t.name} #{@objects.join(" ")}"
|
|
|
|
runq "ranlib", t.name, "#{c(:RANLIB)} #{t.name}"
|
2010-07-25 20:43:57 +00:00
|
|
|
end
|
2018-04-08 10:09:30 +00:00
|
|
|
end
|
2010-07-25 20:43:57 +00:00
|
|
|
|
2018-04-08 10:09:30 +00:00
|
|
|
def create_specific_dll
|
2010-07-25 20:43:57 +00:00
|
|
|
file "#{@target}.dll" => @objects do |t|
|
2016-03-26 11:34:52 +00:00
|
|
|
runq "link", t.name, <<-COMMAND
|
2010-08-01 10:53:34 +00:00
|
|
|
#{c(:CXX)} #{$flags[:ldflags]} #{$system_libdirs} -shared -Wl,--export-all -Wl,--out-implib=#{t.name}.a -o #{t.name} #{@objects.join(" ")} #{@libraries.join(" ")}
|
2010-07-25 20:43:57 +00:00
|
|
|
COMMAND
|
|
|
|
end
|
2018-04-08 10:09:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create_specific
|
|
|
|
if @build_dll
|
|
|
|
create_specific_dll
|
|
|
|
else
|
|
|
|
create_specific_static
|
|
|
|
end
|
2010-07-25 20:43:57 +00:00
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
end
|