-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathipopt.BUILD
131 lines (124 loc) · 4.69 KB
/
ipopt.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
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
# We build IPOPT by shelling out to autotools.
# A prefix-string for genrule cmd attributes, which uses the Kythe cdexec tool,
# in quiet mode, to execute in the genrule output directory.
CDEXEC = "$(location @//tools/third_party/kythe/tools/cdexec:cdexec) -q $(@D)"
# We run autotools in a genrule, and only files explicitly identified as outputs
# of that genrule can be made available to other rules. Therefore, we need a
# list of every file in the IPOPT install.
# See https://github.com/bazelbuild/bazel/issues/281.
# find include/coin -name "*.h" -o -name "*.hpp" -o -name "*.hdd" | sort |
# sed 's/$/",/g'| sed 's/^/"/g'
IPOPT_HDRS = [
"include/coin/AmplTNLP.hpp",
"include/coin/HSLLoader.h",
"include/coin/IpAlgTypes.hpp",
"include/coin/IpBlas.hpp",
"include/coin/IpCachedResults.hpp",
"include/coin/IpCompoundVector.hpp",
"include/coin/IpDebug.hpp",
"include/coin/IpDenseVector.hpp",
"include/coin/IpException.hpp",
"include/coin/IpExpansionMatrix.hpp",
"include/coin/IpIpoptApplication.hpp",
"include/coin/IpIpoptCalculatedQuantities.hpp",
"include/coin/IpIpoptData.hpp",
"include/coin/IpIpoptNLP.hpp",
"include/coin/IpIteratesVector.hpp",
"include/coin/IpJournalist.hpp",
"include/coin/IpLapack.hpp",
"include/coin/IpMatrix.hpp",
"include/coin/IpNLP.hpp",
"include/coin/IpNLPScaling.hpp",
"include/coin/IpObserver.hpp",
"include/coin/IpoptConfig.h",
"include/coin/IpOptionsList.hpp",
"include/coin/IpOrigIpoptNLP.hpp",
"include/coin/IpReferenced.hpp",
"include/coin/IpRegOptions.hpp",
"include/coin/IpReturnCodes.h",
"include/coin/IpReturnCodes.hpp",
"include/coin/IpReturnCodes_inc.h",
"include/coin/IpSmartPtr.hpp",
"include/coin/IpSolveStatistics.hpp",
"include/coin/IpStdCInterface.h",
"include/coin/IpSymMatrix.hpp",
"include/coin/IpTaggedObject.hpp",
"include/coin/IpTimedTask.hpp",
"include/coin/IpTimingStatistics.hpp",
"include/coin/IpTNLPAdapter.hpp",
"include/coin/IpTNLP.hpp",
"include/coin/IpTNLPReducer.hpp",
"include/coin/IpTypes.hpp",
"include/coin/IpUtils.hpp",
"include/coin/IpVector.hpp",
"include/coin/PardisoLoader.h",
"include/coin/ThirdParty/arith.h",
"include/coin/ThirdParty/asl.h",
"include/coin/ThirdParty/asl_pfg.h",
"include/coin/ThirdParty/asl_pfgh.h",
"include/coin/ThirdParty/defs.h",
"include/coin/ThirdParty/dmumps_c.h",
"include/coin/ThirdParty/funcadd.h",
"include/coin/ThirdParty/getstub.h",
"include/coin/ThirdParty/macros.h",
"include/coin/ThirdParty/metis.h",
"include/coin/ThirdParty/mpi.h",
"include/coin/ThirdParty/mumps_compat.h",
"include/coin/ThirdParty/mumps_c_types.h",
"include/coin/ThirdParty/nlp2.h",
"include/coin/ThirdParty/nlp.h",
"include/coin/ThirdParty/proto.h",
"include/coin/ThirdParty/psinfo.h",
"include/coin/ThirdParty/rename.h",
"include/coin/ThirdParty/stdio1.h",
"include/coin/ThirdParty/struct.h",
]
# ls lib | grep "\.a$" | sed 's/$/",/g'| sed 's/^/"lib\//g'
# These are artisanally topo-sorted: demand before supply.
# If you change the order, you may get undefined-reference linker errors.
IPOPT_LIBS = [
"lib/libipopt.a",
"lib/libipoptamplinterface.a",
"lib/libcoinmumps.a",
"lib/libcoinmetis.a",
"lib/libcoinasl.a",
"lib/libcoinlapack.a",
"lib/libcoinblas.a",
]
# Invokes ./configure, make, and make install to build IPOPT. We arbitrarily
# use make -j 8 and hope for the best in terms of overall CPU consumption, since
# Bazel has no way to tell a genrule how many cores it should use.
#
# We emit static libraries because dynamic libraries would have different names
# on OS X and on Linux, and Bazel genrules don't allow platform-dependent outs.
# https://github.com/bazelbuild/bazel/issues/281
BUILD_IPOPT_CMD = (
CDEXEC + " `pwd`/external/ipopt/configure --enable-shared=no 2> /dev/null" +
" && " + CDEXEC + " make -j 32 2> /dev/null" +
" && " + CDEXEC + " make install 2> /dev/null"
)
genrule(
name = "build_with_autotools",
srcs = glob(["**/*"]),
outs = IPOPT_HDRS + IPOPT_LIBS,
cmd = BUILD_IPOPT_CMD,
tools = ["@//tools/third_party/kythe/tools/cdexec:cdexec"],
visibility = ["//visibility:private"],
)
# Only Linux builds should depend on this target. gfortran is not available as
# a system library on OS X.
# TODO(david-german-tri): Ingest the fortran library path from the pkg-config
# files generated during the IPOPT build.
cc_library(
name = "lib",
srcs = IPOPT_LIBS,
hdrs = IPOPT_HDRS,
includes = ["include/coin"],
linkopts = [
"-lgfortran",
"-ldl",
],
linkstatic = 1,
visibility = ["//visibility:public"],
alwayslink = 1,
)