From e260f85f2c890c2a2d7f1204670f12265171dca5 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Tue, 26 Apr 2022 18:06:15 +0000 Subject: [PATCH 1/2] build: simplify jnilib copy Signed-off-by: Snow Pettersen --- bazel/kotlin_lib.bzl | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bazel/kotlin_lib.bzl b/bazel/kotlin_lib.bzl index 8369840568..a1c5e15491 100644 --- a/bazel/kotlin_lib.bzl +++ b/bazel/kotlin_lib.bzl @@ -57,14 +57,6 @@ def envoy_mobile_so_to_jni_lib(name, native_dep, testonly = False): 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), ) From e0093371146e83ec9e96a1a73e41e6c02af0d722 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Tue, 26 Apr 2022 18:21:49 +0000 Subject: [PATCH 2/2] use copylib Signed-off-by: Snow Pettersen --- bazel/kotlin_lib.bzl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/bazel/kotlin_lib.bzl b/bazel/kotlin_lib.bzl index a1c5e15491..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,14 +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 = """ - cp $< $@ - """.replace("{}", lib_name), )