cxxproject 0.6.28 → 0.6.29
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/Gemfile.lock +3 -3
- data/lib/cxxproject/buildingblocks/executable.rb +13 -33
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +8 -21
- data/lib/cxxproject/buildingblocks/source_library.rb +10 -23
- data/lib/cxxproject/ext/file.rb +34 -48
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +2 -2
- data/lib/cxxproject/utils/process.rb +10 -12
- data/lib/cxxproject/version.rb +1 -1
- data/rake_helper/spec.rb +6 -22
- metadata +3 -6
- data/spec/cxxproject_2_rake_spe.rb +0 -167
- data/spec/object_dependency_spe.rb +0 -60
- data/spec/project_path_spe.rb +0 -70
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
builder (3.
|
4
|
+
builder (3.1.3)
|
5
5
|
diff-lcs (1.1.3)
|
6
6
|
frazzle (0.1.3)
|
7
7
|
grit (2.5.0)
|
@@ -17,9 +17,9 @@ GEM
|
|
17
17
|
rspec-expectations (~> 2.11.0)
|
18
18
|
rspec-mocks (~> 2.11.0)
|
19
19
|
rspec-core (2.11.1)
|
20
|
-
rspec-expectations (2.11.
|
20
|
+
rspec-expectations (2.11.3)
|
21
21
|
diff-lcs (~> 1.1.3)
|
22
|
-
rspec-mocks (2.11.
|
22
|
+
rspec-mocks (2.11.2)
|
23
23
|
ruby_parser (2.3.1)
|
24
24
|
sexp_processor (~> 3.0)
|
25
25
|
sexp_processor (3.2.0)
|
@@ -142,41 +142,21 @@ module Cxxproject
|
|
142
142
|
cmd += linker[:LIB_POSTFIX_FLAGS].split(" ") # TODO ... is this still needed e.g. for diab
|
143
143
|
|
144
144
|
mapfileStr = @mapfile ? " >#{@mapfile}" : ""
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
end
|
159
|
-
printCmd(cmdLinePrint, "Linking #{get_executable_name}", false)
|
160
|
-
consoleOutput = `#{strCmd}`
|
161
|
-
consoleOutput.concat(read_file_or_empty_string(get_temp_filename))
|
162
|
-
else
|
163
|
-
rd, wr = IO.pipe
|
164
|
-
cmdLinePrint = cmd
|
165
|
-
printCmd(cmdLinePrint, "Linking #{get_executable_name}", false)
|
166
|
-
cmd << {
|
167
|
-
:out=> @mapfile ? "#{@mapfile}" : wr, # > xy.map
|
168
|
-
:err=>wr
|
169
|
-
}
|
170
|
-
sp = spawn(*cmd)
|
171
|
-
cmd.pop
|
172
|
-
|
173
|
-
# for console print
|
174
|
-
cmd << " >#{@mapfile}" if @mapfile
|
175
|
-
consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
|
176
|
-
end
|
145
|
+
rd, wr = IO.pipe
|
146
|
+
cmdLinePrint = cmd
|
147
|
+
printCmd(cmdLinePrint, "Linking #{get_executable_name}", false)
|
148
|
+
cmd << {
|
149
|
+
:out=> @mapfile ? "#{@mapfile}" : wr, # > xy.map
|
150
|
+
:err=>wr
|
151
|
+
}
|
152
|
+
sp = spawn(*cmd)
|
153
|
+
cmd.pop
|
154
|
+
|
155
|
+
# for console print
|
156
|
+
cmd << " >#{@mapfile}" if @mapfile
|
157
|
+
consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
|
177
158
|
|
178
159
|
process_result(cmdLinePrint, consoleOutput, linker[:ERROR_PARSER], nil)
|
179
|
-
|
180
160
|
check_config_file()
|
181
161
|
end
|
182
162
|
end
|
@@ -286,27 +286,14 @@ module Cxxproject
|
|
286
286
|
cmd += compiler[:PREPRO_FLAGS].split(" ") if Rake::application.preproFlags
|
287
287
|
cmd << sourceRel
|
288
288
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
else
|
298
|
-
consoleOutput = `#{cmd.join(" ")} 2>&1`
|
299
|
-
end
|
300
|
-
else
|
301
|
-
rd, wr = IO.pipe
|
302
|
-
cmd << {
|
303
|
-
:err=>wr,
|
304
|
-
:out=>wr
|
305
|
-
}
|
306
|
-
sp = spawn(*cmd)
|
307
|
-
cmd.pop
|
308
|
-
consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
|
309
|
-
end
|
289
|
+
rd, wr = IO.pipe
|
290
|
+
cmd << {
|
291
|
+
:err=>wr,
|
292
|
+
:out=>wr
|
293
|
+
}
|
294
|
+
sp = spawn(*cmd)
|
295
|
+
cmd.pop
|
296
|
+
consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
|
310
297
|
|
311
298
|
process_result(cmd, consoleOutput, compiler[:ERROR_PARSER], "Compiling #{sourceRel}")
|
312
299
|
|
@@ -80,29 +80,16 @@ module Cxxproject
|
|
80
80
|
cmd << aname # -o debug/x.exe
|
81
81
|
cmd += objs
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
94
|
-
else
|
95
|
-
cmd.map! {|c| c.include?(' ') ? "\"#{c}\"" : c }
|
96
|
-
rd, wr = IO.pipe
|
97
|
-
cmd << {
|
98
|
-
:err => wr,
|
99
|
-
:out => wr
|
100
|
-
}
|
101
|
-
sp = spawn(*cmd)
|
102
|
-
cmd.pop
|
103
|
-
|
104
|
-
consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
|
105
|
-
end
|
83
|
+
cmd.map! {|c| c.include?(' ') ? "\"#{c}\"" : c }
|
84
|
+
rd, wr = IO.pipe
|
85
|
+
cmd << {
|
86
|
+
:err => wr,
|
87
|
+
:out => wr
|
88
|
+
}
|
89
|
+
sp = spawn(*cmd)
|
90
|
+
cmd.pop
|
91
|
+
|
92
|
+
consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
|
106
93
|
|
107
94
|
process_result(cmd, consoleOutput, archiver[:ERROR_PARSER], "Creating #{aname}")
|
108
95
|
|
data/lib/cxxproject/ext/file.rb
CHANGED
@@ -5,61 +5,47 @@ class File
|
|
5
5
|
SLASH = '/'
|
6
6
|
|
7
7
|
def self.is_absolute?(filename)
|
8
|
-
|
9
|
-
filename[0] == 47 or filename[1] == 58 # 47 = /, 58 = :
|
10
|
-
else
|
11
|
-
filename[0] == SLASH or filename[1] == ':'
|
12
|
-
end
|
8
|
+
filename[0] == SLASH or filename[1] == ':'
|
13
9
|
end
|
14
10
|
|
15
11
|
def self.rel_from_to_project(from,to,endWithSlash = true)
|
16
12
|
return nil if from.nil? or to.nil?
|
17
|
-
|
18
|
-
toSplitted = to.split('/')
|
19
|
-
fromSplitted = from.split('/')
|
20
|
-
|
21
|
-
max = [toSplitted.length, fromSplitted.length].min
|
22
|
-
|
23
|
-
return nil if max < 1
|
24
|
-
|
25
|
-
i = 0
|
26
13
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
14
|
+
toSplitted = to.split('/')
|
15
|
+
fromSplitted = from.split('/')
|
16
|
+
max = [toSplitted.length, fromSplitted.length].min
|
17
|
+
return nil if max < 1
|
18
|
+
|
19
|
+
i = 0
|
20
|
+
# path letter in windows may be case different
|
21
|
+
if toSplitted[0].length > 1 and fromSplitted[0].length > 1
|
22
|
+
i = 1 if toSplitted[0][1] == ':' and fromSplitted[0][1] == ':' and toSplitted[0].swapcase[0] == fromSplitted[0][0]
|
23
|
+
end
|
24
|
+
while i < max
|
25
|
+
break if toSplitted[i] != fromSplitted[i]
|
26
|
+
i += 1
|
27
|
+
end
|
28
|
+
j = i
|
29
|
+
res = []
|
30
|
+
while i < fromSplitted.length
|
31
|
+
res << ".."
|
32
|
+
i += 1
|
33
|
+
end
|
34
|
+
|
35
|
+
while j < toSplitted.length
|
36
|
+
res << toSplitted[j]
|
37
|
+
j += 1
|
38
|
+
end
|
39
|
+
|
40
|
+
if res.length == 0
|
41
|
+
return ""
|
42
|
+
end
|
43
|
+
|
44
|
+
res = res.join('/')
|
45
|
+
res += "/" if endWithSlash
|
46
|
+
res
|
60
47
|
end
|
61
48
|
|
62
|
-
|
63
49
|
def self.add_prefix(prefix, file)
|
64
50
|
if not prefix or is_absolute?(file)
|
65
51
|
file
|
@@ -18,7 +18,7 @@ module Cxxproject
|
|
18
18
|
# simple class to colorize compiler output
|
19
19
|
# the class depends on the rainbow gem
|
20
20
|
class ColorizingFormatter
|
21
|
-
|
21
|
+
|
22
22
|
# colors are not instance vars due to caching the building blocks
|
23
23
|
def self.setColorScheme(scheme)
|
24
24
|
if scheme == :black
|
@@ -76,7 +76,7 @@ module Cxxproject
|
|
76
76
|
else
|
77
77
|
res << l
|
78
78
|
end
|
79
|
-
res << "\n"
|
79
|
+
res << "\n"
|
80
80
|
end
|
81
81
|
rescue Exception => e
|
82
82
|
puts "Error while parsing compiler output: #{e}"
|
@@ -5,14 +5,14 @@ module Cxxproject
|
|
5
5
|
|
6
6
|
def self.readOutput(sp, rd, wr)
|
7
7
|
wr.close
|
8
|
-
|
8
|
+
|
9
9
|
consoleOutput = ""
|
10
10
|
begin
|
11
|
-
while not rd.eof?
|
11
|
+
while not rd.eof?
|
12
12
|
tmp = rd.read(1000)
|
13
13
|
if (tmp != nil)
|
14
14
|
consoleOutput << tmp
|
15
|
-
end
|
15
|
+
end
|
16
16
|
end
|
17
17
|
rescue Exception=>e
|
18
18
|
# Seems to be a bug in ruby: sometimes there is a bad file descriptor on Windows instead of eof, which causes
|
@@ -20,24 +20,22 @@ module Cxxproject
|
|
20
20
|
# how to "break" the loop.
|
21
21
|
# This problem occurs on Windows command shell and Cygwin.
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
Process.wait(sp)
|
25
25
|
rd.close
|
26
|
-
|
27
|
-
# seems that pipe cannot handle non-ascii characters right on windows (even with correct encoding)
|
26
|
+
|
27
|
+
# seems that pipe cannot handle non-ascii characters right on windows (even with correct encoding)
|
28
28
|
consoleOutput.gsub!(/\xE2\x80\x98/,"`") # ���
|
29
29
|
consoleOutput.gsub!(/\xE2\x80\x99/,"'") # ���
|
30
|
-
|
30
|
+
|
31
31
|
consoleOutput
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.spawnProcess(cmdLine)
|
35
|
-
return system(cmdLine) if Cxxproject::Utils.old_ruby?
|
36
|
-
|
37
35
|
@@pid = spawn(cmdLine)
|
38
36
|
pid, status = Process.wait2(@@pid)
|
39
37
|
@@pid = nil
|
40
|
-
status.success?
|
38
|
+
status.success?
|
41
39
|
end
|
42
40
|
|
43
41
|
def self.killProcess
|
@@ -47,7 +45,7 @@ module Cxxproject
|
|
47
45
|
end
|
48
46
|
@@pid = nil
|
49
47
|
end
|
50
|
-
|
48
|
+
|
51
49
|
end
|
52
50
|
|
53
|
-
end
|
51
|
+
end
|
data/lib/cxxproject/version.rb
CHANGED
data/rake_helper/spec.rb
CHANGED
@@ -44,7 +44,9 @@ def new_rspec
|
|
44
44
|
desc "Run examples"
|
45
45
|
RSpec::Core::RakeTask.new() do |t|
|
46
46
|
t.pattern = SPEC_PATTERN
|
47
|
-
|
47
|
+
if ENV['BUILD_SERVER']
|
48
|
+
t.rspec_opts = '-r ./junit.rb -f JUnit -o build/test_details.xml'
|
49
|
+
end
|
48
50
|
end
|
49
51
|
|
50
52
|
desc 'Run examples with coverage'
|
@@ -52,30 +54,12 @@ def new_rspec
|
|
52
54
|
CLOBBER.include('coverage')
|
53
55
|
end
|
54
56
|
|
55
|
-
def old_rspec
|
56
|
-
require 'spec/rake/spectask'
|
57
|
-
desc "Run examples"
|
58
|
-
Spec::Rake::SpecTask.new() do |t|
|
59
|
-
t.spec_files = SPEC_PATTERN
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
57
|
namespace :spec do
|
64
|
-
|
65
|
-
new_rspec
|
66
|
-
rescue LoadError
|
67
|
-
begin
|
68
|
-
old_rspec
|
69
|
-
rescue LoadError
|
70
|
-
desc "Run examples"
|
71
|
-
task 'spec' do
|
72
|
-
puts 'rspec not installed...! please install with "gem install rspec"'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
58
|
+
new_rspec
|
76
59
|
end
|
60
|
+
|
77
61
|
task :spec do
|
78
62
|
puts 'Please use spec:spec or spec:coverage'
|
79
63
|
end
|
80
|
-
task :gem => [:spec]
|
81
64
|
|
65
|
+
task :gem => [:spec]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cxxproject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.29
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colored
|
@@ -168,12 +168,9 @@ files:
|
|
168
168
|
- rake_helper/spec.rb
|
169
169
|
- roodi.yml
|
170
170
|
- spec/building_block_spec.rb
|
171
|
-
- spec/cxxproject_2_rake_spe.rb
|
172
171
|
- spec/file_ext_spec.rb
|
173
172
|
- spec/ide_interface_spec.rb
|
174
|
-
- spec/object_dependency_spe.rb
|
175
173
|
- spec/plugin_context_spec.rb
|
176
|
-
- spec/project_path_spe.rb
|
177
174
|
- spec/provider_spec.rb
|
178
175
|
- spec/rake_listener_ext_spec.rb
|
179
176
|
- spec/spec_helper.rb
|
@@ -220,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
217
|
version: '0'
|
221
218
|
segments:
|
222
219
|
- 0
|
223
|
-
hash:
|
220
|
+
hash: 4389251987030978626
|
224
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
222
|
none: false
|
226
223
|
requirements:
|
@@ -1,167 +0,0 @@
|
|
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 check_rebuilding (end_product, prereq_file, should_rebuild = true)
|
38
|
-
sleep(1)
|
39
|
-
FileUtils.touch prereq_file
|
40
|
-
# prereq_file should be newer
|
41
|
-
File.mtime(prereq_file).should > File.mtime(end_product)
|
42
|
-
rebuild
|
43
|
-
if should_rebuild
|
44
|
-
# prereq_file should NOT be newer
|
45
|
-
File.mtime(prereq_file).should <= File.mtime(end_product)
|
46
|
-
else
|
47
|
-
# prereq_file should still be newer
|
48
|
-
File.mtime(prereq_file).should > File.mtime(end_product)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def execute_all_tasks(tasks)
|
53
|
-
tasks.each do |t|
|
54
|
-
t.invoke
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def fresh_cxx
|
59
|
-
Cxxproject::Utils.cleanup_rake
|
60
|
-
outputdir = 'output'
|
61
|
-
CxxProject2Rake.new(Dir.glob('**/project.rb'), outputdir, 'gcc')
|
62
|
-
end
|
63
|
-
|
64
|
-
def cleanup
|
65
|
-
rm_r 'output' if File.directory?('output')
|
66
|
-
end
|
67
|
-
|
68
|
-
ONLY_ONE_HEADER = "#{RSPECDIR}/testdata/onlyOneHeader"
|
69
|
-
describe CxxProject2Rake do
|
70
|
-
before(:all) do
|
71
|
-
Rake::application.options.silent = true
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should provide runtask for executables' do
|
75
|
-
cd ONLY_ONE_HEADER, :verbose => false do
|
76
|
-
cleanup
|
77
|
-
tasks = fresh_cxx.all_tasks
|
78
|
-
Rake::Task['run:basic'].invoke
|
79
|
-
cleanup
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should rebuild only when one file was changed' do
|
84
|
-
require 'cxxproject/ext/rake_listener'
|
85
|
-
require 'cxxproject/ext/rake_dirty'
|
86
|
-
|
87
|
-
listener = SpecTaskListener.new
|
88
|
-
Rake::add_listener(listener)
|
89
|
-
cd(ONLY_ONE_HEADER, :verbose => false) do
|
90
|
-
# fresh build
|
91
|
-
listener.reset_exec_count
|
92
|
-
cleanup
|
93
|
-
|
94
|
-
tasks = fresh_cxx.all_tasks
|
95
|
-
CLOBBER.each { |fn| rm_r fn rescue nil }
|
96
|
-
execute_all_tasks(tasks)
|
97
|
-
fresh_build_steps = listener.get_exec_count
|
98
|
-
|
99
|
-
# rebuild, nothing changed
|
100
|
-
listener.reset_exec_count
|
101
|
-
execute_all_tasks(tasks)
|
102
|
-
rebuild_build_steps = listener.get_exec_count
|
103
|
-
|
104
|
-
# rebuild, nothing changed
|
105
|
-
listener.reset_exec_count
|
106
|
-
execute_all_tasks(tasks)
|
107
|
-
listener.get_exec_count.should == rebuild_build_steps
|
108
|
-
|
109
|
-
# rebuild after header changed
|
110
|
-
listener.reset_exec_count
|
111
|
-
sleep(1)
|
112
|
-
files2touch = Dir.glob('help.h')
|
113
|
-
FileUtils.touch files2touch
|
114
|
-
execute_all_tasks(fresh_cxx.all_tasks)
|
115
|
-
rebuild_after_touch_steps = listener.get_exec_count
|
116
|
-
rebuild_after_touch_steps.should > rebuild_build_steps
|
117
|
-
|
118
|
-
# rebuild, nothing changed
|
119
|
-
listener.reset_exec_count
|
120
|
-
execute_all_tasks(tasks)
|
121
|
-
listener.get_exec_count.should == rebuild_build_steps
|
122
|
-
|
123
|
-
cleanup
|
124
|
-
end
|
125
|
-
Rake::remove_listener(listener)
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'should rebuild when any source file changes' do
|
129
|
-
cd("#{RSPECDIR}/testdata/basic", :verbose => false) do
|
130
|
-
cleanup
|
131
|
-
|
132
|
-
tasks = fresh_cxx.all_tasks
|
133
|
-
CLOBBER.each { |fn| rm_r fn rescue nil }
|
134
|
-
execute_all_tasks(tasks)
|
135
|
-
|
136
|
-
# dependencies: exe -> libC -> libB
|
137
|
-
|
138
|
-
headerA = 'exe12/help.h'
|
139
|
-
sourceA = 'exe12/main.cpp'
|
140
|
-
projectA = 'exe12/project.rb'
|
141
|
-
headerB = 'lib1/lib1.h'
|
142
|
-
sourceB = 'lib1/lib1.cpp'
|
143
|
-
projectB = 'lib1/project.rb'
|
144
|
-
headerC = 'lib2/lib2.h'
|
145
|
-
sourceC = 'lib2/lib2.cpp'
|
146
|
-
projectC = 'lib2/project.rb'
|
147
|
-
exe = 'output/basic.exe'
|
148
|
-
libB = 'output/libs/lib1.a'
|
149
|
-
libC = 'output/libs/lib2.a'
|
150
|
-
|
151
|
-
check_rebuilding exe, headerA
|
152
|
-
check_rebuilding exe, sourceA
|
153
|
-
check_rebuilding exe, projectA
|
154
|
-
check_rebuilding exe, headerB
|
155
|
-
check_rebuilding exe, headerC
|
156
|
-
check_rebuilding libB, sourceA, false
|
157
|
-
check_rebuilding libB, sourceB
|
158
|
-
|
159
|
-
check_rebuilding libB, sourceC, false
|
160
|
-
check_rebuilding libC, sourceB
|
161
|
-
|
162
|
-
cleanup
|
163
|
-
Cxxproject::Utils.cleanup_rake
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'cxxproject'
|
3
|
-
require 'cxxproject/ext/rake_listener.rb'
|
4
|
-
require 'cxxproject/utils/cleanup'
|
5
|
-
|
6
|
-
describe Rake::Task do
|
7
|
-
compiler = 'gcc'
|
8
|
-
before(:each) do
|
9
|
-
Rake::application.options.silent = true
|
10
|
-
Cxxproject::Utils.cleanup_rake
|
11
|
-
end
|
12
|
-
after(:each) do
|
13
|
-
Cxxproject::Utils.cleanup_rake
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should fail if source of object is missing' do
|
17
|
-
file 'test.cc' => 'compiler'
|
18
|
-
File.delete('test.cc') if File.exists?('test.cc')
|
19
|
-
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
20
|
-
cxx = CxxProject2Rake.new([], 'build', compiler)
|
21
|
-
|
22
|
-
task = Rake::application['lib:testlib']
|
23
|
-
task.invoke
|
24
|
-
task.failure.should eq(true)
|
25
|
-
|
26
|
-
FileUtils.rm_rf('build')
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should not fail if include-dependency of object is missing' do
|
30
|
-
File.open('test.cc', 'w') do |io|
|
31
|
-
io.puts('#include "test.h"')
|
32
|
-
end
|
33
|
-
|
34
|
-
File.open('test.h', 'w') do |io|
|
35
|
-
end
|
36
|
-
|
37
|
-
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
38
|
-
CxxProject2Rake.new([], 'build', compiler)
|
39
|
-
|
40
|
-
task = Rake::application['lib:testlib']
|
41
|
-
task.invoke
|
42
|
-
task.failure.should == false
|
43
|
-
|
44
|
-
Cxxproject::Utils.cleanup_rake
|
45
|
-
|
46
|
-
FileUtils.rm_rf('test.h')
|
47
|
-
File.open('test.cc', 'w') do |io|
|
48
|
-
end
|
49
|
-
|
50
|
-
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
51
|
-
CxxProject2Rake.new([], 'build', compiler)
|
52
|
-
|
53
|
-
task = Rake::application['build/libs/libtestlib.a']
|
54
|
-
task.invoke
|
55
|
-
task.failure.should == false
|
56
|
-
|
57
|
-
FileUtils.rm_rf('test.cc')
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
data/spec/project_path_spe.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'cxxproject'
|
3
|
-
require 'cxxproject/utils/cleanup'
|
4
|
-
|
5
|
-
RSPECDIR = File.dirname(__FILE__)
|
6
|
-
|
7
|
-
describe CxxProject2Rake do
|
8
|
-
|
9
|
-
def execute_all_tasks(tasks)
|
10
|
-
tasks.each do |t|
|
11
|
-
t.invoke
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def fresh_cxx(outputdir,base)
|
16
|
-
Cxxproject::Utils.cleanup_rake
|
17
|
-
project_configs = nil
|
18
|
-
cd base do # have to be relative to base
|
19
|
-
project_configs = Dir.glob('**/project.rb')
|
20
|
-
end
|
21
|
-
CxxProject2Rake.new(project_configs, outputdir, 'gcc', base)
|
22
|
-
end
|
23
|
-
|
24
|
-
# def is_older? fileA, fileB
|
25
|
-
# File.mtime(fileA) < File.mtime(fileB)
|
26
|
-
# end
|
27
|
-
|
28
|
-
# def is_newer? fileA, fileB
|
29
|
-
# File.mtime(fileA) > File.mtime(fileB)
|
30
|
-
# end
|
31
|
-
|
32
|
-
def test_on_level(base, outputdir)
|
33
|
-
libOne = "#{outputdir}/libs/lib1.a"
|
34
|
-
libTwo = "#{outputdir}/libs/lib2.a"
|
35
|
-
exe = "#{outputdir}/basic.exe"
|
36
|
-
exe2 = "#{outputdir}/debug.exe"
|
37
|
-
files = [libOne,libTwo,exe,exe2]
|
38
|
-
rm_r outputdir if File.directory?(outputdir)
|
39
|
-
tasks = fresh_cxx(outputdir, base).all_tasks
|
40
|
-
CLOBBER.each { |fn| rm_r fn rescue nil }
|
41
|
-
|
42
|
-
files.all? {|f| File.exists?(f).should be_false }
|
43
|
-
|
44
|
-
execute_all_tasks(tasks)
|
45
|
-
|
46
|
-
files.all? {|f| File.exists?(f).should be_true }
|
47
|
-
|
48
|
-
# cleanup
|
49
|
-
rm_r outputdir if File.directory?(outputdir)
|
50
|
-
Cxxproject::Utils.cleanup_rake
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should resolve paths on different levels' do
|
54
|
-
outputdir = 'output'
|
55
|
-
|
56
|
-
cd("#{RSPECDIR}/testdata/multiple_levels", :verbose => false) do
|
57
|
-
test_on_level(".", outputdir)
|
58
|
-
end
|
59
|
-
|
60
|
-
cd("#{RSPECDIR}/testdata/multiple_levels/mainproject", :verbose => false) do
|
61
|
-
test_on_level("..", outputdir)
|
62
|
-
end
|
63
|
-
|
64
|
-
cd("#{RSPECDIR}/testdata", :verbose => false) do
|
65
|
-
test_on_level("multiple_levels/", outputdir)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|