From 62a7e5cf010a01601f8af4ddbe142a570752d4ed Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Sun, 11 Dec 2016 11:16:13 -0800 Subject: [PATCH] Initialize Bazel WORKSPACE and a testing packages --- .gitignore | 3 +++ WORKSPACE | 8 ++++++++ third_party/protobuf_test/BUILD | 17 +++++++++++++++++ third_party/protobuf_test/README.md | 1 + third_party/protobuf_test/example.proto | 7 +++++++ third_party/protobuf_test/example_lib.cc | 6 ++++++ third_party/protobuf_test/example_lib.h | 7 +++++++ 7 files changed, 49 insertions(+) create mode 100644 WORKSPACE create mode 100644 third_party/protobuf_test/BUILD create mode 100644 third_party/protobuf_test/README.md create mode 100644 third_party/protobuf_test/example.proto create mode 100644 third_party/protobuf_test/example_lib.cc create mode 100644 third_party/protobuf_test/example_lib.h diff --git a/.gitignore b/.gitignore index 35bed0accda..1c9730a5ad5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ build/ .pydevproject Makefile .test_env/ + +*~ +bazel-* diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 00000000000..06495690ab9 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,8 @@ +git_repository( + name = "org_pubref_rules_protobuf", + remote = "https://github.com/pubref/rules_protobuf", + tag = "v0.7.1", +) + +load("@org_pubref_rules_protobuf//cpp:rules.bzl", "cpp_proto_repositories") +cpp_proto_repositories() diff --git a/third_party/protobuf_test/BUILD b/third_party/protobuf_test/BUILD new file mode 100644 index 00000000000..7c5b1c69947 --- /dev/null +++ b/third_party/protobuf_test/BUILD @@ -0,0 +1,17 @@ +licenses(["notice"]) # Apache 2.0 + +load("@org_pubref_rules_protobuf//cpp:rules.bzl", "cpp_proto_library") + +cpp_proto_library( + name = "example_proto", + protos = [ + "example.proto" + ], +) + +cc_library( + name = "example_lib", + srcs = ["example_lib.cc"], + hdrs = ["example_lib.h"], + deps = [":example_proto"], +) diff --git a/third_party/protobuf_test/README.md b/third_party/protobuf_test/README.md new file mode 100644 index 00000000000..e8bdeee6fee --- /dev/null +++ b/third_party/protobuf_test/README.md @@ -0,0 +1 @@ +This package tests that Bazel can build protobuf related rules. diff --git a/third_party/protobuf_test/example.proto b/third_party/protobuf_test/example.proto new file mode 100644 index 00000000000..57c52d3521f --- /dev/null +++ b/third_party/protobuf_test/example.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +package protos; + +message Greeting { + string name = 1; +} diff --git a/third_party/protobuf_test/example_lib.cc b/third_party/protobuf_test/example_lib.cc new file mode 100644 index 00000000000..8d55ed66dea --- /dev/null +++ b/third_party/protobuf_test/example_lib.cc @@ -0,0 +1,6 @@ +#include "third_party/protobuf_test/example_lib.h" +#include + +std::string get_greet(const ::protos::Greeting& who) { + return "Hello " + who.name(); +} diff --git a/third_party/protobuf_test/example_lib.h b/third_party/protobuf_test/example_lib.h new file mode 100644 index 00000000000..eaf4dd4cea7 --- /dev/null +++ b/third_party/protobuf_test/example_lib.h @@ -0,0 +1,7 @@ +#pragma once + +#include "third_party/protobuf_test/example.pb.h" + +#include + +std::string get_greet(const ::protos::Greeting &who); -- GitLab