Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bazel rule closure_grpc_web_library #219

Merged
merged 1 commit into from
Aug 6, 2018

Conversation

Yannic
Copy link
Contributor

@Yannic Yannic commented Aug 4, 2018

No description provided.

@stanley-cheung
Copy link
Collaborator

Wow, this is great! Thanks for the contribution! I will take a closer look shortly. Will let test run first.

ctx.attr._grpc_web_clientreadablestream,
ctx.attr._grpc_web_error,
ctx.attr._grpc_web_grpcwebclientbase
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why only these 4 classes? Why not Status and StatusCode etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only need to add the directly goog.required classes to deps, Status, StatusCode, etc are included as transitive deps by those 4 classes.
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpc_generator.cc#L409
(Only mode GrpcWeb seems to be open source).

),
"_grpc_web_grpcwebclientbase": attr.label(
default = Label("//javascript/net/grpc/web:grpcwebclientbase"),
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, why just these 4 classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

sha256 = "a80acb69c63d5f6437b099c111480a4493bad4592015af2127a2f49fb7512d8d",
strip_prefix = "rules_closure-0.7.0",
sha256 = "248a7a98eb3962d9f0013e543ea79c5063a83bac7af349ebf412d844e6ab3035",
strip_prefix = "rules_closure-53f2cab21fa6c608f32f114387d88ffd7868c5fc",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this particular commit? Something new available after 0.7.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit includes bazelbuild/rules_closure#278, which is required for this because closure_proto_aspect, which we need to generate the normal proto js files, is not exposed by rules_closure (Everything which starts with _ is private in bazel).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can only merge this PR after bazelbuild/rules_closure#278 got merged right?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically you can merge this, you'll just be dependent on a commit that's not in rules_closure's master branch (until it gets merged, that is).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's exactly like @oferb said, there is no technical reason to block this until the other PR is merged.

ctx.attr._grpc_web_clientreadablestream,
ctx.attr._grpc_web_error,
ctx.attr._grpc_web_grpcwebclientbase
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only need to add the directly goog.required classes to deps, Status, StatusCode, etc are included as transitive deps by those 4 classes.
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpc_generator.cc#L409
(Only mode GrpcWeb seems to be open source).

),
"_grpc_web_grpcwebclientbase": attr.label(
default = Label("//javascript/net/grpc/web:grpcwebclientbase"),
),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

sha256 = "a80acb69c63d5f6437b099c111480a4493bad4592015af2127a2f49fb7512d8d",
strip_prefix = "rules_closure-0.7.0",
sha256 = "248a7a98eb3962d9f0013e543ea79c5063a83bac7af349ebf412d844e6ab3035",
strip_prefix = "rules_closure-53f2cab21fa6c608f32f114387d88ffd7868c5fc",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit includes bazelbuild/rules_closure#278, which is required for this because closure_proto_aspect, which we need to generate the normal proto js files, is not exposed by rules_closure (Everything which starts with _ is private in bazel).

),
'import_style': attr.string(
default = 'closure',
values = ['closure', 'commonjs'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd like to remove commonjs as a possible value for now. Most of rules_closure doesn't work with commonjs anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it because the output of this rule is expected to mostly feed into other closure_js_library rule, which expects goog.require() style includes anyways?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restriction to goog.require() is required because closure_proto_{aspect,library} (which generates the protobuf messages for us to avoid duplicate provide errors) does not support commonjs import style (yet). I will create a follow-up PR once this is fixed in rules_closure (Maybe we can create an issue for this and assign it to me).

@stanley-cheung
Copy link
Collaborator

stanley-cheung commented Aug 5, 2018

I just want to confirm the goal of this:

  1. The output of this closure_grpc_web_library rule should be able to feed into other rules, like a closure_js_library.
  2. We should see the <proto>.grpc.js output in the bazel-bin directory somewhere?

@@ -25,6 +25,7 @@ docker build -t grpc-web:ubuntu_16_04 \
docker-compose build

bazel test javascript/net/grpc/web/...
bazel test net/grpc/gateway/examples/...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this needs to be bazel build for now, instead of bazel test. Since there's no test target for now, the exit status of this command is 4, which invalidates the whole kokoro run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Yannic
Copy link
Contributor Author

Yannic commented Aug 5, 2018

  1. The output of this closure_grpc_web_library rule should be able to feed into other rules, like a closure_js_library.

Exactly. closure_grpc_web_library can be used, and is only really useful, as a dependency of closure_js_{*}.

  1. We should see the .grpc.js output in the bazel-bin directory somewhere?

Well, the <proto>.grpc.js output may only be created if another target depends on it to reduce build time. This is similar to rules in rules_closure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants