cxxproject 0.2 → 0.4.6
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 +55 -33
- data/bin/cxx +10 -0
- data/lib/cxxproject/buildingblocks/binary_library.rb +16 -0
- data/lib/cxxproject/buildingblocks/building_block.rb +93 -0
- data/lib/cxxproject/buildingblocks/command_line.rb +30 -0
- data/lib/cxxproject/buildingblocks/custom_building_block.rb +17 -0
- data/lib/cxxproject/buildingblocks/executable.rb +49 -0
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +57 -0
- data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +35 -0
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +85 -0
- data/lib/cxxproject/buildingblocks/makefile.rb +35 -0
- data/lib/cxxproject/buildingblocks/module.rb +14 -0
- data/lib/cxxproject/buildingblocks/single_source.rb +11 -0
- data/lib/cxxproject/buildingblocks/source_library.rb +31 -0
- data/lib/cxxproject/extensions/file_ext.rb +47 -0
- data/lib/cxxproject/extensions/rake_dirty_ext.rb +30 -0
- data/lib/cxxproject/extensions/rake_ext.rb +158 -0
- data/lib/cxxproject/extensions/rake_listener_ext.rb +53 -0
- data/lib/cxxproject/extensions/stdout_ext.rb +35 -0
- data/lib/cxxproject/extensions/string_ext.rb +9 -0
- data/lib/cxxproject/task_maker.rb +418 -0
- data/lib/cxxproject/testinstanceeval.rb +65 -0
- data/lib/cxxproject/toolchain/base.rb +98 -0
- data/lib/cxxproject/toolchain/diab.rb +47 -0
- data/lib/cxxproject/toolchain/gcc.rb +39 -0
- data/lib/cxxproject/toolchain/provider.rb +18 -0
- data/lib/cxxproject/torake/compiler.rb +10 -0
- data/lib/cxxproject/torake.rb +152 -0
- data/lib/cxxproject/utils/dot/building_block_graph_writer.rb +19 -0
- data/lib/cxxproject/utils/dot/graph_writer.rb +53 -0
- data/lib/cxxproject/utils/dot/task_graph_writer.rb +34 -0
- data/lib/cxxproject/utils/ubigraph.rb +237 -0
- data/lib/cxxproject/{utils.rb → utils/utils.rb} +19 -1
- data/lib/cxxproject.rb +13 -223
- data/lib/tools/Rakefile.rb.template +10 -0
- data/lib/tools/project.rb.template +6 -0
- data/lib/tools/projectWizard.rb +44 -0
- data/spec/build_dependencies_spec.rb +169 -0
- data/spec/building_block_spec.rb +12 -0
- data/spec/dir_spec.rb +13 -0
- data/spec/project_path_spec.rb +73 -0
- data/spec/rake_listener_ext_spec.rb +25 -0
- data/spec/string_spec.rb +11 -0
- data/spec/testdata/basic/exe12/project.rb +5 -0
- data/spec/testdata/basic/lib1/project.rb +5 -0
- data/spec/testdata/basic/lib2/project.rb +8 -0
- data/spec/testdata/multiple_levels/libs/lib1/project.rb +5 -0
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +19 -0
- data/spec/testdata/multiple_levels/mainproject/basic/project.rb +8 -0
- data/spec/testdata/onlyOneHeader/Rakefile.rb +4 -0
- data/spec/testdata/onlyOneHeader/project.rb +4 -0
- metadata +83 -19
- data/lib/cxxproject/compiler.rb +0 -80
- data/lib/cxxproject/dependencies.rb +0 -41
- data/spec/dependencies_spec.rb +0 -19
- /data/lib/cxxproject/{gcccompiler.rb → torake/gcccompiler.rb} +0 -0
- /data/lib/cxxproject/{osxcompiler.rb → torake/osxcompiler.rb} +0 -0
@@ -0,0 +1,169 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
+
require 'cxxproject'
|
3
|
+
|
4
|
+
RSPECDIR = File.dirname(__FILE__)
|
5
|
+
puts RSPECDIR
|
6
|
+
class SpecTaskListener
|
7
|
+
def initialize
|
8
|
+
@task_execution_count = 0
|
9
|
+
end
|
10
|
+
def before_prerequisites(name)
|
11
|
+
end
|
12
|
+
|
13
|
+
def after_prerequisites(name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def before_execute(name)
|
17
|
+
@task_execution_count += 1
|
18
|
+
end
|
19
|
+
|
20
|
+
def after_execute(name)
|
21
|
+
end
|
22
|
+
def reset_exec_count()
|
23
|
+
@task_execution_count = 0
|
24
|
+
end
|
25
|
+
def get_exec_count()
|
26
|
+
@task_execution_count
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe CxxProject2Rake do
|
31
|
+
def count_needed_tasks(tasks)
|
32
|
+
needed = 0
|
33
|
+
tasks.each do |tn|
|
34
|
+
t = tn[:task]
|
35
|
+
if t.needed?
|
36
|
+
needed = needed + 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
needed
|
40
|
+
end
|
41
|
+
def execute_all_tasks(tasks)
|
42
|
+
tasks.each do |tn|
|
43
|
+
t = tn[:task]
|
44
|
+
t.invoke
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def fresh_cxx
|
49
|
+
ALL_BUILDING_BLOCKS.clear
|
50
|
+
Rake.application.clear
|
51
|
+
outputdir = 'output'
|
52
|
+
CxxProject2Rake.new(Dir.glob('**/project.rb'), outputdir, GCCChain)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should rebuild only when one file was changed' do
|
56
|
+
require 'cxxproject/extensions/rake_listener_ext'
|
57
|
+
require 'cxxproject/extensions/rake_dirty_ext'
|
58
|
+
listener = SpecTaskListener.new
|
59
|
+
Rake::add_listener(listener)
|
60
|
+
cd("#{RSPECDIR}/testdata/onlyOneHeader", :verbose => false) do
|
61
|
+
# fresh build
|
62
|
+
listener.reset_exec_count
|
63
|
+
rm_r 'output' if File.directory?('output')
|
64
|
+
tasks = fresh_cxx.all_tasks
|
65
|
+
CLOBBER.each { |fn| rm_r fn rescue nil }
|
66
|
+
execute_all_tasks(tasks)
|
67
|
+
fresh_build_steps = listener.get_exec_count
|
68
|
+
|
69
|
+
# rebuild, nothing changed
|
70
|
+
listener.reset_exec_count
|
71
|
+
execute_all_tasks(tasks)
|
72
|
+
rebuild_build_steps = listener.get_exec_count
|
73
|
+
|
74
|
+
# rebuild, nothing changed
|
75
|
+
listener.reset_exec_count
|
76
|
+
execute_all_tasks(tasks)
|
77
|
+
listener.get_exec_count.should == rebuild_build_steps
|
78
|
+
|
79
|
+
|
80
|
+
# rebuild after header changed
|
81
|
+
listener.reset_exec_count
|
82
|
+
sleep(0.1)
|
83
|
+
files2touch = Dir.glob('help.h')
|
84
|
+
FileUtils.touch files2touch
|
85
|
+
execute_all_tasks(fresh_cxx.all_tasks)
|
86
|
+
rebuild_after_touch_steps = listener.get_exec_count
|
87
|
+
rebuild_after_touch_steps.should > rebuild_build_steps
|
88
|
+
|
89
|
+
# rebuild, nothing changed
|
90
|
+
listener.reset_exec_count
|
91
|
+
execute_all_tasks(tasks)
|
92
|
+
listener.get_exec_count.should == rebuild_build_steps
|
93
|
+
|
94
|
+
# cleanup
|
95
|
+
rm_r 'output' if File.directory?('output')
|
96
|
+
end
|
97
|
+
Rake::remove_listener(listener)
|
98
|
+
end
|
99
|
+
|
100
|
+
def rebuild
|
101
|
+
tasks = fresh_cxx.all_tasks
|
102
|
+
execute_all_tasks(tasks)
|
103
|
+
end
|
104
|
+
|
105
|
+
def is_older? fileA, fileB
|
106
|
+
File.mtime(fileA) < File.mtime(fileB)
|
107
|
+
end
|
108
|
+
|
109
|
+
def is_newer? fileA, fileB
|
110
|
+
File.mtime(fileA) > File.mtime(fileB)
|
111
|
+
end
|
112
|
+
|
113
|
+
def check_rebuilding (end_product, prereq_file, should_rebuild = true)
|
114
|
+
sleep(1)
|
115
|
+
FileUtils.touch prereq_file
|
116
|
+
# prereq_file should be newer
|
117
|
+
File.mtime(prereq_file).should > File.mtime(end_product)
|
118
|
+
rebuild
|
119
|
+
if should_rebuild
|
120
|
+
# prereq_file should NOT be newer
|
121
|
+
File.mtime(prereq_file).should <= File.mtime(end_product)
|
122
|
+
else
|
123
|
+
# prereq_file should still be newer
|
124
|
+
File.mtime(prereq_file).should > File.mtime(end_product)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should rebuild when any source file changes' do
|
129
|
+
cd("#{RSPECDIR}/testdata/basic", :verbose => false) do
|
130
|
+
rm_r 'output' if File.directory?('output')
|
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/lib1.a'
|
148
|
+
libC = 'output/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
|
+
rm_r 'output' if File.directory?('output')
|
163
|
+
ALL_BUILDING_BLOCKS.clear
|
164
|
+
Rake.application.clear
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'cxxproject'
|
2
|
+
|
3
|
+
describe BuildingBlock do
|
4
|
+
it 'should build the right dependency-chain' do
|
5
|
+
lib1 = SourceLibrary.new('1')
|
6
|
+
lib2 = SourceLibrary.new('2').set_dependencies(['1'])
|
7
|
+
lib3 = SourceLibrary.new('3').set_dependencies(['1'])
|
8
|
+
lib4 = SourceLibrary.new('4').set_dependencies(['2', '3'])
|
9
|
+
deps = lib4.calc_transitive_dependencies
|
10
|
+
deps.should == ['4', '2', '3', '1']
|
11
|
+
end
|
12
|
+
end
|
data/spec/dir_spec.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
+
require 'cxxproject'
|
3
|
+
|
4
|
+
RSPECDIR = File.dirname(__FILE__)
|
5
|
+
|
6
|
+
describe CxxProject2Rake do
|
7
|
+
|
8
|
+
def execute_all_tasks(tasks)
|
9
|
+
tasks.each do |tn|
|
10
|
+
t = tn[:task]
|
11
|
+
t.invoke
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def fresh_cxx(outputdir,base)
|
16
|
+
ALL_BUILDING_BLOCKS.clear
|
17
|
+
Rake.application.clear
|
18
|
+
project_configs = nil
|
19
|
+
cd base do # have to be relative to base
|
20
|
+
project_configs = Dir.glob('**/project.rb')
|
21
|
+
end
|
22
|
+
CxxProject2Rake.new(project_configs, outputdir, GCCChain, base, Logger::DEBUG)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def is_older? fileA, fileB
|
27
|
+
File.mtime(fileA) < File.mtime(fileB)
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_newer? fileA, fileB
|
31
|
+
File.mtime(fileA) > File.mtime(fileB)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_on_level(base, outputdir)
|
35
|
+
libOne = "#{outputdir}/lib1.a"
|
36
|
+
libTwo = "#{outputdir}/lib2.a"
|
37
|
+
exe = "#{outputdir}/basic.exe"
|
38
|
+
exe2 = "#{outputdir}/debug.exe"
|
39
|
+
|
40
|
+
rm_r outputdir if File.directory?(outputdir)
|
41
|
+
tasks = fresh_cxx(outputdir, base).all_tasks
|
42
|
+
CLOBBER.each { |fn| rm_r fn rescue nil }
|
43
|
+
|
44
|
+
[libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_false }
|
45
|
+
|
46
|
+
execute_all_tasks(tasks)
|
47
|
+
|
48
|
+
[libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_true }
|
49
|
+
|
50
|
+
# cleanup
|
51
|
+
rm_r outputdir if File.directory?(outputdir)
|
52
|
+
ALL_BUILDING_BLOCKS.clear
|
53
|
+
Rake.application.clear
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should resolve paths on different levels' do
|
57
|
+
outputdir = 'output'
|
58
|
+
|
59
|
+
cd("#{RSPECDIR}/testdata/multiple_levels", :verbose => false) do
|
60
|
+
test_on_level(".", outputdir)
|
61
|
+
end
|
62
|
+
|
63
|
+
cd("#{RSPECDIR}/testdata/multiple_levels/mainproject", :verbose => false) do
|
64
|
+
test_on_level("..", outputdir)
|
65
|
+
end
|
66
|
+
|
67
|
+
cd("#{RSPECDIR}/testdata", :verbose => false) do
|
68
|
+
test_on_level("multiple_levels/", outputdir)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'cxxproject/extensions/rake_listener_ext.rb'
|
2
|
+
|
3
|
+
describe Rake::Task do
|
4
|
+
|
5
|
+
it "should call a listener for prerequisites and execute" do
|
6
|
+
Rake.application.clear
|
7
|
+
t = task "test"
|
8
|
+
|
9
|
+
l = mock
|
10
|
+
Rake::add_listener(l)
|
11
|
+
|
12
|
+
l.should_receive(:before_prerequisites).with('test')
|
13
|
+
l.should_receive(:after_prerequisites).with('test')
|
14
|
+
l.should_receive(:before_execute).with('test')
|
15
|
+
l.should_receive(:after_execute).with('test')
|
16
|
+
t.invoke
|
17
|
+
|
18
|
+
Rake::remove_listener(l)
|
19
|
+
|
20
|
+
t.invoke
|
21
|
+
|
22
|
+
Rake.application.clear
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/spec/string_spec.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'cxxproject'
|
2
|
+
|
3
|
+
describe String do
|
4
|
+
it 'should remove from start if matching' do
|
5
|
+
s = "abcd"
|
6
|
+
s.remove_from_start('abc').should == 'd'
|
7
|
+
end
|
8
|
+
it 'should not change the string if the start does not match' do
|
9
|
+
"abcd".remove_from_start('z').should == 'abcd'
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
cxx_configuration do
|
2
|
+
deps = ['1', BinaryLibrary.new('z')]
|
3
|
+
deps << BinaryLibrary.new('dl') if 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
|
metadata
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cxxproject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 3
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
|
8
|
+
- 4
|
9
|
+
- 6
|
10
|
+
version: 0.4.6
|
9
11
|
platform: ruby
|
10
12
|
authors:
|
11
13
|
- ""
|
@@ -13,29 +15,87 @@ autorequire:
|
|
13
15
|
bindir: bin
|
14
16
|
cert_chain: []
|
15
17
|
|
16
|
-
date:
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
date: 2011-05-20 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: highline
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 15
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 6
|
32
|
+
- 0
|
33
|
+
version: 1.6.0
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
20
36
|
description: " Some more high level building blocks for cpp projects.\n"
|
21
|
-
email:
|
22
|
-
executables:
|
23
|
-
|
37
|
+
email: oliver.mueller@gmail.com
|
38
|
+
executables:
|
39
|
+
- cxx
|
24
40
|
extensions: []
|
25
41
|
|
26
42
|
extra_rdoc_files: []
|
27
43
|
|
28
44
|
files:
|
29
|
-
- lib/cxxproject/
|
30
|
-
- lib/cxxproject/
|
31
|
-
- lib/cxxproject/
|
32
|
-
- lib/cxxproject/
|
33
|
-
- lib/cxxproject/
|
45
|
+
- lib/cxxproject/buildingblocks/binary_library.rb
|
46
|
+
- lib/cxxproject/buildingblocks/building_block.rb
|
47
|
+
- lib/cxxproject/buildingblocks/command_line.rb
|
48
|
+
- lib/cxxproject/buildingblocks/custom_building_block.rb
|
49
|
+
- lib/cxxproject/buildingblocks/executable.rb
|
50
|
+
- lib/cxxproject/buildingblocks/has_dependencies_mixin.rb
|
51
|
+
- lib/cxxproject/buildingblocks/has_libraries_mixin.rb
|
52
|
+
- lib/cxxproject/buildingblocks/has_sources_mixin.rb
|
53
|
+
- lib/cxxproject/buildingblocks/makefile.rb
|
54
|
+
- lib/cxxproject/buildingblocks/module.rb
|
55
|
+
- lib/cxxproject/buildingblocks/single_source.rb
|
56
|
+
- lib/cxxproject/buildingblocks/source_library.rb
|
57
|
+
- lib/cxxproject/extensions/file_ext.rb
|
58
|
+
- lib/cxxproject/extensions/rake_dirty_ext.rb
|
59
|
+
- lib/cxxproject/extensions/rake_ext.rb
|
60
|
+
- lib/cxxproject/extensions/rake_listener_ext.rb
|
61
|
+
- lib/cxxproject/extensions/stdout_ext.rb
|
62
|
+
- lib/cxxproject/extensions/string_ext.rb
|
63
|
+
- lib/cxxproject/task_maker.rb
|
64
|
+
- lib/cxxproject/testinstanceeval.rb
|
65
|
+
- lib/cxxproject/toolchain/base.rb
|
66
|
+
- lib/cxxproject/toolchain/diab.rb
|
67
|
+
- lib/cxxproject/toolchain/gcc.rb
|
68
|
+
- lib/cxxproject/toolchain/provider.rb
|
69
|
+
- lib/cxxproject/torake/compiler.rb
|
70
|
+
- lib/cxxproject/torake/gcccompiler.rb
|
71
|
+
- lib/cxxproject/torake/osxcompiler.rb
|
72
|
+
- lib/cxxproject/torake.rb
|
73
|
+
- lib/cxxproject/utils/dot/building_block_graph_writer.rb
|
74
|
+
- lib/cxxproject/utils/dot/graph_writer.rb
|
75
|
+
- lib/cxxproject/utils/dot/task_graph_writer.rb
|
76
|
+
- lib/cxxproject/utils/ubigraph.rb
|
77
|
+
- lib/cxxproject/utils/utils.rb
|
34
78
|
- lib/cxxproject.rb
|
79
|
+
- lib/tools/projectWizard.rb
|
80
|
+
- lib/tools/project.rb.template
|
81
|
+
- lib/tools/Rakefile.rb.template
|
35
82
|
- Rakefile.rb
|
36
|
-
- spec/
|
37
|
-
|
38
|
-
|
83
|
+
- spec/build_dependencies_spec.rb
|
84
|
+
- spec/building_block_spec.rb
|
85
|
+
- spec/dir_spec.rb
|
86
|
+
- spec/project_path_spec.rb
|
87
|
+
- spec/rake_listener_ext_spec.rb
|
88
|
+
- spec/string_spec.rb
|
89
|
+
- spec/testdata/basic/exe12/project.rb
|
90
|
+
- spec/testdata/basic/lib1/project.rb
|
91
|
+
- spec/testdata/basic/lib2/project.rb
|
92
|
+
- spec/testdata/multiple_levels/libs/lib1/project.rb
|
93
|
+
- spec/testdata/multiple_levels/libs/lib2/project.rb
|
94
|
+
- spec/testdata/multiple_levels/mainproject/basic/project.rb
|
95
|
+
- spec/testdata/onlyOneHeader/project.rb
|
96
|
+
- spec/testdata/onlyOneHeader/Rakefile.rb
|
97
|
+
- bin/cxx
|
98
|
+
homepage: https://github.com/marcmo/cxxproject
|
39
99
|
licenses: []
|
40
100
|
|
41
101
|
post_install_message:
|
@@ -44,23 +104,27 @@ rdoc_options: []
|
|
44
104
|
require_paths:
|
45
105
|
- lib
|
46
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
47
108
|
requirements:
|
48
109
|
- - ">="
|
49
110
|
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
50
112
|
segments:
|
51
113
|
- 0
|
52
114
|
version: "0"
|
53
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
54
117
|
requirements:
|
55
118
|
- - ">="
|
56
119
|
- !ruby/object:Gem::Version
|
120
|
+
hash: 3
|
57
121
|
segments:
|
58
122
|
- 0
|
59
123
|
version: "0"
|
60
124
|
requirements: []
|
61
125
|
|
62
126
|
rubyforge_project:
|
63
|
-
rubygems_version: 1.3
|
127
|
+
rubygems_version: 1.8.3
|
64
128
|
signing_key:
|
65
129
|
specification_version: 3
|
66
130
|
summary: Cpp Support for Rake.
|
data/lib/cxxproject/compiler.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
class Compiler
|
2
|
-
def initialize(output_path)
|
3
|
-
@output_path = output_path
|
4
|
-
end
|
5
|
-
|
6
|
-
def include(name)
|
7
|
-
CLEAN.include(name)
|
8
|
-
# ALL.include(name)
|
9
|
-
end
|
10
|
-
|
11
|
-
def transitive_includes(lib)
|
12
|
-
res = Dependencies.transitive_dependencies([lib.name]).map do |i|
|
13
|
-
i.includes.map { |include| File.join(i.base, include) }
|
14
|
-
end
|
15
|
-
return res.flatten
|
16
|
-
end
|
17
|
-
def transitive_libs(from)
|
18
|
-
res = Dependencies.transitive_dependencies([from.name]).delete_if{|i|i.instance_of?(Exe)}.map do |i|
|
19
|
-
"#{@output_path}/lib#{i.name}.a"
|
20
|
-
end
|
21
|
-
return res
|
22
|
-
end
|
23
|
-
|
24
|
-
def create_object_file(lib, relative_source)
|
25
|
-
source = File.join(lib.base, relative_source)
|
26
|
-
out = File.join(@output_path, "#{source}.o")
|
27
|
-
outputdir = File.dirname(out)
|
28
|
-
directory outputdir
|
29
|
-
include(out)
|
30
|
-
desc "compiling #{source}"
|
31
|
-
res = file out => [source, outputdir] do |t|
|
32
|
-
includes = transitive_includes(lib)
|
33
|
-
include_string = includes.inject('') { | res, i | "#{res} -I#{i} " }
|
34
|
-
sh "g++ -c #{source} #{include_string} -o #{t.name}"
|
35
|
-
end
|
36
|
-
return res
|
37
|
-
end
|
38
|
-
|
39
|
-
def static_lib_path(name)
|
40
|
-
libname = "lib#{name}.a"
|
41
|
-
fullpath = File.join(@output_path, libname)
|
42
|
-
return fullpath
|
43
|
-
end
|
44
|
-
|
45
|
-
def create_source_lib(lib, objects)
|
46
|
-
fullpath = static_lib_path(lib.name)
|
47
|
-
command = objects.inject("ar -r #{fullpath}") do |command, o|
|
48
|
-
"#{command} #{o}"
|
49
|
-
end
|
50
|
-
include(fullpath)
|
51
|
-
deps = objects.dup
|
52
|
-
deps += lib.dependencies.map {|dep|static_lib_path(dep)}
|
53
|
-
desc "link lib #{lib.name}"
|
54
|
-
res = file fullpath => deps do
|
55
|
-
sh command
|
56
|
-
end
|
57
|
-
return res
|
58
|
-
end
|
59
|
-
|
60
|
-
def create_exe(exe, objects)
|
61
|
-
exename = "#{exe.name}.exe"
|
62
|
-
fullpath = File.join(@output_path, exename)
|
63
|
-
command = objects.inject("g++ -o #{fullpath}") do |command, o|
|
64
|
-
"#{command} #{o}"
|
65
|
-
end
|
66
|
-
|
67
|
-
dep_paths = exe.dependencies.map {|dep|static_lib_path(dep)}
|
68
|
-
include(fullpath)
|
69
|
-
deps = objects.dup
|
70
|
-
deps += dep_paths
|
71
|
-
desc "link exe #{exe.name}"
|
72
|
-
res = file fullpath => deps do
|
73
|
-
libs = transitive_libs(exe)
|
74
|
-
command = libs.inject(command) { |command, l| "#{command} #{l}" }
|
75
|
-
sh command
|
76
|
-
end
|
77
|
-
return res
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
@@ -1,41 +0,0 @@
|
|
1
|
-
class Dependencies
|
2
|
-
|
3
|
-
attr_reader :all_libs
|
4
|
-
|
5
|
-
def initialize(lib_strings)
|
6
|
-
@all_libs = []
|
7
|
-
lib_strings.each do |lib_string|
|
8
|
-
add(lib_string)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.transitive_dependencies(lib)
|
13
|
-
return Dependencies.new(lib).all_libs
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def self.tr_libs(libs)
|
19
|
-
return LibHelper.new(libs).all_libs
|
20
|
-
end
|
21
|
-
|
22
|
-
def add_unique(lib)
|
23
|
-
@all_libs.delete(lib)
|
24
|
-
@all_libs.push(lib)
|
25
|
-
end
|
26
|
-
|
27
|
-
def add(lib)
|
28
|
-
bb = ALL_BUILDING_BLOCKS[lib]
|
29
|
-
if !bb
|
30
|
-
raise "dependency not found #{lib}"
|
31
|
-
end
|
32
|
-
add_unique(bb)
|
33
|
-
bb.dependencies.each do |dep|
|
34
|
-
add(dep)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
data/spec/dependencies_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'cxxproject'
|
2
|
-
|
3
|
-
describe Dependencies do
|
4
|
-
it 'should build the right dependency-chain' do
|
5
|
-
lib1 = SourceLibrary.new('1')
|
6
|
-
lib2 = SourceLibrary.new('2')
|
7
|
-
lib2.dependencies = ['1']
|
8
|
-
lib3 = SourceLibrary.new('3')
|
9
|
-
lib3.dependencies = ['1']
|
10
|
-
lib4 = SourceLibrary.new('4')
|
11
|
-
lib4.dependencies = ['2', '3']
|
12
|
-
deps = Dependencies.transitive_dependencies(['4'])
|
13
|
-
deps.map {|d|d.name}.should == ['4', '2', '3', '1']
|
14
|
-
end
|
15
|
-
it 'should create .d files' do
|
16
|
-
pending
|
17
|
-
1.should == 0
|
18
|
-
end
|
19
|
-
end
|
File without changes
|
File without changes
|