-
Notifications
You must be signed in to change notification settings - Fork 1
/
BUILD.bazel
156 lines (144 loc) · 3.68 KB
/
BUILD.bazel
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
load("@rules_cc//cc:defs.bzl", "cc_test","cc_library")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake", "make", "configure_make")
package(default_visibility = ["//visibility:public"])
cmake(
name = "pcre",
cache_entries = {
"CMAKE_C_FLAGS": "-fPIC",
},
lib_source = "@pcre//:all_srcs",
out_static_libs = ["libpcre.a"],
)
# Each full make will take about 10 minutes to run
make(
name = "openblas_lib",
lib_source = "@openblas//:all_srcs",
out_static_libs = ["libopenblas.a"],
# experiment to export build data
build_data = [
"@openblas//:README.md",
],
out_data_dirs = ["share"],
)
cc_library(
name = "openblas_lib_bazel",
srcs = [],
visibility = ["//visibility:public"],
deps = [
":openblas_lib",
]
)
# There may be a bad symlinked header and the workaround is at:
# https://github.com/bazelbuild/rules_foreign_cc/issues/1129#issuecomment-1863628259
cmake(
name = "superlu_lib",
cache_entries = {
# "CMAKE_INSTALL_PREFIX": ".",
# "CMAKE_INSTALL_INCLUDEDIR": "include",
# deps ":openblas_lib_bazel" will be copied to "$EXT_BUILD_DEPS"
# The directory structure of ":openblas_lib_bazel" are retained,
# usually libraries are under /lib and headers are under /include
"TPL_BLAS_LIBRARIES": "$EXT_BUILD_DEPS/lib/libopenblas.a"
},
lib_source = "@superlu//:all_srcs",
out_static_libs = ["libsuperlu.a"],
deps = [
# cannot directly use ":openblas_lib",
# need bridged through a `cc_library` containing ":openblas_lib"
# i.e. ":openblas_lib_bazel"
":openblas_lib_bazel"
],
linkopts = ["-lpthread"],
)
cmake(
name = "armadillo_lib",
cache_entries = {
"BUILD_SHARED_LIBS": "OFF",
},
lib_source = "@armadillo//:all_srcs",
out_static_libs = ["libarmadillo.a"],
deps = [
":openblas_lib_bazel"
],
copts =[
"-DARMA_DONT_USE_WRAPPER"
],
linkopts = [
"-lgfortran",
],
)
cc_library(
name = "hdf5_deps_lib",
deps = [
":z_lib",
":libaec",
],
)
#
configure_make(
name = "hdf5_lib",
configure_in_place = True,
configure_options = [
"--with-szlib=libaec/include,$EXT_BUILD_DEPS/libaec/lib",
"--with-zlib=z_lib/include,$EXT_BUILD_DEPS/z_lib/lib",
],
lib_source = "@hdf5//:all_srcs",
deps = [
":hdf5_deps_lib",
],
out_static_libs = ["libhdf5.a"],
linkopts = ["-lpthread"],
includes = [
"z_lib/include",
"libaec/include",
]
)
cmake(
name = "z_lib",
cache_entries = {
"BUILD_SHARED_LIBS": "OFF",
},
lib_source = "@zlib//:all_srcs",
out_static_libs = ["libz.a"],
copts = ["-fPIC"] # this is necessary otherwise will cause hdf5 build to complain
)
cmake(
name = "libaec",
cache_entries = {
"BUILD_SHARED_LIBS": "OFF",
},
lib_source = "@libaec//:all_srcs",
out_static_libs = [
"libaec.a",
"libsz.a",
],
)
#
configure_make(
name = "libmatio_lib",
configure_in_place = True,
configure_options = [
"--enable-mat73=yes",
"--enable-extended-sparse=yes",
"--with-hdf5=\"$EXT_BUILD_DEPS/hdf5_lib/lib\"",
"--with-zlib=\"$EXT_BUILD_DEPS/z_lib/lib\"",
"--with-default-file-ver=7.3",
],
lib_source = "@libmatio//:all_srcs",
deps = [
":hdf5_lib",
":z_lib",
],
out_static_libs = ["libmatio.a"],
linkopts = ["-lpthread"],
)
cmake(
name = "libjsoncpp",
cache_entries = {
"BUILD_SHARED_LIBS": "OFF",
},
lib_source = "@jsoncpp//:all_srcs",
out_static_libs = [
"libjsoncpp.a",
],
)