cxx 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitignore +2 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +35 -0
  5. data/Rakefile.rb +30 -0
  6. data/junit.rb +91 -0
  7. data/lib/cxx/eval_context.rb +8 -33
  8. data/lib/cxx/version.rb +1 -1
  9. data/rake_helper/spec.rb +14 -0
  10. data/spec/cxx_spec.rb +166 -0
  11. data/spec/object_dependency_spec.rb +63 -0
  12. data/spec/project_path_spec.rb +69 -0
  13. data/spec/testdata/basic/exe12/help.cpp +5 -0
  14. data/spec/testdata/basic/exe12/help.h +6 -0
  15. data/spec/testdata/basic/exe12/main.cpp +10 -0
  16. data/spec/testdata/basic/exe12/project.rb +5 -0
  17. data/spec/testdata/basic/lib1/lib1.cpp +7 -0
  18. data/spec/testdata/basic/lib1/lib1.h +8 -0
  19. data/spec/testdata/basic/lib1/project.rb +5 -0
  20. data/spec/testdata/basic/lib2/lib2.cpp +17 -0
  21. data/spec/testdata/basic/lib2/lib2.h +6 -0
  22. data/spec/testdata/basic/lib2/project.rb +8 -0
  23. data/spec/testdata/multiple_levels/libs/lib1/lib1.cpp +7 -0
  24. data/spec/testdata/multiple_levels/libs/lib1/lib1.h +8 -0
  25. data/spec/testdata/multiple_levels/libs/lib1/project.rb +5 -0
  26. data/spec/testdata/multiple_levels/libs/lib2/lib2.cpp +21 -0
  27. data/spec/testdata/multiple_levels/libs/lib2/lib2.h +6 -0
  28. data/spec/testdata/multiple_levels/libs/lib2/project.rb +19 -0
  29. data/spec/testdata/multiple_levels/mainproject/basic/help.cpp +5 -0
  30. data/spec/testdata/multiple_levels/mainproject/basic/help.h +6 -0
  31. data/spec/testdata/multiple_levels/mainproject/basic/main.cpp +10 -0
  32. data/spec/testdata/multiple_levels/mainproject/basic/project.rb +8 -0
  33. data/spec/testdata/onlyOneHeader/.gitignore +1 -0
  34. data/spec/testdata/onlyOneHeader/Rakefile.rb +4 -0
  35. data/spec/testdata/onlyOneHeader/help.cpp +5 -0
  36. data/spec/testdata/onlyOneHeader/help.h +7 -0
  37. data/spec/testdata/onlyOneHeader/main.cpp +8 -0
  38. data/spec/testdata/onlyOneHeader/project.rb +4 -0
  39. data/spec/testdata/onlyOneHeader/testin.c +0 -0
  40. metadata +37 -2
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
1
  pkg
2
+ spec/build
3
+ build/test_details.xml
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@cxxproject_tests --create
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+ gem 'rspec'
3
+ gem 'grit'
4
+ gem 'roodi'
5
+ gem 'builder'
6
+ gem 'gem-release'
@@ -0,0 +1,35 @@
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
@@ -1,3 +1,33 @@
1
1
  require "bundler/gem_tasks"
2
+ require './rake_helper/spec.rb'
2
3
 
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
@@ -0,0 +1,91 @@
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
+
@@ -3,18 +3,6 @@ require 'cxxproject/context'
3
3
  require 'cxxproject/utils/utils'
4
4
 
5
5
  module Cxx
6
- class BinaryLibs
7
- class << self
8
- def [](*libs)
9
- libraries = Array.new
10
- libs.each do |x|
11
- libraries << Cxxproject::BinaryLibrary.new(x)
12
- end
13
- libraries
14
- end
15
- end
16
- end
17
-
18
6
  class EvalContext
19
7
  include Cxxproject
20
8
  include Cxxproject::Context
@@ -38,7 +26,6 @@ module Cxx
38
26
  # * :sources
39
27
  # * :includes
40
28
  # * :dependencies
41
- # * :libpath
42
29
  # * :output_dir
43
30
  def exe(name, hash)
44
31
  raise "not a hash" unless hash.is_a?(Hash)
@@ -46,7 +33,6 @@ module Cxx
46
33
  bblock = Cxxproject::Executable.new(name)
47
34
  bblock.set_sources(hash[:sources]) if hash.has_key?(:sources)
48
35
  bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes)
49
- calc_lib_searchpath(hash).each { |sp| bblock.add_lib_element(Cxxproject::HasLibraries::SEARCH_PATH, sp) }
50
36
  if hash.has_key?(:dependencies)
51
37
  bblock.set_dependencies(hash[:dependencies])
52
38
  hash[:dependencies].each { |d| bblock.add_lib_element(Cxxproject::HasLibraries::DEPENDENCY, d) }
@@ -55,18 +41,6 @@ module Cxx
55
41
  all_blocks << bblock
56
42
  end
57
43
 
58
- def calc_lib_searchpath(hash)
59
- if hash.has_key?(:libpath)
60
- hash[:libpath]
61
- else
62
- if Cxxproject::Utils::OS.linux? || Cxxproject::Utils::OS.mac?
63
- ["/usr/local/lib","/usr/lib"]
64
- elsif Cxxproject::Utils::OS.windows?
65
- ["C:/tool/cygwin/lib", "C:/Tool/cygwin/usr/local/lib"]
66
- end
67
- end
68
- end
69
-
70
44
  # specify a sourcelib
71
45
  # hash supports:
72
46
  # * :sources
@@ -92,23 +66,24 @@ module Cxx
92
66
  all_blocks << bblock
93
67
  end
94
68
 
95
- def bin_lib(name, hash={})
69
+ def bin_lib(name, hash=Hash.new)
96
70
  raise "not a hash" unless hash.is_a?(Hash)
97
71
  check_hash(hash, [:includes, :lib_path])
72
+
98
73
  bblock = Cxxproject::BinaryLibrary.new(name)
99
74
  bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes)
100
75
  bblock.add_lib_element(Cxxproject::HasLibraries::SEARCH_PATH, hash[:lib_path], true) if hash.has_key?(:lib_path)
76
+ return bblock
101
77
  end
102
78
 
103
79
  # specify some binary libs
104
80
  # returns all binary libs as array
105
- def bin_libs(*names)
106
- res = []
81
+ def bin_libs(names, hash=Hash.new)
82
+ raise "not a hash" unless hash.is_a?(Hash)
83
+ check_hash(hash, [:includes, :lib_path])
84
+
107
85
  mapped = names.map{|n|n.to_s}
108
- mapped.each do |name|
109
- res << Cxxproject::BinaryLibrary.new(name)
110
- end
111
- mapped
86
+ return mapped.map{|name|bin_lib(name, hash)}
112
87
  end
113
88
 
114
89
  def compile(name, hash)
@@ -1,4 +1,4 @@
1
1
  module Cxx
2
- VERSION = '0.1.13'
2
+ VERSION = '0.1.14'
3
3
  end
4
4
 
@@ -0,0 +1,14 @@
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]
@@ -0,0 +1,166 @@
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
@@ -0,0 +1,63 @@
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
@@ -0,0 +1,69 @@
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
+
@@ -0,0 +1,5 @@
1
+ #include "help.h"
2
+ #include <iostream>
3
+ void helpMe() {
4
+ std::cout << "help me" << std::endl;
5
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef help_h_
2
+ #define help_h_
3
+
4
+ void helpMe();
5
+
6
+ #endif
@@ -0,0 +1,10 @@
1
+ // #include "lib2.h"
2
+ #include <iostream>
3
+ #include "help.h"
4
+
5
+ int main(int argc, char** args) {
6
+ helpMe();
7
+ // lib2();
8
+ std::cout << "hello world" << std::endl;
9
+ return 0;
10
+ }
@@ -0,0 +1,5 @@
1
+ cxx_configuration do
2
+ exe "basic",
3
+ :sources => FileList.new('**/*.cpp'),
4
+ :dependencies => ['2']
5
+ end
@@ -0,0 +1,7 @@
1
+ #include "lib1.h"
2
+
3
+ #include <iostream>
4
+
5
+ void lib1() {
6
+ std::cout << "lib1" << std::endl;
7
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef lib1_h_
2
+ #define lib1_h_
3
+
4
+ void lib1();
5
+
6
+
7
+ #endif
8
+
@@ -0,0 +1,5 @@
1
+ cxx_configuration do
2
+ source_lib "1",
3
+ :sources => ['lib1.cpp'],
4
+ :includes => ['.']
5
+ end
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef lib2_h_
2
+ #define lib2_h_
3
+
4
+ void lib2();
5
+
6
+ #endif
@@ -0,0 +1,8 @@
1
+ cxx_configuration do
2
+ deps = ['1', BinaryLibrary.new('z')]
3
+ deps << BinaryLibrary.new('dl') if Utils::OS.linux?
4
+ source_lib "2",
5
+ :sources => FileList['**/*.cpp'],
6
+ :dependencies => deps,
7
+ :includes => ['.']
8
+ end
@@ -0,0 +1,7 @@
1
+ #include "lib1.h"
2
+
3
+ #include <iostream>
4
+
5
+ void lib1() {
6
+ std::cout << "lib1" << std::endl;
7
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef lib1_h_
2
+ #define lib1_h_
3
+
4
+ void lib1();
5
+
6
+
7
+ #endif
8
+
@@ -0,0 +1,5 @@
1
+ cxx_configuration do
2
+ source_lib "1",
3
+ :sources => FileList['lib1.cpp'],
4
+ :includes => ['.']
5
+ end
@@ -0,0 +1,21 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef lib2_h_
2
+ #define lib2_h_
3
+
4
+ void lib2();
5
+
6
+ #endif
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,5 @@
1
+ #include "help.h"
2
+ #include <iostream>
3
+ void helpMe() {
4
+ std::cout << "help me" << std::endl;
5
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef help_h_
2
+ #define help_h_
3
+
4
+ void helpMe();
5
+
6
+ #endif
@@ -0,0 +1,10 @@
1
+ #include "lib2.h"
2
+ #include <iostream>
3
+ #include "help.h"
4
+
5
+ int main(int argc, char** args) {
6
+ helpMe();
7
+ lib2();
8
+ std::cout << "hello world" << std::endl;
9
+ return 0;
10
+ }
@@ -0,0 +1,8 @@
1
+ cxx_configuration do
2
+ exe "basic",
3
+ :sources => FileList['**/*.cpp'],
4
+ :dependencies => ['2']
5
+ exe "debug",
6
+ :sources => FileList['**/*.cpp'],
7
+ :dependencies => ['2_debug']
8
+ end
@@ -0,0 +1,4 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","..","lib")
2
+ require 'cxxproject'
3
+ BuildDir='output'
4
+ CxxProject2Rake.new(['project.rb'], BuildDir, "clang")
@@ -0,0 +1,5 @@
1
+ #include "help.h"
2
+ #include <iostream>
3
+ void helpMe() {
4
+ std::cout << "help me" << std::endl;
5
+ }
@@ -0,0 +1,7 @@
1
+ #ifndef help_h_
2
+ #define help_h_
3
+
4
+
5
+ void helpMe();
6
+
7
+ #endif
@@ -0,0 +1,8 @@
1
+ #include <iostream>
2
+ #include "help.h"
3
+
4
+ int main(int argc, char** args) {
5
+ helpMe();
6
+ std::cout << "hello world" << std::endl;
7
+ return 0;
8
+ }
@@ -0,0 +1,4 @@
1
+ cxx_configuration do
2
+ exe "basic",
3
+ :sources => FileList.new('**/*.cpp')
4
+ end
File without changes
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.13
4
+ version: 0.1.14
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-10 00:00:00.000000000 Z
12
+ date: 2012-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cxxproject
@@ -51,15 +51,50 @@ extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
53
  - .gitignore
54
+ - .rvmrc
55
+ - Gemfile
56
+ - Gemfile.lock
54
57
  - Rakefile.rb
55
58
  - bin/cxx
56
59
  - cxx.gemspec
60
+ - junit.rb
57
61
  - lib/cxx.rb
58
62
  - lib/cxx/eval_context.rb
59
63
  - lib/cxx/version.rb
60
64
  - lib/cxx/wizard/Rakefile.rb.template
61
65
  - lib/cxx/wizard/project.rb.template
62
66
  - lib/cxx/wizard/project_wizard.rb
67
+ - rake_helper/spec.rb
68
+ - spec/cxx_spec.rb
69
+ - spec/object_dependency_spec.rb
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
63
98
  homepage:
64
99
  licenses: []
65
100
  post_install_message: