diff --git a/bazel/kotlin_lib.bzl b/bazel/kotlin_lib.bzl index 8369840568..1fafc0a058 100644 --- a/bazel/kotlin_lib.bzl +++ b/bazel/kotlin_lib.bzl @@ -1,4 +1,5 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library") +load("@bazel_skylib//rules:copy_file.bzl", "copy_file") # This is the magic function which helps get the name of the native library # from the native dependency. In general, the bazel cc_binary rules will @@ -49,22 +50,9 @@ def envoy_mobile_kt_library(name, visibility = None, srcs = [], deps = [], expor # ) def envoy_mobile_so_to_jni_lib(name, native_dep, testonly = False): lib_name = native_lib_name(native_dep) - output = "{}.jnilib".format(lib_name) - - return native.genrule( + copy_file( name = name, + src = native_dep, + out = "{}.jnilib".format(lib_name), testonly = testonly, - outs = [output], - srcs = [native_dep], - cmd = """ - so_file="{}.so" - if [ ! -f $$so_file ]; then - dir=$$(dirname $@) - cp $< $$dir/{}.so 2>/dev/null || : - chmod 755 $$dir/{}.so - fi - - cp $< $@ - chmod 755 $@ - """.replace("{}", lib_name), )