rake-builder 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES ADDED
@@ -0,0 +1,5 @@
1
+ = Rake::Cpp Changelog
2
+
3
+ == Version 0.0.1
4
+
5
+ * Initial version
data/COPYING ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Joe Yates
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,105 @@
1
+ = rake-builder - Rake for C/C++/Objective-C/Objective-C++ Projects
2
+
3
+ rake-builder provides a simple interface for building C, C++,
4
+ Objective-C and Objective-C++ projects.
5
+ It uses rake, which was created as a make replacement,
6
+ and specializes it for the specific purpose of compiling
7
+ single projects.
8
+
9
+ Projects are managed and built via a 'Rakefile'.
10
+
11
+ Here is a typical example:
12
+
13
+ require 'rubygems' if RUBY_VERSION < '1.9'
14
+ require 'rake'
15
+ require 'rake/builder'
16
+
17
+ Rake::Builder.new do |builder|
18
+ builder.target = 'my_program'
19
+ builder.source_search_paths = [ 'src' ]
20
+ builder.header_search_paths = [ 'include' ]
21
+ end
22
+
23
+ = Installation
24
+
25
+ $ sudo gem install rake-builder
26
+
27
+ = Hello World! Example
28
+
29
+ See the 'examples' directory.
30
+
31
+ The Hello World! project should build and run:
32
+
33
+ $ cd examples/01_hello_world_cpp
34
+ $ rake run
35
+ Hello World!
36
+
37
+ = Usage
38
+
39
+ See the 'examples' directory.
40
+
41
+ If you've installed the gem system-wide, type the following to go to
42
+ the correct directory:
43
+
44
+ $ cd `gem environment gemdir`/gems/rake-builder/examples
45
+
46
+ = Tasks
47
+
48
+ You can list tasks as follows:
49
+
50
+ $ rake -T
51
+ rake build # Compile and build 'hello-world'
52
+ rake clean # Remove temporary files
53
+ rake compile # Compile all sources
54
+ rake default # Equivalent to 'rake build'
55
+ rake run # Run 'hello-world'
56
+
57
+ = Online
58
+
59
+ * 'Source code'[http://github.com/joeyates/rake-builder]
60
+ * Documentation[http://rdoc.info/projects/joeyates/rake-builder]
61
+ * Gem[http://rubygems.org/gems/rake-builder]
62
+
63
+ = Limitations
64
+
65
+ == File Modification Times
66
+
67
+ Rake's FileTask decides whether a file needs rebuilding by comparing on disk file
68
+ modification times (see the private method <em>out_of_date?</em>, which returns true if the
69
+ dependency was modified *after* the dependent).
70
+ Unfortunately, most modern file systems hold modification times in whole
71
+ seconds. If a dependency and a dependent were modificed during the same second,
72
+ <b>even if the dependency were modified later</b>, <em>out_of_date?</em> gives *false*
73
+ which is not the correct answer.
74
+
75
+ This problem is mostly felt in testing, where file modification times are temporarily
76
+ modified to test dependencies. Also, tests wait for second to complete after building.
77
+
78
+ === File Modification Time Resolutions
79
+
80
+ * Ext3[http://en.wikipedia.org/wiki/Ext3] - resolution: 1s
81
+ * Ext4[http://en.wikipedia.org/wiki/Ext4] - resolution: 1 microsecond
82
+ * Hierarchical_File_System[http://en.wikipedia.org/wiki/Hierarchical_File_System] - resolution: 1s
83
+ * HFS_Plus[http://en.wikipedia.org/wiki/HFS_Plus] - resolution: 1s
84
+
85
+ == Source Files with the Same Name
86
+
87
+ Currently, object files from all source files are placed in the same directory.
88
+ So, if there are two source files with the same name, they will overwrite each other.
89
+
90
+ = Status
91
+
92
+ * Builds C and C++ projects using gcc
93
+
94
+ = Alternatives
95
+
96
+ * make
97
+ * CMake
98
+ * Boost.Build
99
+ * rakepp - another take on using rake for c++ projects
100
+
101
+ = TODO
102
+
103
+ * Objective-C/Objective-C++ builds
104
+ * pre-compiled headers
105
+ * parallel builds
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+ require 'rake'
3
+ require 'rake/gempackagetask'
4
+ require 'spec/rake/spectask'
5
+ require 'rake/rdoctask'
6
+ $:.unshift( File.dirname( __FILE__ ) + '/lib' )
7
+ require 'rake/builder'
8
+
9
+ ADMIN_FILES = FileList[ 'CHANGES', 'COPYING', 'Rakefile', 'README.rdoc' ]
10
+ SOURCE_FILES = FileList[ 'lib/**/*.rb' ]
11
+ SPEC_FILES = FileList[ 'spec/**/*' ]
12
+ EXAMPLE_EXTRA_FILES = FileList[ 'examples/README.rdoc' ] + FileList[ 'examples/**/Rakefile' ]
13
+ EXAMPLE_SOURCE_FILES = FileList[ 'examples/**/*.{h,c,cpp,m}' ]
14
+ RDOC_FILES = FileList[ 'COPYING', 'README.rdoc' ] + SOURCE_FILES + EXAMPLE_EXTRA_FILES
15
+ RDOC_OPTS = [ '--quiet', '--main', 'README.rdoc', '--inline-source' ]
16
+
17
+ spec = Gem::Specification.new do |s|
18
+ s.name = 'rake-builder'
19
+ s.summary = 'Rake for C/C++ Projects'
20
+ s.description = 'Provides Rake:Builder, a specific rake TaskLib for building C, C++, Objective-C and Objective-C++ projects'
21
+ s.version = Rake::Builder::VERSION::STRING
22
+
23
+ s.homepage = 'http://github.com/joeyates/rake-builder'
24
+ s.author = 'Joe Yates'
25
+ s.email = 'joe.g.yates@gmail.com'
26
+
27
+ s.files = ADMIN_FILES +
28
+ SOURCE_FILES +
29
+ EXAMPLE_SOURCE_FILES +
30
+ EXAMPLE_EXTRA_FILES
31
+ s.require_paths = [ 'lib' ]
32
+ s.add_dependency( 'rake', '>= 0.8.7' )
33
+
34
+ s.has_rdoc = true
35
+ s.rdoc_options += RDOC_OPTS
36
+ s.extra_rdoc_files = RDOC_FILES
37
+
38
+ s.test_files = SPEC_FILES
39
+ end
40
+
41
+ Rake::GemPackageTask.new( spec ) do |pkg|
42
+ end
43
+
44
+ Spec::Rake::SpecTask.new do |t|
45
+ t.spec_files = FileList[ 'spec/**/*_spec.rb' ]
46
+ t.spec_opts += [ '--color', '--format specdoc' ]
47
+ end
48
+
49
+ Spec::Rake::SpecTask.new( 'spec:rcov' ) do |t|
50
+ t.spec_files = FileList[ 'spec/**/*_spec.rb' ]
51
+ t.rcov = true
52
+ t.rcov_opts = [ '--exclude spec' ]
53
+ end
54
+
55
+ Rake::RDocTask.new do |rdoc|
56
+ rdoc.rdoc_dir = 'html'
57
+ rdoc.options += RDOC_OPTS
58
+ rdoc.title = 'Rake for C/C++/Objective-C/Objective-C++ Projects'
59
+ rdoc.rdoc_files.add RDOC_FILES
60
+ end
@@ -0,0 +1,13 @@
1
+ =begin
2
+
3
+ = A Minimal Example for Rake-Builder
4
+
5
+ =end
6
+
7
+ require 'rubygems' if RUBY_VERSION < '1.9'
8
+ require 'rake'
9
+ require 'rake/builder'
10
+
11
+ Rake::Builder.new do |builder|
12
+ builder.target = 'hello_world_cpp'
13
+ end
@@ -0,0 +1,7 @@
1
+ #include <iostream>
2
+
3
+ int main(int argc, char *argv[]) {
4
+ std::cout << "Hello World!\n";
5
+
6
+ return 0;
7
+ }
@@ -0,0 +1,8 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+ require 'rake'
3
+ require 'rake/builder'
4
+
5
+ Rake::Builder.new do |builder|
6
+ builder.target = 'hello_world_c'
7
+ builder.programming_language = 'c'
8
+ end
@@ -0,0 +1,7 @@
1
+ #include <stdio.h>
2
+
3
+ int main(int argc, char *argv[]) {
4
+ printf( "Hello World!\n" );
5
+
6
+ return 0;
7
+ }
@@ -0,0 +1,10 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+ require 'rake'
3
+ require 'rake/builder'
4
+
5
+ Rake::Builder.new do |builder|
6
+ builder.target = 'search-paths'
7
+ builder.source_search_paths = [ 'src' ]
8
+ builder.header_search_paths = [ 'include' ]
9
+ builder.objects_path = '.'
10
+ end
@@ -0,0 +1,7 @@
1
+ #ifndef __MAIN_H__
2
+ #define __MAIN_H__
3
+
4
+ #include <stdio.h>
5
+ #include <dirent.h>
6
+
7
+ #endif // ndef __MAIN_H__
@@ -0,0 +1,17 @@
1
+ #include "main.h"
2
+
3
+ int main( int argc, char *argv[] ) {
4
+ printf( "The complete contents of this directory:\n" );
5
+
6
+ DIR *directory = opendir( "." );
7
+ if( directory == NULL ) {
8
+ puts( "Can't read directory" );
9
+ return 1;
10
+ }
11
+ while( struct dirent * file = readdir( directory ) ) {
12
+ puts( file->d_name );
13
+ }
14
+ closedir( directory );
15
+
16
+ return 0;
17
+ }
@@ -0,0 +1,13 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+ require 'rake'
3
+ require 'rake/builder'
4
+
5
+ Rake::Builder.new do |builder|
6
+ builder.target = 'zlib'
7
+ builder.programming_language = 'c'
8
+ builder.source_search_paths = [ 'src' ]
9
+ builder.header_search_paths = [ 'include' ]
10
+ builder.objects_path = '.'
11
+ builder.library_dependencies << 'z'
12
+ builder.generated_files << 'rake.gz'
13
+ end
@@ -0,0 +1,7 @@
1
+ #ifndef __MAIN_H__
2
+ #define __MAIN_H__
3
+
4
+ #include <stdio.h>
5
+ #include <zlib.h>
6
+
7
+ #endif // ndef __MAIN_H__
@@ -0,0 +1,11 @@
1
+ #include "main.h"
2
+
3
+ int main( int argc, char *argv[] ) {
4
+ gzFile gzip;
5
+
6
+ gzip = gzopen("rake.gz", "w");
7
+ gzprintf( gzip, "Hello!" );
8
+ gzclose( gzip );
9
+
10
+ return 0;
11
+ }
@@ -0,0 +1,19 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+ require 'rake'
3
+ require 'rake/builder'
4
+
5
+ Rake::Builder.new do |builder|
6
+ builder.target = 'unit'
7
+ builder.source_search_paths = [ 'src' ]
8
+ builder.header_search_paths = [ 'include' ]
9
+ end
10
+
11
+ Rake::Builder.new do |builder|
12
+ builder.task_namespace = 'test'
13
+ builder.target = 'test_unit'
14
+ builder.source_search_paths = [ 'test', 'src/units.*' ]
15
+ builder.header_search_paths = [ 'include' ]
16
+ builder.objects_path = 'test'
17
+ builder.compilation_options = '-DDEBUG'
18
+ end
19
+
@@ -0,0 +1,7 @@
1
+ #ifndef __MAIN_H__
2
+ #define __MAIN_H__
3
+
4
+ #include <iostream>
5
+ using namespace std;
6
+
7
+ #endif // ndef __MAIN_H__
@@ -0,0 +1,18 @@
1
+ #ifndef __UNITS_H__
2
+ #define __UNITS_H__
3
+
4
+ #include <ostream>;
5
+ #include <string>;
6
+ using namespace std;
7
+
8
+ class Unit
9
+ {
10
+ friend ostream &operator<<( ostream &out, Unit &unit );
11
+ public:
12
+ Unit() : name( "Mile" ) {}
13
+ string to_string();
14
+ private:
15
+ string name;
16
+ };
17
+
18
+ #endif // ndef __UNITS_H__
@@ -0,0 +1,9 @@
1
+ #include "main.h"
2
+ #include "units.h"
3
+
4
+ int main( int argc, char *argv[] ) {
5
+ Unit unit;
6
+ cout << unit << endl;
7
+
8
+ return 0;
9
+ }
@@ -0,0 +1,13 @@
1
+ #include "units.h"
2
+
3
+ ostream &operator<<( ostream &out, Unit &unit )
4
+ {
5
+ out << unit.name;
6
+ return out;
7
+ }
8
+
9
+ string Unit::to_string()
10
+ {
11
+ return name;
12
+ }
13
+
@@ -0,0 +1,12 @@
1
+ #include <assert.h>
2
+ #include <iostream>
3
+ #include "units.h"
4
+
5
+ int main( int argc, char *argv[] ) {
6
+ Unit unit;
7
+ assert( unit.to_string() == "Mile" );
8
+ cout << "." << endl;
9
+ cout << "All tests passed" << endl;
10
+
11
+ return 0;
12
+ }
@@ -0,0 +1,9 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+ require 'rake'
3
+ require 'rake/builder'
4
+
5
+ Rake::Builder.new do |builder|
6
+ builder.target = 'hello_world_objective_c'
7
+ builder.programming_language = 'objective-c'
8
+ builder.library_dependencies = ''
9
+ end
@@ -0,0 +1,7 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ int main(void)
4
+ {
5
+ // NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
6
+ NSString *hello = @"Hello World!";
7
+ }
@@ -0,0 +1,33 @@
1
+ = Examples
2
+
3
+ == 1. Hello World! in C++
4
+
5
+ The Hello World! project should build and run as follows:
6
+
7
+ $ cd 01_hello_world_cpp
8
+ $ rake run
9
+ Hello World!
10
+
11
+ This is the simplest possible type of project:
12
+ - Only one source file,
13
+ - Rakefile and source file in the same directory,
14
+ - no non-standard header or library dependencies.
15
+
16
+ == 2. Hello World! in C
17
+
18
+ Same as the above, but for C.
19
+
20
+ == 3. Search Paths
21
+
22
+ Source files and headers in different directories
23
+
24
+ == 4. Zlib
25
+
26
+ Library dependencies.
27
+
28
+ == 5. Main Project and Tests
29
+
30
+ In this case, there are two build projects,
31
+ one for the main executable and one for tests.
32
+
33
+ The tests are in the 'test' namespace.