rake-builder 0.0.13 → 0.0.14
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/Rakefile +16 -37
- data/lib/rake/builder.rb +142 -37
- data/lib/rake/builder/qt_builder.rb +3 -3
- data/lib/rake/builder/version.rb +15 -0
- data/lib/rake/local_config.rb +40 -0
- data/spec/libraries_spec.rb +2 -2
- data/spec/local_config_spec.rb +8 -31
- data/spec/target_spec.rb +6 -2
- metadata +12 -41
data/Rakefile
CHANGED
@@ -1,47 +1,16 @@
|
|
1
1
|
require 'rubygems' if RUBY_VERSION < '1.9'
|
2
2
|
require 'rake'
|
3
|
-
require 'rake/gempackagetask'
|
4
|
-
require 'spec/rake/spectask'
|
5
3
|
require 'rake/rdoctask'
|
4
|
+
require 'spec/rake/spectask'
|
6
5
|
$:.unshift( File.dirname( __FILE__ ) + '/lib' )
|
7
|
-
require 'rake/builder'
|
6
|
+
require 'rake/builder/version'
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
EXAMPLE_SOURCE_FILES = FileList[ 'examples/**/*.{h,c,cpp,m}' ]
|
14
|
-
RDOC_FILES = FileList[ 'COPYING', 'README.rdoc' ] + SOURCE_FILES + EXAMPLE_EXTRA_FILES
|
8
|
+
RDOC_FILES = FileList[ 'COPYING', 'README.rdoc' ] +
|
9
|
+
FileList[ 'lib/**/*.rb' ] +
|
10
|
+
FileList[ 'examples/README.rdoc' ] +
|
11
|
+
FileList[ 'examples/**/Rakefile' ]
|
15
12
|
RDOC_OPTS = [ '--quiet', '--main', 'README.rdoc', '--inline-source' ]
|
16
13
|
|
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
|
-
s.rubyforge_project = 'nowarning'
|
27
|
-
|
28
|
-
s.files = ADMIN_FILES +
|
29
|
-
SOURCE_FILES +
|
30
|
-
EXAMPLE_SOURCE_FILES +
|
31
|
-
EXAMPLE_EXTRA_FILES
|
32
|
-
s.require_paths = [ 'lib' ]
|
33
|
-
s.add_dependency( 'rake', '>= 0.8.7' )
|
34
|
-
|
35
|
-
s.has_rdoc = true
|
36
|
-
s.rdoc_options += RDOC_OPTS
|
37
|
-
s.extra_rdoc_files = RDOC_FILES
|
38
|
-
|
39
|
-
s.test_files = SPEC_FILES
|
40
|
-
end
|
41
|
-
|
42
|
-
Rake::GemPackageTask.new( spec ) do |pkg|
|
43
|
-
end
|
44
|
-
|
45
14
|
Spec::Rake::SpecTask.new do |t|
|
46
15
|
t.spec_files = FileList[ 'spec/**/*_spec.rb' ]
|
47
16
|
t.spec_opts += [ '--color', '--format specdoc' ]
|
@@ -59,3 +28,13 @@ Rake::RDocTask.new do |rdoc|
|
|
59
28
|
rdoc.title = 'Rake for C/C++/Objective-C/Objective-C++ Projects'
|
60
29
|
rdoc.rdoc_files.add RDOC_FILES
|
61
30
|
end
|
31
|
+
|
32
|
+
desc "Build the gem"
|
33
|
+
task :build do
|
34
|
+
system "gem build rake-builder.gemspec"
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Publish gem version #{ Rake::Builder::VERSION::STRING }"
|
38
|
+
task :release => :build do
|
39
|
+
system "gem push rake-builder-#{ Rake::Builder::VERSION::STRING }.gem"
|
40
|
+
end
|
data/lib/rake/builder.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'rubygems' if RUBY_VERSION < '1.9'
|
2
2
|
require 'logger'
|
3
|
-
require 'yaml'
|
4
3
|
require 'rake'
|
5
4
|
require 'rake/tasklib'
|
6
5
|
require 'rake/path'
|
6
|
+
require 'rake/local_config'
|
7
7
|
require 'rake/file_task_alias'
|
8
8
|
require 'compiler'
|
9
9
|
|
@@ -15,10 +15,6 @@ module Rake
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
# Error indicating that the project failed to build.
|
19
|
-
class BuildFailureError < StandardError
|
20
|
-
end
|
21
|
-
|
22
18
|
class Builder < TaskLib
|
23
19
|
|
24
20
|
module VERSION #:nodoc:
|
@@ -29,6 +25,25 @@ module Rake
|
|
29
25
|
STRING = [ MAJOR, MINOR, TINY ].join('.')
|
30
26
|
end
|
31
27
|
|
28
|
+
class BuilderError < StandardError
|
29
|
+
attr_accessor :namespace
|
30
|
+
|
31
|
+
def initialize( message, namespace = nil )
|
32
|
+
super( message )
|
33
|
+
@namespace = namespace
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
message = super
|
38
|
+
message = "#{ @namespace }: #{ message }" if @namespace
|
39
|
+
message
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Error indicating that the project failed to build.
|
44
|
+
class BuildFailure < BuilderError
|
45
|
+
end
|
46
|
+
|
32
47
|
# The file to be built
|
33
48
|
attr_accessor :target
|
34
49
|
|
@@ -192,8 +207,8 @@ module Rake
|
|
192
207
|
@compilation_options += [ architecture_option ] if RUBY_PLATFORM =~ /apple/i
|
193
208
|
@compilation_options.uniq!
|
194
209
|
|
195
|
-
@programming_language.downcase
|
196
|
-
raise "Don't know how to build '#{ @programming_language }' programs" if KNOWN_LANGUAGES[ @programming_language ].nil?
|
210
|
+
@programming_language = @programming_language.to_s.downcase
|
211
|
+
raise BuilderError.new( "Don't know how to build '#{ @programming_language }' programs", task_namespace ) if KNOWN_LANGUAGES[ @programming_language ].nil?
|
197
212
|
@compiler ||= KNOWN_LANGUAGES[ @programming_language ][ :compiler ]
|
198
213
|
@linker ||= KNOWN_LANGUAGES[ @programming_language ][ :linker ]
|
199
214
|
@source_file_extension ||= KNOWN_LANGUAGES[ @programming_language ][ :source_file_extension ]
|
@@ -202,12 +217,13 @@ module Rake
|
|
202
217
|
@header_search_paths = Rake::Path.expand_all_with_root( @header_search_paths, @rakefile_path )
|
203
218
|
@library_paths = Rake::Path.expand_all_with_root( @library_paths, @rakefile_path )
|
204
219
|
|
205
|
-
raise "The target name cannot be nil" if @target.nil?
|
206
|
-
raise "The target name cannot be an empty string" if @target == ''
|
220
|
+
raise BuilderError.new( "The target name cannot be nil", task_namespace ) if @target.nil?
|
221
|
+
raise BuilderError.new( "The target name cannot be an empty string", task_namespace ) if @target == ''
|
207
222
|
@objects_path = Rake::Path.expand_with_root( @objects_path, @rakefile_path )
|
208
|
-
@target =
|
223
|
+
@target = @target
|
209
224
|
@target_type ||= type( @target )
|
210
|
-
raise "Building #{ @target_type } targets is not supported" if ! TARGET_TYPES.include?( @target_type )
|
225
|
+
raise BuilderError.new( "Building #{ @target_type } targets is not supported", task_namespace ) if ! TARGET_TYPES.include?( @target_type )
|
226
|
+
|
211
227
|
@install_path ||= default_install_path( @target_type )
|
212
228
|
|
213
229
|
@linker_options ||= ''
|
@@ -220,7 +236,7 @@ module Rake
|
|
220
236
|
|
221
237
|
@makedepend_file = @objects_path + '/.' + target_basename + '.depend.mf'
|
222
238
|
|
223
|
-
raise "No source files found" if source_files.length == 0
|
239
|
+
raise BuilderError.new( "No source files found", task_namespace ) if source_files.length == 0
|
224
240
|
end
|
225
241
|
|
226
242
|
def define_tasks
|
@@ -244,10 +260,14 @@ module Rake
|
|
244
260
|
end
|
245
261
|
|
246
262
|
def define
|
263
|
+
task :environment do
|
264
|
+
logger.level = Logger::DEBUG if ENV[ 'DEBUG' ]
|
265
|
+
end
|
266
|
+
|
247
267
|
if @target_type == :executable
|
248
268
|
desc "Run '#{ target_basename }'"
|
249
269
|
task :run => :build do
|
250
|
-
command = "cd #{ @rakefile_path } && #{ @target }"
|
270
|
+
command = "cd #{ @rakefile_path } && #{ @target }"
|
251
271
|
puts shell( command, Logger::INFO )
|
252
272
|
end
|
253
273
|
end
|
@@ -256,18 +276,23 @@ module Rake
|
|
256
276
|
FileTaskAlias.define_task( :build, @target )
|
257
277
|
|
258
278
|
desc "Build '#{ target_basename }'"
|
259
|
-
file @target => [ scoped_task( :
|
279
|
+
file @target => [ scoped_task( :environment ),
|
280
|
+
scoped_task( :compile ),
|
281
|
+
*@target_prerequisites ] do | t |
|
260
282
|
shell "rm -f #{ t.name }"
|
261
283
|
build_commands.each do | command |
|
262
284
|
shell command
|
263
285
|
end
|
264
|
-
raise
|
286
|
+
raise BuildFailure.new( "The build command failed" ) if ! File.exist?( t.name )
|
265
287
|
end
|
266
288
|
|
267
289
|
desc "Compile all sources"
|
268
290
|
# Only import dependencies when we're compiling
|
269
291
|
# otherwise makedepend gets run on e.g. 'rake -T'
|
270
|
-
task :compile => [
|
292
|
+
task :compile => [ scoped_task( :environment ),
|
293
|
+
@makedepend_file,
|
294
|
+
scoped_task( :load_makedepend ),
|
295
|
+
*object_files ]
|
271
296
|
|
272
297
|
source_files.each do |src|
|
273
298
|
define_compile_task( src )
|
@@ -275,12 +300,13 @@ module Rake
|
|
275
300
|
|
276
301
|
directory @objects_path
|
277
302
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
303
|
+
task :local_config do
|
304
|
+
if ! File.exist?( local_config )
|
305
|
+
@logger.add( Logger::DEBUG, "Creating file '#{ local_config }'" )
|
306
|
+
added_includes = @compiler_data.include_paths( missing_headers )
|
307
|
+
config = Rake::LocalConfig.new( local_config )
|
308
|
+
config.include_paths = added_includes
|
309
|
+
config.save
|
284
310
|
end
|
285
311
|
end
|
286
312
|
|
@@ -293,14 +319,10 @@ module Rake
|
|
293
319
|
shell command
|
294
320
|
end
|
295
321
|
|
296
|
-
task :load_local_config => local_config do
|
297
|
-
config =
|
298
|
-
|
299
|
-
|
300
|
-
raise "Config file version missing" if version.nil?
|
301
|
-
|
302
|
-
config[ :include_paths ] ||= []
|
303
|
-
@include_paths += Rake::Path.expand_all_with_root( config[ :include_paths ], @rakefile_path )
|
322
|
+
task :load_local_config => scoped_task( :local_config ) do
|
323
|
+
config = LocalConfig.new( local_config )
|
324
|
+
config.load
|
325
|
+
@include_paths += Rake::Path.expand_all_with_root( config.include_paths, @rakefile_path )
|
304
326
|
end
|
305
327
|
|
306
328
|
task :missing_headers => [ *generated_headers ] do
|
@@ -364,9 +386,74 @@ module Rake
|
|
364
386
|
begin
|
365
387
|
shell "rm '#{ destination }'", Logger::INFO
|
366
388
|
rescue Errno::EACCES => e
|
367
|
-
raise "You do not have premission to uninstall '#{ destination }'\nTry\n $ sudo rake #{ scoped_task( :uninstall ) }"
|
389
|
+
raise BuilderError.new( "You do not have premission to uninstall '#{ destination }'\nTry\n $ sudo rake #{ scoped_task( :uninstall ) }", task_namespace )
|
368
390
|
end
|
369
391
|
end
|
392
|
+
|
393
|
+
desc "Create a '#{ makefile_name }' to build the project"
|
394
|
+
file "#{ makefile_name }" => [ @makedepend_file, scoped_task( :load_makedepend ) ] do | t |
|
395
|
+
objects = object_files.collect { | f | f.sub( "#{ @objects_path }", '$(OBJECT_DIR)' ) }
|
396
|
+
objects_list = objects.join( ' ' )
|
397
|
+
case @target_type
|
398
|
+
when :executable
|
399
|
+
target_name = 'EXECUTABLE_TARGET'
|
400
|
+
target_ref = "$(#{ target_name })"
|
401
|
+
target_actions =
|
402
|
+
" $(LINKER) $(LINK_FLAGS) -o #{ target_ref } $(OBJECTS)
|
403
|
+
"
|
404
|
+
when :static_library
|
405
|
+
target_name = 'LIB_TARGET'
|
406
|
+
target_ref = "$(#{ target_name })"
|
407
|
+
target_actions =
|
408
|
+
" rm -f #{ target_ref }
|
409
|
+
ar -cq #{ target_ref } $(OBJECTS)
|
410
|
+
ranlib #{ target_ref }
|
411
|
+
"
|
412
|
+
when :shared_library
|
413
|
+
target_name = 'LIB_TARGET'
|
414
|
+
target_ref = "$(#{ target_name })"
|
415
|
+
target_actions =
|
416
|
+
" $(LINKER) -shared -o #{ target_ref } $(OBJECTS) $(LINK_FLAGS)
|
417
|
+
"
|
418
|
+
end
|
419
|
+
|
420
|
+
variables = <<EOT
|
421
|
+
COMPILER = #{ @compiler }
|
422
|
+
COMPILER_FLAGS = #{ compiler_flags }
|
423
|
+
LINKER = #{ @linker }
|
424
|
+
LINK_FLAGS = #{ link_flags }
|
425
|
+
OBJECT_DIR = #{ @objects_path }
|
426
|
+
OBJECTS = #{ objects_list }
|
427
|
+
#{ target_name } = #{ @target }
|
428
|
+
EOT
|
429
|
+
rules = <<EOT
|
430
|
+
|
431
|
+
all: #{ target_ref }
|
432
|
+
|
433
|
+
clean:
|
434
|
+
rm -f $(OBJECTS)
|
435
|
+
rm -f #{ target_ref }
|
436
|
+
|
437
|
+
#{ target_ref }: $(OBJECTS)
|
438
|
+
#{ target_actions }
|
439
|
+
EOT
|
440
|
+
|
441
|
+
source_groups = group_files_by_path( source_files )
|
442
|
+
source_groups.each.with_index do | gp, i |
|
443
|
+
variables << "SOURCE_#{ i + 1 } = #{ gp[ 0 ] }\n"
|
444
|
+
rules << <<EOT
|
445
|
+
|
446
|
+
$(OBJECT_DIR)/%.o: $(SOURCE_#{ i + 1 })/%.cpp
|
447
|
+
$(COMPILER) -c $(COMPILER_FLAGS) -o $@ $<
|
448
|
+
EOT
|
449
|
+
end
|
450
|
+
|
451
|
+
File.open( t.name, 'w' ) do | file |
|
452
|
+
file.write variables
|
453
|
+
file.write rules
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
370
457
|
end
|
371
458
|
|
372
459
|
def generated_headers
|
@@ -385,7 +472,7 @@ module Rake
|
|
385
472
|
object = object_path( source )
|
386
473
|
@generated_files << object
|
387
474
|
file object => [ source ] do |t|
|
388
|
-
@logger.add( Logger::
|
475
|
+
@logger.add( Logger::DEBUG, "Compiling '#{ source }'" )
|
389
476
|
command = "#{ @compiler } -c #{ compiler_flags } -o #{ object } #{ source }"
|
390
477
|
shell command
|
391
478
|
end
|
@@ -394,7 +481,7 @@ module Rake
|
|
394
481
|
def build_commands
|
395
482
|
case @target_type
|
396
483
|
when :executable
|
397
|
-
[ "#{ @linker }
|
484
|
+
[ "#{ @linker } -o #{ @target } #{ file_list( object_files ) } #{ link_flags }" ]
|
398
485
|
when :static_library
|
399
486
|
[ "ar -cq #{ @target } #{ file_list( object_files ) }",
|
400
487
|
"ranlib #{ @target }" ]
|
@@ -440,7 +527,7 @@ module Rake
|
|
440
527
|
end
|
441
528
|
|
442
529
|
def link_flags
|
443
|
-
flags = [ @linker_options,
|
530
|
+
flags = [ @linker_options, library_paths_list, library_dependencies_list ]
|
444
531
|
flags << architecture_option if RUBY_PLATFORM =~ /darwin/i
|
445
532
|
flags.join( " " )
|
446
533
|
end
|
@@ -471,15 +558,33 @@ module Rake
|
|
471
558
|
case target_type
|
472
559
|
when :executable
|
473
560
|
'/usr/local/bin'
|
474
|
-
else
|
561
|
+
else
|
475
562
|
'/usr/local/lib'
|
476
563
|
end
|
477
564
|
end
|
478
565
|
|
566
|
+
def group_files_by_path( files )
|
567
|
+
files.group_by do | f |
|
568
|
+
m = f.match( /(.*?)?\/?([^\/]+)$/ )
|
569
|
+
m[ 1 ]
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
# Files
|
574
|
+
|
479
575
|
def target_basename
|
480
576
|
File.basename( @target )
|
481
577
|
end
|
482
578
|
|
579
|
+
def makefile_name
|
580
|
+
extension = if ! task_namespace.nil? && ! task_namespace.to_s.empty?
|
581
|
+
'.' + task_namespace.to_s
|
582
|
+
else
|
583
|
+
''
|
584
|
+
end
|
585
|
+
"Makefile#{ extension }"
|
586
|
+
end
|
587
|
+
|
483
588
|
# Lists of files
|
484
589
|
|
485
590
|
def find_files( paths, extension )
|
@@ -517,7 +622,7 @@ module Rake
|
|
517
622
|
begin
|
518
623
|
`mkdir -p '#{ destination_path }'`
|
519
624
|
rescue Errno::EACCES => e
|
520
|
-
raise "Permission denied to created directory '#{ destination_path }'"
|
625
|
+
raise BuilderError.new( "Permission denied to created directory '#{ destination_path }'", task_namespace )
|
521
626
|
end
|
522
627
|
install( installable_header[ :source_file ], destination_path )
|
523
628
|
end
|
@@ -556,7 +661,7 @@ module Rake
|
|
556
661
|
shell "cp '#{ source_pathname }' '#{ destination_path }'", Logger::INFO
|
557
662
|
rescue Errno::EACCES => e
|
558
663
|
source_filename = File.basename( source_pathname ) rescue '????'
|
559
|
-
raise "You do not have permission to install '#{ source_filename }' to '#{ destination_path }'\nTry\n $ sudo rake install"
|
664
|
+
raise BuilderError.new( "You do not have permission to install '#{ source_filename }' to '#{ destination_path }'\nTry\n $ sudo rake install", task_namespace )
|
560
665
|
end
|
561
666
|
end
|
562
667
|
|
@@ -34,7 +34,7 @@ module Rake
|
|
34
34
|
@framework_paths = [ '/Library/Frameworks' ]
|
35
35
|
@moc_defines = [ '-D__APPLE__', '-D__GNUC__' ]
|
36
36
|
else
|
37
|
-
raise "Unrecognised platform"
|
37
|
+
raise BuilderError.new( "Unrecognised platform" )
|
38
38
|
end
|
39
39
|
@compilation_defines = [ '-DQT_GUI_LIB', '-DQT_CORE_LIB', '-DQT_SHARED' ]
|
40
40
|
@resource_files = []
|
@@ -42,8 +42,8 @@ module Rake
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def configure
|
45
|
-
raise 'programming_language must be C++' if @programming_language.downcase != 'c++'
|
46
|
-
raise 'qt_version must be set' if ! @qt_version
|
45
|
+
raise BuilderError.new( 'programming_language must be C++' ) if @programming_language.downcase != 'c++'
|
46
|
+
raise BuilderError.new( 'qt_version must be set' ) if ! @qt_version
|
47
47
|
|
48
48
|
super
|
49
49
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
|
5
|
+
class LocalConfig
|
6
|
+
|
7
|
+
attr_accessor :config
|
8
|
+
|
9
|
+
def initialize( file_name )
|
10
|
+
@file_name = file_name
|
11
|
+
@config = { :rake_builder => { :config_file => { :version=> '1.0' } },
|
12
|
+
:include_paths => [] }
|
13
|
+
end
|
14
|
+
|
15
|
+
def load
|
16
|
+
@config = YAML.load_file( @file_name )
|
17
|
+
|
18
|
+
version = @config[ :rake_builder ][ :config_file ][ :version ]
|
19
|
+
raise Rake::Builder::BuilderError.new( 'Config file version missing' ) if version.nil?
|
20
|
+
|
21
|
+
@config[ :include_paths ] ||= []
|
22
|
+
end
|
23
|
+
|
24
|
+
def save
|
25
|
+
File.open( @file_name, 'w' ) do | file |
|
26
|
+
file.write @config.to_yaml
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def include_paths
|
31
|
+
@config[ :include_paths ]
|
32
|
+
end
|
33
|
+
|
34
|
+
def include_paths=( include_paths )
|
35
|
+
@config[ :include_paths ] = include_paths
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/spec/libraries_spec.rb
CHANGED
@@ -22,12 +22,12 @@ describe 'when using libraries' do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'fails to build if libraries are missing' do
|
25
|
-
|
25
|
+
expect do
|
26
26
|
@project = cpp_task( :executable ) do |builder|
|
27
27
|
builder.library_dependencies = [ 'library_that_doesnt_exist' ]
|
28
28
|
end
|
29
29
|
Rake::Task[ 'build' ].invoke
|
30
|
-
end.
|
30
|
+
end.to raise_error( Rake::Builder::BuildFailure )
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
data/spec/local_config_spec.rb
CHANGED
@@ -19,44 +19,21 @@ describe 'local config files' do
|
|
19
19
|
end.should_not raise_error
|
20
20
|
end
|
21
21
|
|
22
|
-
it 'loads
|
22
|
+
it 'loads config files' do
|
23
23
|
save_config
|
24
|
-
|
25
|
-
|
24
|
+
config = Rake::LocalConfig.new( @local_config_file )
|
25
|
+
config.load
|
26
|
+
|
27
|
+
config.include_paths. should include( @expected_path )
|
26
28
|
end
|
27
29
|
|
28
30
|
it 'fails if there\'s no version' do
|
29
31
|
@config[ :rake_builder ][ :config_file ].delete( :version )
|
30
32
|
save_config
|
31
33
|
lambda do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
it 'for the default namespace, loads only the \'.rake-builder\' config file' do
|
37
|
-
namespaced_config_path = @local_config_file + '.foo'
|
38
|
-
namespaced_config = @config.dup
|
39
|
-
unexpected_path = '/this/shouldnt/show/up'
|
40
|
-
namespaced_config[ :include_paths ] = [ unexpected_path ]
|
41
|
-
save_config
|
42
|
-
save_config( namespaced_config, namespaced_config_path )
|
43
|
-
@builder = cpp_task( :executable )
|
44
|
-
@builder.include_paths.should include( @expected_path )
|
45
|
-
@builder.include_paths.should_not include( unexpected_path )
|
46
|
-
`rm -f '#{ namespaced_config_path }'`
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'for a particular namespace, loads only that namespace\'s config file' do
|
50
|
-
namespaced_config_path = @local_config_file + '.foo'
|
51
|
-
namespaced_config = @config.dup
|
52
|
-
unexpected_path = '/this/shouldnt/show/up'
|
53
|
-
namespaced_config[ :include_paths ] = [ unexpected_path ]
|
54
|
-
save_config
|
55
|
-
save_config( namespaced_config, namespaced_config_path )
|
56
|
-
@builder = cpp_task( :executable, 'foo' )
|
57
|
-
@builder.include_paths.should_not include( @expected_path )
|
58
|
-
@builder.include_paths.should include( unexpected_path )
|
59
|
-
`rm -f '#{ namespaced_config_path }'`
|
34
|
+
config = Rake::LocalConfig.new( @local_config_file )
|
35
|
+
config.load
|
36
|
+
end.should raise_error( Rake::Builder::BuilderError, 'Config file version missing' )
|
60
37
|
end
|
61
38
|
|
62
39
|
private
|
data/spec/target_spec.rb
CHANGED
@@ -6,13 +6,17 @@ describe 'when creating tasks' do
|
|
6
6
|
Rake::Task.clear
|
7
7
|
end
|
8
8
|
|
9
|
+
after( :each ) do
|
10
|
+
`rm -f spec/.rake-builder.foo`
|
11
|
+
end
|
12
|
+
|
9
13
|
it 'raises an error when the target is an empty string' do
|
10
14
|
lambda do
|
11
15
|
Rake::Builder.new do |builder|
|
12
16
|
builder.target = ''
|
13
17
|
builder.source_search_paths = [ 'cpp_project' ]
|
14
18
|
end
|
15
|
-
end.should raise_error(
|
19
|
+
end.should raise_error( Rake::Builder::BuilderError, 'The target name cannot be an empty string' )
|
16
20
|
end
|
17
21
|
|
18
22
|
it 'raises an error when the target is set to nil' do
|
@@ -21,7 +25,7 @@ describe 'when creating tasks' do
|
|
21
25
|
builder.target = nil
|
22
26
|
builder.source_search_paths = [ 'cpp_project' ]
|
23
27
|
end
|
24
|
-
end.should raise_error(
|
28
|
+
end.should raise_error( Rake::Builder::BuilderError, 'The target name cannot be nil' )
|
25
29
|
end
|
26
30
|
|
27
31
|
it 'sets the target to \'a.out\' if it is not set' 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:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 14
|
10
|
+
version: 0.0.14
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joe Yates
|
@@ -15,46 +15,18 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-04 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
22
|
-
name: rake
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 49
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 8
|
33
|
-
- 7
|
34
|
-
version: 0.8.7
|
35
|
-
type: :runtime
|
36
|
-
version_requirements: *id001
|
20
|
+
dependencies: []
|
21
|
+
|
37
22
|
description: Provides Rake:Builder, a specific rake TaskLib for building C, C++, Objective-C and Objective-C++ projects
|
38
23
|
email: joe.g.yates@gmail.com
|
39
24
|
executables: []
|
40
25
|
|
41
26
|
extensions: []
|
42
27
|
|
43
|
-
extra_rdoc_files:
|
44
|
-
|
45
|
-
- README.rdoc
|
46
|
-
- lib/compiler.rb
|
47
|
-
- lib/rake/builder/qt_builder.rb
|
48
|
-
- lib/rake/builder.rb
|
49
|
-
- lib/rake/file_task_alias.rb
|
50
|
-
- lib/rake/path.rb
|
51
|
-
- examples/README.rdoc
|
52
|
-
- examples/01_hello_world_cpp/Rakefile
|
53
|
-
- examples/02_hello_world_c/Rakefile
|
54
|
-
- examples/03_search_paths/Rakefile
|
55
|
-
- examples/04_zlib/Rakefile
|
56
|
-
- examples/05_tests/Rakefile
|
57
|
-
- examples/06_hello_world_objective_c/Rakefile
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
58
30
|
files:
|
59
31
|
- CHANGES
|
60
32
|
- COPYING
|
@@ -62,8 +34,10 @@ files:
|
|
62
34
|
- README.rdoc
|
63
35
|
- lib/compiler.rb
|
64
36
|
- lib/rake/builder/qt_builder.rb
|
37
|
+
- lib/rake/builder/version.rb
|
65
38
|
- lib/rake/builder.rb
|
66
39
|
- lib/rake/file_task_alias.rb
|
40
|
+
- lib/rake/local_config.rb
|
67
41
|
- lib/rake/path.rb
|
68
42
|
- examples/03_search_paths/include/main.h
|
69
43
|
- examples/04_zlib/include/main.h
|
@@ -106,11 +80,8 @@ homepage: http://github.com/joeyates/rake-builder
|
|
106
80
|
licenses: []
|
107
81
|
|
108
82
|
post_install_message:
|
109
|
-
rdoc_options:
|
110
|
-
|
111
|
-
- --main
|
112
|
-
- README.rdoc
|
113
|
-
- --inline-source
|
83
|
+
rdoc_options: []
|
84
|
+
|
114
85
|
require_paths:
|
115
86
|
- lib
|
116
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|