lib/rbplusplus/extension.rb in rbplusplus-0.1 vs lib/rbplusplus/extension.rb in rbplusplus-0.1.1

- old
+ new

@@ -52,20 +52,28 @@ attr_accessor :lib_paths # List of libraries to link attr_accessor :libraries + # List of extra CXXFLAGS that might need to be added to compile lines + attr_accessor :cxxflags + + # List of extra LDFLAGS that might need to be added to compile lines + attr_accessor :ldflags + # Create a new Ruby extension with a given name. This name will be # the module built into the extension. # This constructor can be standalone or take a block. def initialize(name, &block) @name = name @modules = [] @writer_mode = :multiple @includes = [] @lib_paths = [] @libraries = [] + @cxxflags = [] + @ldflags = [] if block build_working_dir(&block) block.call(self) build @@ -81,10 +89,12 @@ # Options can be the following: # # * <tt>:include_paths</tt> - An array or string of full paths to be added as -I flags # * <tt>:library_paths</tt> - An array or string of full paths to be added as -L flags # * <tt>:libraries</tt> - An array or string of full paths to be added as -l flags + # * <tt>:cxxflags</tt> - An array or string of flags to be added to command line for parsing / compiling + # * <tt>:ldflags</tt> - An array or string of flags to be added to command line for linking def sources(dirs, options = {}) parser_options = {} if (paths = options.delete(:include_paths)) @includes << paths @@ -97,10 +107,19 @@ if (libs = options.delete(:libraries)) @libraries << libs end + if (flags = options.delete(:cxxflags)) + @cxxflags << flags + parser_options[:cxxflags] = @cxxflags + end + + if (flags = options.delete(:ldflags)) + @ldflags << flags + end + @parser = RbGCCXML.parse(dirs, parser_options) end # Set a namespace to be the main namespace used for this extension. # Specifing a namespace on the Extension itself will mark functions, @@ -149,9 +168,11 @@ # Create the extconf.rb extconf = Writers::ExtensionWriter.new(@builder, @working_dir) extconf.includes = @includes extconf.library_paths = @lib_paths extconf.libraries = @libraries + extconf.cxxflags = @cxxflags + extconf.ldflags = @ldflags extconf.write end # Compile the extension. # This will create an rbpp_compile.log file in @working_dir. View this