-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into node_electron_build
- Loading branch information
Showing
364 changed files
with
8,556 additions
and
5,416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
bind( | ||
name = "nanopb", | ||
actual = "//third_party/nanopb", | ||
) | ||
|
||
bind( | ||
name = "libssl", | ||
actual = "@submodule_boringssl//:ssl", | ||
) | ||
|
||
bind( | ||
name = "zlib", | ||
actual = "@submodule_zlib//:z", | ||
) | ||
|
||
bind( | ||
name = "protobuf", | ||
actual = "@submodule_protobuf//:protobuf", | ||
) | ||
|
||
bind( | ||
name = "protobuf_clib", | ||
actual = "@submodule_protobuf//:protoc_lib", | ||
) | ||
|
||
bind( | ||
name = "protocol_compiler", | ||
actual = "@submodule_protobuf//:protoc", | ||
) | ||
|
||
new_local_repository( | ||
name = "submodule_boringssl", | ||
path = "third_party/boringssl-with-bazel", | ||
build_file = "third_party/boringssl-with-bazel/BUILD", | ||
) | ||
|
||
new_local_repository( | ||
name = "submodule_zlib", | ||
path = "third_party/zlib", | ||
build_file = "third_party/zlib.BUILD", | ||
) | ||
|
||
new_local_repository( | ||
name = "submodule_protobuf", | ||
path = "third_party/protobuf", | ||
build_file = "third_party/protobuf/BUILD", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package(default_visibility = ["//:__subpackages__"]) | ||
|
||
load(":cc_grpc_library.bzl", "cc_grpc_library") | ||
|
||
cc_grpc_library( | ||
name = "well_known_protos", | ||
srcs = "@submodule_protobuf//:well_known_protos", | ||
proto_only = True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"""Generates and compiles C++ grpc stubs from proto_library rules.""" | ||
|
||
load("//:bazel/generate_cc.bzl", "generate_cc") | ||
|
||
def cc_grpc_library(name, srcs, deps, proto_only, **kwargs): | ||
"""Generates C++ grpc classes from a .proto file. | ||
Assumes the generated classes will be used in cc_api_version = 2. | ||
Arguments: | ||
name: name of rule. | ||
srcs: a single proto_library, which wraps the .proto files with services. | ||
deps: a list of C++ proto_library (or cc_proto_library) which provides | ||
the compiled code of any message that the services depend on. | ||
**kwargs: rest of arguments, e.g., compatible_with and visibility. | ||
""" | ||
if len(srcs) > 1: | ||
fail("Only one srcs value supported", "srcs") | ||
|
||
proto_target = "_" + name + "_only" | ||
codegen_target = "_" + name + "_codegen" | ||
codegen_grpc_target = "_" + name + "_grpc_codegen" | ||
proto_deps = ["_" + dep + "_only" for dep in deps if dep.find(':') == -1] | ||
proto_deps += [dep.split(':')[0] + ':' + "_" + dep.split(':')[1] + "_only" for dep in deps if dep.find(':') != -1] | ||
|
||
native.proto_library( | ||
name = proto_target, | ||
srcs = srcs, | ||
deps = proto_deps, | ||
**kwargs | ||
) | ||
|
||
generate_cc( | ||
name = codegen_target, | ||
srcs = [proto_target], | ||
**kwargs | ||
) | ||
|
||
if not proto_only: | ||
generate_cc( | ||
name = codegen_grpc_target, | ||
srcs = [proto_target], | ||
plugin = "//:grpc_cpp_plugin", | ||
**kwargs | ||
) | ||
|
||
if not proto_only: | ||
native.cc_library( | ||
name = name, | ||
srcs = [":" + codegen_grpc_target, ":" + codegen_target], | ||
hdrs = [":" + codegen_grpc_target, ":" + codegen_target], | ||
deps = deps + ["//:grpc++", "//:grpc++_codegen_proto", "//external:protobuf"], | ||
**kwargs | ||
) | ||
else: | ||
native.cc_library( | ||
name = name, | ||
srcs = [":" + codegen_target], | ||
hdrs = [":" + codegen_target], | ||
deps = deps + ["//external:protobuf"], | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Generates C++ grpc stubs from proto_library rules. | ||
This is an internal rule used by cc_grpc_library, and shouldn't be used | ||
directly. | ||
""" | ||
|
||
def generate_cc_impl(ctx): | ||
"""Implementation of the generate_cc rule.""" | ||
protos = [f for src in ctx.attr.srcs for f in src.proto.direct_sources] | ||
includes = [f for src in ctx.attr.srcs for f in src.proto.transitive_imports] | ||
outs = [] | ||
if ctx.executable.plugin: | ||
outs += [proto.basename[:-len(".proto")] + ".grpc.pb.h" for proto in protos] | ||
outs += [proto.basename[:-len(".proto")] + ".grpc.pb.cc" for proto in protos] | ||
else: | ||
outs += [proto.basename[:-len(".proto")] + ".pb.h" for proto in protos] | ||
outs += [proto.basename[:-len(".proto")] + ".pb.cc" for proto in protos] | ||
out_files = [ctx.new_file(out) for out in outs] | ||
# The following should be replaced with ctx.configuration.buildout | ||
# whenever this is added to Skylark. | ||
dir_out = out_files[0].dirname[:-len(protos[0].dirname)] | ||
|
||
arguments = [] | ||
if ctx.executable.plugin: | ||
arguments += ["--plugin=protoc-gen-PLUGIN=" + ctx.executable.plugin.path] | ||
arguments += ["--PLUGIN_out=" + ",".join(ctx.attr.flags) + ":" + dir_out] | ||
else: | ||
arguments += ["--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out] | ||
arguments += ["-I{0}={0}".format(include.path) for include in includes] | ||
arguments += [proto.path for proto in protos] | ||
|
||
ctx.action( | ||
inputs = protos + includes, | ||
outputs = out_files, | ||
executable = ctx.executable._protoc, | ||
arguments = arguments, | ||
) | ||
|
||
return struct(files=set(out_files)) | ||
|
||
generate_cc = rule( | ||
attrs = { | ||
"srcs": attr.label_list( | ||
mandatory = True, | ||
non_empty = True, | ||
providers = ["proto"], | ||
), | ||
"plugin": attr.label( | ||
executable = True, | ||
providers = ["files_to_run"], | ||
cfg = "host", | ||
), | ||
"flags": attr.string_list( | ||
mandatory = False, | ||
allow_empty = True, | ||
), | ||
"_protoc": attr.label( | ||
default = Label("//external:protocol_compiler"), | ||
executable = True, | ||
cfg = "host", | ||
), | ||
}, | ||
# We generate .h files, so we need to output to genfiles. | ||
output_to_genfiles = True, | ||
implementation = generate_cc_impl, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright 2016, Google Inc. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are | ||
# met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above | ||
# copyright notice, this list of conditions and the following disclaimer | ||
# in the documentation and/or other materials provided with the | ||
# distribution. | ||
# * Neither the name of Google Inc. nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# | ||
# This is for the gRPC build system. This isn't intended to be used outsite of | ||
# the BUILD file for gRPC. It contains the mapping for the template system we | ||
# use to generate other platform's build system files. | ||
# | ||
|
||
def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language = "C++"): | ||
copts = [] | ||
if language.upper() == "C": | ||
copts = ["-std=c99"] | ||
native.cc_library( | ||
name = name, | ||
srcs = srcs, | ||
hdrs = hdrs + public_hdrs, | ||
deps = deps + ["//external:" + dep for dep in external_deps], | ||
copts = copts, | ||
linkopts = ["-pthread"], | ||
includes = [ | ||
"include" | ||
] | ||
) | ||
|
||
def grpc_proto_plugin(name, srcs = [], deps = []): | ||
native.cc_binary( | ||
name = name, | ||
srcs = srcs, | ||
deps = deps, | ||
) | ||
|
||
load("//:bazel/cc_grpc_library.bzl", "cc_grpc_library") | ||
|
||
def grpc_proto_library(name, srcs = [], deps = [], well_known_deps = [], has_services = True): | ||
cc_grpc_library( | ||
name = name, | ||
srcs = srcs, | ||
deps = deps, | ||
proto_only = not has_services, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.