Skip to content

Commit

Permalink
Merge pull request #209 from stanley-cheung/bazel-and-tests
Browse files Browse the repository at this point in the history
Add bazel integration and tests
  • Loading branch information
stanley-cheung authored Jul 27, 2018
2 parents 448007f + 20c07fe commit a28cbe0
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 14 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/bazel-*
bazel-bin
bazel-genfiles
bazel-grpc-web
bazel-out
bazel-testlogs
9 changes: 0 additions & 9 deletions BUILD

This file was deleted.

14 changes: 11 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
workspace(name = "com_github_grpc_grpc_web")

http_archive(
name = "com_google_protobuf",
url = "https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-cpp-3.5.1.zip",
strip_prefix = "protobuf-3.5.1",
name = "io_bazel_rules_closure",
sha256 = "a80acb69c63d5f6437b099c111480a4493bad4592015af2127a2f49fb7512d8d",
strip_prefix = "rules_closure-0.7.0",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.7.0.tar.gz",
"https://github.com/bazelbuild/rules_closure/archive/0.7.0.tar.gz",
],
)

load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories")

closure_repositories()
151 changes: 151 additions & 0 deletions javascript/net/grpc/web/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package(default_visibility = ["//visibility:public"])

load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_test")

cc_binary(
name = "protoc-gen-grpc-web",
srcs = [
"grpc_generator.cc",
],
deps = [
"@com_google_protobuf//:protoc_lib"
],
)

closure_js_library(
name = "abstractclientbase",
srcs = [
"abstractclientbase.js",
],
deps = [
":clientreadablestream",
":error",
],
)

closure_js_library(
name = "clientreadablestream",
srcs = [
"clientreadablestream.js",
],
)

closure_js_library(
name = "error",
srcs = [
"error.js",
],
)

closure_js_library(
name = "generictransportinterface",
srcs = [
"generictransportinterface.js",
],
deps = [
"@io_bazel_rules_closure//closure/library/net/streams:nodereadablestream",
"@io_bazel_rules_closure//closure/library/net:xhrio",
],
)

closure_js_library(
name = "grpcwebclientbase",
srcs = [
"grpcwebclientbase.js",
],
suppress = [
"checkTypes",
"reportUnknownTypes",
],
deps = [
":abstractclientbase",
":grpcwebclientreadablestream",
":statuscode",
"@io_bazel_rules_closure//closure/library/crypt:base64",
"@io_bazel_rules_closure//closure/library/net:xhrio",
"@io_bazel_rules_closure//closure/library/net/rpc:httpcors",
],
)

closure_js_library(
name = "grpcwebclientreadablestream",
srcs = [
"grpcwebclientreadablestream.js",
],
deps = [
":clientreadablestream",
":generictransportinterface",
":grpcwebstreamparser",
":status",
":statuscode",
"@io_bazel_rules_closure//closure/library/crypt:base64",
"@io_bazel_rules_closure//closure/library/events:events",
"@io_bazel_rules_closure//closure/library/net:errorcode",
"@io_bazel_rules_closure//closure/library/net:eventtype",
"@io_bazel_rules_closure//closure/library/net:xhrio",
"@io_bazel_rules_closure//closure/library/net:xmlhttp",
],
suppress = [
"reportUnknownTypes",
],
)

closure_js_library(
name = "grpcwebstreamparser",
srcs = [
"grpcwebstreamparser.js",
],
suppress = [
"reportUnknownTypes",
],
deps = [
"@io_bazel_rules_closure//closure/library/asserts",
"@io_bazel_rules_closure//closure/library/net/streams:streamparser",
],
)

closure_js_library(
name = "status",
srcs = [
"status.js",
],
)

closure_js_library(
name = "statuscode",
srcs = [
"statuscode.js",
],
)

closure_js_test(
name = "grpcwebclientbase_test",
srcs = [
"grpcwebclientbase_test.js",
],
entry_points = [
"goog:grpc.web.GrpcWebClientBaseTest",
],
deps = [
"@io_bazel_rules_closure//closure/library:testing",
],
)

closure_js_test(
name = "grpcwebstreamparser_test",
srcs = [
"grpcwebstreamparser_test.js",
],
entry_points = [
"goog:grpc.web.GrpcWebStreamParserTest",
],
suppress = [
"reportUnknownTypes",
],
deps = [
":grpcwebstreamparser",
"@io_bazel_rules_closure//closure/library:testing",
],
)
3 changes: 2 additions & 1 deletion javascript/net/grpc/web/grpc_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ string GetModeVar(const Mode mode) {
case GRPCWEB:
return "GrpcWeb";
}
return "";
}

string GetDeserializeMethodName(const string& mode_var) {
Expand Down Expand Up @@ -289,7 +290,7 @@ class GrpcCodeGenerator : public CodeGenerator {

string file_name;
string mode;
for (int i = 0; i < options.size(); ++i) {
for (uint i = 0; i < options.size(); ++i) {
if (options[i].first == "out") {
file_name = options[i].second;
} else if (options[i].first == "mode") {
Expand Down
35 changes: 35 additions & 0 deletions javascript/net/grpc/web/grpcwebclientbase_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
goog.module('grpc.web.GrpcWebClientBaseTest');
goog.setTestOnly('grpc.web.GrpcWebClientBaseTest');

var testSuite = goog.require('goog.testing.testSuite');
goog.require('goog.testing.jsunit');

testSuite({
setUp: function() {
},

tearDown: function() {
},


testTrivial: function() {
assertEquals(1, 1);
},
});
Loading

0 comments on commit a28cbe0

Please sign in to comment.