grpc-cython-copts.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. diff --git bazel/cython_library.bzl bazel/cython_library.bzl
  2. --- bazel/cython_library.bzl
  3. +++ bazel/cython_library.bzl
  4. @@ -10,15 +10,16 @@
  5. -def pyx_library(name, deps = [], py_deps = [], srcs = [], **kwargs):
  6. +def pyx_library(name, deps = [], cc_kwargs = {}, py_deps = [], srcs = [], **kwargs):
  7. """Compiles a group of .pyx / .pxd / .py files.
  8. First runs Cython to create .cpp files for each input .pyx or .py + .pxd
  9. - pair. Then builds a shared object for each, passing "deps" to each cc_binary
  10. - rule (includes Python headers by default). Finally, creates a py_library rule
  11. - with the shared objects and any pure Python "srcs", with py_deps as its
  12. - dependencies; the shared objects can be imported like normal Python files.
  13. + pair. Then builds a shared object for each, passing "deps" and `**cc_kwargs`
  14. + to each cc_binary rule (includes Python headers by default). Finally, creates
  15. + a py_library rule with the shared objects and any pure Python "srcs", with py_deps
  16. + as its dependencies; the shared objects can be imported like normal Python files.
  17. Args:
  18. name: Name for the rule.
  19. deps: C/C++ dependencies of the Cython (e.g. Numpy headers).
  20. + cc_kwargs: cc_binary extra arguments such as copts, linkstatic, linkopts, features
  21. @@ -57,7 +59,8 @@ def pyx_library(name, deps = [], py_deps = [], srcs = [], **kwargs):
  22. - shared_object_name = stem + ".so"
  23. + shared_object_name = stem + ".so"
  24. native.cc_binary(
  25. - name = shared_object_name,
  26. + name = cc_kwargs.pop("name", shared_object_name),
  27. - srcs = [stem + ".cpp"],
  28. + srcs = [stem + ".cpp"] + cc_kwargs.pop("srcs", []),
  29. - deps = deps + ["@local_config_python//:python_headers"],
  30. + deps = deps + ["@local_config_python//:python_headers"] + cc_kwargs.pop("deps", []),
  31. - defines = defines,
  32. + defines = defines,
  33. - linkshared = 1,
  34. + linkshared = cc_kwargs.pop("linkshared", 1),
  35. + **cc_kwargs
  36. )
  37. --