ADD: added new version of protobuf
This commit is contained in:
@@ -1 +0,0 @@
|
||||
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
|
||||
@@ -1,4 +1,4 @@
|
||||
// See README.md for information and build instructions.
|
||||
// See README.txt for information and build instructions.
|
||||
|
||||
import com.example.tutorial.protos.AddressBook;
|
||||
import com.example.tutorial.protos.Person;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// See README.md for information and build instructions.
|
||||
// See README.txt for information and build instructions.
|
||||
|
||||
import com.example.tutorial.protos.AddressBook;
|
||||
import com.example.tutorial.protos.Person;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# See README.md.
|
||||
# See README.txt.
|
||||
|
||||
.PHONY: all cpp java python clean
|
||||
|
||||
@@ -13,14 +13,13 @@ python: add_person_python list_people_python
|
||||
|
||||
clean:
|
||||
rm -f add_person_cpp list_people_cpp add_person_java list_people_java add_person_python list_people_python
|
||||
rm -f javac_middleman AddPerson*.class ListPeople*.class com/example/tutorial/protos/*.class
|
||||
rm -f protoc_middleman addressbook.pb.cc addressbook.pb.h addressbook_pb2.py com/example/tutorial/protos/*.java
|
||||
rm -f javac_middleman AddPerson*.class ListPeople*.class com/example/tutorial/*.class
|
||||
rm -f protoc_middleman addressbook.pb.cc addressbook.pb.h addressbook_pb2.py com/example/tutorial/AddressBookProtos.java
|
||||
rm -f *.pyc
|
||||
rm -f go/tutorialpb/*.pb.go add_person_go list_people_go
|
||||
rm -f protoc_middleman_dart dart_tutorial/*.pb*.dart
|
||||
rmdir dart_tutorial 2>/dev/null || true
|
||||
rmdir tutorial 2>/dev/null || true
|
||||
rmdir com/example/tutorial/protos 2>/dev/null || true
|
||||
rmdir com/example/tutorial 2>/dev/null || true
|
||||
rmdir com/example 2>/dev/null || true
|
||||
rmdir com 2>/dev/null || true
|
||||
@@ -41,11 +40,11 @@ protoc_middleman_dart: addressbook.proto
|
||||
|
||||
add_person_cpp: add_person.cc protoc_middleman
|
||||
pkg-config --cflags protobuf # fails if protobuf is not installed
|
||||
c++ -std=c++14 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
|
||||
c++ -std=c++11 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
|
||||
|
||||
list_people_cpp: list_people.cc protoc_middleman
|
||||
pkg-config --cflags protobuf # fails if protobuf is not installed
|
||||
c++ -std=c++14 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
|
||||
c++ -std=c++11 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
|
||||
|
||||
add_person_dart: add_person.dart protoc_middleman_dart
|
||||
|
||||
@@ -64,7 +63,7 @@ list_people_gotest: go/tutorialpb/addressbook.pb.go
|
||||
cd go && go test ./cmd/list_people
|
||||
|
||||
javac_middleman: AddPerson.java ListPeople.java protoc_middleman
|
||||
javac -cp $$CLASSPATH AddPerson.java ListPeople.java com/example/tutorial/protos/*.java
|
||||
javac -cp $$CLASSPATH AddPerson.java ListPeople.java com/example/tutorial/AddressBookProtos.java
|
||||
@touch javac_middleman
|
||||
|
||||
add_person_java: javac_middleman
|
||||
|
||||
@@ -28,7 +28,7 @@ Then you can run the built binary:
|
||||
$ bazel-bin/add_person_cpp addressbook.data
|
||||
|
||||
To use protobuf in your own bazel project, please follow instructions in the
|
||||
[BUILD.bazel](BUILD.bazel) file and [WORKSPACE](WORKSPACE) file.
|
||||
[BUILD](BUILD) file and [WORKSPACE](WORKSPACE) file.
|
||||
|
||||
## Build the example using make
|
||||
|
||||
@@ -37,14 +37,14 @@ minimum requirement is to install protocol compiler (i.e., the protoc binary)
|
||||
and the protobuf runtime for the language you want to build.
|
||||
|
||||
You can simply run "make" to build the example for all languages (except for
|
||||
Go). However, since different languages have different installation requirements,
|
||||
Go). However, since different language has different installation requirement,
|
||||
it will likely fail. It's better to follow individual instructions below to
|
||||
build only the language you are interested in.
|
||||
|
||||
### C++
|
||||
|
||||
You can follow instructions in [../src/README.md](../src/README.md) to install
|
||||
protoc from source.
|
||||
protoc and protobuf C++ runtime from source.
|
||||
|
||||
Then run "make cpp" in this examples directory to build the C++ example. It
|
||||
will create two executables: add_person_cpp and list_people_cpp. These programs
|
||||
|
||||
@@ -10,11 +10,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
#
|
||||
# http_archive(
|
||||
# name = "com_google_protobuf",
|
||||
# sha256 = "c29d8b4b79389463c546f98b15aa4391d4ed7ec459340c47bffe15db63eb9126",
|
||||
# strip_prefix = "protobuf-3.21.3",
|
||||
# urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.3.tar.gz"],
|
||||
# strip_prefix = "protobuf-main",
|
||||
# urls = ["https://github.com/protocolbuffers/protobuf/archive/main.zip"],
|
||||
# )
|
||||
|
||||
local_repository(
|
||||
name = "com_google_protobuf",
|
||||
path = "..",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// See README.md for information and build instructions.
|
||||
// See README.txt for information and build instructions.
|
||||
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
# See README.md for information and build instructions.
|
||||
# See README.txt for information and build instructions.
|
||||
|
||||
import addressbook_pb2
|
||||
import sys
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// See README.md for information and build instructions.
|
||||
// See README.txt for information and build instructions.
|
||||
//
|
||||
// Note: START and END tags are used in comments to define sections used in
|
||||
// tutorials. They are not part of the syntax for Protocol Buffers.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// See README.md for information and build instructions.
|
||||
// See README.txt for information and build instructions.
|
||||
|
||||
#include <fstream>
|
||||
#include <google/protobuf/util/time_util.h>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
# See README.md for information and build instructions.
|
||||
# See README.txt for information and build instructions.
|
||||
|
||||
from __future__ import print_function
|
||||
import addressbook_pb2
|
||||
|
||||
Reference in New Issue
Block a user