cxxproject 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cxxproject/buildingblocks/building_block.rb +1 -0
- data/lib/cxxproject/ext/rake.rb +0 -1
- data/lib/cxxproject/torake.rb +11 -8
- data/lib/cxxproject/utils/cleanup.rb +1 -0
- data/lib/cxxproject/utils/exit_helper.rb +2 -2
- data/lib/cxxproject/version.rb +1 -1
- data/spec/building_block_spec.rb +6 -5
- data/spec/cxxproject_2_rake_spec.rb +1 -20
- data/spec/ide_interface_spec.rb +2 -2
- data/spec/object_dependency_spec.rb +6 -29
- data/spec/project_path_spec.rb +4 -4
- metadata +3 -3
data/lib/cxxproject/ext/rake.rb
CHANGED
data/lib/cxxproject/torake.rb
CHANGED
@@ -19,15 +19,15 @@ require 'rubygems'
|
|
19
19
|
module Cxxproject
|
20
20
|
|
21
21
|
class CxxProject2Rake
|
22
|
-
attr_accessor :
|
22
|
+
attr_accessor :base_dir, :all_tasks
|
23
23
|
|
24
|
-
def initialize(projects, build_dir, toolchain_name,
|
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
|
-
@
|
30
|
-
cd(@
|
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}\",
|
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(@
|
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(@
|
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
|
@@ -3,7 +3,7 @@ module Cxxproject
|
|
3
3
|
end
|
4
4
|
|
5
5
|
class ExitHelper
|
6
|
-
@@exit_code =
|
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
|
data/lib/cxxproject/version.rb
CHANGED
data/spec/building_block_spec.rb
CHANGED
@@ -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',
|
42
|
-
|
43
|
-
cxx.prepare_block(lib1, Provider[
|
44
|
-
cxx.prepare_block(lib2, Provider[
|
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',
|
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,
|
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
|
data/spec/ide_interface_spec.rb
CHANGED
@@ -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',
|
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',
|
38
|
+
CxxProject2Rake.new([], 'build', compiler)
|
39
39
|
|
40
40
|
task = Rake::application['lib:testlib']
|
41
41
|
task.invoke
|
42
|
-
task.failure.should
|
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',
|
51
|
+
CxxProject2Rake.new([], 'build', compiler)
|
52
52
|
|
53
53
|
task = Rake::application['build/libs/libtestlib.a']
|
54
54
|
task.invoke
|
55
|
-
task.failure.should
|
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
|
data/spec/project_path_spec.rb
CHANGED
@@ -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,
|
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
|
-
|
43
|
+
files.all? {|f| File.exists?(f).should be_false }
|
44
44
|
|
45
45
|
execute_all_tasks(tasks)
|
46
46
|
|
47
|
-
|
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
|
+
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-
|
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:
|
143
|
+
hash: -4017156678674831276
|
144
144
|
segments:
|
145
145
|
- 0
|
146
146
|
version: "0"
|