forked from tensorflow/tfjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
184 lines (169 loc) · 4.62 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =============================================================================
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test", "pkg_npm")
load("//tools:copy_to_dist.bzl", "copy_to_dist", "copy_ts_library_to_dist")
load("//tools:tfjs_bundle.bzl", "tfjs_bundle")
load("//tools:tfjs_web_test.bzl", "tfjs_web_test")
package(default_visibility = ["//visibility:public"])
# Allow typescript rules in any package to reference this file
exports_files([
"tsconfig.json",
"package.json",
])
tfjs_bundle(
name = "tf-core",
entry_point = "//tfjs-core/src:index.ts",
external = [
"crypto",
],
leave_as_require = [
"crypto",
"node-fetch",
"util",
],
umd_name = "tf",
deps = [
"//tfjs-core/src:tfjs-core_lib",
],
)
copy_ts_library_to_dist(
name = "copy_src_to_dist",
srcs = [
"//tfjs-core/src:tfjs-core_lib",
"//tfjs-core/src:tfjs-core_src_lib",
"//tfjs-core/src:tfjs-core_test_lib",
],
root = "src",
)
copy_to_dist(
name = "copy_bundles",
srcs = [
":tf-core",
":tf-core.es2017",
":tf-core.es2017.min",
":tf-core.fesm",
":tf-core.fesm.min",
":tf-core.min",
":tf-core.node",
],
)
copy_ts_library_to_dist(
name = "copy_test_snippets",
srcs = [
"//tfjs-core/scripts/test_snippets:test_snippets_util_lib",
],
root = ".",
)
copy_file(
name = "copy_miniprogram",
src = ":tf-core.min.js",
out = "dist/miniprogram/index.js",
)
copy_file(
name = "copy_miniprogram_map",
src = ":tf-core.min.js.map",
out = "dist/miniprogram/index.js.map",
)
pkg_npm(
name = "tfjs-core_pkg",
package_name = "@tensorflow/tfjs-core",
srcs = [
"README.md",
"package.json",
],
tags = ["ci"],
deps = [
":copy_bundles",
":copy_miniprogram",
":copy_miniprogram_map",
":copy_src_to_dist",
":copy_test_snippets",
],
)
tfjs_web_test(
name = "tfjs-core_test",
srcs = [
"//tfjs-core/src:tfjs-core_test_bundle",
],
browsers = [
"bs_chrome_mac",
"bs_firefox_mac",
"bs_safari_mac",
"bs_ios_12",
"bs_android_9",
"win_10_chrome",
],
static_files = [
# Listed here so sourcemaps are served
"//tfjs-core/src:tfjs-core_test_bundle",
],
)
# Defined here because chdir must be a subdirectory of the directory the rule is
# defined in.
nodejs_test(
name = "test_snippets_test",
chdir = "tfjs-core",
data = [
":tsconfig.json",
"//:tsconfig.json",
"//tfjs-backend-cpu/src:tfjs-backend-cpu_lib",
"//tfjs-core/scripts/test_snippets:test_snippets_lib",
"//tfjs-core/src:all_srcs",
],
entry_point = "//tfjs-core/scripts/test_snippets:test_snippets.ts",
link_workspace_root = True,
tags = [
"ci",
# Run the test locally since it makes http requests.
"no-remote-exec",
"requires-network",
],
)
nodejs_test(
name = "tfjs-core_node_test",
data = [
"//tfjs-backend-cpu/src:tfjs-backend-cpu_lib",
"//tfjs-core/src:setup_test_lib",
"//tfjs-core/src:test_node_lib",
"//tfjs-core/src:tfjs-core_lib",
"//tfjs-core/src:tfjs-core_src_lib",
"//tfjs-core/src:tfjs-core_test_lib",
],
entry_point = "//tfjs-core/src:test_node.ts",
link_workspace_root = True,
tags = ["ci"],
)
nodejs_test(
name = "tfjs-core_async_backends_test",
data = [
"//tfjs-backend-cpu/src:tfjs-backend-cpu_lib",
"//tfjs-core/src:tfjs-core_test_lib",
],
entry_point = "//tfjs-core/src:test_async_backends.ts",
link_workspace_root = True,
tags = ["ci"],
)
test_suite(
name = "tests",
tests = [
":test_snippets_test",
":tfjs-core_async_backends_test",
":tfjs-core_node_test",
":tfjs-core_test",
"//tfjs-core/src:worker_node_test",
"//tfjs-core/src:worker_test",
],
)