You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
743 B

1 month ago
  1. _SHARED_LIB_SUFFIX = {
  2. "//conditions:default": ".so",
  3. "//:windows": ".dll",
  4. }
  5. def py_extension(name, srcs, hdrs = [], copts = [], features = [], deps = []):
  6. for shared_lib_suffix in _SHARED_LIB_SUFFIX.values():
  7. shared_lib_name = name + shared_lib_suffix
  8. native.cc_binary(
  9. name = shared_lib_name,
  10. linkshared = True,
  11. linkstatic = True,
  12. srcs = srcs + hdrs,
  13. copts = copts,
  14. features = features,
  15. deps = deps,
  16. )
  17. return native.py_library(
  18. name = name,
  19. data = select({
  20. platform: [name + shared_lib_suffix]
  21. for platform, shared_lib_suffix in _SHARED_LIB_SUFFIX.items()
  22. }),
  23. )