-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
repository.bzl
47 lines (42 loc) · 1.54 KB
/
repository.bzl
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
# -*- python -*-
# This is a Bazel repository_rule for the Gurobi solver. See
# https://www.bazel.io/versions/master/docs/skylark/repository_rules.html
load("@drake//tools/workspace:os.bzl", "determine_os")
# Ubuntu only: GUROBI_HOME should be the linux64 directory in the Gurobi 9.5
# release.
#
def _gurobi_impl(repo_ctx):
os_result = determine_os(repo_ctx)
if os_result.error != None:
fail(os_result.error)
if os_result.is_macos:
# Gurobi must be installed into its standard location.
gurobi_home = "/Library/gurobi951/macos_universal2"
repo_ctx.symlink(gurobi_home, "gurobi-distro")
build_flavor = "macos"
else:
# The default directory for the downloaded gurobi is
# /opt/gurobi951/linux64. If the user does not use the default
# directory, the he/she should set GUROBI_HOME environment variable to
# the gurobi file location.
gurobi_home = repo_ctx.os.environ.get("GUROBI_HOME", "")
repo_ctx.symlink(
gurobi_home or "/opt/gurobi951/linux64",
"gurobi-distro",
)
build_flavor = "ubuntu"
# Emit the generated BUILD.bazel file.
repo_ctx.template(
"BUILD.bazel",
Label("@drake//tools/workspace/gurobi:" +
"package-{}.BUILD.bazel.in".format(build_flavor)),
substitutions = {
"{gurobi_home}": gurobi_home,
},
executable = False,
)
gurobi_repository = repository_rule(
environ = ["GUROBI_HOME"],
local = True,
implementation = _gurobi_impl,
)