Squashed 'third_party/rules_rust/' content from commit bf59038ca
git-subtree-dir: third_party/rules_rust
git-subtree-split: bf59038cac11798cbaef9f3bf965bad8182b97fa
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
Change-Id: I5a20e403203d670df467ea97dde9a4ac40339a8d
diff --git a/examples/third_party/openssl/BUILD.bazel b/examples/third_party/openssl/BUILD.bazel
new file mode 100644
index 0000000..ea1a6b9
--- /dev/null
+++ b/examples/third_party/openssl/BUILD.bazel
@@ -0,0 +1,11 @@
+# The code here was picked up from the `rules_foreign_cc` openssl example
+# https://github.com/bazelbuild/rules_foreign_cc/tree/0.5.1/examples/third_party/openssl
+
+exports_files(
+ [
+ "BUILD.nasm.bazel",
+ "BUILD.openssl.bazel",
+ "BUILD.perl.bazel",
+ ],
+ visibility = ["//visibility:public"],
+)
diff --git a/examples/third_party/openssl/BUILD.nasm.bazel b/examples/third_party/openssl/BUILD.nasm.bazel
new file mode 100644
index 0000000..05d571d
--- /dev/null
+++ b/examples/third_party/openssl/BUILD.nasm.bazel
@@ -0,0 +1,17 @@
+# The code here was picked up from the `rules_foreign_cc` openssl example
+# https://github.com/bazelbuild/rules_foreign_cc/tree/0.5.1/examples/third_party/openssl
+
+load("@bazel_skylib//rules:select_file.bzl", "select_file")
+
+package(default_visibility = ["//visibility:public"])
+
+filegroup(
+ name = "all_srcs",
+ srcs = glob(["**"]),
+)
+
+select_file(
+ name = "nasm",
+ srcs = ":all_srcs",
+ subpath = "nasm.exe",
+)
diff --git a/examples/third_party/openssl/BUILD.openssl.bazel b/examples/third_party/openssl/BUILD.openssl.bazel
new file mode 100644
index 0000000..865fe22
--- /dev/null
+++ b/examples/third_party/openssl/BUILD.openssl.bazel
@@ -0,0 +1,100 @@
+# The code here was picked up from the `rules_foreign_cc` openssl example
+# https://github.com/bazelbuild/rules_foreign_cc/tree/0.5.1/examples/third_party/openssl
+
+load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make", "configure_make_variant")
+
+# Read https://wiki.openssl.org/index.php/Compilation_and_Installation
+
+filegroup(
+ name = "all_srcs",
+ srcs = glob(["**"]),
+)
+
+CONFIGURE_OPTIONS = [
+ "no-comp",
+ "no-idea",
+ "no-weak-ssl-ciphers",
+ "no-shared",
+]
+
+LIB_NAME = "openssl"
+
+MAKE_TARGETS = [
+ "build_libs",
+ "install_dev",
+]
+
+config_setting(
+ name = "msvc_compiler",
+ flag_values = {
+ "@bazel_tools//tools/cpp:compiler": "msvc-cl",
+ },
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "openssl",
+ actual = select({
+ ":msvc_compiler": "openssl_msvc",
+ "//conditions:default": "openssl_default",
+ }),
+ visibility = ["//visibility:public"],
+)
+
+configure_make_variant(
+ name = "openssl_msvc",
+ build_data = [
+ "@nasm_windows//:nasm",
+ "@perl_windows//:perl",
+ ],
+ configure_command = "Configure",
+ configure_in_place = True,
+ configure_options = CONFIGURE_OPTIONS + [
+ "VC-WIN64A",
+ # Unset Microsoft Assembler (MASM) flags set by built-in MSVC toolchain,
+ # as NASM is unsed to build OpenSSL rather than MASM
+ "ASFLAGS=\" \"",
+ ],
+ configure_prefix = "$PERL",
+ env = {
+ # The Zi flag must be set otherwise OpenSSL fails to build due to missing .pdb files
+ "CFLAGS": "-Zi",
+ "PATH": "$(dirname $(execpath @nasm_windows//:nasm)):$PATH",
+ "PERL": "$(execpath @perl_windows//:perl)",
+ },
+ lib_name = LIB_NAME,
+ lib_source = ":all_srcs",
+ out_static_libs = [
+ "libssl.lib",
+ "libcrypto.lib",
+ ],
+ targets = MAKE_TARGETS,
+ toolchain = "@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain",
+)
+
+configure_make(
+ name = "openssl_default",
+ configure_command = "config",
+ configure_in_place = True,
+ configure_options = CONFIGURE_OPTIONS,
+ env = select({
+ "@platforms//os:macos": {"AR": ""},
+ "//conditions:default": {},
+ }),
+ lib_name = LIB_NAME,
+ lib_source = ":all_srcs",
+ # Note that for Linux builds, libssl must come before libcrypto on the linker command-line.
+ # As such, libssl must be listed before libcrypto
+ out_static_libs = [
+ "libssl.a",
+ "libcrypto.a",
+ ],
+ targets = MAKE_TARGETS,
+)
+
+filegroup(
+ name = "gen_dir",
+ srcs = [":openssl"],
+ output_group = "gen_dir",
+ visibility = ["//visibility:public"],
+)
diff --git a/examples/third_party/openssl/BUILD.perl.bazel b/examples/third_party/openssl/BUILD.perl.bazel
new file mode 100644
index 0000000..9c5d9c1
--- /dev/null
+++ b/examples/third_party/openssl/BUILD.perl.bazel
@@ -0,0 +1,17 @@
+# The code here was picked up from the `rules_foreign_cc` openssl example
+# https://github.com/bazelbuild/rules_foreign_cc/tree/0.5.1/examples/third_party/openssl
+
+load("@bazel_skylib//rules:select_file.bzl", "select_file")
+
+package(default_visibility = ["//visibility:public"])
+
+filegroup(
+ name = "all_srcs",
+ srcs = glob(["**"]),
+)
+
+select_file(
+ name = "perl",
+ srcs = ":all_srcs",
+ subpath = "perl/bin/perl.exe",
+)
diff --git a/examples/third_party/openssl/openssl_repositories.bzl b/examples/third_party/openssl/openssl_repositories.bzl
new file mode 100644
index 0000000..2047ebf
--- /dev/null
+++ b/examples/third_party/openssl/openssl_repositories.bzl
@@ -0,0 +1,45 @@
+"""A module defining the third party dependency OpenSSL
+
+The code here was picked up from the `rules_foreign_cc` openssl example
+https://github.com/bazelbuild/rules_foreign_cc/tree/0.5.1/examples/third_party/openssl
+"""
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
+
+def openssl_repositories():
+ maybe(
+ http_archive,
+ name = "openssl",
+ build_file = Label("//third_party/openssl:BUILD.openssl.bazel"),
+ sha256 = "892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5",
+ strip_prefix = "openssl-1.1.1k",
+ urls = [
+ "https://mirror.bazel.build/www.openssl.org/source/openssl-1.1.1k.tar.gz",
+ "https://www.openssl.org/source/openssl-1.1.1k.tar.gz",
+ "https://github.com/openssl/openssl/archive/OpenSSL_1_1_1k.tar.gz",
+ ],
+ )
+
+ maybe(
+ http_archive,
+ name = "nasm_windows",
+ build_file = Label("//third_party/openssl:BUILD.nasm.bazel"),
+ sha256 = "f5c93c146f52b4f1664fa3ce6579f961a910e869ab0dae431bd871bdd2584ef2",
+ strip_prefix = "nasm-2.15.05",
+ urls = [
+ "https://mirror.bazel.build/www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/nasm-2.15.05-win64.zip",
+ "https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/nasm-2.15.05-win64.zip",
+ ],
+ )
+
+ maybe(
+ http_archive,
+ name = "perl_windows",
+ build_file = Label("//third_party/openssl:BUILD.perl.bazel"),
+ sha256 = "aeb973da474f14210d3e1a1f942dcf779e2ae7e71e4c535e6c53ebabe632cc98",
+ urls = [
+ "https://mirror.bazel.build/strawberryperl.com/download/5.32.1.1/strawberry-perl-5.32.1.1-64bit.zip",
+ "https://strawberryperl.com/download/5.32.1.1/strawberry-perl-5.32.1.1-64bit.zip",
+ ],
+ )