cxxproject 0.6.29 → 0.6.30
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +195 -65
- data/lib/cxxproject/buildingblocks/building_block.rb +1 -1
- data/lib/cxxproject/buildingblocks/executable.rb +3 -0
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +5 -5
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +30 -16
- data/lib/cxxproject/buildingblocks/single_source.rb +0 -1
- data/lib/cxxproject/ext/rake_listener.rb +11 -13
- data/lib/cxxproject/plugin_context.rb +6 -4
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +8 -5
- data/lib/cxxproject/utils/printer.rb +6 -6
- data/lib/cxxproject/version.rb +1 -1
- data/lib/cxxproject.rb +0 -1
- metadata +37 -145
- data/.gitignore +0 -18
- data/.rvmrc +0 -1
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -35
- data/Rakefile.rb +0 -125
- data/cxxproject.gemspec +0 -22
- data/example/.gitignore +0 -1
- data/example/Rakefile.rb +0 -35
- data/example/big_project/.gitignore +0 -2
- data/example/big_project/Rakefile_generator.rb +0 -80
- data/example/big_project/fak.h +0 -9
- data/example/custom/.gitignore +0 -1
- data/example/custom/Rakefile.rb +0 -12
- data/example/custom/foo.cpp +0 -5
- data/example/custom/project.rb +0 -27
- data/example/dependency_tests/Rakefile.rb +0 -3
- data/example/dependency_tests/help1.h +0 -12
- data/example/dependency_tests/help2.h +0 -10
- data/example/dependency_tests/main.cpp +0 -6
- data/example/dependency_tests/project.rb +0 -3
- data/example/generator/Rakefile.rb +0 -12
- data/example/generator/main/main.cpp +0 -3
- data/example/generator/main/project/project.rb +0 -3
- data/example/oneFileOnly/Rakefile.rb +0 -3
- data/example/oneFileOnly/config.h +0 -2
- data/example/oneFileOnly/main.cpp +0 -8
- data/example/oneFileOnly/project_compile.rb +0 -3
- data/example/protobuf/.gitignore +0 -4
- data/example/protobuf/Rakefile.rb +0 -70
- data/example/protobuf/addressbook/addressbook.proto +0 -24
- data/example/protobuf/addressbook/addressbook_read.cc +0 -67
- data/example/protobuf/addressbook/addressbook_write.cc +0 -93
- data/example/protobuf/addressbook/project.rb +0 -16
- data/example/protobuf/protobuf.files +0 -37
- data/example/protobuf/protobuf_project.rb +0 -9
- data/example/simpleUnitTest/Rakefile.rb +0 -4
- data/example/simpleUnitTest/atest.cpp +0 -16
- data/example/simpleUnitTest/atest.h +0 -11
- data/example/simpleUnitTest/project.rb +0 -5
- data/example/simpleUnitTest/test.cpp +0 -13
- data/example/strange_dirs/Rakefile.rb +0 -4
- data/example/strange_dirs/lazyLib/project.rb +0 -5
- data/example/strange_dirs/main/main.cpp +0 -5
- data/example/strange_dirs/main/project.rb +0 -5
- data/example/strange_dirs/src/test.cpp +0 -4
- data/example/test.rb +0 -10
- data/example/three_tests/Rakefile.rb +0 -5
- data/example/three_tests/allsuites/project.rb +0 -4
- data/example/three_tests/main/main.cpp +0 -13
- data/example/three_tests/main/project.rb +0 -5
- data/example/three_tests/suite1/project.rb +0 -6
- data/example/three_tests/suite1/suite1.cpp +0 -3
- data/example/three_tests/suite1/suite1.h +0 -28
- data/example/three_tests/suite2/project.rb +0 -6
- data/example/three_tests/suite2/suite2.cpp +0 -3
- data/example/three_tests/suite2/suite2.h +0 -29
- data/junit.rb +0 -91
- data/lib/cxxproject/ext/string.rb +0 -9
- data/plugins/tmp/.rvmrc +0 -1
- data/plugins/tmp/BuildDir/objects/testme/test.o +0 -0
- data/plugins/tmp/BuildDir/objects/testme/test.o.d +0 -1
- data/plugins/tmp/BuildDir/testme.exe +0 -0
- data/plugins/tmp/Rakefile.rb +0 -6
- data/plugins/tmp/project.rb +0 -6
- data/plugins/tmp/reinstall/Rakefile.rb +0 -15
- data/plugins/tmp/test.cpp +0 -7
- data/rake_helper/perftools.rb +0 -34
- data/rake_helper/spec.rb +0 -65
- data/roodi.yml +0 -8
- data/spec/building_block_spec.rb +0 -103
- data/spec/file_ext_spec.rb +0 -30
- data/spec/ide_interface_spec.rb +0 -41
- data/spec/plugin_context_spec.rb +0 -57
- data/spec/provider_spec.rb +0 -39
- data/spec/rake_listener_ext_spec.rb +0 -58
- data/spec/spec_helper.rb +0 -18
- data/spec/string_spec.rb +0 -11
- 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/spec/toolchain_spec.rb +0 -29
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'rake/clean'
|
3
|
-
|
4
|
-
NR_OF_PROJECTS = 6000
|
5
|
-
PROJECTS = {}
|
6
|
-
MAX_SOURCES = 20
|
7
|
-
MAX_FIB = 12
|
8
|
-
|
9
|
-
directory 'gen'
|
10
|
-
|
11
|
-
def create_project(name)
|
12
|
-
base = File.join('gen', "project_#{name}")
|
13
|
-
FileUtils.mkdir_p(base)
|
14
|
-
sources = rand(MAX_SOURCES)
|
15
|
-
PROJECTS[name] = sources
|
16
|
-
sources.times do |i|
|
17
|
-
File.open(File.join(base, "#{name}_file_#{i}.cxx"), 'w') do |io|
|
18
|
-
io.puts("#include <stdio.h>\n#include \"../../fak.h\"\nvoid print_#{name}_#{i}() {printf(\"%ld\\n\", fib<#{rand(MAX_FIB)+1}>::value);}")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
File.open(File.join(base, "lib_#{name}.h"), 'w') do |io|
|
22
|
-
sources.times do |i|
|
23
|
-
io.puts("void print_#{name}_#{i}();")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
File.open(File.join(base, 'project.rb'), 'w') do |io|
|
28
|
-
io.puts('cxx_configuration do')
|
29
|
-
io.puts(" source_lib '#{name}', :sources => Dir.glob('*.cxx'), :includes => ['.']")
|
30
|
-
io.puts('end')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
desc "Creating #{PROJECTS} projects"
|
35
|
-
task :create_projects => [:gen] do
|
36
|
-
NR_OF_PROJECTS.times do |i|
|
37
|
-
create_project(i)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
desc 'creating rakefile'
|
42
|
-
task 'Rakefile.rb' => [:gen] do
|
43
|
-
File.open(File.join('gen', 'Rakefile.rb'), 'w') do |io|
|
44
|
-
io.puts("$:.unshift File.join(File.dirname(__FILE__),'..','..','..','lib')")
|
45
|
-
io.puts("require 'cxxproject'")
|
46
|
-
io.puts("CxxProject2Rake.new(Dir.glob('**/*project.rb'), 'build', 'gcc', '.')")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
desc 'create a main project'
|
51
|
-
task :create_main => [:create_projects, :gen] do
|
52
|
-
base = File.join('gen', 'main')
|
53
|
-
FileUtils.mkdir_p(base)
|
54
|
-
File.open(File.join(base, 'main.cxx'), 'w') do |io|
|
55
|
-
NR_OF_PROJECTS.times do |i|
|
56
|
-
io.puts("#include \"lib_#{i}.h\"")
|
57
|
-
end
|
58
|
-
io.puts('#include <stdio.h>')
|
59
|
-
io.puts('int main(int argc, char** args) {')
|
60
|
-
NR_OF_PROJECTS.times do |name|
|
61
|
-
PROJECTS[name].times do |i|
|
62
|
-
io.puts(" print_#{name}_#{i}();")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
io.puts(' printf("\\n");')
|
66
|
-
io.puts('}')
|
67
|
-
end
|
68
|
-
deps = []
|
69
|
-
NR_OF_PROJECTS.times do |i|
|
70
|
-
deps << "'#{i}'"
|
71
|
-
end
|
72
|
-
File.open(File.join(base, 'project.rb'), 'w') do |io|
|
73
|
-
io.puts('cxx_configuration do')
|
74
|
-
io.puts(" exe 'main', :sources => ['main.cxx'], :dependencies => [#{deps.join(', ')}]")
|
75
|
-
io.puts('end')
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
task :default => [:create_main, 'Rakefile.rb']
|
80
|
-
CLEAN.include('gen')
|
data/example/big_project/fak.h
DELETED
data/example/custom/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
BuildDir
|
data/example/custom/Rakefile.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","..","lib")
|
2
|
-
require 'cxxproject'
|
3
|
-
BuildDir = "BuildDir"
|
4
|
-
|
5
|
-
dependent_projects = ['./project.rb']
|
6
|
-
CxxProject2Rake.new(dependent_projects, BuildDir, "gcc", './')
|
7
|
-
|
8
|
-
unittest_flags = {
|
9
|
-
:DEFINES => ['UNIT_TEST','CPPUNIT_MAIN=main'],
|
10
|
-
:FLAGS => "-O0 -g3 -Wall"
|
11
|
-
}
|
12
|
-
toolchain = Provider.modify_cpp_compiler("gcc", unittest_flags)
|
data/example/custom/project.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
cxx_configuration do
|
2
|
-
|
3
|
-
source_lib "testme",
|
4
|
-
:sources => FileList['**/*.cpp'],
|
5
|
-
:includes => ['include'],
|
6
|
-
:dependencies => []
|
7
|
-
|
8
|
-
# using lambdas
|
9
|
-
custom "testcustom",
|
10
|
-
:execute => lambda { puts "executing testcustom" },
|
11
|
-
:dependencies => ["testme"]
|
12
|
-
|
13
|
-
def foo
|
14
|
-
puts "foo for testcustom2"
|
15
|
-
end
|
16
|
-
|
17
|
-
# using methods
|
18
|
-
custom "testcustom2",
|
19
|
-
:execute => method(:foo),
|
20
|
-
:dependencies => ["testcustom"]
|
21
|
-
|
22
|
-
# using new lambda syntax
|
23
|
-
custom "testcustom3",
|
24
|
-
:execute => -> { puts "executing testcustom3" },
|
25
|
-
:dependencies => ["testcustom2"]
|
26
|
-
|
27
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","..","lib")
|
2
|
-
|
3
|
-
require 'cxxproject'
|
4
|
-
|
5
|
-
DIR = 'build/gen'
|
6
|
-
directory DIR
|
7
|
-
|
8
|
-
file File.join(DIR, 'test.cpp') => DIR do |t|
|
9
|
-
sh "touch #{t.name}"
|
10
|
-
end
|
11
|
-
|
12
|
-
CxxProject2Rake.new('main/project/project.rb' , 'build', "gcc", '.')
|
data/example/protobuf/.gitignore
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","..","lib")
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
PROTOBUF_VERSION='2.4.1'
|
6
|
-
PROTOBUF_BASE="protobuf-#{PROTOBUF_VERSION}"
|
7
|
-
PROTOBUF_ARCHIVE="#{PROTOBUF_BASE}.tar.gz"
|
8
|
-
PROTOBUF_DOWNLOAD="tmp/#{PROTOBUF_ARCHIVE}"
|
9
|
-
|
10
|
-
directory 'tmp'
|
11
|
-
|
12
|
-
desc "download protobuf #{PROTOBUF_VERSION}"
|
13
|
-
file PROTOBUF_DOWNLOAD => 'tmp' do
|
14
|
-
cd 'tmp' do
|
15
|
-
command = "wget http://protobuf.googlecode.com/files/#{PROTOBUF_ARCHIVE}"
|
16
|
-
sh command
|
17
|
-
sleep(2)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
PROTOBUF_TMP = File.join(PROTOBUF_BASE, 'tmp')
|
22
|
-
PROTOC = File.join(PROTOBUF_TMP, 'src', 'protoc')
|
23
|
-
PROTOBUF_CONFIG_H=File.join(PROTOBUF_TMP, 'config.h')
|
24
|
-
|
25
|
-
PROTOBUF_LITE_SOURCES=YAML.load(IO.read('protobuf.files')).map{ | i | File.join(PROTOBUF_BASE, 'src', i)}
|
26
|
-
file PROTOBUF_LITE_SOURCES[0] => PROTOBUF_DOWNLOAD do |t|
|
27
|
-
command = "tar xf #{PROTOBUF_DOWNLOAD}"
|
28
|
-
sh command
|
29
|
-
command = "find #{PROTOBUF_BASE}/ -exec touch {} \\;"
|
30
|
-
sh command
|
31
|
-
sleep(2) # wait for file timestamps to matter
|
32
|
-
end
|
33
|
-
|
34
|
-
directory PROTOBUF_TMP
|
35
|
-
desc 'configure protobuf'
|
36
|
-
file PROTOBUF_CONFIG_H => PROTOBUF_LITE_SOURCES + [PROTOBUF_TMP] do
|
37
|
-
cd PROTOBUF_TMP do
|
38
|
-
command = '../configure'
|
39
|
-
sh command
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
desc 'build protoc'
|
44
|
-
file PROTOC => [PROTOBUF_CONFIG_H] do
|
45
|
-
cd PROTOBUF_TMP do
|
46
|
-
command = 'make'
|
47
|
-
sh command
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
require 'cxxproject'
|
52
|
-
|
53
|
-
GEN_FOLDER = File.join('addressbook', 'gen')
|
54
|
-
CLEAN.include('GEN_FOLDER')
|
55
|
-
|
56
|
-
directory GEN_FOLDER
|
57
|
-
['addressbook.pb.h', 'addressbook.pb.cc'].each do |f|
|
58
|
-
desc 'protoc addressbook.proto'
|
59
|
-
file File.join(GEN_FOLDER, 'addressbook', f) => [File.join('addressbook', 'addressbook.proto'), GEN_FOLDER, PROTOC] do
|
60
|
-
command = "#{PROTOC} --cpp_out=#{GEN_FOLDER} #{File.join('addressbook', 'addressbook.proto')}"
|
61
|
-
sh command
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
CxxProject2Rake.new(FileList['**/*project.rb'] , "build", "gcc", ".")
|
66
|
-
|
67
|
-
|
68
|
-
CLEAN.include('tmp')
|
69
|
-
CLEAN.include(PROTOBUF_BASE)
|
70
|
-
CLEAN.include(GEN_FOLDER)
|
@@ -1,24 +0,0 @@
|
|
1
|
-
package tutorial;
|
2
|
-
|
3
|
-
message Person {
|
4
|
-
required string name = 1;
|
5
|
-
required int32 id = 2;
|
6
|
-
optional string email = 3;
|
7
|
-
|
8
|
-
enum PhoneType {
|
9
|
-
MOBILE = 0;
|
10
|
-
HOME = 1;
|
11
|
-
WORK = 2;
|
12
|
-
}
|
13
|
-
|
14
|
-
message PhoneNumber {
|
15
|
-
required string number = 1;
|
16
|
-
optional PhoneType type = 2 [default = HOME];
|
17
|
-
}
|
18
|
-
|
19
|
-
repeated PhoneNumber phone = 4;
|
20
|
-
}
|
21
|
-
|
22
|
-
message AddressBook {
|
23
|
-
repeated Person person = 1;
|
24
|
-
}
|
@@ -1,67 +0,0 @@
|
|
1
|
-
#include <iostream>
|
2
|
-
#include <fstream>
|
3
|
-
#include <string>
|
4
|
-
#include "addressbook/addressbook.pb.h"
|
5
|
-
|
6
|
-
using namespace std;
|
7
|
-
|
8
|
-
// Iterates though all people in the AddressBook and prints info about them.
|
9
|
-
void ListPeople(const tutorial::AddressBook& address_book) {
|
10
|
-
for (int i = 0; i < address_book.person_size(); i++) {
|
11
|
-
const tutorial::Person& person = address_book.person(i);
|
12
|
-
|
13
|
-
cout << "Person ID: " << person.id() << endl;
|
14
|
-
cout << " Name: " << person.name() << endl;
|
15
|
-
if (person.has_email()) {
|
16
|
-
cout << " E-mail address: " << person.email() << endl;
|
17
|
-
}
|
18
|
-
|
19
|
-
for (int j = 0; j < person.phone_size(); j++) {
|
20
|
-
const tutorial::Person::PhoneNumber& phone_number = person.phone(j);
|
21
|
-
|
22
|
-
switch (phone_number.type()) {
|
23
|
-
case tutorial::Person::MOBILE:
|
24
|
-
cout << " Mobile phone #: ";
|
25
|
-
break;
|
26
|
-
case tutorial::Person::HOME:
|
27
|
-
cout << " Home phone #: ";
|
28
|
-
break;
|
29
|
-
case tutorial::Person::WORK:
|
30
|
-
cout << " Work phone #: ";
|
31
|
-
break;
|
32
|
-
}
|
33
|
-
cout << phone_number.number() << endl;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
// Main function: Reads the entire address book from a file and prints all
|
39
|
-
// the information inside.
|
40
|
-
int main(int argc, char* argv[]) {
|
41
|
-
// Verify that the version of the library that we linked against is
|
42
|
-
// compatible with the version of the headers we compiled against.
|
43
|
-
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
44
|
-
|
45
|
-
if (argc != 2) {
|
46
|
-
cerr << "Usage: " << argv[0] << " ADDRESS_BOOK_FILE" << endl;
|
47
|
-
return -1;
|
48
|
-
}
|
49
|
-
|
50
|
-
tutorial::AddressBook address_book;
|
51
|
-
|
52
|
-
{
|
53
|
-
// Read the existing address book.
|
54
|
-
fstream input(argv[1], ios::in | ios::binary);
|
55
|
-
if (!address_book.ParseFromIstream(&input)) {
|
56
|
-
cerr << "Failed to parse address book." << endl;
|
57
|
-
return -1;
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
ListPeople(address_book);
|
62
|
-
|
63
|
-
// Optional: Delete all global objects allocated by libprotobuf.
|
64
|
-
google::protobuf::ShutdownProtobufLibrary();
|
65
|
-
|
66
|
-
return 0;
|
67
|
-
}
|
@@ -1,93 +0,0 @@
|
|
1
|
-
#include <iostream>
|
2
|
-
#include <fstream>
|
3
|
-
#include <string>
|
4
|
-
#include "addressbook/addressbook.pb.h"
|
5
|
-
using namespace std;
|
6
|
-
|
7
|
-
// This function fills in a Person message based on user input.
|
8
|
-
void PromptForAddress(tutorial::Person* person) {
|
9
|
-
cout << "Enter person ID number: ";
|
10
|
-
int id;
|
11
|
-
cin >> id;
|
12
|
-
person->set_id(id);
|
13
|
-
cin.ignore(256, '\n');
|
14
|
-
|
15
|
-
cout << "Enter name: ";
|
16
|
-
getline(cin, *person->mutable_name());
|
17
|
-
|
18
|
-
cout << "Enter email address (blank for none): ";
|
19
|
-
string email;
|
20
|
-
getline(cin, email);
|
21
|
-
if (!email.empty()) {
|
22
|
-
person->set_email(email);
|
23
|
-
}
|
24
|
-
|
25
|
-
while (true) {
|
26
|
-
cout << "Enter a phone number (or leave blank to finish): ";
|
27
|
-
string number;
|
28
|
-
getline(cin, number);
|
29
|
-
if (number.empty()) {
|
30
|
-
break;
|
31
|
-
}
|
32
|
-
|
33
|
-
tutorial::Person::PhoneNumber* phone_number = person->add_phone();
|
34
|
-
phone_number->set_number(number);
|
35
|
-
|
36
|
-
cout << "Is this a mobile, home, or work phone? ";
|
37
|
-
string type;
|
38
|
-
getline(cin, type);
|
39
|
-
if (type == "mobile") {
|
40
|
-
phone_number->set_type(tutorial::Person::MOBILE);
|
41
|
-
} else if (type == "home") {
|
42
|
-
phone_number->set_type(tutorial::Person::HOME);
|
43
|
-
} else if (type == "work") {
|
44
|
-
phone_number->set_type(tutorial::Person::WORK);
|
45
|
-
} else {
|
46
|
-
cout << "Unknown phone type. Using default." << endl;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
// Main function: Reads the entire address book from a file,
|
52
|
-
// adds one person based on user input, then writes it back out to the same
|
53
|
-
// file.
|
54
|
-
int main(int argc, char* argv[]) {
|
55
|
-
// Verify that the version of the library that we linked against is
|
56
|
-
// compatible with the version of the headers we compiled against.
|
57
|
-
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
58
|
-
|
59
|
-
if (argc != 2) {
|
60
|
-
cerr << "Usage: " << argv[0] << " ADDRESS_BOOK_FILE" << endl;
|
61
|
-
return -1;
|
62
|
-
}
|
63
|
-
|
64
|
-
tutorial::AddressBook address_book;
|
65
|
-
|
66
|
-
{
|
67
|
-
// Read the existing address book.
|
68
|
-
fstream input(argv[1], ios::in | ios::binary);
|
69
|
-
if (!input) {
|
70
|
-
cout << argv[1] << ": File not found. Creating a new file." << endl;
|
71
|
-
} else if (!address_book.ParseFromIstream(&input)) {
|
72
|
-
cerr << "Failed to parse address book." << endl;
|
73
|
-
return -1;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
// Add an address.
|
78
|
-
PromptForAddress(address_book.add_person());
|
79
|
-
|
80
|
-
{
|
81
|
-
// Write the new address book back to disk.
|
82
|
-
fstream output(argv[1], ios::out | ios::trunc | ios::binary);
|
83
|
-
if (!address_book.SerializeToOstream(&output)) {
|
84
|
-
cerr << "Failed to write address book." << endl;
|
85
|
-
return -1;
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
// Optional: Delete all global objects allocated by libprotobuf.
|
90
|
-
google::protobuf::ShutdownProtobufLibrary();
|
91
|
-
|
92
|
-
return 0;
|
93
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
cxx_configuration do
|
2
|
-
|
3
|
-
source_lib 'addressbook_pb_api',
|
4
|
-
:sources => ['gen/addressbook/addressbook.pb.cc'],
|
5
|
-
:includes => ['gen'],
|
6
|
-
:dependencies => ['protobuf']
|
7
|
-
|
8
|
-
exe 'addressbook_write',
|
9
|
-
:sources => ['addressbook_write.cc'],
|
10
|
-
:dependencies => ['addressbook_pb_api']
|
11
|
-
|
12
|
-
exe 'addressbook_read',
|
13
|
-
:sources => ['addressbook_read.cc'],
|
14
|
-
:dependencies => ['addressbook_pb_api']
|
15
|
-
|
16
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
- google/protobuf/stubs/common.cc
|
2
|
-
- google/protobuf/stubs/once.cc
|
3
|
-
- google/protobuf/stubs/hash.h
|
4
|
-
- google/protobuf/stubs/map-util.h
|
5
|
-
- google/protobuf/stubs/stl_util-inl.h
|
6
|
-
- google/protobuf/extension_set.cc
|
7
|
-
- google/protobuf/generated_message_util.cc
|
8
|
-
- google/protobuf/message_lite.cc
|
9
|
-
- google/protobuf/repeated_field.cc
|
10
|
-
- google/protobuf/wire_format_lite.cc
|
11
|
-
- google/protobuf/io/coded_stream.cc
|
12
|
-
- google/protobuf/io/coded_stream_inl.h
|
13
|
-
- google/protobuf/io/zero_copy_stream.cc
|
14
|
-
- google/protobuf/io/zero_copy_stream_impl_lite.cc
|
15
|
-
- google/protobuf/stubs/strutil.cc
|
16
|
-
- google/protobuf/stubs/strutil.h
|
17
|
-
- google/protobuf/stubs/substitute.cc
|
18
|
-
- google/protobuf/stubs/substitute.h
|
19
|
-
- google/protobuf/stubs/structurally_valid.cc
|
20
|
-
- google/protobuf/descriptor.cc
|
21
|
-
- google/protobuf/descriptor.pb.cc
|
22
|
-
- google/protobuf/descriptor_database.cc
|
23
|
-
- google/protobuf/dynamic_message.cc
|
24
|
-
- google/protobuf/extension_set_heavy.cc
|
25
|
-
- google/protobuf/generated_message_reflection.cc
|
26
|
-
- google/protobuf/message.cc
|
27
|
-
- google/protobuf/reflection_ops.cc
|
28
|
-
- google/protobuf/service.cc
|
29
|
-
- google/protobuf/text_format.cc
|
30
|
-
- google/protobuf/unknown_field_set.cc
|
31
|
-
- google/protobuf/wire_format.cc
|
32
|
-
- google/protobuf/io/gzip_stream.cc
|
33
|
-
- google/protobuf/io/printer.cc
|
34
|
-
- google/protobuf/io/tokenizer.cc
|
35
|
-
- google/protobuf/io/zero_copy_stream_impl.cc
|
36
|
-
- google/protobuf/compiler/importer.cc
|
37
|
-
- google/protobuf/compiler/parser.cc
|
@@ -1,9 +0,0 @@
|
|
1
|
-
cxx_configuration do
|
2
|
-
deps = [BinaryLibrary.new('z'), BinaryLibrary.new('pthread')]
|
3
|
-
|
4
|
-
source_lib 'protobuf',
|
5
|
-
:sources => PROTOBUF_LITE_SOURCES.delete_if{ |i| i.index('.h') },
|
6
|
-
:includes => [File.join(PROTOBUF_BASE, 'src'), File.join(PROTOBUF_BASE, 'tmp')],
|
7
|
-
:dependencies => deps,
|
8
|
-
:file_dependencies => [PROTOBUF_CONFIG_H]
|
9
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
#include <cassert>
|
2
|
-
|
3
|
-
#include <cppunit/TestCase.h>
|
4
|
-
#include <cppunit/ui/text/TestRunner.h>
|
5
|
-
#include <cppunit/extensions/TestFactoryRegistry.h>
|
6
|
-
|
7
|
-
int main( int argc, char **argv) {
|
8
|
-
CppUnit::TextUi::TestRunner runner;
|
9
|
-
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
10
|
-
runner.addTest( registry.makeTest() );
|
11
|
-
bool wasSuccessful = runner.run( );
|
12
|
-
return wasSuccessful ? 0 : 1;
|
13
|
-
}
|