Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Ruby Programming Language

Using Rake to build C++


I'm making myself a build environment and found this Rake thingy that
seemed just to good to pass upon. But since I don't know any Ruby I'm
struggling a bit.

I'm making a couple of tasks to compile and link C++ code and it seems
like I've misunderstood the file task somewhat. In the example code
below, the compilation and linking is never run, what am I doing wrong?

cppTasks.rb:
def compileTask inclDirs, flags
  inclDirs = inclDirs.collect { |dir| '-I' + dir }
  inclDirs = inclDirs.join(' ')
  flags = flags.join(' ')

  SRC_FILES.each do |srcFile|
    objFile = File.join(OBJ_DIR, srcFile.pathmap("%f").ext('o'))
    file objFile => [srcFile] do
      sh "g++ #{inclDirs} #{flags} -c #{srcFile} -o #{objFile}"
    end
  end
end

def linkTask libDirs, libs, flags, target
  libDirs = libDirs.collect { |dir| '-L' + dir}
  libs = libs.collect { |lib| '-l' + (lib[/lib(.+)\./, 1])}

  flags = flags + ((File.extname(target) == '.so') ? ['-shared'] :
['-c'])

  libDirs = libDirs.join(' ')
  libs = libs.join(' ')
  flags = flags.join(' ')

  targetFile = File.join(BUILD_DIR, target)

  file targetFile => OBJ_FILES do
    objFiles = OBJ_FILES.collect { |objFile| objFile + ' ' }
    sh "g++ #{libDirs} #{libs} #{flags} #{objFiles} -o #{targetFile}"
  end
end

Cheers,
Magnus

--
Posted via http://www.ruby-forum.com/.

Oh, another thing while I'm at it. Is there any way to "export"
variables defined in one task to make them visible in other task?
Similar to  "antcall"
(http://ant.apache.org/manual/CoreTasks/antcall.html) with the flag
inheritAll.

I'm having problems with dependencies between variables and I would like
to have a little more control over when they are assigned instead of
just at the moment when they are imported.

--
Posted via http://www.ruby-forum.com/.

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc