Skip to content

Instantly share code, notes, and snippets.

@tomas-stefano
Created October 31, 2010 22:41
Show Gist options
  • Select an option

  • Save tomas-stefano/657269 to your computer and use it in GitHub Desktop.

Select an option

Save tomas-stefano/657269 to your computer and use it in GitHub Desktop.
Rakefile from a C Library and Cgreen Tests
#
# Rakefile with a C Library with the following tree:
#├── library
#│   ├── something.c
#│   └── something.h
#├── specifications
#│   ├── all_specifications.c
#│   ├── all_specifications.o
#│   ├── something_spec.c
#│   └── something_spec.o
#
#
require 'rake/clean'
CLEAN.include('specifications/*.o', 'library/*.o')
CLOBBER.include('specifications')
SOURCE = FileList['library/*.c']
OBJECT_SOURCE = SOURCE.ext('o')
TEST_SOURCE = FileList['specifications/*.c']
OBJECT_SOURCE_TEST = TEST_SOURCE.ext('o')
file OBJECT_SOURCE_TEST => OBJECT_SOURCE do |t|
sh "cc -Wall -I library -c -o #{t.name} #{t.source}"
end
desc 'Generate the binary Runner of Specifications'
file 'specifications' => OBJECT_SOURCE_TEST do
sh "cc -Wall -o specifications -lcgreen #{OBJECT_SOURCE_TEST}"
end
rule '.o' => '.c' do |t|
sh "cc -Wall -I library -c -o #{t.name} #{t.source}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment