rake-builder 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,4 +1,4 @@
1
- = Rake::Cpp Changelog
1
+ = Rake::Builder Changelog
2
2
 
3
3
  == Version 0.0.1
4
4
 
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = rake-builder - Rake for C/C++/Objective-C/Objective-C++ Projects
1
+ = rake-builder - Rake for C, C++, Objective-C and Objective-C++ Projects
2
2
 
3
3
  rake-builder builds C, C++, Objective-C and Objective-C++
4
4
  projects.
@@ -125,7 +125,9 @@ So, if there are two source files with the same name, they will overwrite each o
125
125
 
126
126
  = Alternatives
127
127
 
128
- * make
129
- * CMake
128
+ * GNU build system, a.k.a. Autotools: autoconf, configure, make, etc.
130
129
  * Boost.Build
130
+ * CMake
131
131
  * rakepp - another customisation of Rake for C++ projects
132
+ * Scons
133
+ * waf[http://code.google.com/p/waf/]
data/lib/rake/builder.rb CHANGED
@@ -2,25 +2,15 @@ require 'rubygems' if RUBY_VERSION < '1.9'
2
2
  require 'logger'
3
3
  require 'rake'
4
4
  require 'rake/tasklib'
5
+ require 'rake/path'
6
+ require 'rake/file_task_alias'
5
7
 
6
8
  module Rake
7
9
 
8
- # A task whose behaviour depends on a FileTask
9
- class FileTaskAlias < Task
10
-
11
- attr_accessor :target
12
-
13
- def self.define_task( name, target, &block )
14
- alias_task = super( { name => [] }, &block )
15
- alias_task.target = target
16
- alias_task.prerequisites.unshift( target )
17
- alias_task
18
- end
19
-
20
- def needed?
21
- Rake::Task[ @target ].needed?
10
+ class Formatter < Logger::Formatter
11
+ def call(severity, time, progname, msg)
12
+ msg2str(msg) << "\n"
22
13
  end
23
-
24
14
  end
25
15
 
26
16
  # Error indicating that the project failed to build.
@@ -32,25 +22,11 @@ module Rake
32
22
  module VERSION #:nodoc:
33
23
  MAJOR = 0
34
24
  MINOR = 0
35
- TINY = 10
25
+ TINY = 11
36
26
 
37
27
  STRING = [ MAJOR, MINOR, TINY ].join('.')
38
28
  end
39
29
 
40
- # Expand path to an absolute path relative to the supplied root
41
- def self.expand_path_with_root( path, root )
42
- if path =~ /^\//
43
- File.expand_path( path )
44
- else
45
- File.expand_path( root + '/' + path )
46
- end
47
- end
48
-
49
- # Expand an array of paths to absolute paths relative to the supplied root
50
- def self.expand_paths_with_root( paths, root )
51
- paths.map{ |path| expand_path_with_root( path, root ) }
52
- end
53
-
54
30
  # The file to be built
55
31
  attr_accessor :target
56
32
 
@@ -91,7 +67,7 @@ module Rake
91
67
  # The linker that will be used
92
68
  attr_accessor :linker
93
69
 
94
- # Extension of source files (default 'cpp' for C++ and 'c' fo C)
70
+ # Extension of source files (default 'cpp' for C++ and 'c' for C)
95
71
  attr_accessor :source_file_extension
96
72
 
97
73
  # Extension of header files (default 'h')
@@ -111,12 +87,12 @@ module Rake
111
87
 
112
88
  # Directories/file globs to search for header files
113
89
  # When static libraries are installed,
114
- # headers are install too.
90
+ # headers are installed too.
115
91
  # During installation, the destination path is:
116
92
  # /usr/local/include + the relative path
117
93
  # This 'relative path' is calculated as follows:
118
- # 1. Named files are installed directly under /usr/local/include
119
- # 2. Files found by directory are also installed directly under /usr/local/include
94
+ # 1. Any files named in header_search_paths are installed directly under /usr/local/include
95
+ # 2. The contents of any directory named in header_search_paths are also installed directly under /usr/local/include
120
96
  # 3. Files found by glob have the fixed part of the glob removed and
121
97
  # the relative path calculated:
122
98
  # E.g. files found with './include/**/*' will have './include' removed to calculate the
@@ -137,7 +113,7 @@ module Rake
137
113
  # Directory to be used for object files
138
114
  attr_accessor :objects_path
139
115
 
140
- # extra options to pass to the compiler
116
+ # Array of extra options to pass to the compiler
141
117
  attr_accessor :compilation_options
142
118
 
143
119
  # Additional include directories for compilation
@@ -165,7 +141,7 @@ module Rake
165
141
  attr_accessor :logger
166
142
 
167
143
  def initialize( &block )
168
- save_rakefile_info( caller[0] )
144
+ save_rakefile_info( block )
169
145
  initialize_attributes
170
146
  block.call( self )
171
147
  configure
@@ -177,17 +153,20 @@ module Rake
177
153
 
178
154
  # Source files found in source_search_paths
179
155
  def source_files
180
- @source_fies ||= find_files( @source_search_paths, @source_file_extension )
156
+ @source_files ||= find_files( @source_search_paths, @source_file_extension ).uniq
157
+ @source_files
181
158
  end
182
159
 
183
160
  # Header files found in header_search_paths
184
161
  def header_files
185
- @header_files ||= find_files( @header_search_paths, @header_file_extension )
162
+ @header_files ||= find_files( @header_search_paths, @header_file_extension ).uniq
163
+ @header_files
186
164
  end
187
165
 
188
166
  def initialize_attributes
189
167
  @logger = Logger.new( STDOUT )
190
168
  @logger.level = Logger::UNKNOWN
169
+ @logger.formatter = Formatter.new
191
170
  @programming_language = 'c++'
192
171
  @header_file_extension = 'h'
193
172
  @objects_path = @rakefile_path.dup
@@ -198,6 +177,7 @@ module Rake
198
177
  @header_search_paths = [ @rakefile_path.dup ]
199
178
  @target = 'a.out'
200
179
  @generated_files = []
180
+ @compilation_options = []
201
181
  end
202
182
 
203
183
  def configure
@@ -207,22 +187,21 @@ module Rake
207
187
  @linker ||= KNOWN_LANGUAGES[ @programming_language ][ :linker ]
208
188
  @source_file_extension ||= KNOWN_LANGUAGES[ @programming_language ][ :source_file_extension ]
209
189
 
210
- @source_search_paths = Rake::Builder.expand_paths_with_root( @source_search_paths, @rakefile_path )
211
- @header_search_paths = Rake::Builder.expand_paths_with_root( @header_search_paths, @rakefile_path )
212
- @library_paths = Rake::Builder.expand_paths_with_root( @library_paths, @rakefile_path )
190
+ @source_search_paths = Rake::Path.expand_all_with_root( @source_search_paths, @rakefile_path )
191
+ @header_search_paths = Rake::Path.expand_all_with_root( @header_search_paths, @rakefile_path )
192
+ @library_paths = Rake::Path.expand_all_with_root( @library_paths, @rakefile_path )
213
193
 
214
194
  raise "The target name cannot be nil" if @target.nil?
215
195
  raise "The target name cannot be an empty string" if @target == ''
216
- @objects_path = Rake::Builder.expand_path_with_root( @objects_path, @rakefile_path )
217
- @target = Rake::Builder.expand_path_with_root( @target, @objects_path )
196
+ @objects_path = Rake::Path.expand_with_root( @objects_path, @rakefile_path )
197
+ @target = Rake::Path.expand_with_root( @target, @objects_path )
218
198
  @target_type ||= type( @target )
219
199
  raise "Building #{ @target_type } targets is not supported" if ! TARGET_TYPES.include?( @target_type )
220
200
  @install_path ||= default_install_path( @target_type )
221
201
 
222
- @compilation_options ||= ''
223
202
  @linker_options ||= ''
224
203
  @include_paths ||= @header_search_paths.dup
225
- @generated_files = Rake::Builder.expand_paths_with_root( @generated_files, @rakefile_path )
204
+ @generated_files = Rake::Path.expand_all_with_root( @generated_files, @rakefile_path )
226
205
 
227
206
  @default_task ||= :build
228
207
  @target_prerequisites << @rakefile
@@ -231,7 +210,7 @@ module Rake
231
210
 
232
211
  load_local_config
233
212
 
234
- @include_paths = Rake::Builder.expand_paths_with_root( @include_paths, @rakefile_path )
213
+ @include_paths = Rake::Path.expand_all_with_root( @include_paths, @rakefile_path )
235
214
 
236
215
  raise "No source files found" if source_files.length == 0
237
216
  end
@@ -239,7 +218,7 @@ module Rake
239
218
  def local_config
240
219
  filename = '.rake-builder'
241
220
  filename += '.' + @task_namespace.to_s if @task_namespace
242
- Rake::Builder.expand_path_with_root( filename, @rakefile_path )
221
+ Rake::Path.expand_with_root( filename, @rakefile_path )
243
222
  end
244
223
 
245
224
  def load_local_config
@@ -290,16 +269,7 @@ module Rake
290
269
  desc "Build '#{ target_basename }'"
291
270
  file @target => [ scoped_task( :compile ), *@target_prerequisites ] do |t|
292
271
  shell "rm -f #{ t.name }"
293
- case @target_type
294
- when :executable
295
- shell "#{ @linker } #{ link_flags } -o #{ @target } #{ file_list( object_files ) }"
296
- when :static_library
297
- @logger.add( Logger::INFO, "Builing library '#{ t.name }'" )
298
- shell "ar -cq #{ t.name } #{ file_list( object_files ) }"
299
- when :shared_library
300
- @logger.add( Logger::INFO, "Builing library '#{ t.name }'" )
301
- shell "#{ @linker } -shared -o #{ t.name } #{ file_list( object_files ) } #{ link_flags }"
302
- end
272
+ shell build_command
303
273
  raise BuildFailureError if ! File.exist?( t.name )
304
274
  end
305
275
 
@@ -309,12 +279,7 @@ module Rake
309
279
  task :compile => [ @makedepend_file, scoped_task( :load_makedepend ), *object_files ]
310
280
 
311
281
  source_files.each do |src|
312
- object = object_path( src )
313
- @generated_files << object
314
- file object => [ src ] do |t|
315
- @logger.add( Logger::INFO, "Compiling '#{ src }'" )
316
- shell "#{ @compiler } #{ compiler_flags } -c -o #{ object } #{ src }"
317
- end
282
+ define_compile_task( src )
318
283
  end
319
284
 
320
285
  file @makedepend_file => [ *project_files ] do
@@ -328,7 +293,7 @@ module Rake
328
293
  # the standard rake mkdepend loader doesn't do what we want,
329
294
  # as it assumes files will be compiled in their own directory.
330
295
  task :load_makedepend => @makedepend_file do
331
- object_to_source = source_files.inject( {} ) do |memo, source|
296
+ object_to_source = source_files.inject( {} ) do | memo, source |
332
297
  mapped_object = source.gsub( '.' + @source_file_extension, '.o' )
333
298
  memo[ mapped_object ] = source
334
299
  memo
@@ -348,14 +313,14 @@ module Rake
348
313
 
349
314
  desc "List generated files (which are removed with 'rake #{ scoped_task( :clean ) }')"
350
315
  task :generated_files do
351
- puts @generated_files.inspect
316
+ puts generated_files.inspect
352
317
  end
353
318
 
354
319
  # Re-implement :clean locally for project and within namespace
355
320
  # Standard :clean is a singleton
356
321
  desc "Remove temporary files"
357
322
  task :clean do
358
- @generated_files.each do |file|
323
+ generated_files.each do |file|
359
324
  shell "rm -f #{ file }"
360
325
  end
361
326
  end
@@ -372,7 +337,7 @@ module Rake
372
337
 
373
338
  desc "Uninstall '#{ target_basename }' from '#{ @install_path }'"
374
339
  task :uninstall, [] => [] do
375
- destination = File.join( @install_path, File.basename( @target ) )
340
+ destination = File.join( @install_path, target_basename )
376
341
  if ! File.exist?( destination )
377
342
  @logger.add( Logger::INFO, "The file '#{ destination }' does not exist" )
378
343
  next
@@ -380,10 +345,9 @@ module Rake
380
345
  begin
381
346
  shell "rm '#{ destination }'", Logger::INFO
382
347
  rescue Errno::EACCES => e
383
- raise "You do not have premission to uninstall '#{ destination }'\nTry\n $ sudo rake uninstall"
348
+ raise "You do not have premission to uninstall '#{ destination }'\nTry\n $ sudo rake #{ scoped_task( :uninstall ) }"
384
349
  end
385
350
  end
386
-
387
351
  end
388
352
 
389
353
  def scoped_task( task )
@@ -394,6 +358,26 @@ module Rake
394
358
  end
395
359
  end
396
360
 
361
+ def define_compile_task( source )
362
+ object = object_path( source )
363
+ @generated_files << object
364
+ file object => [ source ] do |t|
365
+ @logger.add( Logger::INFO, "Compiling '#{ source }'" )
366
+ shell "#{ @compiler } -c #{ compiler_flags } -o #{ object } #{ source }"
367
+ end
368
+ end
369
+
370
+ def build_command
371
+ case @target_type
372
+ when :executable
373
+ "#{ @linker } #{ link_flags } -o #{ @target } #{ file_list( object_files ) }"
374
+ when :static_library
375
+ "ar -cq #{ @target } #{ file_list( object_files ) }"
376
+ when :shared_library
377
+ "#{ @linker } -shared -o #{ @target } #{ file_list( object_files ) } #{ link_flags }"
378
+ end
379
+ end
380
+
397
381
  def type( target )
398
382
  case target
399
383
  when /\.a/
@@ -412,7 +396,7 @@ module Rake
412
396
  end
413
397
 
414
398
  def compiler_flags
415
- include_path + ' ' + @compilation_options
399
+ include_path + ' ' + compilation_options.join( " " )
416
400
  end
417
401
 
418
402
  def link_flags
@@ -421,14 +405,19 @@ module Rake
421
405
 
422
406
  # Paths
423
407
 
424
- def save_rakefile_info( caller )
425
- @rakefile = caller.match(/^([^\:]+)/)[1]
408
+ def save_rakefile_info( block )
409
+ if RUBY_VERSION < '1.9'
410
+ # Hack the path from the block String representation
411
+ @rakefile = block.to_s.match( /@([^\:]+):/ )[ 1 ]
412
+ else
413
+ @rakefile = block.source_location
414
+ end
426
415
  @rakefile_path = File.expand_path( File.dirname( @rakefile ) )
427
416
  end
428
417
 
429
418
  def object_path( source_path_name )
430
419
  o_name = File.basename( source_path_name ).gsub( '.' + @source_file_extension, '.o' )
431
- Rake::Builder.expand_path_with_root( o_name, @objects_path )
420
+ Rake::Path.expand_with_root( o_name, @objects_path )
432
421
  end
433
422
 
434
423
  def default_install_path( target_type )
@@ -447,18 +436,8 @@ module Rake
447
436
  # Lists of files
448
437
 
449
438
  def find_files( paths, extension )
450
- files = paths.reduce( [] ) do | memo, path |
451
- case
452
- when File.file?( path )
453
- files = FileList[ path ]
454
- when ( path =~ /[\*\?]/ )
455
- files = FileList[ path ]
456
- else
457
- files = FileList[ path + '/*.' + extension ]
458
- end
459
- memo + files
460
- end
461
- Rake::Builder.expand_paths_with_root( files, @rakefile_path )
439
+ files = Rake::Path.find_files( paths, extension )
440
+ Rake::Path.expand_all_with_root( files, @rakefile_path )
462
441
  end
463
442
 
464
443
  # TODO: make this return a FileList, not a plain Array
@@ -486,7 +465,7 @@ module Rake
486
465
  # TODO: make install_headers_path a configuration option
487
466
  install_headers_path = '/usr/local/include'
488
467
 
489
- installable_headers.each do | installable_header |
468
+ project_headers.each do | installable_header |
490
469
  destination_path = File.join( install_headers_path, installable_header[ :relative_path ] )
491
470
  begin
492
471
  `mkdir -p '#{ destination_path }'`
@@ -497,29 +476,25 @@ module Rake
497
476
  end
498
477
  end
499
478
 
500
- def subtract_path_prefix( prefix, path )
501
- path[ prefix.size .. -1 ]
502
- end
503
-
504
- def installable_headers
479
+ def project_headers
505
480
  @header_search_paths.reduce( [] ) do | memo, search |
506
481
  non_glob_search = ( search.match( /^([^\*\?]*)/ ) )[ 1 ]
507
482
  case
508
483
  when ( non_glob_search !~ /#{ @rakefile_path }/ )
509
484
  # Skip paths that are not inside the project
510
485
  when File.file?( search )
511
- full_path = Rake::Builder.expand_path_with_root( search, @rakefile_path )
486
+ full_path = Rake::Path.expand_with_root( search, @rakefile_path )
512
487
  memo << { :source_file => search, :relative_path => '' }
513
488
  when File.directory?( search )
514
489
  FileList[ search + '/*.' + @header_file_extension ].each do | pathname |
515
- full_path = Rake::Builder.expand_path_with_root( pathname, @rakefile_path )
490
+ full_path = Rake::Path.expand_with_root( pathname, @rakefile_path )
516
491
  memo << { :source_file => pathname, :relative_path => '' }
517
492
  end
518
493
  when ( search =~ /[\*\?]/ )
519
494
  FileList[ search ].each do | pathname |
520
- full_path = Rake::Builder.expand_path_with_root( pathname, @rakefile_path )
495
+ full_path = Rake::Path.expand_with_root( pathname, @rakefile_path )
521
496
  directory = File.dirname( full_path )
522
- relative = subtract_path_prefix( non_glob_search, directory )
497
+ relative = Rake::Path.subtract_prefix( non_glob_search, directory )
523
498
  memo << { :source_file => pathname, :relative_path => relative }
524
499
  end
525
500
  else
@@ -538,7 +513,7 @@ module Rake
538
513
  end
539
514
  end
540
515
 
541
- def shell( command, log_level = Logger::ERROR )
516
+ def shell( command, log_level = Logger::DEBUG )
542
517
  @logger.add( log_level, command )
543
518
  `#{ command }`
544
519
  end
@@ -0,0 +1,145 @@
1
+ require 'rake/builder'
2
+
3
+ module Rake
4
+
5
+ class QtBuilder < Builder
6
+
7
+ # TODO:
8
+ # generate Info.plist
9
+ # package task
10
+
11
+ attr_accessor :frameworks
12
+ attr_accessor :resource_files
13
+ attr_accessor :qt_version
14
+ attr_accessor :architecture
15
+
16
+ def initialize( &block )
17
+ super( &block )
18
+ end
19
+
20
+ private
21
+
22
+ # Overrrides
23
+
24
+ def initialize_attributes
25
+ super
26
+ @programming_language = 'c++'
27
+ @header_file_extension = 'h'
28
+ @frameworks = [ 'QtGui', 'QtCore' ]
29
+ @framework_paths = [ '/Library/Frameworks' ]
30
+ @compilation_defines = '-DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED'
31
+ @moc_defines = '-D__APPLE__ -D__GNUC__'
32
+ @resource_files = []
33
+ end
34
+
35
+ def configure
36
+ raise 'programming_language must be C++' if @programming_language.downcase != 'c++'
37
+ raise 'qt_version must be set' if ! @qt_version
38
+
39
+ super
40
+
41
+ @resource_files = Rake::Path.expand_all_with_root( @resource_files, @rakefile_path )
42
+ @compilation_options += [ '-pipe', '-g', '-gdwarf-2', '-Wall', '-W' ]
43
+ @compilation_options.uniq!
44
+ @architecture ||= 'i386'
45
+ @compilation_options += [ architecture_option ]
46
+
47
+ @frameworks.each do | framework |
48
+ @include_paths << "/Library/Frameworks/#{ framework }.framework/Versions/#{ qt_major }/Headers"
49
+ @include_paths << "/usr/include/#{ framework }"
50
+ end
51
+ end
52
+
53
+ def define
54
+ super
55
+ define_moc_tasks
56
+ define_resource_tasks
57
+ end
58
+
59
+ def generated_files
60
+ super + moc_files + qrc_files
61
+ end
62
+
63
+ def source_files
64
+ ( super + moc_files + qrc_files ).uniq
65
+ end
66
+
67
+ def compiler_flags
68
+ [ compilation_options.join( ' ' ), @compilation_defines, include_path, framework_path_list ].join( ' ' )
69
+ end
70
+
71
+ def link_flags
72
+ [ '-headerpad_max_install_names', architecture_option, @linker_options, library_paths_list, library_dependencies_list, framework_path_list, framework_list ].join( " " )
73
+ end
74
+
75
+ # QT-specific
76
+
77
+ def qt_major
78
+ @qt_version.match( /^(\d+)/ )[ 1 ]
79
+ end
80
+
81
+ def architecture_option
82
+ "-arch #{ @architecture }"
83
+ end
84
+
85
+ def framework_path_list
86
+ @framework_paths.map { |p| "-F#{ p }" }.join( " " )
87
+ end
88
+
89
+ def framework_list
90
+ @frameworks.map { |p| "-framework #{ p }" }.join( " " )
91
+ end
92
+
93
+ # MOC
94
+
95
+ def define_moc_tasks
96
+ project_headers.each do | header |
97
+ header_file = header[ :source_file ]
98
+ moc = moc_pathname( header_file )
99
+
100
+ file moc => [ header_file ] do |t|
101
+ command = "moc #{ @compilation_defines } #{ framework_path_list } #{ @moc_defines } #{ header_file } -o #{ moc }"
102
+ shell command
103
+ end
104
+
105
+ define_compile_task( moc )
106
+ end
107
+ end
108
+
109
+ def moc_files
110
+ @moc_files ||= project_headers.collect do | header |
111
+ moc_pathname( header[ :source_file ] )
112
+ end
113
+ end
114
+
115
+ def moc_pathname( header_name )
116
+ moc_name = 'moc_' + File.basename( header_name ).gsub( '.' + @header_file_extension, '.cpp' )
117
+ Rake::Path.expand_with_root( moc_name, @objects_path )
118
+ end
119
+
120
+ # Resources
121
+
122
+ def define_resource_tasks
123
+ @resource_files.each do | resource |
124
+ qrc = qrc_pathname( resource )
125
+ file qrc => [ resource ] do |t|
126
+ command = "rcc -name #{ target_basename } #{ resource } -o #{ qrc }"
127
+ shell command
128
+ end
129
+ end
130
+ end
131
+
132
+ def qrc_files
133
+ @resource_files.collect do | resource |
134
+ qrc_pathname( resource )
135
+ end
136
+ end
137
+
138
+ def qrc_pathname( resource_name )
139
+ qrc_name = 'qrc_' + File.basename( resource_name ).gsub( '.qrc', '.cpp' )
140
+ Rake::Path.expand_with_root( qrc_name, @objects_path )
141
+ end
142
+
143
+ end
144
+
145
+ end
@@ -0,0 +1,24 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+ require 'rake/tasklib'
3
+
4
+ module Rake
5
+
6
+ # A task whose behaviour depends on a FileTask
7
+ class FileTaskAlias < Task
8
+
9
+ attr_accessor :target
10
+
11
+ def self.define_task( name, target, &block )
12
+ alias_task = super( { name => [] }, &block )
13
+ alias_task.target = target
14
+ alias_task.prerequisites.unshift( target )
15
+ alias_task
16
+ end
17
+
18
+ def needed?
19
+ Rake::Task[ @target ].needed?
20
+ end
21
+
22
+ end
23
+
24
+ end
data/lib/rake/path.rb ADDED
@@ -0,0 +1,41 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+
3
+ module Rake
4
+
5
+ module Path
6
+
7
+ def self.find_files( paths, extension )
8
+ files = paths.reduce( [] ) do | memo, path |
9
+ case
10
+ when File.file?( path )
11
+ files = FileList[ path ]
12
+ when ( path =~ /[\*\?]/ )
13
+ files = FileList[ path ]
14
+ else
15
+ files = FileList[ path + '/*.' + extension ]
16
+ end
17
+ memo + files
18
+ end
19
+ end
20
+
21
+ # Expand path to an absolute path relative to the supplied root
22
+ def self.expand_with_root( path, root )
23
+ if path =~ /^\//
24
+ File.expand_path( path )
25
+ else
26
+ File.expand_path( root + '/' + path )
27
+ end
28
+ end
29
+
30
+ # Expand an array of paths to absolute paths relative to the supplied root
31
+ def self.expand_all_with_root( paths, root )
32
+ paths.map{ |path| expand_with_root( path, root ) }
33
+ end
34
+
35
+ def self.subtract_prefix( prefix, path )
36
+ path[ prefix.size .. -1 ]
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -5,13 +5,13 @@ describe 'when building a C project' do
5
5
  include RakeBuilderHelper
6
6
 
7
7
  before( :all ) do
8
- @test_output_file = Rake::Builder.expand_path_with_root( 'rake-c-testfile.txt', SPEC_PATH )
8
+ @test_output_file = Rake::Path.expand_with_root( 'rake-c-testfile.txt', SPEC_PATH )
9
9
  end
10
10
 
11
11
  before( :each ) do
12
12
  Rake::Task.clear
13
13
  @project = c_task( :executable )
14
- @expected_generated = Rake::Builder.expand_paths_with_root( [ './main.o', @project.makedepend_file, @project.target ], SPEC_PATH )
14
+ @expected_generated = Rake::Path.expand_all_with_root( [ './main.o', @project.makedepend_file, @project.target ], SPEC_PATH )
15
15
  `rm -f #{ @test_output_file }`
16
16
  `rm -f #{ @project.target }`
17
17
  end
@@ -5,11 +5,11 @@ describe 'when building an executable' do
5
5
  include RakeBuilderHelper
6
6
 
7
7
  before( :all ) do
8
- @test_output_file = Rake::Builder.expand_path_with_root(
8
+ @test_output_file = Rake::Path.expand_with_root(
9
9
  'rake-builder-testfile.txt', SPEC_PATH )
10
- @expected_target = Rake::Builder.expand_path_with_root(
11
- RakeBuilderHelper::TARGET[ :executable ],
12
- SPEC_PATH )
10
+ @expected_target = Rake::Path.expand_with_root(
11
+ RakeBuilderHelper::TARGET[ :executable ],
12
+ SPEC_PATH )
13
13
  end
14
14
 
15
15
  before( :each ) do
@@ -42,18 +42,6 @@ describe 'when building an executable' do
42
42
  missing_tasks.should == []
43
43
  end
44
44
 
45
- it 'finds source files' do
46
- expected_sources = Rake::Builder.expand_paths_with_root(
47
- [ 'cpp_project/main.cpp' ], SPEC_PATH )
48
- @project.source_files.should == expected_sources
49
- end
50
-
51
- it 'finds header files' do
52
- expected_headers = Rake::Builder.expand_paths_with_root(
53
- [ 'cpp_project/main.h' ], SPEC_PATH )
54
- @project.header_files.should == expected_headers
55
- end
56
-
57
45
  it 'builds the program with \'build\'' do
58
46
  Rake::Task[ 'build' ].invoke
59
47
  exist?( @project.target ).should be_true
@@ -30,7 +30,7 @@ describe 'the dependencies system' do
30
30
  end
31
31
  Rake::Task.clear
32
32
  @project = cpp_task( :executable )
33
- object_file_path = Rake::Builder.expand_path_with_root( 'main.o', SPEC_PATH )
33
+ object_file_path = Rake::Path.expand_with_root( 'main.o', SPEC_PATH )
34
34
  Rake::Task[ object_file_path ].needed?.should be_false
35
35
  end
36
36
 
@@ -40,16 +40,16 @@ describe 'the dependencies system' do
40
40
  end
41
41
  Rake::Task.clear
42
42
  @project = cpp_task( :executable )
43
- source_file_path = Rake::Builder.expand_path_with_root( 'cpp_project/main.cpp', SPEC_PATH )
44
- object_file_path = Rake::Builder.expand_path_with_root( 'main.o', SPEC_PATH )
43
+ source_file_path = Rake::Path.expand_with_root( 'cpp_project/main.cpp', SPEC_PATH )
44
+ object_file_path = Rake::Path.expand_with_root( 'main.o', SPEC_PATH )
45
45
  touching_temporarily( source_file_path, File.mtime( object_file_path ) + 1 ) do
46
46
  Rake::Task[ object_file_path ].needed?.should be_true
47
47
  end
48
48
  end
49
49
 
50
50
  it 'recompiles source files, if header dependencies' do
51
- header_file_path = Rake::Builder.expand_path_with_root( 'cpp_project/main.h', SPEC_PATH )
52
- object_file_path = Rake::Builder.expand_path_with_root( 'main.o', SPEC_PATH )
51
+ header_file_path = Rake::Path.expand_with_root( 'cpp_project/main.h', SPEC_PATH )
52
+ object_file_path = Rake::Path.expand_with_root( 'main.o', SPEC_PATH )
53
53
  isolating_seconds do
54
54
  Rake::Task[ 'compile' ].invoke
55
55
  end
@@ -7,7 +7,7 @@ describe 'when handling generated files' do
7
7
  before( :each ) do
8
8
  Rake::Task.clear
9
9
  @project = cpp_task( :executable )
10
- @expected_generated = Rake::Builder.expand_paths_with_root(
10
+ @expected_generated = Rake::Path.expand_all_with_root(
11
11
  [
12
12
  'main.o',
13
13
  'rake-builder-testfile.txt',
@@ -50,7 +50,7 @@ describe 'when adding generated files' do
50
50
 
51
51
  before( :each ) do
52
52
  @file = 'foobar.txt'
53
- @file_with_path = Rake::Builder.expand_path_with_root( @file, SPEC_PATH )
53
+ @file_with_path = Rake::Path.expand_with_root( @file, SPEC_PATH )
54
54
  end
55
55
 
56
56
  it 'includes added files' do
@@ -7,7 +7,7 @@ describe 'local config files' do
7
7
  include RakeBuilderHelper
8
8
 
9
9
  before( :each ) do
10
- @local_config_file = Rake::Builder.expand_path_with_root( '.rake-builder', LOCAL_CONFIG_SPEC_PATH )
10
+ @local_config_file = Rake::Path.expand_with_root( '.rake-builder', LOCAL_CONFIG_SPEC_PATH )
11
11
  @expected_path = "/some/special/path"
12
12
  @config = {:rake_builder=>{:config_file=>{:version=>"1.0"}}, :include_paths=>[ @expected_path ]}
13
13
  `rm -f '#{ @local_config_file }'`
data/spec/logger_spec.rb CHANGED
@@ -18,4 +18,7 @@ describe 'the logger' do
18
18
  end.should_not raise_exception
19
19
  end
20
20
 
21
+ # TODO: check the output
22
+ # builder.logger.level = Logger::DEBUG
23
+
21
24
  end
@@ -5,11 +5,11 @@ describe 'when building an Objective-C executable' do
5
5
  include RakeBuilderHelper
6
6
 
7
7
  before( :all ) do
8
- @test_output_file = Rake::Builder.expand_path_with_root(
8
+ @test_output_file = Rake::Path.expand_with_root(
9
9
  'rake-builder-testfile.txt', SPEC_PATH )
10
- @expected_target = Rake::Builder.expand_path_with_root(
11
- RakeBuilderHelper::TARGET[ :executable ],
12
- SPEC_PATH )
10
+ @expected_target = Rake::Path.expand_with_root(
11
+ RakeBuilderHelper::TARGET[ :executable ],
12
+ SPEC_PATH )
13
13
  end
14
14
 
15
15
  before( :each ) do
@@ -42,18 +42,6 @@ describe 'when building an Objective-C executable' do
42
42
  missing_tasks.should == []
43
43
  end
44
44
 
45
- it 'finds source files' do
46
- expected_sources = Rake::Builder.expand_paths_with_root(
47
- [ 'objective_c_project/main.m' ], SPEC_PATH )
48
- @project.source_files.should == expected_sources
49
- end
50
-
51
- it 'finds header files' do
52
- expected_headers = Rake::Builder.expand_paths_with_root(
53
- [ 'objective_c_project/main.h' ], SPEC_PATH )
54
- @project.header_files.should == expected_headers
55
- end
56
-
57
45
  it 'builds the program with \'build\'' do
58
46
  Rake::Task[ 'build' ].invoke
59
47
  exist?( @project.target ).should be_true
data/spec/target_spec.rb CHANGED
@@ -28,7 +28,7 @@ describe 'when creating tasks' do
28
28
  builder = Rake::Builder.new do |builder|
29
29
  builder.source_search_paths = [ 'cpp_project' ]
30
30
  end
31
- builder.target.should == Rake::Builder.expand_path_with_root( 'a.out', SPEC_PATH )
31
+ builder.target.should == Rake::Path.expand_with_root( 'a.out', SPEC_PATH )
32
32
  end
33
33
 
34
34
  it 'raises an error when the supplied target_type is unknown' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-builder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 10
10
- version: 0.0.10
9
+ - 11
10
+ version: 0.0.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joe Yates
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-25 00:00:00 +01:00
18
+ date: 2010-08-28 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -43,7 +43,10 @@ extensions: []
43
43
  extra_rdoc_files:
44
44
  - COPYING
45
45
  - README.rdoc
46
+ - lib/rake/builder/qt_builder.rb
46
47
  - lib/rake/builder.rb
48
+ - lib/rake/file_task_alias.rb
49
+ - lib/rake/path.rb
47
50
  - examples/README.rdoc
48
51
  - examples/01_hello_world_cpp/Rakefile
49
52
  - examples/02_hello_world_c/Rakefile
@@ -56,7 +59,10 @@ files:
56
59
  - COPYING
57
60
  - Rakefile
58
61
  - README.rdoc
62
+ - lib/rake/builder/qt_builder.rb
59
63
  - lib/rake/builder.rb
64
+ - lib/rake/file_task_alias.rb
65
+ - lib/rake/path.rb
60
66
  - examples/03_search_paths/include/main.h
61
67
  - examples/04_zlib/include/main.h
62
68
  - examples/05_tests/include/main.h