cxxproject 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -190,6 +190,7 @@ module Cxxproject
190
190
  if hasError
191
191
  if not errorPrinted
192
192
  Printer.printError "Error: system command failed"
193
+ Printer.printError console_output
193
194
  res = ErrorDesc.new
194
195
  res.file_name = @project_dir
195
196
  res.line_number = 0
@@ -263,7 +263,6 @@ module Rake
263
263
  end
264
264
 
265
265
  define_method(:invoke) do |*args|
266
- Cxxproject::ExitHelper.set_exit_code(0)
267
266
  invoke_org.bind(self).call(*args)
268
267
  if @failure or Rake.application.idei.get_abort
269
268
  Cxxproject::ExitHelper.set_exit_code(1)
@@ -19,15 +19,15 @@ require 'rubygems'
19
19
  module Cxxproject
20
20
 
21
21
  class CxxProject2Rake
22
- attr_accessor :base, :all_tasks
22
+ attr_accessor :base_dir, :all_tasks
23
23
 
24
- def initialize(projects, build_dir, toolchain_name, base='.', &option_block)
24
+ def initialize(projects, build_dir, toolchain_name, base_dir='.', &option_block)
25
25
  load_cxx_plugins
26
26
  option_block.call if option_block
27
27
  toolchain = Provider[toolchain_name]
28
28
  raise "no provider with name \"#{toolchain_name}\" found" unless toolchain
29
- @base = base
30
- cd(@base, :verbose => false) do
29
+ @base_dir = base_dir
30
+ cd(@base_dir, :verbose => false) do
31
31
  @projects = projects.to_a
32
32
  end
33
33
 
@@ -42,7 +42,6 @@ module Cxxproject
42
42
  initialize_logging(build_dir)
43
43
  @all_tasks = instantiate_tasks(toolchain, build_dir)
44
44
 
45
-
46
45
  create_generic_tasks
47
46
  create_console_colorization
48
47
  create_multitask
@@ -88,11 +87,13 @@ module Cxxproject
88
87
  @log.level = Logger::ERROR
89
88
  @log.level = Logger::INFO if RakeFileUtils.verbose == true
90
89
  @log.level = Logger::DEBUG if Rake::application.options.trace
91
- @log.debug "initializing for build_dir: \"#{build_dir}\", base: \"#{@base}\""
90
+ @log.debug "initializing for build_dir: \"#{build_dir}\", base_dir: \"#{@base_dir}\""
92
91
  end
92
+
93
93
  def describe_clean_task
94
94
  Rake::Task[:clean].add_description('clean')
95
95
  end
96
+
96
97
  def create_bail_on_first_task
97
98
  desc 'set bail on first error'
98
99
  task :bail_on_first_error do
@@ -176,7 +177,7 @@ module Cxxproject
176
177
  end
177
178
 
178
179
  def check_for_project_configs
179
- cd(@base, :verbose => false) do
180
+ cd(@base_dir, :verbose => false) do
180
181
  @projects.each do |p|
181
182
  abort "project config #{p} cannot be found!" unless File.exists?(p)
182
183
  end
@@ -190,7 +191,7 @@ module Cxxproject
190
191
  end
191
192
 
192
193
  def register_projects()
193
- cd(@base,:verbose => false) do |b|
194
+ cd(@base_dir,:verbose => false) do |b|
194
195
  @projects.each_with_index do |project_file, i|
195
196
  @log.debug "register project #{project_file}"
196
197
  dirname = File.dirname(project_file)
@@ -202,6 +203,7 @@ module Cxxproject
202
203
  end
203
204
  end
204
205
  end
206
+
205
207
  def eval_file(b, project_file)
206
208
  loadContext = EvalContext.new
207
209
  begin
@@ -220,6 +222,7 @@ module Cxxproject
220
222
  end
221
223
  end
222
224
  end
225
+
223
226
  def define_project_info_task
224
227
  desc "shows your defined projects"
225
228
  task :project_info do
@@ -8,6 +8,7 @@ module Cxxproject
8
8
  def self.cleanup_rake()
9
9
  ALL_BUILDING_BLOCKS.clear
10
10
  Rake.application.clear
11
+ Cxxproject::ExitHelper.set_exit_code(nil)
11
12
  Rake.application.idei.set_abort(false)
12
13
  CLEAN.pending_add.clear
13
14
  CLEAN.items.clear
@@ -3,7 +3,7 @@ module Cxxproject
3
3
  end
4
4
 
5
5
  class ExitHelper
6
- @@exit_code = 0
6
+ @@exit_code = nil
7
7
  @@exit_test = false
8
8
 
9
9
  def self.set_exit_code(val)
@@ -36,5 +36,5 @@ module Cxxproject
36
36
  end
37
37
 
38
38
  at_exit do
39
- exit(Cxxproject::ExitHelper.exit_code)
39
+ exit(Cxxproject::ExitHelper.exit_code) unless Cxxproject::ExitHelper.exit_code.nil?
40
40
  end
@@ -1,7 +1,7 @@
1
1
  module Cxxproject
2
2
  class Version
3
3
  def self.cxxproject
4
- "0.6.5"
4
+ "0.6.6"
5
5
  end
6
6
  end
7
7
  end
@@ -5,6 +5,7 @@ require 'cxxproject'
5
5
  require 'cxxproject/utils/cleanup'
6
6
 
7
7
  describe Cxxproject::BuildingBlock do
8
+ compiler = 'gcc'
8
9
 
9
10
  before(:each) do
10
11
  Cxxproject::Utils.cleanup_rake
@@ -38,10 +39,10 @@ describe Cxxproject::BuildingBlock do
38
39
  lib2 = Cxxproject::SourceLibrary.new('lib2').set_sources(['test.cc']).set_output_dir('build2')
39
40
  lib2.set_project_dir(File.join(Dir.pwd, 'lib2'))
40
41
 
41
- cxx = CxxProject2Rake.new([], 'build', "clang")
42
-
43
- cxx.prepare_block(lib1, Provider["clang"], "build")
44
- cxx.prepare_block(lib2, Provider["clang"], "build")
42
+ cxx = CxxProject2Rake.new([], 'build', compiler)
43
+
44
+ cxx.prepare_block(lib1, Provider[compiler], "build")
45
+ cxx.prepare_block(lib2, Provider[compiler], "build")
45
46
 
46
47
  lib1.complete_output_dir.should eq(File.join(Dir.pwd, 'build'))
47
48
  lib2.complete_output_dir.should eq(File.join(Dir.pwd, 'lib2', 'build2'))
@@ -50,7 +51,7 @@ describe Cxxproject::BuildingBlock do
50
51
  it 'should raise exception if building block cannot be resolved' do
51
52
  expect do
52
53
  lib1 = Cxxproject::SourceLibrary.new('1').set_dependencies(['unresolved'])
53
- cxx = CxxProject2Rake.new([], 'build', "clang")
54
+ cxx = CxxProject2Rake.new([], 'build', compiler)
54
55
  end.to raise_exception(RuntimeError, 'Error: while reading config file for 1: dependent building block "unresolved" was specified but not found!')
55
56
  end
56
57
 
@@ -34,14 +34,6 @@ def rebuild
34
34
  execute_all_tasks(tasks)
35
35
  end
36
36
 
37
- #def is_older? fileA, fileB
38
- # File.mtime(fileA) < File.mtime(fileB)
39
- #end
40
- #
41
- #def is_newer? fileA, fileB
42
- # File.mtime(fileA) > File.mtime(fileB)
43
- #end
44
-
45
37
  def check_rebuilding (end_product, prereq_file, should_rebuild = true)
46
38
  sleep(1)
47
39
  FileUtils.touch prereq_file
@@ -66,24 +58,13 @@ end
66
58
  def fresh_cxx
67
59
  Cxxproject::Utils.cleanup_rake
68
60
  outputdir = 'output'
69
- CxxProject2Rake.new(Dir.glob('**/project.rb'), outputdir, "clang")
61
+ CxxProject2Rake.new(Dir.glob('**/project.rb'), outputdir, 'gcc')
70
62
  end
71
63
 
72
64
  def cleanup
73
65
  rm_r 'output' if File.directory?('output')
74
66
  end
75
67
 
76
- #def count_needed_tasks(tasks)
77
- # needed = 0
78
- # tasks.each do |tn|
79
- # t = tn[:task]
80
- # if t.needed?
81
- # needed = needed + 1
82
- # end
83
- # end
84
- # needed
85
- #end
86
-
87
68
  ONLY_ONE_HEADER = "#{RSPECDIR}/testdata/onlyOneHeader"
88
69
  describe CxxProject2Rake do
89
70
  before(:all) do
@@ -25,8 +25,8 @@ describe Cxxproject::IDEInterface do
25
25
  error.file_name = 'filename'
26
26
  error.message = 'error'
27
27
  packet = ide.create_error_packet(error)
28
-
29
- if not Cxxproject::Utils.old_ruby? # in Ruby 1.8.6 there is no bytes methods...
28
+
29
+ if not Cxxproject::Utils.old_ruby? # in Ruby 1.8.6 there is no bytes methods...
30
30
  e = packet.bytes
31
31
  e.next.should eq(1)
32
32
  check_long(e, 22)
@@ -4,7 +4,7 @@ require 'cxxproject/ext/rake_listener.rb'
4
4
  require 'cxxproject/utils/cleanup'
5
5
 
6
6
  describe Rake::Task do
7
-
7
+ compiler = 'gcc'
8
8
  before(:each) do
9
9
  Rake::application.options.silent = true
10
10
  Cxxproject::Utils.cleanup_rake
@@ -17,7 +17,7 @@ describe Rake::Task do
17
17
  file 'test.cc' => 'compiler'
18
18
  File.delete('test.cc') if File.exists?('test.cc')
19
19
  sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
20
- cxx = CxxProject2Rake.new([], 'build', "clang")
20
+ cxx = CxxProject2Rake.new([], 'build', compiler)
21
21
 
22
22
  task = Rake::application['lib:testlib']
23
23
  task.invoke
@@ -35,11 +35,11 @@ describe Rake::Task do
35
35
  end
36
36
 
37
37
  sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
38
- CxxProject2Rake.new([], 'build', "clang")
38
+ CxxProject2Rake.new([], 'build', compiler)
39
39
 
40
40
  task = Rake::application['lib:testlib']
41
41
  task.invoke
42
- task.failure.should eq(false)
42
+ task.failure.should == false
43
43
 
44
44
  Cxxproject::Utils.cleanup_rake
45
45
 
@@ -48,36 +48,13 @@ describe Rake::Task do
48
48
  end
49
49
 
50
50
  sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
51
- CxxProject2Rake.new([], 'build', "clang")
51
+ CxxProject2Rake.new([], 'build', compiler)
52
52
 
53
53
  task = Rake::application['build/libs/libtestlib.a']
54
54
  task.invoke
55
- task.failure.should eq(false)
55
+ task.failure.should == false
56
56
 
57
57
  FileUtils.rm_rf('test.cc')
58
58
  end
59
59
 
60
- it 'should not fail if generated headerfile is missing' do
61
- file 'test.h' do
62
- sh 'touch test.h'
63
- end
64
-
65
- file 'test.cc' => 'test.h' do |t|
66
- File.open(t.name, 'w') do |io|
67
- io.puts('#include "test.h"')
68
- end
69
- end
70
-
71
- sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
72
- CxxProject2Rake.new([], 'build', "clang")
73
-
74
- task = Rake::application['build/libs/libtestlib.a']
75
- task.invoke
76
- task.failure.should eq(false)
77
-
78
- FileUtils.rm_rf('build')
79
- FileUtils.rm_rf('test.cc')
80
- FileUtils.rm_rf('test.h')
81
- end
82
-
83
60
  end
@@ -18,7 +18,7 @@ describe CxxProject2Rake do
18
18
  cd base do # have to be relative to base
19
19
  project_configs = Dir.glob('**/project.rb')
20
20
  end
21
- CxxProject2Rake.new(project_configs, outputdir, "clang", base)
21
+ CxxProject2Rake.new(project_configs, outputdir, 'gcc', base)
22
22
  end
23
23
 
24
24
 
@@ -35,16 +35,16 @@ describe CxxProject2Rake do
35
35
  libTwo = "#{outputdir}/libs/lib2.a"
36
36
  exe = "#{outputdir}/basic.exe"
37
37
  exe2 = "#{outputdir}/debug.exe"
38
-
38
+ files = [libOne,libTwo,exe,exe2]
39
39
  rm_r outputdir if File.directory?(outputdir)
40
40
  tasks = fresh_cxx(outputdir, base).all_tasks
41
41
  CLOBBER.each { |fn| rm_r fn rescue nil }
42
42
 
43
- [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_false }
43
+ files.all? {|f| File.exists?(f).should be_false }
44
44
 
45
45
  execute_all_tasks(tasks)
46
46
 
47
- [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_true }
47
+ files.all? {|f| File.exists?(f).should be_true }
48
48
 
49
49
  # cleanup
50
50
  rm_r outputdir if File.directory?(outputdir)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cxxproject
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.5
5
+ version: 0.6.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - oliver mueller
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-07-06 00:00:00 Z
13
+ date: 2012-07-10 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: highline
@@ -140,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
- hash: 2926216662613263501
143
+ hash: -4017156678674831276
144
144
  segments:
145
145
  - 0
146
146
  version: "0"