Skip to content

Commit

Permalink
openssl uses rules_perl toolchain on Linux and Mac
Browse files Browse the repository at this point in the history
This demonstrates that toolchains can be propery used in
rules_foreign_cc rules.

rules_perl doesn't currently have a Windows toolchain, but when it does,
we can stop bringing along our own.
  • Loading branch information
illicitonion committed Oct 18, 2021
1 parent becbfe2 commit db41223
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 8 additions & 2 deletions examples/third_party/openssl/BUILD.openssl.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -91,6 +96,7 @@ configure_make(
"libcrypto.a",
],
targets = MAKE_TARGETS,
toolchains = ["@rules_perl//:current_toolchain"],
)

filegroup(
Expand Down
10 changes: 10 additions & 0 deletions examples/third_party/openssl/openssl_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ 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.
maybe(
http_archive,
name = "perl",
Expand Down
7 changes: 7 additions & 0 deletions examples/third_party/openssl/openssl_setup.bzl
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions examples/third_party/setup.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load("//openssl:openssl_setup.bzl", "openssl_setup")

def setup():
openssl_setup()

0 comments on commit db41223

Please sign in to comment.