github.com/prysmaticlabs/prysm@v1.4.4/third_party/herumi/bls_eth_go_binary.BUILD (about) 1 load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 3 config_setting( 4 name = "use_gmp", 5 values = {"define": "BLS_USE_GMP=true"}, 6 ) 7 8 config_setting( 9 name = "use_openssl", 10 values = {"define": "BLS_USE_OPENSSL=true"}, 11 ) 12 13 OPTS = [ 14 "-DMCL_LLVM_BMI2=0", 15 "-DMCL_USE_LLVM=1", 16 "-DMCL_VINT_FIXED_BUFFER", 17 "-DMCL_SIZEOF_UNIT=8", 18 "-DMCL_MAX_BIT_SIZE=384", 19 "-DCYBOZU_DONT_USE_EXCEPTION", 20 "-DCYBOZU_DONT_USE_STRING", 21 "-DBLS_SWAP_G", 22 "-DBLS_ETH", 23 ] + select({ 24 ":use_gmp": [], 25 "//conditions:default": [ 26 "-DMCL_USE_VINT", 27 ], 28 }) + select({ 29 ":use_openssl": [], 30 "//conditions:default": [ 31 "-DMCL_DONT_USE_OPENSSL", 32 ], 33 }) 34 35 genrule( 36 name = "base64_ll", 37 outs = ["src/base64.ll"], # llvm assembly language file. 38 tools = [ 39 "@herumi_mcl//:src_gen", 40 ], 41 cmd = "touch func.list && $(location @herumi_mcl//:src_gen) -u 64 -f func.list > $@", 42 ) 43 44 genrule( 45 name = "base64_o", 46 srcs = [ 47 "src/base64.ll", 48 ], 49 outs = ["base64.o"], 50 cmd = "$(CC) $(CC_FLAGS) -c -o $@ $(location src/base64.ll)", 51 toolchains = [ 52 "@bazel_tools//tools/cpp:current_cc_toolchain", 53 "@bazel_tools//tools/cpp:cc_flags", 54 ], 55 ) 56 57 cc_library( 58 name = "lib", 59 srcs = [ 60 "@herumi_mcl//:src/fp.cpp", 61 "@herumi_bls//:src/bls_c384_256.cpp", 62 "@herumi_bls//:src/bls_c_impl.hpp", 63 ":base64_o", 64 ], 65 deps = ["@herumi_mcl//:bn"], 66 includes = [ 67 "bls/include", 68 ], 69 hdrs = [ 70 "bls/include/bls/bls.h", 71 "bls/include/bls/bls384_256.h", 72 "bls/include/mcl/bn.h", 73 "bls/include/mcl/bn_c384_256.h", 74 "@herumi_mcl//:include/mcl/curve_type.h", 75 ], 76 copts = OPTS + [ 77 "-std=c++03", 78 ], 79 linkopts = select({ 80 ":use_gmp": ["-lgmp"], 81 "//conditions:default": [], 82 }) + select({ 83 ":use_openssl": [ 84 "-lssl", 85 "-lcrypto", 86 ], 87 "//conditions:default": [], 88 }), 89 visibility = ["//visibility:public"], 90 ) 91 92 cc_library( 93 name = "precompiled", 94 srcs = select({ 95 "@io_bazel_rules_go//go/platform:android_arm": [ 96 "bls/lib/android/armeabi-v7a/libbls384_256.a", 97 ], 98 "@io_bazel_rules_go//go/platform:linux_arm64": [ 99 "bls/lib/linux/arm64/libbls384_256.a", 100 ], 101 "@io_bazel_rules_go//go/platform:android_arm64": [ 102 "bls/lib/android/arm64-v8a/libbls384_256.a", 103 ], 104 "@io_bazel_rules_go//go/platform:darwin_amd64": [ 105 "bls/lib/darwin/amd64/libbls384_256.a", 106 ], 107 "@io_bazel_rules_go//go/platform:linux_amd64": [ 108 "bls/lib/linux/amd64/libbls384_256.a", 109 ], 110 "@io_bazel_rules_go//go/platform:windows_amd64": [ 111 "bls/lib/windows/amd64/libbls384_256.a", 112 ], 113 "//conditions:default": [], 114 }), 115 hdrs = [ 116 "bls/include/bls/bls.h", 117 "bls/include/bls/bls384_256.h", 118 "bls/include/mcl/bn.h", 119 "bls/include/mcl/bn_c384_256.h", 120 "bls/include/mcl/curve_type.h", 121 ], 122 includes = [ 123 "bls/include", 124 ], 125 deprecation = "Using precompiled BLS archives. To build BLS from source with llvm, use --config=llvm.", 126 ) 127 128 config_setting( 129 name = "llvm_compiler_enabled", 130 define_values = { 131 "compiler": "llvm", 132 }, 133 ) 134 135 go_library( 136 name = "go_default_library", 137 importpath = "github.com/herumi/bls-eth-go-binary/bls", 138 srcs = [ 139 "bls/bls.go", 140 "bls/callback.go", 141 "bls/cast.go", 142 "bls/mcl.go", 143 ], 144 cdeps = select({ 145 ":llvm_compiler_enabled": [":lib"], 146 "//conditions:default": [":precompiled"], 147 }), 148 cgo = True, 149 copts = OPTS, 150 visibility = [ 151 # Additional access will require security approval. 152 "@prysm//shared/bls/herumi:__pkg__", 153 "@com_github_wealdtech_go_eth2_types_v2//:__pkg__", 154 ], 155 clinkopts = select({ 156 "@prysm//fuzz:fuzzing_enabled": ["-Wl,--unresolved-symbols=ignore-all", "-fsanitize=address"], 157 "//conditions:default": [], 158 }), 159 )