forked from google-coral/libedgetpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
workspace.bzl
109 lines (98 loc) · 3.34 KB
/
workspace.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
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
"""
This module contains workspace definitions for building and using libedgetpu.
"""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
TENSORFLOW_COMMIT = "f394a768719a55b5c351ed1ecab2ec6f16f99dd4"
TENSORFLOW_SHA256 = "cb286abee7ee9cf5c8701d85fcc88f0fd59e72492ec4f254156de486e3e905c1"
IO_BAZEL_RULES_CLOSURE_COMMIT = "308b05b2419edb5c8ee0471b67a40403df940149"
IO_BAZEL_RULES_CLOSURE_SHA256 = "5b00383d08dd71f28503736db0500b6fb4dda47489ff5fc6bed42557c07c6ba9"
CORAL_CROSSTOOL_COMMIT = "9e00d5be43bf001f883b5700f5d04882fea00229"
CORAL_CROSSTOOL_SHA256 = "cb31b1417ccdcf7dd9fca5ec63e1571672372c30427730255997a547569d2feb"
def libedgetpu_dependencies(
tensorflow_commit = TENSORFLOW_COMMIT,
tensorflow_sha256 = TENSORFLOW_SHA256,
io_bazel_rules_closure_commit = IO_BAZEL_RULES_CLOSURE_COMMIT,
io_bazel_rules_closure_sha256 = IO_BAZEL_RULES_CLOSURE_SHA256,
coral_crosstool_commit = CORAL_CROSSTOOL_COMMIT,
coral_crosstool_sha256 = CORAL_CROSSTOOL_SHA256):
maybe(
http_archive,
name = "org_tensorflow",
urls = [
"https://github.com/tensorflow/tensorflow/archive/" + tensorflow_commit + ".tar.gz",
],
sha256 = tensorflow_sha256,
strip_prefix = "tensorflow-" + tensorflow_commit,
)
maybe(
http_archive,
name = "io_bazel_rules_closure",
urls = [
"https://github.com/bazelbuild/rules_closure/archive/" + io_bazel_rules_closure_commit + ".tar.gz", # 2019-06-13
],
sha256 = io_bazel_rules_closure_sha256,
strip_prefix = "rules_closure-" + io_bazel_rules_closure_commit,
)
maybe(
http_archive,
name = "coral_crosstool",
urls = [
"https://github.com/google-coral/crosstool/archive/" + coral_crosstool_commit + ".tar.gz",
],
sha256 = coral_crosstool_sha256,
strip_prefix = "crosstool-" + coral_crosstool_commit,
)
maybe(
libusb_repository,
name = "libusb",
)
def _libusb_impl(ctx):
lower_name = ctx.os.name.lower()
if lower_name.startswith("linux"):
path = "/usr/include"
build_file_content = """
cc_library(
name = "headers",
includes = ["root"],
hdrs = ["root/libusb-1.0/libusb.h"],
visibility = ["//visibility:public"],
)
"""
elif lower_name.startswith("windows"):
path = str(ctx.path(Label("@//:WORKSPACE"))) + "/../../libusb-1.0.22"
build_file_content = """
cc_library(
name = "headers",
includes = ["root/include"],
hdrs = ["root/include/libusb-1.0/libusb.h"],
visibility = ["//visibility:public"],
)
cc_import(
name = "shared",
interface_library = "root/MS64/dll/libusb-1.0.lib",
shared_library = "root/MS64/dll/libusb-1.0.dll",
visibility = ["//visibility:public"],
)
"""
elif lower_name.startswith("mac os x"):
path = "/opt/local/include/"
build_file_content = """
cc_library(
name = "headers",
includes = ["root"],
hdrs = ["root/libusb-1.0/libusb.h"],
visibility = ["//visibility:public"],
)
"""
else:
fail("Unsupported operating system.")
ctx.symlink(path, "root")
ctx.file(
"BUILD",
content = build_file_content,
executable = False,
)
libusb_repository = repository_rule(
implementation = _libusb_impl,
)