-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmp.BUILD
72 lines (67 loc) · 1.95 KB
/
gmp.BUILD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
_OPTS = [
"-Werror",
"-pedantic-errors",
"-Weverything",
"--system-header-prefix=gmp",
"-fPIC",
]
_COPTS = _OPTS + ["-std=c17"]
_CXXOPTS = _OPTS + ["-std=c++17"]
cc_library(
name = "gmp",
srcs = ["libgmp.a"],
hdrs = ["include/gmp.h"],
includes = ["include"],
copts = _COPTS,
# Using an empty include_prefix causes Bazel to emit -I instead of -iquote
# options for the include directory, so that #include <gmp.h> works.
#include_prefix = "",
visibility = ["//visibility:public"],
)
cc_library(
name = "gmpxx",
srcs = ["libgmpxx.a"],
hdrs = ["include/gmpxx.h"],
includes = ["include"],
copts = _CXXOPTS,
# Using an empty include_prefix causes Bazel to emit -I instead of -iquote
# options for the include directory, so that #include <gmpxx.h> works.
#include_prefix = "",
visibility = ["//visibility:public"],
)
genrule(
name = "gmp-build",
srcs = glob(
["**/*"],
exclude = ["bazel-*"],
),
outs = [
"libgmp.a",
"libgmpxx.a",
"include/gmp.h",
"include/gmpxx.h",
],
cmd = """
export CFLAGS="-fPIC"
export CXXFLAGS="-fPIC"
CONFIGURE_LOG=$$(mktemp)
MAKE_LOG=$$(mktemp)
GMP_ROOT=$$(dirname $(location configure))
pushd $$GMP_ROOT > /dev/null
mkdir -p /tmp/gmp
if ! ./configure --prefix=/tmp/gmp --enable-cxx --disable-assembly > $$CONFIGURE_LOG; then
cat $$CONFIGURE_LOG
fi
if ! make -j`nproc` > $$MAKE_LOG; then
cat $$MAKE_LOG
fi
if ! make install > $$MAKE_LOG; then
cat $$MAKE_LOG
fi
popd > /dev/null
cp /tmp/gmp/lib/libgmp.a $(location libgmp.a)
cp /tmp/gmp/lib/libgmpxx.a $(location libgmpxx.a)
cp /tmp/gmp/include/gmp.h $(location include/gmp.h)
cp /tmp/gmp/include/gmpxx.h $(location include/gmpxx.h)
""",
)