-
Notifications
You must be signed in to change notification settings - Fork 757
/
BUILD
209 lines (192 loc) · 6.99 KB
/
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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
load("//tools/build/bazel:variables.bzl", "ONOS_VERSION")
load(
"//tools/build/bazel:modules.bzl",
"CORE",
"FEATURES",
"apps",
"extensions",
"profiles",
)
#
# ONOS Package Profiles
# Usage: bazel build onos-package --define profile=<profile name>
# Example: bazel build onos-package --define profile=minimal
#
# To view or update which apps and features are included in each
# profile, open: tools/build/bazel/modules.bzl
#
profiles([
"minimal",
"seba",
"stratum",
"sdfabric",
"sona",
])
filegroup(
name = "onos",
srcs = CORE + [
"//tools/build/conf:onos-build-conf",
":onos-package-admin",
":onos-package-test",
":onos-package",
] + select({
":minimal_profile": extensions("minimal") + apps("minimal"),
":seba_profile": extensions("seba") + apps("seba"),
":stratum_profile": extensions("stratum") + apps("stratum"),
":sdfabric_profile": extensions("sdfabric") + apps("sdfabric"),
":sona_profile": extensions("sona") + apps("sona"),
"//conditions:default": extensions() + apps(),
}),
visibility = ["//visibility:public"],
)
KARAF = "@apache_karaf//:apache_karaf"
BRANDING = "//tools/package/branding:onos-tools-package-branding"
LOG4J_EXTRA = "//tools/package/log4j2-extra:onos-log4j2-extra"
# Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools
genrule(
name = "onos-karaf",
srcs = [
KARAF,
BRANDING,
LOG4J_EXTRA,
] + glob([
"tools/package/bin/*",
"tools/package/etc/*",
"tools/package/init/*",
"tools/package/runtime/bin/*",
]),
outs = ["karaf.zip"],
cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) '' $(location %s) tools/package" %
(KARAF, ONOS_VERSION, BRANDING, LOG4J_EXTRA),
tools = ["tools/package/onos-prep-karaf"],
)
# Generates the principal onos.tar.gz bundle
genrule(
name = "onos-package",
srcs = [
"//tools/package/features:onos-features",
":onos-karaf",
] + FEATURES + select({
":minimal_profile": apps("minimal"),
":seba_profile": apps("seba"),
":stratum_profile": apps("stratum"),
":sdfabric_profile": apps("sdfabric"),
":sona_profile": apps("sona"),
"//conditions:default": apps(),
}),
outs = ["onos.tar.gz"],
cmd = "$(location tools/package/onos_stage.py) $(location onos.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
output_to_bindir = True,
tags = ["local"],
tools = ["tools/package/onos_stage.py"],
)
# Generates the onos-admin.tar.gz file with remote admin tools
genrule(
name = "onos-package-admin",
srcs = glob([
"tools/package/runtime/bin/*",
"tools/dev/bin/onos-create-app",
"tools/test/bin/onos",
]),
outs = ["onos-admin.tar.gz"],
cmd = "mkdir onos-admin-%s; cp $(SRCS) onos-admin-%s; tar hzcf $(location onos-admin.tar.gz) onos-admin-%s" %
(ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
output_to_bindir = True,
)
# Generates the onos-test.tar.gz file with test tools
genrule(
name = "onos-package-test",
srcs = glob([
"tools/build/envDefaults",
"tools/dev/bash_profile",
"tools/dev/bin/onos-create-app",
"tools/test/**/*",
"tools/package/runtime/bin/*",
]),
outs = ["onos-test.tar.gz"],
cmd = "mkdir onos-test-%s; cp -r tools onos-test-%s; tar hzcf $(location onos-test.tar.gz) onos-test-%s" %
(ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
output_to_bindir = True,
)
# Runs ONOS as a single instance from the /tmp directory
alias(
name = "onos-local",
actual = select({
":run_with_absolute_javabase": ":onos-local_absolute-javabase",
"//conditions:default": ":onos-local_current-jdk",
}),
)
config_setting(
name = "run_with_absolute_javabase",
define_values = {
"RUN_WITH_ABSOLUTE_JAVABASE": "true",
},
)
# Run onos-local with JAVA_HOME set to ABSOLUTE_JAVABASE (see .bazelrc)
genrule(
name = "onos-local_absolute-javabase",
srcs = [":onos-local-base"],
outs = ["onos-runner_absolute-javabase"],
cmd = "sed \"s#ABSOLUTE_JAVABASE=#ABSOLUTE_JAVABASE=$(ABSOLUTE_JAVABASE)#\" " +
"$(location onos-local-base) > $(location onos-runner_absolute-javabase)",
executable = True,
output_to_bindir = True,
visibility = ["//visibility:private"],
)
# Run onos-local with the same JDK used for the build, packaged in a tarball.
genrule(
name = "onos-local_current-jdk",
srcs = [
":onos-local-base",
"//tools/build/jdk:current_jdk_tar",
],
outs = ["onos-runner_current-jdk"],
cmd = "sed \"s#JDK_TAR=#JDK_TAR=$(location //tools/build/jdk:current_jdk_tar)#\" " +
"$(location :onos-local-base) > $(location onos-runner_current-jdk); ",
executable = True,
output_to_bindir = True,
visibility = ["//visibility:private"],
)
# Create an onos-runner script based on onos-run-karaf
genrule(
name = "onos-local-base",
srcs = [
":onos-package",
"tools/package/onos-run-karaf",
] + glob(["tools/package/config/**"]),
outs = ["onos-runner"],
cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " +
"$(location tools/package/onos-run-karaf) > $(location onos-runner); " +
"chmod +x $(location onos-runner)",
visibility = ["//visibility:private"],
)
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
buildifier(
name = "buildifier_check",
exclude_patterns = [
"./tools/build/bazel/generate_workspace.bzl",
"./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
"./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
"./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
"./web/gui2/node_modules/@bazel/rollup/rollup_bundle.bzl",
"./web/gui2/node_modules/@bazel/typescript/internal/ts_project.bzl",
"./web/gui2/node_modules/@bazel/typescript/internal/build_defs.bzl",
"./web/gui2/node_modules/@bazel/protractor/protractor_web_test.bzl",
"./web/gui2/node_modules/@bazel/typescript/third_party/github.com/bazelbuild/bazel/src/main/protobuf/BUILD.bazel",
],
mode = "check",
)
buildifier(
name = "buildifier_fix",
exclude_patterns = [
"./tools/build/bazel/generate_workspace.bzl",
"./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
"./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
"./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
"./web/gui2/node_modules/@bazel/typescript/internal/ts_project.bzl",
"./web/gui2/node_modules/@bazel/typescript/internal/build_defs.bzl",
"./web/gui2/node_modules/@bazel/protractor/protractor_web_test.bzl",
"./web/gui2/node_modules/@bazel/typescript/third_party/github.com/bazelbuild/bazel/src/main/protobuf/BUILD.bazel",
],
mode = "fix",
)