cxxproject 0.5.48 → 0.5.59
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.rb +116 -116
- data/bin/cxx +10 -10
- data/lib/cxxproject.rb +23 -23
- data/lib/cxxproject/buildingblocks/binary_library.rb +39 -39
- data/lib/cxxproject/buildingblocks/building_block.rb +251 -239
- data/lib/cxxproject/buildingblocks/command_line.rb +79 -79
- data/lib/cxxproject/buildingblocks/custom_building_block.rb +39 -41
- data/lib/cxxproject/buildingblocks/executable.rb +257 -249
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +83 -83
- data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -20
- data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +34 -34
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +371 -364
- data/lib/cxxproject/buildingblocks/makefile.rb +153 -153
- data/lib/cxxproject/buildingblocks/module.rb +35 -35
- data/lib/cxxproject/buildingblocks/single_source.rb +33 -33
- data/lib/cxxproject/buildingblocks/source_library.rb +124 -124
- data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -40
- data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +41 -33
- data/lib/cxxproject/errorparser/error_parser.rb +50 -50
- data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +35 -30
- data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +35 -29
- data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -30
- data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +30 -29
- data/lib/cxxproject/eval_context.rb +144 -136
- data/lib/cxxproject/ext/file.rb +71 -71
- data/lib/cxxproject/ext/filelist.rb +6 -6
- data/lib/cxxproject/ext/progressbar.rb +20 -20
- data/lib/cxxproject/ext/rake.rb +419 -397
- data/lib/cxxproject/ext/rake_dirty.rb +30 -30
- data/lib/cxxproject/ext/rake_listener.rb +59 -59
- data/lib/cxxproject/ext/stdout.rb +44 -44
- data/lib/cxxproject/ext/string.rb +9 -9
- data/lib/cxxproject/ide_interface.rb +187 -181
- data/lib/cxxproject/toolchain/clang.rb +39 -39
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -99
- data/lib/cxxproject/toolchain/diab.rb +3 -1
- data/lib/cxxproject/toolchain/gcc.rb +2 -1
- data/lib/cxxproject/toolchain/provider.rb +131 -128
- data/lib/cxxproject/toolchain/toolchain.rb +38 -38
- data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -23
- data/lib/cxxproject/torake.rb +218 -216
- data/lib/cxxproject/utils/cleanup.rb +20 -20
- data/lib/cxxproject/utils/console.rb +6 -6
- data/lib/cxxproject/utils/exit_helper.rb +40 -40
- data/lib/cxxproject/utils/graphstream.rb +154 -154
- data/lib/cxxproject/utils/optional.rb +16 -16
- data/lib/cxxproject/utils/printer.rb +50 -50
- data/lib/cxxproject/utils/process.rb +52 -52
- data/lib/cxxproject/utils/progress.rb +66 -66
- data/lib/cxxproject/utils/progress_helper.rb +77 -77
- data/lib/cxxproject/utils/rbcurse.rb +284 -284
- data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -14
- data/lib/cxxproject/utils/rbcurse_progress.rb +71 -71
- data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -51
- data/lib/cxxproject/utils/stats.rb +60 -60
- data/lib/cxxproject/utils/ubigraph.rb +228 -228
- data/lib/cxxproject/utils/utils.rb +60 -37
- data/lib/cxxproject/utils/valgrind.rb +11 -11
- data/lib/cxxproject/version.rb +7 -7
- data/lib/tools/Rakefile.rb.template +10 -10
- data/lib/tools/project.rb.template +6 -6
- data/lib/tools/project_wizard.rb +66 -66
- data/spec/building_block_spec.rb +56 -56
- data/spec/cxxproject_2_rake_spec.rb +186 -186
- data/spec/file_ext_spec.rb +30 -30
- data/spec/ide_interface_spec.rb +41 -41
- data/spec/object_dependency_spec.rb +83 -83
- data/spec/project_path_spec.rb +71 -71
- data/spec/rake_listener_ext_spec.rb +58 -58
- data/spec/spec_helper.rb +18 -18
- data/spec/string_spec.rb +11 -11
- data/spec/testdata/basic/exe12/project.rb +5 -5
- data/spec/testdata/basic/lib1/project.rb +5 -5
- data/spec/testdata/basic/lib2/project.rb +8 -8
- data/spec/testdata/multiple_levels/libs/lib1/project.rb +5 -5
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +19 -19
- data/spec/testdata/multiple_levels/mainproject/basic/project.rb +8 -8
- data/spec/testdata/onlyOneHeader/Rakefile.rb +4 -4
- data/spec/testdata/onlyOneHeader/project.rb +4 -4
- data/spec/toolchain_spec.rb +29 -29
- metadata +58 -58
@@ -1,37 +1,60 @@
|
|
1
|
-
module Cxxproject
|
2
|
-
module Utils
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
1
|
+
module Cxxproject
|
2
|
+
module Utils
|
3
|
+
|
4
|
+
def self.flagSplit(str)
|
5
|
+
hasQuote = false
|
6
|
+
hasDoubleQuote = false
|
7
|
+
ar = []
|
8
|
+
s = ""
|
9
|
+
|
10
|
+
str.split("").each do |i|
|
11
|
+
hasDoubleQuote = !hasDoubleQuote if !hasQuote and i == '"'
|
12
|
+
hasQuote = !hasQuote if !hasDoubleQuote and i == '\''
|
13
|
+
if i == ' '
|
14
|
+
if not hasDoubleQuote and not hasQuote
|
15
|
+
ar << s if s.length > 0
|
16
|
+
s = ""
|
17
|
+
next
|
18
|
+
end
|
19
|
+
end
|
20
|
+
s << i
|
21
|
+
end
|
22
|
+
ar << s if s.length > 0
|
23
|
+
ar
|
24
|
+
end
|
25
|
+
|
26
|
+
# Simple helper query the operating system we are running in
|
27
|
+
module OS
|
28
|
+
|
29
|
+
# Is it windows
|
30
|
+
def OS.windows?
|
31
|
+
(RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/) != nil
|
32
|
+
end
|
33
|
+
|
34
|
+
# Is it osx
|
35
|
+
def OS.mac?
|
36
|
+
(RUBY_PLATFORM =~ /darwin/) != nil
|
37
|
+
end
|
38
|
+
|
39
|
+
# Is it kind of unix
|
40
|
+
def OS.unix?
|
41
|
+
!OS.windows?
|
42
|
+
end
|
43
|
+
|
44
|
+
# Is it linux
|
45
|
+
def OS.linux?
|
46
|
+
OS.unix? and not OS.mac?
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.deep_copy(x)
|
52
|
+
Marshal.load(Marshal.dump(x))
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.old_ruby?
|
56
|
+
RUBY_VERSION[0..2] == "1.8"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module Cxxproject
|
2
|
-
class Valgrind
|
3
|
-
@@valgrind_available = nil
|
4
|
-
def self.available?
|
5
|
-
if @@valgrind_available == nil
|
6
|
-
@@valgrind_available = `which valgrind`.strip.length > 0
|
7
|
-
end
|
8
|
-
return @@valgrind_available
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
1
|
+
module Cxxproject
|
2
|
+
class Valgrind
|
3
|
+
@@valgrind_available = nil
|
4
|
+
def self.available?
|
5
|
+
if @@valgrind_available == nil
|
6
|
+
@@valgrind_available = `which valgrind 2>&1`.strip.length > 0
|
7
|
+
end
|
8
|
+
return @@valgrind_available
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/cxxproject/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module Cxxproject
|
2
|
-
class Version
|
3
|
-
def self.cxxproject
|
4
|
-
"0.5.
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
1
|
+
module Cxxproject
|
2
|
+
class Version
|
3
|
+
def self.cxxproject
|
4
|
+
"0.5.59"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'cxxproject'
|
2
|
-
BuildDir = "BuildDir"
|
3
|
-
|
4
|
-
unittest_flags = {
|
5
|
-
:DEFINES => ['UNIT_TEST','CPPUNIT_MAIN=main'],
|
6
|
-
:FLAGS => "-O0 -g3 -Wall"
|
7
|
-
}
|
8
|
-
toolchain = Provider.modify_cpp_compiler("GCC", unittest_flags)
|
9
|
-
dependent_projects = ['./project.rb']
|
10
|
-
CxxProject2Rake.new(dependent_projects, BuildDir, toolchain, './')
|
1
|
+
require 'cxxproject'
|
2
|
+
BuildDir = "BuildDir"
|
3
|
+
|
4
|
+
unittest_flags = {
|
5
|
+
:DEFINES => ['UNIT_TEST','CPPUNIT_MAIN=main'],
|
6
|
+
:FLAGS => "-O0 -g3 -Wall"
|
7
|
+
}
|
8
|
+
toolchain = Provider.modify_cpp_compiler("GCC", unittest_flags)
|
9
|
+
dependent_projects = ['./project.rb']
|
10
|
+
CxxProject2Rake.new(dependent_projects, BuildDir, toolchain, './')
|
@@ -1,6 +1,6 @@
|
|
1
|
-
cxx_configuration do
|
2
|
-
<%= building_block %> "<%= name %>",
|
3
|
-
:sources => FileList['**/*.cpp'],
|
4
|
-
:includes => ['include'],
|
5
|
-
:dependencies => []
|
6
|
-
end
|
1
|
+
cxx_configuration do
|
2
|
+
<%= building_block %> "<%= name %>",
|
3
|
+
:sources => FileList['**/*.cpp'],
|
4
|
+
:includes => ['include'],
|
5
|
+
:dependencies => []
|
6
|
+
end
|
data/lib/tools/project_wizard.rb
CHANGED
@@ -1,66 +1,66 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'erb'
|
3
|
-
|
4
|
-
def choose_building_block
|
5
|
-
res = nil
|
6
|
-
choose do |menu|
|
7
|
-
menu.prompt = "what building block do you want to start with?"
|
8
|
-
|
9
|
-
menu.choice(:exe) { res = "exe" }
|
10
|
-
menu.choice(:lib) { res = "source_lib" }
|
11
|
-
end
|
12
|
-
res
|
13
|
-
end
|
14
|
-
|
15
|
-
def choose_generate_makefile
|
16
|
-
res = true
|
17
|
-
choose do |menu|
|
18
|
-
menu.prompt = 'generate rakefile?'
|
19
|
-
menu.choice(:yes) { res = true }
|
20
|
-
menu.choice(:no) { res = false }
|
21
|
-
end
|
22
|
-
res
|
23
|
-
end
|
24
|
-
|
25
|
-
def prepare_project(d)
|
26
|
-
begin
|
27
|
-
require 'highline/import'
|
28
|
-
|
29
|
-
if agree("This will create a new cxx-project config in dir \"#{d}\" \nAre you sure you want to continue? [yn] ")
|
30
|
-
bb = choose_building_block
|
31
|
-
generate_makefile = choose_generate_makefile
|
32
|
-
|
33
|
-
create_project(d, bb, generate_makefile)
|
34
|
-
else
|
35
|
-
say "stopped project creation"
|
36
|
-
end
|
37
|
-
rescue LoadError
|
38
|
-
puts "Please 'gem install highline'"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
def create_project(d, bb, generate_rakefile)
|
44
|
-
rakefile_template = File.join(File.dirname(__FILE__),"..","tools","Rakefile.rb.template")
|
45
|
-
projectrb_template = File.join(File.dirname(__FILE__),"..","tools","project.rb.template")
|
46
|
-
s1 = IO.read(rakefile_template)
|
47
|
-
s2 = IO.read(projectrb_template)
|
48
|
-
name = "testme"
|
49
|
-
building_block = bb
|
50
|
-
mkdir_p(d, :verbose => false)
|
51
|
-
cd(d,:verbose => false) do
|
52
|
-
if ((File.exists? "Rakefile.rb") || (File.exists? "project.rb"))
|
53
|
-
abort "cannot create project in this directory, existing files would be overwritten!"
|
54
|
-
end
|
55
|
-
if generate_rakefile
|
56
|
-
write_template('Rakefile.rb', s1, binding)
|
57
|
-
end
|
58
|
-
write_template('project.rb', s2, binding)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def write_template(name, template_string, b)
|
63
|
-
File.open(name, 'w') do |f|
|
64
|
-
f.write ERB.new(template_string).result(b)
|
65
|
-
end
|
66
|
-
end
|
1
|
+
require 'rake'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
def choose_building_block
|
5
|
+
res = nil
|
6
|
+
choose do |menu|
|
7
|
+
menu.prompt = "what building block do you want to start with?"
|
8
|
+
|
9
|
+
menu.choice(:exe) { res = "exe" }
|
10
|
+
menu.choice(:lib) { res = "source_lib" }
|
11
|
+
end
|
12
|
+
res
|
13
|
+
end
|
14
|
+
|
15
|
+
def choose_generate_makefile
|
16
|
+
res = true
|
17
|
+
choose do |menu|
|
18
|
+
menu.prompt = 'generate rakefile?'
|
19
|
+
menu.choice(:yes) { res = true }
|
20
|
+
menu.choice(:no) { res = false }
|
21
|
+
end
|
22
|
+
res
|
23
|
+
end
|
24
|
+
|
25
|
+
def prepare_project(d)
|
26
|
+
begin
|
27
|
+
require 'highline/import'
|
28
|
+
|
29
|
+
if agree("This will create a new cxx-project config in dir \"#{d}\" \nAre you sure you want to continue? [yn] ")
|
30
|
+
bb = choose_building_block
|
31
|
+
generate_makefile = choose_generate_makefile
|
32
|
+
|
33
|
+
create_project(d, bb, generate_makefile)
|
34
|
+
else
|
35
|
+
say "stopped project creation"
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
puts "Please 'gem install highline'"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def create_project(d, bb, generate_rakefile)
|
44
|
+
rakefile_template = File.join(File.dirname(__FILE__),"..","tools","Rakefile.rb.template")
|
45
|
+
projectrb_template = File.join(File.dirname(__FILE__),"..","tools","project.rb.template")
|
46
|
+
s1 = IO.read(rakefile_template)
|
47
|
+
s2 = IO.read(projectrb_template)
|
48
|
+
name = "testme"
|
49
|
+
building_block = bb
|
50
|
+
mkdir_p(d, :verbose => false)
|
51
|
+
cd(d,:verbose => false) do
|
52
|
+
if ((File.exists? "Rakefile.rb") || (File.exists? "project.rb"))
|
53
|
+
abort "cannot create project in this directory, existing files would be overwritten!"
|
54
|
+
end
|
55
|
+
if generate_rakefile
|
56
|
+
write_template('Rakefile.rb', s1, binding)
|
57
|
+
end
|
58
|
+
write_template('project.rb', s2, binding)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def write_template(name, template_string, b)
|
63
|
+
File.open(name, 'w') do |f|
|
64
|
+
f.write ERB.new(template_string).result(b)
|
65
|
+
end
|
66
|
+
end
|
data/spec/building_block_spec.rb
CHANGED
@@ -1,56 +1,56 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'rspec'
|
4
|
-
require 'cxxproject'
|
5
|
-
require 'cxxproject/utils/cleanup'
|
6
|
-
|
7
|
-
describe Cxxproject::BuildingBlock do
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
Cxxproject::Utils.cleanup_rake
|
11
|
-
end
|
12
|
-
after(:each) do
|
13
|
-
Cxxproject::Utils.cleanup_rake
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should build the right dependency-chain' do
|
17
|
-
lib1 = Cxxproject::SourceLibrary.new('1')
|
18
|
-
lib2 = Cxxproject::SourceLibrary.new('2').set_dependencies(['1'])
|
19
|
-
lib3 = Cxxproject::SourceLibrary.new('3').set_dependencies(['1'])
|
20
|
-
lib4 = Cxxproject::SourceLibrary.new('4').set_dependencies(['2', '3'])
|
21
|
-
deps = lib4.all_dependencies.map { |d| d.name }
|
22
|
-
deps.should == ['4', '2', '3', '1']
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should build the right dependency-chain for custom blocks' do
|
26
|
-
lib1 = Cxxproject::SourceLibrary.new('1')
|
27
|
-
lib2 = Cxxproject::CustomBuildingBlock.new('2').set_dependencies(['1'])
|
28
|
-
lib3 = Cxxproject::SourceLibrary.new('3').set_dependencies(['1'])
|
29
|
-
lib4 = Cxxproject::CustomBuildingBlock.new('4').set_dependencies(['2', '3'])
|
30
|
-
deps = lib4.all_dependencies.map { |d| d.name }
|
31
|
-
deps.should == ['4', '2', '3', '1']
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should have the right output-directory' do
|
35
|
-
lib1 = Cxxproject::SourceLibrary.new('lib1').set_sources(['test.cc'])
|
36
|
-
lib1.set_project_dir(File.join(Dir.pwd, 'lib1'))
|
37
|
-
|
38
|
-
lib2 = Cxxproject::SourceLibrary.new('lib2').set_sources(['test.cc']).set_output_dir('build2')
|
39
|
-
lib2.set_project_dir(File.join(Dir.pwd, 'lib2'))
|
40
|
-
|
41
|
-
cxx = CxxProject2Rake.new([], 'build', GCCChain)
|
42
|
-
cxx.prepare_block(lib1)
|
43
|
-
cxx.prepare_block(lib2)
|
44
|
-
|
45
|
-
lib1.complete_output_dir.should eq(File.join(Dir.pwd, 'build'))
|
46
|
-
lib2.complete_output_dir.should eq(File.join(Dir.pwd, 'lib2', 'build2'))
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should raise exception if building block cannot be resolved' do
|
50
|
-
expect do
|
51
|
-
lib1 = Cxxproject::SourceLibrary.new('1').set_dependencies(['unresolved'])
|
52
|
-
cxx = CxxProject2Rake.new([], 'build', GCCChain)
|
53
|
-
end.to raise_exception(RuntimeError, 'Error: while reading config file for 1: dependent building block "unresolved" was specified but not found!')
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'cxxproject'
|
5
|
+
require 'cxxproject/utils/cleanup'
|
6
|
+
|
7
|
+
describe Cxxproject::BuildingBlock do
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
Cxxproject::Utils.cleanup_rake
|
11
|
+
end
|
12
|
+
after(:each) do
|
13
|
+
Cxxproject::Utils.cleanup_rake
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should build the right dependency-chain' do
|
17
|
+
lib1 = Cxxproject::SourceLibrary.new('1')
|
18
|
+
lib2 = Cxxproject::SourceLibrary.new('2').set_dependencies(['1'])
|
19
|
+
lib3 = Cxxproject::SourceLibrary.new('3').set_dependencies(['1'])
|
20
|
+
lib4 = Cxxproject::SourceLibrary.new('4').set_dependencies(['2', '3'])
|
21
|
+
deps = lib4.all_dependencies.map { |d| d.name }
|
22
|
+
deps.should == ['4', '2', '3', '1']
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should build the right dependency-chain for custom blocks' do
|
26
|
+
lib1 = Cxxproject::SourceLibrary.new('1')
|
27
|
+
lib2 = Cxxproject::CustomBuildingBlock.new('2').set_dependencies(['1'])
|
28
|
+
lib3 = Cxxproject::SourceLibrary.new('3').set_dependencies(['1'])
|
29
|
+
lib4 = Cxxproject::CustomBuildingBlock.new('4').set_dependencies(['2', '3'])
|
30
|
+
deps = lib4.all_dependencies.map { |d| d.name }
|
31
|
+
deps.should == ['4', '2', '3', '1']
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have the right output-directory' do
|
35
|
+
lib1 = Cxxproject::SourceLibrary.new('lib1').set_sources(['test.cc'])
|
36
|
+
lib1.set_project_dir(File.join(Dir.pwd, 'lib1'))
|
37
|
+
|
38
|
+
lib2 = Cxxproject::SourceLibrary.new('lib2').set_sources(['test.cc']).set_output_dir('build2')
|
39
|
+
lib2.set_project_dir(File.join(Dir.pwd, 'lib2'))
|
40
|
+
|
41
|
+
cxx = CxxProject2Rake.new([], 'build', GCCChain)
|
42
|
+
cxx.prepare_block(lib1)
|
43
|
+
cxx.prepare_block(lib2)
|
44
|
+
|
45
|
+
lib1.complete_output_dir.should eq(File.join(Dir.pwd, 'build'))
|
46
|
+
lib2.complete_output_dir.should eq(File.join(Dir.pwd, 'lib2', 'build2'))
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should raise exception if building block cannot be resolved' do
|
50
|
+
expect do
|
51
|
+
lib1 = Cxxproject::SourceLibrary.new('1').set_dependencies(['unresolved'])
|
52
|
+
cxx = CxxProject2Rake.new([], 'build', GCCChain)
|
53
|
+
end.to raise_exception(RuntimeError, 'Error: while reading config file for 1: dependent building block "unresolved" was specified but not found!')
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -1,186 +1,186 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'cxxproject'
|
3
|
-
require 'cxxproject/utils/cleanup'
|
4
|
-
|
5
|
-
RSPECDIR = File.dirname(__FILE__)
|
6
|
-
puts RSPECDIR
|
7
|
-
|
8
|
-
class SpecTaskListener
|
9
|
-
def initialize
|
10
|
-
@task_execution_count = 0
|
11
|
-
end
|
12
|
-
def before_prerequisites(name)
|
13
|
-
end
|
14
|
-
|
15
|
-
def after_prerequisites(name)
|
16
|
-
end
|
17
|
-
|
18
|
-
def before_execute(name)
|
19
|
-
@task_execution_count += 1
|
20
|
-
end
|
21
|
-
|
22
|
-
def after_execute(name)
|
23
|
-
end
|
24
|
-
def reset_exec_count()
|
25
|
-
@task_execution_count = 0
|
26
|
-
end
|
27
|
-
def get_exec_count()
|
28
|
-
@task_execution_count
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def rebuild
|
33
|
-
tasks = fresh_cxx.all_tasks
|
34
|
-
execute_all_tasks(tasks)
|
35
|
-
end
|
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
|
-
def check_rebuilding (end_product, prereq_file, should_rebuild = true)
|
46
|
-
sleep(
|
47
|
-
FileUtils.touch prereq_file
|
48
|
-
# prereq_file should be newer
|
49
|
-
File.mtime(prereq_file).should > File.mtime(end_product)
|
50
|
-
rebuild
|
51
|
-
if should_rebuild
|
52
|
-
# prereq_file should NOT be newer
|
53
|
-
File.mtime(prereq_file).should <= File.mtime(end_product)
|
54
|
-
else
|
55
|
-
# prereq_file should still be newer
|
56
|
-
File.mtime(prereq_file).should > File.mtime(end_product)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def execute_all_tasks(tasks)
|
61
|
-
tasks.each do |t|
|
62
|
-
t.invoke
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def fresh_cxx
|
67
|
-
Cxxproject::Utils.cleanup_rake
|
68
|
-
outputdir = 'output'
|
69
|
-
CxxProject2Rake.new(Dir.glob('**/project.rb'), outputdir, GCCChain)
|
70
|
-
end
|
71
|
-
|
72
|
-
def cleanup
|
73
|
-
rm_r 'output' if File.directory?('output')
|
74
|
-
end
|
75
|
-
|
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
|
-
ONLY_ONE_HEADER = "#{RSPECDIR}/testdata/onlyOneHeader"
|
88
|
-
describe CxxProject2Rake do
|
89
|
-
before(:all) do
|
90
|
-
Rake::application.options.silent = true
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'should provide runtask for executables' do
|
94
|
-
cd ONLY_ONE_HEADER, :verbose => false do
|
95
|
-
cleanup
|
96
|
-
tasks = fresh_cxx.all_tasks
|
97
|
-
Rake::Task['run:basic'].invoke
|
98
|
-
cleanup
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should rebuild only when one file was changed' do
|
103
|
-
require 'cxxproject/ext/rake_listener'
|
104
|
-
require 'cxxproject/ext/rake_dirty'
|
105
|
-
|
106
|
-
listener = SpecTaskListener.new
|
107
|
-
Rake::add_listener(listener)
|
108
|
-
cd(ONLY_ONE_HEADER, :verbose => false) do
|
109
|
-
# fresh build
|
110
|
-
listener.reset_exec_count
|
111
|
-
cleanup
|
112
|
-
|
113
|
-
tasks = fresh_cxx.all_tasks
|
114
|
-
CLOBBER.each { |fn| rm_r fn rescue nil }
|
115
|
-
execute_all_tasks(tasks)
|
116
|
-
fresh_build_steps = listener.get_exec_count
|
117
|
-
|
118
|
-
# rebuild, nothing changed
|
119
|
-
listener.reset_exec_count
|
120
|
-
execute_all_tasks(tasks)
|
121
|
-
rebuild_build_steps = listener.get_exec_count
|
122
|
-
|
123
|
-
# rebuild, nothing changed
|
124
|
-
listener.reset_exec_count
|
125
|
-
execute_all_tasks(tasks)
|
126
|
-
listener.get_exec_count.should == rebuild_build_steps
|
127
|
-
|
128
|
-
# rebuild after header changed
|
129
|
-
listener.reset_exec_count
|
130
|
-
sleep(1)
|
131
|
-
files2touch = Dir.glob('help.h')
|
132
|
-
FileUtils.touch files2touch
|
133
|
-
execute_all_tasks(fresh_cxx.all_tasks)
|
134
|
-
rebuild_after_touch_steps = listener.get_exec_count
|
135
|
-
rebuild_after_touch_steps.should > rebuild_build_steps
|
136
|
-
|
137
|
-
# rebuild, nothing changed
|
138
|
-
listener.reset_exec_count
|
139
|
-
execute_all_tasks(tasks)
|
140
|
-
listener.get_exec_count.should == rebuild_build_steps
|
141
|
-
|
142
|
-
cleanup
|
143
|
-
end
|
144
|
-
Rake::remove_listener(listener)
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'should rebuild when any source file changes' do
|
148
|
-
cd("#{RSPECDIR}/testdata/basic", :verbose => false) do
|
149
|
-
cleanup
|
150
|
-
|
151
|
-
tasks = fresh_cxx.all_tasks
|
152
|
-
CLOBBER.each { |fn| rm_r fn rescue nil }
|
153
|
-
execute_all_tasks(tasks)
|
154
|
-
|
155
|
-
# dependencies: exe -> libC -> libB
|
156
|
-
|
157
|
-
headerA = 'exe12/help.h'
|
158
|
-
sourceA = 'exe12/main.cpp'
|
159
|
-
projectA = 'exe12/project.rb'
|
160
|
-
headerB = 'lib1/lib1.h'
|
161
|
-
sourceB = 'lib1/lib1.cpp'
|
162
|
-
projectB = 'lib1/project.rb'
|
163
|
-
headerC = 'lib2/lib2.h'
|
164
|
-
sourceC = 'lib2/lib2.cpp'
|
165
|
-
projectC = 'lib2/project.rb'
|
166
|
-
exe = 'output/basic.exe'
|
167
|
-
libB = 'output/libs/lib1.a'
|
168
|
-
libC = 'output/libs/lib2.a'
|
169
|
-
|
170
|
-
check_rebuilding exe, headerA
|
171
|
-
check_rebuilding exe, sourceA
|
172
|
-
check_rebuilding exe, projectA
|
173
|
-
check_rebuilding exe, headerB
|
174
|
-
check_rebuilding exe, headerC
|
175
|
-
check_rebuilding libB, sourceA, false
|
176
|
-
check_rebuilding libB, sourceB
|
177
|
-
|
178
|
-
check_rebuilding libB, sourceC, false
|
179
|
-
check_rebuilding libC, sourceB
|
180
|
-
|
181
|
-
cleanup
|
182
|
-
Cxxproject::Utils.cleanup_rake
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cxxproject'
|
3
|
+
require 'cxxproject/utils/cleanup'
|
4
|
+
|
5
|
+
RSPECDIR = File.dirname(__FILE__)
|
6
|
+
puts RSPECDIR
|
7
|
+
|
8
|
+
class SpecTaskListener
|
9
|
+
def initialize
|
10
|
+
@task_execution_count = 0
|
11
|
+
end
|
12
|
+
def before_prerequisites(name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def after_prerequisites(name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def before_execute(name)
|
19
|
+
@task_execution_count += 1
|
20
|
+
end
|
21
|
+
|
22
|
+
def after_execute(name)
|
23
|
+
end
|
24
|
+
def reset_exec_count()
|
25
|
+
@task_execution_count = 0
|
26
|
+
end
|
27
|
+
def get_exec_count()
|
28
|
+
@task_execution_count
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def rebuild
|
33
|
+
tasks = fresh_cxx.all_tasks
|
34
|
+
execute_all_tasks(tasks)
|
35
|
+
end
|
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
|
+
def check_rebuilding (end_product, prereq_file, should_rebuild = true)
|
46
|
+
sleep(2)
|
47
|
+
FileUtils.touch prereq_file
|
48
|
+
# prereq_file should be newer
|
49
|
+
File.mtime(prereq_file).should > File.mtime(end_product)
|
50
|
+
rebuild
|
51
|
+
if should_rebuild
|
52
|
+
# prereq_file should NOT be newer
|
53
|
+
File.mtime(prereq_file).should <= File.mtime(end_product)
|
54
|
+
else
|
55
|
+
# prereq_file should still be newer
|
56
|
+
File.mtime(prereq_file).should > File.mtime(end_product)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def execute_all_tasks(tasks)
|
61
|
+
tasks.each do |t|
|
62
|
+
t.invoke
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def fresh_cxx
|
67
|
+
Cxxproject::Utils.cleanup_rake
|
68
|
+
outputdir = 'output'
|
69
|
+
CxxProject2Rake.new(Dir.glob('**/project.rb'), outputdir, GCCChain)
|
70
|
+
end
|
71
|
+
|
72
|
+
def cleanup
|
73
|
+
rm_r 'output' if File.directory?('output')
|
74
|
+
end
|
75
|
+
|
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
|
+
ONLY_ONE_HEADER = "#{RSPECDIR}/testdata/onlyOneHeader"
|
88
|
+
describe CxxProject2Rake do
|
89
|
+
before(:all) do
|
90
|
+
Rake::application.options.silent = true
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should provide runtask for executables' do
|
94
|
+
cd ONLY_ONE_HEADER, :verbose => false do
|
95
|
+
cleanup
|
96
|
+
tasks = fresh_cxx.all_tasks
|
97
|
+
Rake::Task['run:basic'].invoke
|
98
|
+
cleanup
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should rebuild only when one file was changed' do
|
103
|
+
require 'cxxproject/ext/rake_listener'
|
104
|
+
require 'cxxproject/ext/rake_dirty'
|
105
|
+
|
106
|
+
listener = SpecTaskListener.new
|
107
|
+
Rake::add_listener(listener)
|
108
|
+
cd(ONLY_ONE_HEADER, :verbose => false) do
|
109
|
+
# fresh build
|
110
|
+
listener.reset_exec_count
|
111
|
+
cleanup
|
112
|
+
|
113
|
+
tasks = fresh_cxx.all_tasks
|
114
|
+
CLOBBER.each { |fn| rm_r fn rescue nil }
|
115
|
+
execute_all_tasks(tasks)
|
116
|
+
fresh_build_steps = listener.get_exec_count
|
117
|
+
|
118
|
+
# rebuild, nothing changed
|
119
|
+
listener.reset_exec_count
|
120
|
+
execute_all_tasks(tasks)
|
121
|
+
rebuild_build_steps = listener.get_exec_count
|
122
|
+
|
123
|
+
# rebuild, nothing changed
|
124
|
+
listener.reset_exec_count
|
125
|
+
execute_all_tasks(tasks)
|
126
|
+
listener.get_exec_count.should == rebuild_build_steps
|
127
|
+
|
128
|
+
# rebuild after header changed
|
129
|
+
listener.reset_exec_count
|
130
|
+
sleep(1)
|
131
|
+
files2touch = Dir.glob('help.h')
|
132
|
+
FileUtils.touch files2touch
|
133
|
+
execute_all_tasks(fresh_cxx.all_tasks)
|
134
|
+
rebuild_after_touch_steps = listener.get_exec_count
|
135
|
+
rebuild_after_touch_steps.should > rebuild_build_steps
|
136
|
+
|
137
|
+
# rebuild, nothing changed
|
138
|
+
listener.reset_exec_count
|
139
|
+
execute_all_tasks(tasks)
|
140
|
+
listener.get_exec_count.should == rebuild_build_steps
|
141
|
+
|
142
|
+
cleanup
|
143
|
+
end
|
144
|
+
Rake::remove_listener(listener)
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should rebuild when any source file changes' do
|
148
|
+
cd("#{RSPECDIR}/testdata/basic", :verbose => false) do
|
149
|
+
cleanup
|
150
|
+
|
151
|
+
tasks = fresh_cxx.all_tasks
|
152
|
+
CLOBBER.each { |fn| rm_r fn rescue nil }
|
153
|
+
execute_all_tasks(tasks)
|
154
|
+
|
155
|
+
# dependencies: exe -> libC -> libB
|
156
|
+
|
157
|
+
headerA = 'exe12/help.h'
|
158
|
+
sourceA = 'exe12/main.cpp'
|
159
|
+
projectA = 'exe12/project.rb'
|
160
|
+
headerB = 'lib1/lib1.h'
|
161
|
+
sourceB = 'lib1/lib1.cpp'
|
162
|
+
projectB = 'lib1/project.rb'
|
163
|
+
headerC = 'lib2/lib2.h'
|
164
|
+
sourceC = 'lib2/lib2.cpp'
|
165
|
+
projectC = 'lib2/project.rb'
|
166
|
+
exe = 'output/basic.exe'
|
167
|
+
libB = 'output/libs/lib1.a'
|
168
|
+
libC = 'output/libs/lib2.a'
|
169
|
+
|
170
|
+
check_rebuilding exe, headerA
|
171
|
+
check_rebuilding exe, sourceA
|
172
|
+
check_rebuilding exe, projectA
|
173
|
+
check_rebuilding exe, headerB
|
174
|
+
check_rebuilding exe, headerC
|
175
|
+
check_rebuilding libB, sourceA, false
|
176
|
+
check_rebuilding libB, sourceB
|
177
|
+
|
178
|
+
check_rebuilding libB, sourceC, false
|
179
|
+
check_rebuilding libC, sourceB
|
180
|
+
|
181
|
+
cleanup
|
182
|
+
Cxxproject::Utils.cleanup_rake
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|