Skip to content

Commit 632a834

Browse files
committed
added more libraries to the mix
Change-Id: I64d913ca4a356a54053d6d1f81ced73b65f1e21c
1 parent 779aeb7 commit 632a834

13 files changed

+102
-7
lines changed

Rakefile.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
'cxxproject',
33
'cxx',
44
'cxxproject_gcctoolchain',
5-
'cxxproject_clangtoolchain',
6-
'cxxproject_clanganalyzer',
5+
# 'cxxproject_clangtoolchain',
6+
# 'cxxproject_rpitoolchain',
7+
# 'cxxproject_fsltoolchain',
8+
# 'cxxproject_clanganalyzer',
79
'cxxproject_stats',
10+
'cxxproject_tomake',
811
'cxxproject_console',
9-
'cxxproject_valgrind']
12+
'cxxproject_valgrind',
13+
'cxxproject_gcov']
1014

1115
desc 'cleanup all built gems'
1216
task :clean do

basic/lib2/project.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:sources => FileList['**/*.cpp'],
1010
:dependencies => deps,
1111
:includes => ['.'],
12-
:whole_archive => true
12+
:whole_archive => false
1313

1414
unittest_flags = {
1515
:DEFINES => ['UNIT_TEST','CPPUNIT_MAIN="main"']

gtest/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
*.gc??
12
out

gtest/Rakefile.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
require 'cxx'
22

3-
cxx(Dir['**/project.rb'] , 'out', 'gcc', '.')
3+
flags = {
4+
:FLAGS => ['-coverage']
5+
}
6+
7+
cxx(Dir['**/project.rb'] , 'out', 'gcc', '.') do
8+
Provider.modify_compiler("gcc", :C, flags)
9+
Provider.modify_compiler("gcc", :CPP, flags)
10+
Provider.modify_linker("gcc", flags)
11+
end
12+
13+

gtest/lib1/lib1.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "lib1.h"
2+
3+
int Lib1::f1() {
4+
return 1;
5+
}
6+
7+
int Lib1::f2() {
8+
return 2;
9+
}

gtest/lib1/lib1.h

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef lib1_h_
2+
#define lib1_h_
3+
4+
class Lib1 {
5+
public:
6+
int f1();
7+
int f2();
8+
};
9+
10+
#endif

gtest/lib1/project.rb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cxx_configuration do
2+
source_lib 'lib1',
3+
:sources => ['lib1.cpp'],
4+
:includes => ['.']
5+
6+
end

gtest/lib2/lib2.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "lib2.h"
2+
#include "lib1.h"
3+
4+
int Lib2::f1() {
5+
Lib1 l1;
6+
return l1.f1() * 2;
7+
}
8+
9+
int Lib2::f2() {
10+
return 4;
11+
}
12+
13+
int Lib2::f3() {
14+
return 6;
15+
}
16+

gtest/lib2/lib2.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef lib2_h_
2+
#define lib2_h_
3+
4+
class Lib2 {
5+
6+
public:
7+
int f1();
8+
int f2();
9+
int f3();
10+
};
11+
12+
#endif

gtest/lib2/project.rb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cxx_configuration do
2+
source_lib 'lib2',
3+
:sources => ['lib2.cpp'],
4+
:dependencies => ['lib1'],
5+
:includes => ['.']
6+
end

gtest/project.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
cxx_configuration do
22
source_lib 'small-tests',
33
:sources => ['small-tests.cpp'],
4-
:dependencies => ['gtest'],
4+
:dependencies => ['gtest', 'lib1'],
55
:whole_archive => true
66

77
source_lib 'small-tests2',
88
:sources => ['small-tests2.cpp'],
9-
:dependencies => ['gtest']
9+
:dependencies => ['gtest', 'lib2'],
10+
:whole_archive => true
1011

1112
exe 'all-tests',
1213
:dependencies => ['small-tests', 'small-tests2', 'gtest_main']

gtest/small-tests.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
#include <gtest/gtest.h>
22

3+
#include "lib1.h"
4+
35
TEST(Hello, world1) {
46
EXPECT_EQ(1, 1);
57
}
68

79
TEST(Hello, world2) {
810
EXPECT_EQ(1, 1);
911
}
12+
13+
TEST(Lib1, f1) {
14+
Lib1 lib1;
15+
EXPECT_EQ(1, lib1.f1());
16+
}
17+
18+
TEST(Lib1, f2) {
19+
Lib1 lib1;
20+
EXPECT_EQ(2, lib1.f2());
21+
}
22+

gtest/small-tests2.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#include <gtest/gtest.h>
22

3+
#include "lib2.h"
4+
35
TEST(Hello2, world1) {
46
EXPECT_EQ(1, 1);
57
}
68

79
TEST(Hello2, world2) {
810
EXPECT_TRUE(true);
911
}
12+
13+
TEST(Lib2, f1) {
14+
Lib2 lib2;
15+
EXPECT_EQ(2, lib2.f1());
16+
}

0 commit comments

Comments
 (0)