From 7de17580833dce2e16c3135a60e6e05f30fc9deb Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Mon, 11 Feb 2019 16:49:09 -0500 Subject: [PATCH 1/3] Add gazelle --- BUILD.bazel | 14 ++++++++++---- WORKSPACE | 18 +++++++++++------- bls.c | 4 ++-- example/aggregate-verify/BUILD.bazel | 15 +++++++++++++++ example/hash-map-to-g2/BUILD.bazel | 15 +++++++++++++++ example/parallelize-verification/BUILD.bazel | 15 +++++++++++++++ example/single-sign-verify/BUILD.bazel | 15 +++++++++++++++ 7 files changed, 83 insertions(+), 13 deletions(-) create mode 100644 example/aggregate-verify/BUILD.bazel create mode 100644 example/hash-map-to-g2/BUILD.bazel create mode 100644 example/parallelize-verification/BUILD.bazel create mode 100644 example/single-sign-verify/BUILD.bazel diff --git a/BUILD.bazel b/BUILD.bazel index 2ae572c..55bf1c6 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,4 +1,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@bazel_gazelle//:def.bzl", "gazelle") + +# gazelle:prefix github.com/prysmaticlabs/go-bls +gazelle(name = "gazelle") + +# gazelle:exclude bls.c go_library( name = "go_default_library", @@ -7,14 +13,14 @@ go_library( "crypto.go", ], cdeps = [ - "go-lib", + "go-lib", ], cgo = True, - clinkopts = ["-lstdc++"], - copts = ["-DMCLBN_FP_UNIT_SIZE=6 -DMCL_DONT_USE_OPENSSL"], + clinkopts = ["-lstdc++"], # keep + copts = ["-DMCLBN_FP_UNIT_SIZE=6 -DMCL_DONT_USE_OPENSSL"], # keep importpath = "github.com/prysmaticlabs/go-bls", visibility = ["//visibility:public"], - x_defs = { "bazel": "true" }, + x_defs = {"bazel": "true"}, ) cc_library( diff --git a/WORKSPACE b/WORKSPACE index c69fda3..75ddc19 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -2,22 +2,26 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_go", - url = "https://github.com/bazelbuild/rules_go/releases/download/0.16.6/rules_go-0.16.6.tar.gz", - sha256 = "ade51a315fa17347e5c31201fdc55aa5ffb913377aa315dceb56ee9725e620ee", + urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.17.0/rules_go-0.17.0.tar.gz"], + sha256 = "492c3ac68ed9dcf527a07e6a1b2dcbf199c6bf8b35517951467ac32e421c06c1", ) - -load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains") - +http_archive( + name = "bazel_gazelle", + urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.16.0/bazel-gazelle-0.16.0.tar.gz"], + sha256 = "7949fc6cc17b5b191103e97481cf8889217263acf52e00b560683413af204fcb", +) +load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") go_rules_dependencies() - go_register_toolchains() +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") +gazelle_dependencies() load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( name = "herumi_mcl", remote = "https://github.com/prysmaticlabs/mcl", - commit = "79b3a33e21072712f00985ed2adf34b3bcf0d74e", + commit = "e02b4b6d82bac7898a1963d20c27a9d9db30a6fe", ) git_repository( diff --git a/bls.c b/bls.c index dcf0bc6..4bfa2b0 100644 --- a/bls.c +++ b/bls.c @@ -8,9 +8,9 @@ void blsSignatureAdd(blsSignature *sig, const blsSignature *rhs){} int blsVerify(const blsSignature *sig, const blsPublicKey *pub, const void *m, mclSize size){ return 0; } void mclBnFr_add(mclBnFr *z, const mclBnFr *x, const mclBnFr *y){} void mclBnFr_clear(mclBnFr *x){} -mclSize mclBnFr_deserialize(mclBnFr *x, const void *buf, mclSize bufSize){} +mclSize mclBnFr_deserialize(mclBnFr *x, const void *buf, mclSize bufSize){ return 0; } void mclBnFr_div(mclBnFr *z, const mclBnFr *x, const mclBnFr *y){} -mclSize mclBnFr_getStr(char *buf, mclSize maxBufSize, const mclBnFr *x, int ioMode){} +mclSize mclBnFr_getStr(char *buf, mclSize maxBufSize, const mclBnFr *x, int ioMode){ return 0; } int mclBnFr_setStr(mclBnFr *x, const char *buf, mclSize bufSize, int ioMode){ return 0; } void mclBnFr_inv(mclBnFr *y, const mclBnFr *x){} int mclBnFr_isEqual(const mclBnFr *x, const mclBnFr *y){ return 0; } diff --git a/example/aggregate-verify/BUILD.bazel b/example/aggregate-verify/BUILD.bazel new file mode 100644 index 0000000..901e5cc --- /dev/null +++ b/example/aggregate-verify/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "github.com/prysmaticlabs/go-bls/example/aggregate-verify", + visibility = ["//visibility:private"], + deps = ["//:go_default_library"], +) + +go_binary( + name = "aggregate-verify", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) diff --git a/example/hash-map-to-g2/BUILD.bazel b/example/hash-map-to-g2/BUILD.bazel new file mode 100644 index 0000000..4748b57 --- /dev/null +++ b/example/hash-map-to-g2/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "github.com/prysmaticlabs/go-bls/example/hash-map-to-g2", + visibility = ["//visibility:private"], + deps = ["//:go_default_library"], +) + +go_binary( + name = "hash-map-to-g2", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) diff --git a/example/parallelize-verification/BUILD.bazel b/example/parallelize-verification/BUILD.bazel new file mode 100644 index 0000000..0c8f2a9 --- /dev/null +++ b/example/parallelize-verification/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "github.com/prysmaticlabs/go-bls/example/parallelize-verification", + visibility = ["//visibility:private"], + deps = ["//:go_default_library"], +) + +go_binary( + name = "parallelize-verification", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) diff --git a/example/single-sign-verify/BUILD.bazel b/example/single-sign-verify/BUILD.bazel new file mode 100644 index 0000000..b0c36c8 --- /dev/null +++ b/example/single-sign-verify/BUILD.bazel @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "github.com/prysmaticlabs/go-bls/example/single-sign-verify", + visibility = ["//visibility:private"], + deps = ["//:go_default_library"], +) + +go_binary( + name = "single-sign-verify", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) From 3cf359b7715092d51b9baae9258710f27b0094ee Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Mon, 11 Feb 2019 16:50:24 -0500 Subject: [PATCH 2/3] revert herumi update --- WORKSPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 75ddc19..4aaf58a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -21,7 +21,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( name = "herumi_mcl", remote = "https://github.com/prysmaticlabs/mcl", - commit = "e02b4b6d82bac7898a1963d20c27a9d9db30a6fe", + commit = "79b3a33e21072712f00985ed2adf34b3bcf0d74e", ) git_repository( From c1a865289ef253d2af50f5092c13997ac2b80eae Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Mon, 11 Feb 2019 16:50:58 -0500 Subject: [PATCH 3/3] Run gazelle on workspace --- WORKSPACE | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index 4aaf58a..e77b4ae 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -5,15 +5,21 @@ http_archive( urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.17.0/rules_go-0.17.0.tar.gz"], sha256 = "492c3ac68ed9dcf527a07e6a1b2dcbf199c6bf8b35517951467ac32e421c06c1", ) + http_archive( name = "bazel_gazelle", urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.16.0/bazel-gazelle-0.16.0.tar.gz"], sha256 = "7949fc6cc17b5b191103e97481cf8889217263acf52e00b560683413af204fcb", ) + load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") + go_rules_dependencies() + go_register_toolchains() + load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") + gazelle_dependencies() load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")