diff --git a/examples/WORKSPACE.bazel b/examples/WORKSPACE.bazel index 3b122396b..58107971c 100644 --- a/examples/WORKSPACE.bazel +++ b/examples/WORKSPACE.bazel @@ -35,6 +35,10 @@ load("@rules_foreign_cc_examples_third_party//:repositories.bzl", examples_third examples_third_party_repositories() +load("@rules_foreign_cc_examples_third_party//:setup.bzl", examples_third_party_setup = "setup") + +examples_third_party_setup() + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( diff --git a/examples/third_party/openssl/BUILD.openssl.bazel b/examples/third_party/openssl/BUILD.openssl.bazel index 0a0d5e105..19d0a8cd0 100644 --- a/examples/third_party/openssl/BUILD.openssl.bazel +++ b/examples/third_party/openssl/BUILD.openssl.bazel @@ -79,8 +79,13 @@ configure_make( configure_in_place = True, configure_options = CONFIGURE_OPTIONS, env = select({ - "@platforms//os:macos": {"AR": ""}, - "//conditions:default": {}, + "@platforms//os:macos": { + "AR": "", + "PERL": "$$EXT_BUILD_ROOT$$/$(PERL)", + }, + "//conditions:default": { + "PERL": "$$EXT_BUILD_ROOT$$/$(PERL)", + }, }), lib_name = LIB_NAME, lib_source = ":all_srcs", @@ -91,6 +96,7 @@ configure_make( "libcrypto.a", ], targets = MAKE_TARGETS, + toolchains = ["@rules_perl//:current_toolchain"], ) filegroup( diff --git a/examples/third_party/openssl/openssl_repositories.bzl b/examples/third_party/openssl/openssl_repositories.bzl index 2a11c924e..6231a5fea 100644 --- a/examples/third_party/openssl/openssl_repositories.bzl +++ b/examples/third_party/openssl/openssl_repositories.bzl @@ -28,7 +28,18 @@ def openssl_repositories(): "https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/nasm-2.15.05-win64.zip", ], ) + maybe( + http_archive, + name = "rules_perl", + sha256 = "55fbe071971772758ad669615fc9aac9b126db6ae45909f0f36de499f6201dd3", + strip_prefix = "rules_perl-2f4f36f454375e678e81e5ca465d4d497c5c02da", + urls = [ + "https://github.com/bazelbuild/rules_perl/archive/2f4f36f454375e678e81e5ca465d4d497c5c02da.tar.gz", + ], + ) + # rules_perl doesn't currently support Windows, so we need to bring along our own Perl. + # https://github.com/bazelbuild/rules_perl/issues/30 maybe( http_archive, name = "perl", diff --git a/examples/third_party/openssl/openssl_setup.bzl b/examples/third_party/openssl/openssl_setup.bzl new file mode 100644 index 000000000..9217480a0 --- /dev/null +++ b/examples/third_party/openssl/openssl_setup.bzl @@ -0,0 +1,7 @@ +"""A module initialising the third party dependencies OpenSSL""" + +load("@rules_perl//perl:deps.bzl", "perl_register_toolchains", "perl_rules_dependencies") + +def openssl_setup(): + perl_rules_dependencies() + perl_register_toolchains() diff --git a/examples/third_party/setup.bzl b/examples/third_party/setup.bzl new file mode 100644 index 000000000..2dbfb122e --- /dev/null +++ b/examples/third_party/setup.bzl @@ -0,0 +1,6 @@ +"""A centralized module initializing repositories required for third party examples of rules_foreign_cc which require loading from repositories which themselves were loaded in repositories.bzl.""" + +load("//openssl:openssl_setup.bzl", "openssl_setup") + +def setup(): + openssl_setup()