BuildrForC

Concepts

  • Maven compatible repo
  • Installs dependencies to local repo
    • need an 'install' task that extracts packages (and generates include paths?)
  • Sets a JAVA CLASSPATH. Use this for the Linker and Include paths?

Example

Header only project

repositories.remote << 'file:///deploy-test/repo'
repositories.release_to = 'file:///deploy-test/repo'

define 'Base' do
    task :default => :package
    task :compile do
    end

    project.group = :Modular
    project.version = '1.0'
    package.include(_('Enum'))
    package.exclude('/.git', '/.svn')
    package :zip
end

$[Get Code]1

Shared library projec

require 'buildr/gcc'

repositories.remote << 'file:///deploy-test/repo'
repositories.release_to = 'file:///deploy-test/repo'

BASE = transitive('Modular:Base:zip:1.0')

DEPS = BASE

API = ['inc', 'lib']
EXCLUDE = ['*.swp']
SRC = ['src']

my_layout = Layout.new
my_layout[:source, :main, :c] = 'src'
my_layout[:target, :main, :obj] = 'obj'

define 'Slave', :layout=>my_layout do
    package_with_sources
    project.version = '1.1'
    project.group = :Modular
    compile.using(:gcc)
    compile.with BASE

    package :zip
    package.include(API)
    package.exclude(EXCLUDE)

    #package(:sources).include(API,SRC)
    #package(:sources).exclude(EXCLUDE)
end

$[Get Code]2

Application

repositories.remote << 'file:///deploy-test/repo'
repositories.release_to = 'file:///deploy-test/repo'

SLAVE = transitive('Slave:Slave:zip:1.1')

DEPS = SLAVE

define 'SomeApp' do
        project.version = '0.1.0'
        compile.with DEPS
        package :zip

        build do
                system "cc -I../Base/ -I../Slave/inc -Iinc ../Slave/lib/slave.o src/someapp.c -o someapp.out"
        end
end

$[Get Code]3