Object
A buildable object like a library or executable
# File lib/makeconf/buildable.rb, line 10 def initialize(options) raise ArgumentError unless options.kind_of?(Hash) default = { :id => options[:id], :buildable => true, :distributable => true, :installable => true, :extension => '', :cflags => [], :ldflags => [], :ldadd => [], :rpath => '', :topdir => '', :depends => [], } default.each do |k,v| instance_variable_set('@' + k.to_s, v) end @output = id @output_type = nil # filled in by the derived class # Filled in by sources=() @sources = [] # Parse options # FIXME- consider adding support for: #%w{name enable distributable installable extension # topdir rpath} log.debug "Buildable options: " + options.pretty_inspect options.each do |k,v| log.debug "k=#{k} v=#{v.to_s}" case k when :id @id = v when :cc @cc = v when :cflags v = v.split(' ') if v.kind_of?(String) @cflags = v when :ldflags v = v.split(' ') if v.kind_of?(String) @ldflags = v when :ldadd v = v.split(' ') if v.kind_of?(String) @ldadd = v when :project @project = v when :buildable @buildable = v when :sources v = [ v ] if v.kind_of?(String) @sources = v else throw "Unrecognized option -- #{k}: #{v}" end end log.debug "Buildable parsed as: " + self.pretty_inspect #FIXME: move some of these to the switch statement # # Parse simple textual child elements # %w{cflags ldflags ldadd depends sources}.each do |k| # instance_variable_set('@' + k, yaml[k]) if yaml.has_key? k # end end
# File lib/makeconf/buildable.rb, line 122 def binary? @output_type =~ /binary/ end
# File lib/makeconf/androidproject.rb, line 361 def compile(cc) end
# File lib/makeconf/buildable.rb, line 79 def expand_sources(x) log.info "expanding [#{x.to_s}] to source file list" raise ArgumentError('Wrong type') unless x.is_a? Array # Use glob(3) to expand the list of sources buf = [] x.each do |src| if src =~ /\*/ buf << Dir.glob(src) else buf.push src end end buf.flatten # TODO: elsewhere # Ensure that all source files exist #@sources.each do |src| # throw ArgumentError("#{src} does not exist") unless File.exist? src # end end
Install the output file(s)
# File lib/makeconf/buildable.rb, line 130 def install(installer) # By default, this does nothing. # Derived classes are expected to override this method. end
# File lib/makeconf/buildable.rb, line 107 def library? @output_type == 'shared library' or @output_type == 'static library' end
# File lib/makeconf/buildable.rb, line 111 def library_type case @output_type when 'shared library' return :shared when 'static library' return :static else throw 'Not a library' end end
Return a hash containing Makefile dependencies
# File lib/makeconf/buildable.rb, line 215 def makedepends res = [] if @sources.nil? log.error self.to_s raise 'Missing sources' end # Generate the targets and rules for each translation unit expand_sources(@sources).each do |src| next if src =~ /\.o$/ cc = @project.cc cc.flags = [ @cflags, '-E' ] cc.output = '-' cc.sources = src #TODO: topdir cmd = cc.command + Platform.dev_null_stderr end res end
Last chance to put things into the Makefile
# File lib/makeconf/buildable.rb, line 141 def makefile_hook(makefile) # STUB end
Generated with the Darkfish Rdoc Generator 2.