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