cxx 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cxx.rb +6 -4
- data/lib/cxx/eval_context.rb +22 -7
- data/lib/cxx/version.rb +1 -1
- metadata +5 -43
- data/.gitignore +0 -3
- data/.rvmrc +0 -1
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -35
- data/Rakefile.rb +0 -33
- data/cxx.gemspec +0 -23
- data/junit.rb +0 -91
- data/rake_helper/spec.rb +0 -14
- data/spec/cxx_spec.rb +0 -166
- data/spec/object_dependency_spec.rb +0 -63
- data/spec/project_path_spec.rb +0 -69
- data/spec/testdata/basic/exe12/help.cpp +0 -5
- data/spec/testdata/basic/exe12/help.h +0 -6
- data/spec/testdata/basic/exe12/main.cpp +0 -10
- data/spec/testdata/basic/exe12/project.rb +0 -5
- data/spec/testdata/basic/lib1/lib1.cpp +0 -7
- data/spec/testdata/basic/lib1/lib1.h +0 -8
- data/spec/testdata/basic/lib1/project.rb +0 -5
- data/spec/testdata/basic/lib2/lib2.cpp +0 -17
- data/spec/testdata/basic/lib2/lib2.h +0 -6
- data/spec/testdata/basic/lib2/project.rb +0 -8
- data/spec/testdata/multiple_levels/libs/lib1/lib1.cpp +0 -7
- data/spec/testdata/multiple_levels/libs/lib1/lib1.h +0 -8
- data/spec/testdata/multiple_levels/libs/lib1/project.rb +0 -5
- data/spec/testdata/multiple_levels/libs/lib2/lib2.cpp +0 -21
- data/spec/testdata/multiple_levels/libs/lib2/lib2.h +0 -6
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +0 -19
- data/spec/testdata/multiple_levels/mainproject/basic/help.cpp +0 -5
- data/spec/testdata/multiple_levels/mainproject/basic/help.h +0 -6
- data/spec/testdata/multiple_levels/mainproject/basic/main.cpp +0 -10
- data/spec/testdata/multiple_levels/mainproject/basic/project.rb +0 -8
- data/spec/testdata/onlyOneHeader/.gitignore +0 -1
- data/spec/testdata/onlyOneHeader/Rakefile.rb +0 -4
- data/spec/testdata/onlyOneHeader/help.cpp +0 -5
- data/spec/testdata/onlyOneHeader/help.h +0 -7
- data/spec/testdata/onlyOneHeader/main.cpp +0 -8
- data/spec/testdata/onlyOneHeader/project.rb +0 -4
- data/spec/testdata/onlyOneHeader/testin.c +0 -0
data/lib/cxx.rb
CHANGED
@@ -149,6 +149,9 @@ module Cxx
|
|
149
149
|
end
|
150
150
|
Cxxproject::ALL_BUILDING_BLOCKS.values.inject([]) do |memo,block|
|
151
151
|
@log.debug "creating tasks for block: #{block.name}/taskname: #{block.get_task_name} (#{block})"
|
152
|
+
if block.name != block.get_task_name
|
153
|
+
task block.name => block.get_task_name # create task with simple name of buildinblock
|
154
|
+
end
|
152
155
|
memo << block.convert_to_rake()
|
153
156
|
end
|
154
157
|
end
|
@@ -183,10 +186,12 @@ module Cxx
|
|
183
186
|
|
184
187
|
def eval_file(b, project_file)
|
185
188
|
loadContext = EvalContext.new
|
189
|
+
project_text = File.read(File.basename(project_file))
|
186
190
|
begin
|
187
|
-
loadContext.eval_project(
|
191
|
+
loadContext.eval_project(project_text, project_file, Dir.pwd)
|
188
192
|
rescue Exception => e
|
189
193
|
puts "problems with #{File.join(b, project_file)} in dir: #{Dir.pwd}"
|
194
|
+
puts project_text
|
190
195
|
raise e
|
191
196
|
end
|
192
197
|
|
@@ -194,9 +199,6 @@ module Cxx
|
|
194
199
|
block.
|
195
200
|
set_project_dir(Dir.pwd).
|
196
201
|
set_config_files([Dir.pwd + "/" + project_file])
|
197
|
-
if block.respond_to?(:sources) && block.sources.instance_of?(Rake::FileList)
|
198
|
-
block.set_sources(block.sources.to_a)
|
199
|
-
end
|
200
202
|
end
|
201
203
|
end
|
202
204
|
|
data/lib/cxx/eval_context.rb
CHANGED
@@ -21,6 +21,21 @@ module Cxx
|
|
21
21
|
instance_eval(project_text)
|
22
22
|
end
|
23
23
|
|
24
|
+
def attatch_sources(hash,bblock)
|
25
|
+
if hash.has_key?(:sources)
|
26
|
+
ss = hash[:sources]
|
27
|
+
if ss.class == Array || ss.class == Rake::FileList
|
28
|
+
bblock.set_sources(ss)
|
29
|
+
else
|
30
|
+
raise "sources need to be given in an Array or FileList, not a #{ss.class}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def attatch_includes(hash,bblock)
|
36
|
+
bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes)
|
37
|
+
end
|
38
|
+
|
24
39
|
# specify an executable
|
25
40
|
# hash supports:
|
26
41
|
# * :sources
|
@@ -31,8 +46,8 @@ module Cxx
|
|
31
46
|
raise "not a hash" unless hash.is_a?(Hash)
|
32
47
|
check_hash(hash,[:sources,:includes,:dependencies,:libpath,:output_dir])
|
33
48
|
bblock = Cxxproject::Executable.new(name)
|
34
|
-
|
35
|
-
|
49
|
+
attatch_sources(hash,bblock)
|
50
|
+
attatch_includes(hash,bblock)
|
36
51
|
if hash.has_key?(:dependencies)
|
37
52
|
bblock.set_dependencies(hash[:dependencies])
|
38
53
|
hash[:dependencies].each { |d| bblock.add_lib_element(Cxxproject::HasLibraries::DEPENDENCY, d) }
|
@@ -54,8 +69,8 @@ module Cxx
|
|
54
69
|
check_hash(hash, [:sources, :includes, :dependencies, :toolchain, :file_dependencies, :output_dir, :whole_archive])
|
55
70
|
raise ":sources need to be defined" unless hash.has_key?(:sources)
|
56
71
|
bblock = Cxxproject::SourceLibrary.new(name, hash[:whole_archive])
|
57
|
-
|
58
|
-
|
72
|
+
attatch_sources(hash,bblock)
|
73
|
+
attatch_includes(hash,bblock)
|
59
74
|
bblock.set_tcs(hash[:toolchain]) if hash.has_key?(:toolchain)
|
60
75
|
if hash.has_key?(:dependencies)
|
61
76
|
bblock.set_dependencies(hash[:dependencies])
|
@@ -71,7 +86,7 @@ module Cxx
|
|
71
86
|
check_hash(hash, [:includes, :lib_path])
|
72
87
|
|
73
88
|
bblock = Cxxproject::BinaryLibrary.new(name)
|
74
|
-
|
89
|
+
attatch_includes(hash,bblock)
|
75
90
|
bblock.add_lib_element(Cxxproject::HasLibraries::SEARCH_PATH, hash[:lib_path], true) if hash.has_key?(:lib_path)
|
76
91
|
return bblock
|
77
92
|
end
|
@@ -90,8 +105,8 @@ module Cxx
|
|
90
105
|
raise "not a hash" unless hash.is_a?(Hash)
|
91
106
|
check_hash(hash,[:sources,:includes])
|
92
107
|
bblock = Cxxproject::SingleSource.new(name)
|
93
|
-
|
94
|
-
|
108
|
+
attatch_sources(hash,bblock)
|
109
|
+
attatch_includes(hash,bblock)
|
95
110
|
all_blocks << bblock
|
96
111
|
end
|
97
112
|
|
data/lib/cxx/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cxx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
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-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cxxproject
|
@@ -50,51 +50,13 @@ executables:
|
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
|
-
- .gitignore
|
54
|
-
- .rvmrc
|
55
|
-
- Gemfile
|
56
|
-
- Gemfile.lock
|
57
|
-
- Rakefile.rb
|
58
53
|
- bin/cxx
|
59
|
-
- cxx.gemspec
|
60
|
-
- junit.rb
|
61
|
-
- lib/cxx.rb
|
62
|
-
- lib/cxx/eval_context.rb
|
63
54
|
- lib/cxx/version.rb
|
64
|
-
- lib/cxx/wizard/Rakefile.rb.template
|
65
55
|
- lib/cxx/wizard/project.rb.template
|
66
56
|
- lib/cxx/wizard/project_wizard.rb
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
- spec/project_path_spec.rb
|
71
|
-
- spec/testdata/basic/exe12/help.cpp
|
72
|
-
- spec/testdata/basic/exe12/help.h
|
73
|
-
- spec/testdata/basic/exe12/main.cpp
|
74
|
-
- spec/testdata/basic/exe12/project.rb
|
75
|
-
- spec/testdata/basic/lib1/lib1.cpp
|
76
|
-
- spec/testdata/basic/lib1/lib1.h
|
77
|
-
- spec/testdata/basic/lib1/project.rb
|
78
|
-
- spec/testdata/basic/lib2/lib2.cpp
|
79
|
-
- spec/testdata/basic/lib2/lib2.h
|
80
|
-
- spec/testdata/basic/lib2/project.rb
|
81
|
-
- spec/testdata/multiple_levels/libs/lib1/lib1.cpp
|
82
|
-
- spec/testdata/multiple_levels/libs/lib1/lib1.h
|
83
|
-
- spec/testdata/multiple_levels/libs/lib1/project.rb
|
84
|
-
- spec/testdata/multiple_levels/libs/lib2/lib2.cpp
|
85
|
-
- spec/testdata/multiple_levels/libs/lib2/lib2.h
|
86
|
-
- spec/testdata/multiple_levels/libs/lib2/project.rb
|
87
|
-
- spec/testdata/multiple_levels/mainproject/basic/help.cpp
|
88
|
-
- spec/testdata/multiple_levels/mainproject/basic/help.h
|
89
|
-
- spec/testdata/multiple_levels/mainproject/basic/main.cpp
|
90
|
-
- spec/testdata/multiple_levels/mainproject/basic/project.rb
|
91
|
-
- spec/testdata/onlyOneHeader/.gitignore
|
92
|
-
- spec/testdata/onlyOneHeader/Rakefile.rb
|
93
|
-
- spec/testdata/onlyOneHeader/help.cpp
|
94
|
-
- spec/testdata/onlyOneHeader/help.h
|
95
|
-
- spec/testdata/onlyOneHeader/main.cpp
|
96
|
-
- spec/testdata/onlyOneHeader/project.rb
|
97
|
-
- spec/testdata/onlyOneHeader/testin.c
|
57
|
+
- lib/cxx/wizard/Rakefile.rb.template
|
58
|
+
- lib/cxx/eval_context.rb
|
59
|
+
- lib/cxx.rb
|
98
60
|
homepage:
|
99
61
|
licenses: []
|
100
62
|
post_install_message:
|
data/.gitignore
DELETED
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use 1.9.3@cxxproject_tests --create
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
builder (3.1.3)
|
5
|
-
diff-lcs (1.1.3)
|
6
|
-
gem-release (0.4.1)
|
7
|
-
grit (2.5.0)
|
8
|
-
diff-lcs (~> 1.1)
|
9
|
-
mime-types (~> 1.15)
|
10
|
-
posix-spawn (~> 0.3.6)
|
11
|
-
mime-types (1.19)
|
12
|
-
posix-spawn (0.3.6)
|
13
|
-
roodi (2.1.0)
|
14
|
-
ruby_parser
|
15
|
-
rspec (2.11.0)
|
16
|
-
rspec-core (~> 2.11.0)
|
17
|
-
rspec-expectations (~> 2.11.0)
|
18
|
-
rspec-mocks (~> 2.11.0)
|
19
|
-
rspec-core (2.11.1)
|
20
|
-
rspec-expectations (2.11.3)
|
21
|
-
diff-lcs (~> 1.1.3)
|
22
|
-
rspec-mocks (2.11.2)
|
23
|
-
ruby_parser (2.3.1)
|
24
|
-
sexp_processor (~> 3.0)
|
25
|
-
sexp_processor (3.2.0)
|
26
|
-
|
27
|
-
PLATFORMS
|
28
|
-
ruby
|
29
|
-
|
30
|
-
DEPENDENCIES
|
31
|
-
builder
|
32
|
-
gem-release
|
33
|
-
grit
|
34
|
-
roodi
|
35
|
-
rspec
|
data/Rakefile.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require './rake_helper/spec.rb'
|
3
|
-
|
4
|
-
task :package => :build
|
5
|
-
|
6
|
-
projects = ['frazzle',
|
7
|
-
'cxxproject',
|
8
|
-
'cxxproject_gcctoolchain']
|
9
|
-
|
10
|
-
desc 'cleanup all built gems'
|
11
|
-
task :clean do
|
12
|
-
projects.each do |p|
|
13
|
-
cd "../#{p}" do
|
14
|
-
sh 'rake clobber_package'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'install prerequisites for build'
|
20
|
-
task :wipe_gems do
|
21
|
-
sh "rvm --force gemset empty"
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'install all built gems'
|
25
|
-
task :build_and_install_gems do
|
26
|
-
projects.each do |p|
|
27
|
-
cd "../#{p}" do
|
28
|
-
sh 'rm -rf pkg'
|
29
|
-
sh 'rake package'
|
30
|
-
sh 'rake install'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/cxx.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
gem_name = 'cxx'
|
3
|
-
require File.expand_path("lib/#{gem_name}/version")
|
4
|
-
|
5
|
-
spec = Gem::Specification.new do |s|
|
6
|
-
s.name = gem_name
|
7
|
-
s.version = Cxx::VERSION
|
8
|
-
|
9
|
-
s.description = 'ruby-based dsl for cxxproject'
|
10
|
-
s.summary = 'defines the method cxx_configuration'
|
11
|
-
s.author = 'christian koestlin'
|
12
|
-
s.email = 'christian.koestlin@gmail.com'
|
13
|
-
s.platform = Gem::Platform::RUBY
|
14
|
-
s.files = `git ls-files`.split($\)
|
15
|
-
s.require_path = 'lib'
|
16
|
-
|
17
|
-
s.add_dependency 'cxxproject'
|
18
|
-
s.add_dependency 'highline'
|
19
|
-
|
20
|
-
s.executables = ['cxx']
|
21
|
-
|
22
|
-
s.has_rdoc = false
|
23
|
-
end
|
data/junit.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
|
3
|
-
Copyright (c) 2012, Nathaniel Ritmeyer
|
4
|
-
All rights reserved.
|
5
|
-
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
7
|
-
modification, are permitted provided that the following conditions are met:
|
8
|
-
|
9
|
-
1. Redistributions of source code must retain the above copyright notice,
|
10
|
-
this list of conditions and the following disclaimer.
|
11
|
-
|
12
|
-
2. Redistributions in binary form must reproduce the above copyright
|
13
|
-
notice, this list of conditions and the following disclaimer in the
|
14
|
-
documentation and/or other materials provided with the distribution.
|
15
|
-
|
16
|
-
3. Neither the name Nathaniel Ritmeyer nor the names of contributors to
|
17
|
-
this software may be used to endorse or promote products derived from this
|
18
|
-
software without specific prior written permission.
|
19
|
-
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
21
|
-
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
22
|
-
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
23
|
-
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
24
|
-
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
25
|
-
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
26
|
-
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
27
|
-
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
28
|
-
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
29
|
-
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
30
|
-
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
|
32
|
-
=end
|
33
|
-
|
34
|
-
require 'time'
|
35
|
-
require 'builder'
|
36
|
-
require 'rspec/core/formatters/base_formatter'
|
37
|
-
|
38
|
-
class JUnit < RSpec::Core::Formatters::BaseFormatter
|
39
|
-
def initialize output
|
40
|
-
super output
|
41
|
-
@test_results = []
|
42
|
-
end
|
43
|
-
|
44
|
-
def example_passed example
|
45
|
-
@test_results << example
|
46
|
-
end
|
47
|
-
|
48
|
-
def example_failed example
|
49
|
-
@test_results << example
|
50
|
-
end
|
51
|
-
|
52
|
-
def example_pending example
|
53
|
-
@test_results << example
|
54
|
-
end
|
55
|
-
|
56
|
-
def failure_details_for example
|
57
|
-
exception = example.metadata[:execution_result][:exception]
|
58
|
-
exception.nil? ? "" : "#{exception.message}\n#{format_backtrace(exception.backtrace, example).join("\n")}"
|
59
|
-
end
|
60
|
-
|
61
|
-
def full_name_for example
|
62
|
-
test_name = ""
|
63
|
-
current_example_group = example.metadata[:example_group]
|
64
|
-
until current_example_group.nil? do
|
65
|
-
test_name = "#{current_example_group[:description]}." + test_name
|
66
|
-
current_example_group = current_example_group[:example_group]
|
67
|
-
end
|
68
|
-
test_name << example.metadata[:description]
|
69
|
-
end
|
70
|
-
|
71
|
-
def dump_summary duration, example_count, failure_count, pending_count
|
72
|
-
builder = Builder::XmlMarkup.new :indent => 2
|
73
|
-
builder.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
|
74
|
-
builder.testsuite :errors => 0, :failures => failure_count, :skipped => pending_count, :tests => example_count, :time => duration, :timestamp => Time.now.iso8601 do
|
75
|
-
builder.properties
|
76
|
-
@test_results.each do |test|
|
77
|
-
builder.testcase :classname => full_name_for(test), :name => test.metadata[:full_description], :time => test.metadata[:execution_result][:run_time] do
|
78
|
-
case test.metadata[:execution_result][:status]
|
79
|
-
when "failed"
|
80
|
-
builder.failure :message => "failed #{test.metadata[:full_description]}", :type => "failed" do
|
81
|
-
builder.cdata! failure_details_for test
|
82
|
-
end
|
83
|
-
when "pending" then builder.skipped
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
output.puts builder.target!
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
data/rake_helper/spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'rake/clean'
|
2
|
-
|
3
|
-
SPEC_PATTERN ='spec/**/*_spec.rb'
|
4
|
-
|
5
|
-
require 'rspec/core/rake_task'
|
6
|
-
desc "Run examples"
|
7
|
-
RSpec::Core::RakeTask.new() do |t|
|
8
|
-
t.pattern = SPEC_PATTERN
|
9
|
-
if ENV['BUILD_SERVER']
|
10
|
-
t.rspec_opts = '-r ./junit.rb -f JUnit -o build/test_details.xml'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
task :gem => [:spec]
|
data/spec/cxx_spec.rb
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
require 'cxx'
|
2
|
-
require 'cxxproject/utils/cleanup'
|
3
|
-
|
4
|
-
RSPECDIR = File.dirname(__FILE__)
|
5
|
-
puts RSPECDIR
|
6
|
-
|
7
|
-
class SpecTaskListener
|
8
|
-
def initialize
|
9
|
-
@task_execution_count = 0
|
10
|
-
end
|
11
|
-
def before_prerequisites(name)
|
12
|
-
end
|
13
|
-
|
14
|
-
def after_prerequisites(name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def before_execute(name)
|
18
|
-
@task_execution_count += 1
|
19
|
-
end
|
20
|
-
|
21
|
-
def after_execute(name)
|
22
|
-
end
|
23
|
-
def reset_exec_count()
|
24
|
-
@task_execution_count = 0
|
25
|
-
end
|
26
|
-
def get_exec_count()
|
27
|
-
@task_execution_count
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def rebuild
|
32
|
-
tasks = fresh_cxx.all_tasks
|
33
|
-
execute_all_tasks(tasks)
|
34
|
-
end
|
35
|
-
|
36
|
-
def check_rebuilding (end_product, prereq_file, should_rebuild = true)
|
37
|
-
sleep(1)
|
38
|
-
FileUtils.touch prereq_file
|
39
|
-
# prereq_file should be newer
|
40
|
-
File.mtime(prereq_file).should > File.mtime(end_product)
|
41
|
-
rebuild
|
42
|
-
if should_rebuild
|
43
|
-
# prereq_file should NOT be newer
|
44
|
-
File.mtime(prereq_file).should <= File.mtime(end_product)
|
45
|
-
else
|
46
|
-
# prereq_file should still be newer
|
47
|
-
File.mtime(prereq_file).should > File.mtime(end_product)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def execute_all_tasks(tasks)
|
52
|
-
tasks.each do |t|
|
53
|
-
t.invoke
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def fresh_cxx
|
58
|
-
Cxxproject::Utils.cleanup_rake
|
59
|
-
outputdir = 'output'
|
60
|
-
cxx(FileList['**/project.rb'], outputdir, 'gcc','.')
|
61
|
-
end
|
62
|
-
|
63
|
-
def cleanup
|
64
|
-
rm_r 'output' if File.directory?('output')
|
65
|
-
end
|
66
|
-
|
67
|
-
ONLY_ONE_HEADER = "#{RSPECDIR}/testdata/onlyOneHeader"
|
68
|
-
describe Cxx::RubyDsl do
|
69
|
-
before(:all) do
|
70
|
-
Rake::application.options.silent = true
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should provide runtask for executables' do
|
74
|
-
cd ONLY_ONE_HEADER, :verbose => false do
|
75
|
-
cleanup
|
76
|
-
tasks = fresh_cxx.all_tasks
|
77
|
-
Rake::Task['run:basic'].invoke
|
78
|
-
cleanup
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'should rebuild only when one file was changed' do
|
83
|
-
require 'cxxproject/ext/rake_listener'
|
84
|
-
require 'cxxproject/ext/rake_dirty'
|
85
|
-
|
86
|
-
listener = SpecTaskListener.new
|
87
|
-
Rake::add_listener(listener)
|
88
|
-
cd(ONLY_ONE_HEADER, :verbose => false) do
|
89
|
-
# fresh build
|
90
|
-
listener.reset_exec_count
|
91
|
-
cleanup
|
92
|
-
|
93
|
-
tasks = fresh_cxx.all_tasks
|
94
|
-
CLOBBER.each { |fn| rm_r fn rescue nil }
|
95
|
-
execute_all_tasks(tasks)
|
96
|
-
fresh_build_steps = listener.get_exec_count
|
97
|
-
|
98
|
-
# rebuild, nothing changed
|
99
|
-
listener.reset_exec_count
|
100
|
-
execute_all_tasks(tasks)
|
101
|
-
rebuild_build_steps = listener.get_exec_count
|
102
|
-
|
103
|
-
# rebuild, nothing changed
|
104
|
-
listener.reset_exec_count
|
105
|
-
execute_all_tasks(tasks)
|
106
|
-
listener.get_exec_count.should == rebuild_build_steps
|
107
|
-
|
108
|
-
# rebuild after header changed
|
109
|
-
listener.reset_exec_count
|
110
|
-
sleep(1)
|
111
|
-
files2touch = Dir.glob('help.h')
|
112
|
-
FileUtils.touch files2touch
|
113
|
-
execute_all_tasks(fresh_cxx.all_tasks)
|
114
|
-
rebuild_after_touch_steps = listener.get_exec_count
|
115
|
-
rebuild_after_touch_steps.should > rebuild_build_steps
|
116
|
-
|
117
|
-
# rebuild, nothing changed
|
118
|
-
listener.reset_exec_count
|
119
|
-
execute_all_tasks(tasks)
|
120
|
-
listener.get_exec_count.should == rebuild_build_steps
|
121
|
-
|
122
|
-
cleanup
|
123
|
-
end
|
124
|
-
Rake::remove_listener(listener)
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'should rebuild when any source file changes' do
|
128
|
-
cd("#{RSPECDIR}/testdata/basic", :verbose => false) do
|
129
|
-
cleanup
|
130
|
-
|
131
|
-
tasks = fresh_cxx.all_tasks
|
132
|
-
CLOBBER.each { |fn| rm_r fn rescue nil }
|
133
|
-
execute_all_tasks(tasks)
|
134
|
-
|
135
|
-
# dependencies: exe -> libC -> libB
|
136
|
-
|
137
|
-
headerA = 'exe12/help.h'
|
138
|
-
sourceA = 'exe12/main.cpp'
|
139
|
-
projectA = 'exe12/project.rb'
|
140
|
-
headerB = 'lib1/lib1.h'
|
141
|
-
sourceB = 'lib1/lib1.cpp'
|
142
|
-
projectB = 'lib1/project.rb'
|
143
|
-
headerC = 'lib2/lib2.h'
|
144
|
-
sourceC = 'lib2/lib2.cpp'
|
145
|
-
projectC = 'lib2/project.rb'
|
146
|
-
exe = 'output/basic.exe'
|
147
|
-
libB = 'output/libs/lib1.a'
|
148
|
-
libC = 'output/libs/lib2.a'
|
149
|
-
|
150
|
-
check_rebuilding exe, headerA
|
151
|
-
check_rebuilding exe, sourceA
|
152
|
-
check_rebuilding exe, projectA
|
153
|
-
check_rebuilding exe, headerB
|
154
|
-
check_rebuilding exe, headerC
|
155
|
-
check_rebuilding libB, sourceA, false
|
156
|
-
check_rebuilding libB, sourceB
|
157
|
-
|
158
|
-
check_rebuilding libB, sourceC, false
|
159
|
-
check_rebuilding libC, sourceB
|
160
|
-
|
161
|
-
cleanup
|
162
|
-
Cxxproject::Utils.cleanup_rake
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'cxx'
|
2
|
-
require 'cxxproject/ext/rake_listener.rb'
|
3
|
-
require 'cxxproject/utils/cleanup'
|
4
|
-
|
5
|
-
OUT_DIR='cxxbuild'
|
6
|
-
|
7
|
-
describe Rake::Task do
|
8
|
-
compiler = 'gcc'
|
9
|
-
|
10
|
-
before(:each) do
|
11
|
-
Rake::application.options.silent = true
|
12
|
-
Cxxproject::Utils.cleanup_rake
|
13
|
-
end
|
14
|
-
|
15
|
-
after(:each) do
|
16
|
-
Cxxproject::Utils.cleanup_rake
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should fail if source of object is missing' do
|
20
|
-
file 'test.cc' => 'compiler'
|
21
|
-
File.delete('test.cc') if File.exists?('test.cc')
|
22
|
-
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
23
|
-
cxx = cxx([], OUT_DIR, compiler, '.')
|
24
|
-
|
25
|
-
task = Rake::application['lib:testlib']
|
26
|
-
task.invoke
|
27
|
-
task.failure.should eq(true)
|
28
|
-
|
29
|
-
FileUtils.rm_rf(OUT_DIR)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should not fail if include-dependency of object is missing' do
|
33
|
-
File.open('test.cc', 'w') do |io|
|
34
|
-
io.puts('#include "test.h"')
|
35
|
-
end
|
36
|
-
|
37
|
-
File.open('test.h', 'w') do |io|
|
38
|
-
end
|
39
|
-
|
40
|
-
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
41
|
-
cxx([], OUT_DIR, compiler, '.')
|
42
|
-
|
43
|
-
task = Rake::application['lib:testlib']
|
44
|
-
task.invoke
|
45
|
-
task.failure.should == false
|
46
|
-
|
47
|
-
Cxxproject::Utils.cleanup_rake
|
48
|
-
|
49
|
-
FileUtils.rm_rf('test.h')
|
50
|
-
File.open('test.cc', 'w') do |io|
|
51
|
-
end
|
52
|
-
|
53
|
-
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
54
|
-
cxx([], OUT_DIR, compiler, '.')
|
55
|
-
|
56
|
-
task = Rake::application[File.join(OUT_DIR, 'libs', 'libtestlib.a')]
|
57
|
-
task.invoke
|
58
|
-
task.failure.should == false
|
59
|
-
|
60
|
-
FileUtils.rm_rf('test.cc')
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
data/spec/project_path_spec.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'cxx'
|
2
|
-
require 'cxxproject/utils/cleanup'
|
3
|
-
|
4
|
-
RSPECDIR = File.dirname(__FILE__)
|
5
|
-
|
6
|
-
describe Cxx::RubyDsl do
|
7
|
-
|
8
|
-
def execute_all_tasks(tasks)
|
9
|
-
tasks.each do |t|
|
10
|
-
t.invoke
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def fresh_cxx(outputdir,base)
|
15
|
-
Cxxproject::Utils.cleanup_rake
|
16
|
-
project_configs = nil
|
17
|
-
cd base do # have to be relative to base
|
18
|
-
project_configs = Dir.glob('**/project.rb')
|
19
|
-
end
|
20
|
-
cxx(project_configs, outputdir, 'gcc', base)
|
21
|
-
end
|
22
|
-
|
23
|
-
# def is_older? fileA, fileB
|
24
|
-
# File.mtime(fileA) < File.mtime(fileB)
|
25
|
-
# end
|
26
|
-
|
27
|
-
# def is_newer? fileA, fileB
|
28
|
-
# File.mtime(fileA) > File.mtime(fileB)
|
29
|
-
# end
|
30
|
-
|
31
|
-
def test_on_level(base, outputdir)
|
32
|
-
libOne = "#{outputdir}/libs/lib1.a"
|
33
|
-
libTwo = "#{outputdir}/libs/lib2.a"
|
34
|
-
exe = "#{outputdir}/basic.exe"
|
35
|
-
exe2 = "#{outputdir}/debug.exe"
|
36
|
-
files = [libOne,libTwo,exe,exe2]
|
37
|
-
rm_r outputdir if File.directory?(outputdir)
|
38
|
-
tasks = fresh_cxx(outputdir, base).all_tasks
|
39
|
-
CLOBBER.each { |fn| rm_r fn rescue nil }
|
40
|
-
|
41
|
-
files.all? {|f| File.exists?(f).should be_false }
|
42
|
-
|
43
|
-
execute_all_tasks(tasks)
|
44
|
-
|
45
|
-
files.all? {|f| File.exists?(f).should be_true }
|
46
|
-
|
47
|
-
# cleanup
|
48
|
-
rm_r outputdir if File.directory?(outputdir)
|
49
|
-
Cxxproject::Utils.cleanup_rake
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should resolve paths on different levels' do
|
53
|
-
outputdir = 'output'
|
54
|
-
|
55
|
-
cd("#{RSPECDIR}/testdata/multiple_levels", :verbose => false) do
|
56
|
-
test_on_level(".", outputdir)
|
57
|
-
end
|
58
|
-
|
59
|
-
cd("#{RSPECDIR}/testdata/multiple_levels/mainproject", :verbose => false) do
|
60
|
-
test_on_level("..", outputdir)
|
61
|
-
end
|
62
|
-
|
63
|
-
cd("#{RSPECDIR}/testdata", :verbose => false) do
|
64
|
-
test_on_level("multiple_levels/", outputdir)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
#include "lib2.h"
|
2
|
-
|
3
|
-
#include <iostream>
|
4
|
-
#include <math.h>
|
5
|
-
#include "lib1.h"
|
6
|
-
#include <dlfcn.h>
|
7
|
-
#include <zlib.h>
|
8
|
-
|
9
|
-
void lib2() {
|
10
|
-
std::cout << "lib2" << std::endl;
|
11
|
-
lib1();
|
12
|
-
std::cout << sin(5) << std::endl;
|
13
|
-
void* help = dlopen("test", RTLD_LAZY);
|
14
|
-
std::cout << (long)help << std::endl;
|
15
|
-
Bytef b = 0;
|
16
|
-
uLong res = crc32(0, &b, 1);
|
17
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
#include "lib2.h"
|
2
|
-
|
3
|
-
#include <iostream>
|
4
|
-
#include <math.h>
|
5
|
-
#include "lib1.h"
|
6
|
-
#include <dlfcn.h>
|
7
|
-
#include <zlib.h>
|
8
|
-
|
9
|
-
void lib2() {
|
10
|
-
#ifdef UNIT_TEST
|
11
|
-
std::cout << "lib2 for UNIT_TEST defined" << std::endl;
|
12
|
-
#else
|
13
|
-
std::cout << "lib2" << std::endl;
|
14
|
-
#endif
|
15
|
-
lib1();
|
16
|
-
std::cout << sin(5) << std::endl;
|
17
|
-
void* help = dlopen("test", RTLD_LAZY);
|
18
|
-
std::cout << (long)help << std::endl;
|
19
|
-
Bytef b = 0;
|
20
|
-
uLong res = crc32(0, &b, 1);
|
21
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
cxx_configuration do
|
2
|
-
deps = ['1', BinaryLibrary.new('z')]
|
3
|
-
deps << BinaryLibrary.new('dl') if Utils::OS.linux?
|
4
|
-
|
5
|
-
source_lib "2",
|
6
|
-
:sources => FileList['**/*.cpp'],
|
7
|
-
:dependencies => deps,
|
8
|
-
:includes => ['.']
|
9
|
-
|
10
|
-
|
11
|
-
unittest_flags = {
|
12
|
-
:DEFINES => ['UNIT_TEST','CPPUNIT_MAIN="main"']
|
13
|
-
}
|
14
|
-
source_lib "2_debug",
|
15
|
-
:sources => FileList['**/*.cpp'],
|
16
|
-
:dependencies => deps,
|
17
|
-
:includes => ['.'],
|
18
|
-
:toolchain => Provider.modify_cpp_compiler("gcc", unittest_flags)
|
19
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
output
|
File without changes
|