patching external dependencies

156 views
Skip to first unread message

Niah Son

unread,
Apr 22, 2021, 3:42:37 PM4/22/21
to bazel-discuss
Hi, sending good energy.

Sorry if this is already answered, I am very new to bazel.

I am currently working on porting https://github.com/envoyproxy/envoy-openssl to OpenSSL3.  My question today is "what is the best/easiest way to apply a patch to an external dependency".  In this case here are the relevant bazel config.

file: envoy/bazel/repository_locations.bzl
...
    com_github_grpc_grpc = dict(
        # TODO(JimmyCYJ): Bump to release 1.27
        # This sha on grpc:v1.25.x branch is specifically chosen to fix gRPC STS call credential options.
        sha256 = "bbc8f020f4e85ec029b047fab939b8c81f3d67254b5c724e1003a2bc49ddd123",
        strip_prefix = "grpc-d8f4928fa779f6005a7fe55a176bdb373b0f910f",
        # 2020-02-11
        urls = ["https://github.com/grpc/grpc/archive/d8f4928fa779f6005a7fe55a176bdb373b0f910f.tar.gz"],
        use_category = ["dataplane", "controlplane"],
        cpe = "cpe:2.3:a:grpc:grpc:*",
    ),
...

Then I tried the following change in
file: envoy/bazel/repositories.bzl
...
 def _com_github_grpc_grpc():
-    _repository_impl("com_github_grpc_grpc")
+    _repository_impl(
+        "com_github_grpc_grpc",
+        patches = ["@envoy//bazel/external:grpc_openssl_3.patch"],
+        patch_args = ["-p1"],
+    )
     _repository_impl("build_bazel_rules_apple")
 
     # Rebind some stuff to match what the gRPC Bazel is expecting.
@@ -771,7 +775,11 @@ def _upb():
     )
 
...

Bazel seem to apply my patch (grpc_openssl_3.patch) but fails with the following error.  Any help is welcomed.

bazel build  --verbose_failures=true --explain=bazel-build.log  --verbose_explanations=true -c dbg  //:envoy
Starting local Bazel server and connecting to it...
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
INFO: Repository com_github_grpc_grpc instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule http_archive defined at:
  /home/andrew/.cache/bazel/_bazel_niah/0c54b3404404ff4e054b013c8291a649/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
INFO: Repository 'com_github_grpc_grpc' used the following cache hits instead of downloading the corresponding file.
 * Hash 'bbc8f020f4e85ec029b047fab939b8c81f3d67254b5c724e1003a2bc49ddd123' for https://github.com/grpc/grpc/archive/d8f4928fa779f6005a7fe55a176bdb373b0f910f.tar.gz
If the definition of 'com_github_grpc_grpc' was updated, verify that the hashes were also updated.
ERROR: An error occurred during the fetch of repository 'com_github_grpc_grpc':
   Traceback (most recent call last):


Reply all
Reply to author
Forward
0 new messages