fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
59fab4e7
0.6.0
1"""An openssl build file based on a snippet found in the github issue: 2https://github.com/bazelbuild/rules_foreign_cc/issues/337 3""" 4 5load ( "@rules_foreign_cc//foreign_cc:defs.bzl" , "configure_make" , "configure_make_variant" ) 6 7# Read https://wiki.openssl.org/index.php/Compilation_and_Installation 8 9filegroup ( 10name = "all_srcs" , 11srcs = glob ([ "**" ]), 12) 13 14CONFIGURE_OPTIONS = [ 15"no-comp" , 16"no-idea" , 17"no-weak-ssl-ciphers" , 18"no-shared" , 19] 20 21LIB_NAME = "openssl" 22 23MAKE_TARGETS = [ 24"build_libs" , 25"install_dev" , 26] 27 28config_setting ( 29name = "msvc_compiler" , 30flag_values = { 31"@bazel_tools//tools/cpp:compiler" : "msvc-cl" , 32}, 33visibility = [ "//visibility:public" ], 34) 35 36alias ( 37name = "openssl" , 38actual = select ({ 39":msvc_compiler" : "openssl_msvc" , 40"//conditions:default" : "openssl_default" , 41}), 42visibility = [ "//visibility:public" ], 43) 44 45configure_make_variant ( 46name = "openssl_msvc" , 47build_data = [ 48"@nasm//:nasm" , 49"@perl//:perl" , 50], 51configure_command = "Configure" , 52configure_in_place = True , 53configure_options = CONFIGURE_OPTIONS + [ 54"VC-WIN64A" , 55# Unset Microsoft Assembler (MASM) flags set by built-in MSVC toolchain, 56# as NASM is unsed to build OpenSSL rather than MASM 57 "ASFLAGS=\" \"" , 58], 59configure_prefix = "$PERL" , 60env = { 61# The Zi flag must be set otherwise OpenSSL fails to build due to missing .pdb files 62"CFLAGS" : "-Zi" , 63"PATH" : "$$(dirname $(execpath @nasm//:nasm)):$$PATH" , 64"PERL" : "$(execpath @perl//:perl)" , 65}, 66lib_name = LIB_NAME , 67lib_source = ":all_srcs" , 68out_static_libs = [ 69"libssl.lib" , 70"libcrypto.lib" , 71], 72targets = MAKE_TARGETS , 73toolchain = "@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain" , 74) 75 76configure_make ( 77name = "openssl_default" , 78configure_command = "config" , 79configure_in_place = True , 80configure_options = CONFIGURE_OPTIONS , 81env = select ({ 82"@platforms//os:macos" : { 83"AR" : "" , 84"PERL" : "$$EXT_BUILD_ROOT$$/$(PERL)" , 85}, 86"//conditions:default" : { 87"PERL" : "$$EXT_BUILD_ROOT$$/$(PERL)" , 88}, 89}), 90lib_name = LIB_NAME , 91lib_source = ":all_srcs" , 92# Note that for Linux builds, libssl must come before libcrypto on the linker command-line. 93# As such, libssl must be listed before libcrypto 94out_static_libs = [ 95"libssl.a" , 96"libcrypto.a" , 97], 98targets = MAKE_TARGETS , 99toolchains = [ "@rules_perl//:current_toolchain" ], 100) 101 102filegroup ( 103name = "gen_dir" , 104srcs = [ ":openssl" ], 105output_group = "gen_dir" , 106visibility = [ "//visibility:public" ], 107)