Skip to content

Rake for C, C++, Objective-C and Objective-C++ Projects

License

Notifications You must be signed in to change notification settings

blowback/rake-builder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rake-builder - Rake for C, C++, Objective-C and Objective-C++ Projects

rake-builder builds C, C++, Objective-C and Objective-C++ projects.

Here is a typical example:

require 'rubygems' if RUBY_VERSION < '1.9'
require 'rake'
require 'rake/builder'

Rake::Builder.new do |builder|
  builder.target               = 'my_program'
  builder.source_search_paths  = [ 'src' ]
  builder.header_search_paths  = [ 'include' ]
end

Installation

$ sudo gem install rake-builder

Hello World! Example

See the ‘examples’ directory.

The Hello World! project should build and run:

$ cd examples/01_hello_world_cpp
$ rake run
Hello World!

Usage

See the ‘examples’ directory.

If you’ve installed the gem system-wide, type the following to go to the correct directory:

$ cd `gem environment gemdir`/gems/rake-builder-nnn
$ cd examples

Project Configuration

In order to build on a specific computer, you will need to indicate information like non-standard include paths.

Rake::Builder collects all such information in one file: ‘.rake-builder’

For namespaced tasks, e.g. ‘test:build’, the file is ‘.rake-builer.test’

This file should be created in the same directory as the Rakefile.

The file should be a YAML structure, and must include a version.

Currently, the following can be configured:

  • extra include paths: :include_paths

Example ‘.rake-builder’

---
:rake_builder:
  :config_file:
    :version: "1.0"
:include_paths:
- /opt/local/include
- /usr/include/c++/4.2.1

Default Tasks

  • compile

  • build

  • run - executables only

  • install

  • clean

Installing Headers

If you install a static library, your headers will also be installed. Ensure that you use file globs, e.g. ‘./include/*/.h’, as these will ensure that your headers are installed in the correct subdirectories.

Online

Dependencies

Task dependencies must ensure that out of date files are recreated as needed.

Limitations

File Modification Times

Rake’s FileTask decides whether a file needs rebuilding by comparing on disk file modification times (see the private method out_of_date?, which returns true if the dependency was modified after the dependent). Unfortunately, most modern file systems hold modification times in whole seconds. If a dependency and a dependent were modificed during the same second, even if the dependency were modified later, out_of_date? returns false which is not the correct answer.

This problem is mostly felt in testing, where file modification times are temporarily modified to test dependencies. Also, tests wait for second to complete after building.

File Modification Time Resolutions

Source Files with the Same Name

Currently, object files from all source files are placed in the same directory. So, if there are two source files with the same name, they will overwrite each other.

Status

  • Builds C, C++ and Objective-C projects using GCC.

Alternatives

About

Rake for C, C++, Objective-C and Objective-C++ Projects

Resources

License

Stars

Watchers

Forks

Packages

No packages published