Source release 16.4.0
This commit is contained in:
4
third_party/protobuf/examples/BUILD
vendored
4
third_party/protobuf/examples/BUILD
vendored
@@ -4,6 +4,10 @@
|
||||
# the WORKSPACE file in the same directory with this BUILD file for an
|
||||
# example.
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library")
|
||||
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
|
||||
# For each .proto file, a proto_library target should be defined. This target
|
||||
# is not bound to any particular language. Instead, it defines the dependency
|
||||
# graph of the .proto files (i.e., proto imports) and serves as the provider
|
||||
|
||||
4
third_party/protobuf/examples/README.md
vendored
4
third_party/protobuf/examples/README.md
vendored
@@ -38,7 +38,7 @@ 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 language has different installation requirement,
|
||||
it will likely fail. It's better to follow individual instrutions below to
|
||||
it will likely fail. It's better to follow individual instructions below to
|
||||
build only the language you are interested in.
|
||||
|
||||
### C++
|
||||
@@ -135,7 +135,7 @@ Build the Dart samples in this directory with `make dart`.
|
||||
To run the examples:
|
||||
|
||||
```sh
|
||||
$ dart add_person.dart addessbook.data
|
||||
$ dart add_person.dart addressbook.data
|
||||
$ dart list_people.dart addressbook.data
|
||||
```
|
||||
|
||||
|
||||
53
third_party/protobuf/examples/WORKSPACE
vendored
53
third_party/protobuf/examples/WORKSPACE
vendored
@@ -1,50 +1,31 @@
|
||||
workspace(name = "com_google_protobuf_examples")
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
# This com_google_protobuf repository is required for proto_library rule.
|
||||
# It provides the protocol compiler binary (i.e., protoc).
|
||||
http_archive(
|
||||
#
|
||||
# We declare it as local_repository so we can test changes
|
||||
# before they get merged. You'll want to use the following instead:
|
||||
#
|
||||
# http_archive(
|
||||
# name = "com_google_protobuf",
|
||||
# strip_prefix = "protobuf-master",
|
||||
# urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
|
||||
# )
|
||||
local_repository(
|
||||
name = "com_google_protobuf",
|
||||
strip_prefix = "protobuf-master",
|
||||
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
|
||||
path = "..",
|
||||
)
|
||||
|
||||
# This com_google_protobuf_cc repository is required for cc_proto_library
|
||||
# rule. It provides protobuf C++ runtime. Note that it actually is the same
|
||||
# repo as com_google_protobuf but has to be given a different name as
|
||||
# required by bazel.
|
||||
http_archive(
|
||||
name = "com_google_protobuf_cc",
|
||||
strip_prefix = "protobuf-master",
|
||||
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
|
||||
)
|
||||
|
||||
# Similar to com_google_protobuf_cc but for Java (i.e., java_proto_library).
|
||||
http_archive(
|
||||
name = "com_google_protobuf_java",
|
||||
strip_prefix = "protobuf-master",
|
||||
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
|
||||
)
|
||||
|
||||
# Similar to com_google_protobuf_cc but for Java lite. If you are building
|
||||
# for Android, the lite version should be prefered because it has a much
|
||||
# Similar to com_google_protobuf but for Java lite. If you are building
|
||||
# for Android, the lite version should be preferred because it has a much
|
||||
# smaller code size.
|
||||
http_archive(
|
||||
local_repository(
|
||||
name = "com_google_protobuf_javalite",
|
||||
strip_prefix = "protobuf-javalite",
|
||||
urls = ["https://github.com/protocolbuffers/protobuf/archive/javalite.zip"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "bazel_skylib",
|
||||
sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
|
||||
strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
|
||||
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
|
||||
path = "..",
|
||||
)
|
||||
|
||||
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
|
||||
|
||||
protobuf_deps()
|
||||
|
||||
load("@bazel_skylib//lib:versions.bzl", "versions")
|
||||
|
||||
versions.check(minimum_bazel_version = "0.5.4")
|
||||
|
||||
27
third_party/protobuf/examples/add_person.dart
vendored
27
third_party/protobuf/examples/add_person.dart
vendored
@@ -2,34 +2,31 @@ import 'dart:io';
|
||||
|
||||
import 'dart_tutorial/addressbook.pb.dart';
|
||||
|
||||
// This function fills in a Person message based on user input.
|
||||
/// This function fills in a Person message based on user input.
|
||||
Person promptForAddress() {
|
||||
Person person = Person();
|
||||
final person = Person();
|
||||
|
||||
print('Enter person ID: ');
|
||||
String input = stdin.readLineSync();
|
||||
final input = stdin.readLineSync();
|
||||
person.id = int.parse(input);
|
||||
|
||||
print('Enter name');
|
||||
person.name = stdin.readLineSync();
|
||||
|
||||
print('Enter email address (blank for none) : ');
|
||||
String email = stdin.readLineSync();
|
||||
if (email.isNotEmpty) {
|
||||
person.email = email;
|
||||
}
|
||||
final email = stdin.readLineSync();
|
||||
if (email.isNotEmpty) person.email = email;
|
||||
|
||||
while (true) {
|
||||
print('Enter a phone number (or leave blank to finish): ');
|
||||
String number = stdin.readLineSync();
|
||||
final number = stdin.readLineSync();
|
||||
if (number.isEmpty) break;
|
||||
|
||||
Person_PhoneNumber phoneNumber = Person_PhoneNumber();
|
||||
final phoneNumber = Person_PhoneNumber()..number = number;
|
||||
|
||||
phoneNumber.number = number;
|
||||
print('Is this a mobile, home, or work phone? ');
|
||||
|
||||
String type = stdin.readLineSync();
|
||||
final type = stdin.readLineSync();
|
||||
switch (type) {
|
||||
case 'mobile':
|
||||
phoneNumber.type = Person_PhoneType.MOBILE;
|
||||
@@ -49,15 +46,15 @@ Person promptForAddress() {
|
||||
return person;
|
||||
}
|
||||
|
||||
// Reads the entire address book from a file, adds one person based
|
||||
// on user input, then writes it back out to the same file.
|
||||
main(List<String> arguments) {
|
||||
/// Reads the entire address book from a file, adds one person based
|
||||
/// on user input, then writes it back out to the same file.
|
||||
void main(List<String> arguments) {
|
||||
if (arguments.length != 1) {
|
||||
print('Usage: add_person ADDRESS_BOOK_FILE');
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
File file = File(arguments.first);
|
||||
final file = File(arguments.first);
|
||||
AddressBook addressBook;
|
||||
if (!file.existsSync()) {
|
||||
print('File not found. Creating new file.');
|
||||
|
||||
16
third_party/protobuf/examples/list_people.dart
vendored
16
third_party/protobuf/examples/list_people.dart
vendored
@@ -3,16 +3,16 @@ import 'dart:io';
|
||||
import 'dart_tutorial/addressbook.pb.dart';
|
||||
import 'dart_tutorial/addressbook.pbenum.dart';
|
||||
|
||||
// Iterates though all people in the AddressBook and prints info about them.
|
||||
/// Iterates though all people in the AddressBook and prints info about them.
|
||||
void printAddressBook(AddressBook addressBook) {
|
||||
for (Person person in addressBook.people) {
|
||||
for (var person in addressBook.people) {
|
||||
print('Person ID: ${person.id}');
|
||||
print(' Name: ${person.name}');
|
||||
if (person.hasEmail()) {
|
||||
print(' E-mail address:${person.email}');
|
||||
}
|
||||
|
||||
for (Person_PhoneNumber phoneNumber in person.phones) {
|
||||
for (var phoneNumber in person.phones) {
|
||||
switch (phoneNumber.type) {
|
||||
case Person_PhoneType.MOBILE:
|
||||
print(' Mobile phone #: ');
|
||||
@@ -32,16 +32,16 @@ void printAddressBook(AddressBook addressBook) {
|
||||
}
|
||||
}
|
||||
|
||||
// Reads the entire address book from a file and prints all
|
||||
// the information inside.
|
||||
main(List<String> arguments) {
|
||||
/// Reads the entire address book from a file and prints all
|
||||
/// the information inside.
|
||||
void main(List<String> arguments) {
|
||||
if (arguments.length != 1) {
|
||||
print('Usage: list_person ADDRESS_BOOK_FILE');
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Read the existing address book.
|
||||
File file = new File(arguments.first);
|
||||
AddressBook addressBook = new AddressBook.fromBuffer(file.readAsBytesSync());
|
||||
final file = new File(arguments.first);
|
||||
final addressBook = new AddressBook.fromBuffer(file.readAsBytesSync());
|
||||
printAddressBook(addressBook);
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"]) # BSD/MIT-like license (for zlib)
|
||||
|
||||
_ZLIB_HEADERS = [
|
||||
"crc32.h",
|
||||
"deflate.h",
|
||||
"gzguts.h",
|
||||
"inffast.h",
|
||||
"inffixed.h",
|
||||
"inflate.h",
|
||||
"inftrees.h",
|
||||
"trees.h",
|
||||
"zconf.h",
|
||||
"zlib.h",
|
||||
"zutil.h",
|
||||
]
|
||||
|
||||
_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
|
||||
|
||||
# In order to limit the damage from the `includes` propagation
|
||||
# via `:zlib`, copy the public headers to a subdirectory and
|
||||
# expose those.
|
||||
genrule(
|
||||
name = "copy_public_headers",
|
||||
srcs = _ZLIB_HEADERS,
|
||||
outs = _ZLIB_PREFIXED_HEADERS,
|
||||
cmd = "cp $(SRCS) $(@D)/zlib/include/",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "zlib",
|
||||
srcs = [
|
||||
"adler32.c",
|
||||
"compress.c",
|
||||
"crc32.c",
|
||||
"deflate.c",
|
||||
"gzclose.c",
|
||||
"gzlib.c",
|
||||
"gzread.c",
|
||||
"gzwrite.c",
|
||||
"infback.c",
|
||||
"inffast.c",
|
||||
"inflate.c",
|
||||
"inftrees.c",
|
||||
"trees.c",
|
||||
"uncompr.c",
|
||||
"zutil.c",
|
||||
# Include the un-prefixed headers in srcs to work
|
||||
# around the fact that zlib isn't consistent in its
|
||||
# choice of <> or "" delimiter when including itself.
|
||||
] + _ZLIB_HEADERS,
|
||||
hdrs = _ZLIB_PREFIXED_HEADERS,
|
||||
copts = [
|
||||
"-Wno-unused-variable",
|
||||
"-Wno-implicit-function-declaration",
|
||||
],
|
||||
includes = ["zlib/include/"],
|
||||
)
|
||||
Reference in New Issue
Block a user