blob: b83515b28d61f905f0c875da068f23d70a330771 [file] [log] [blame]
Thomas Vachuskae17756d2018-10-31 15:23:55 -07001load("//tools/build/bazel:variables.bzl", "ONOS_VERSION")
pierventre18917912020-01-07 11:28:46 -08002load(
3 "//tools/build/bazel:modules.bzl",
4 "CORE",
5 "FEATURES",
6 "apps",
7 "extensions",
8 "profiles",
9)
10
11#
12# ONOS Package Profiles
13# Usage: bazel build onos-package --define profile=<profile name>
14# Example: bazel build onos-package --define profile=minimal
15#
16# To view or update which apps and features are included in each
17# profile, open: tools/build/bazel/modules.bzl
18#
19profiles([
20 "minimal",
21 "seba",
22 "stratum",
pierventre8a95ee42020-06-30 22:04:16 +020023 "tost",
Jian Li4170ab72020-07-22 17:34:55 +090024 "sona",
pierventre18917912020-01-07 11:28:46 -080025])
Thomas Vachuskaaab45d12018-06-05 16:39:46 -070026
Ray Milkey7dac7da2017-08-01 16:56:05 -070027filegroup(
28 name = "onos",
pierventre18917912020-01-07 11:28:46 -080029 srcs = CORE + [
Thomas Vachuska5538d9e2018-08-14 09:59:35 -070030 "//tools/build/conf:onos-build-conf",
Ray Milkey15053f02018-06-13 10:00:45 -070031 ":onos-package-admin",
32 ":onos-package-test",
33 ":onos-package",
pierventre18917912020-01-07 11:28:46 -080034 ] + select({
35 ":minimal_profile": extensions("minimal") + apps("minimal"),
36 ":seba_profile": extensions("seba") + apps("seba"),
37 ":stratum_profile": extensions("stratum") + apps("stratum"),
pierventre8a95ee42020-06-30 22:04:16 +020038 ":tost_profile": extensions("tost") + apps("tost"),
Jian Li4170ab72020-07-22 17:34:55 +090039 ":sona_profile": extensions("sona") + apps("sona"),
pierventre18917912020-01-07 11:28:46 -080040 "//conditions:default": extensions() + apps(),
41 }),
Thomas Vachuska0f956032018-06-12 10:41:12 -070042 visibility = ["//visibility:public"],
43)
44
Ray Milkeya8ac7e32018-09-04 15:52:14 -070045KARAF = "@apache_karaf//:apache_karaf"
Ray Milkey15053f02018-06-13 10:00:45 -070046
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070047BRANDING = "//tools/package/branding:onos-tools-package-branding"
48
Daniele Moro27527592020-02-03 23:33:55 -080049LOG4J_EXTRA = "//tools/package/log4j2-extra:onos-log4j2-extra"
50
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070051# Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools
52genrule(
53 name = "onos-karaf",
Ray Milkey15053f02018-06-13 10:00:45 -070054 srcs = [
55 KARAF,
Ray Milkey15053f02018-06-13 10:00:45 -070056 BRANDING,
Daniele Moro27527592020-02-03 23:33:55 -080057 LOG4J_EXTRA,
Ray Milkey15053f02018-06-13 10:00:45 -070058 ] + glob([
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070059 "tools/package/bin/*",
60 "tools/package/etc/*",
61 "tools/package/init/*",
Ray Milkey15053f02018-06-13 10:00:45 -070062 "tools/package/runtime/bin/*",
63 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070064 outs = ["karaf.zip"],
Daniele Moro27527592020-02-03 23:33:55 -080065 cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) '' $(location %s) tools/package" %
66 (KARAF, ONOS_VERSION, BRANDING, LOG4J_EXTRA),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070067 tools = ["tools/package/onos-prep-karaf"],
68)
69
70# Generates the principal onos.tar.gz bundle
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070071genrule(
72 name = "onos-package",
Ray Milkey15053f02018-06-13 10:00:45 -070073 srcs = [
74 "//tools/package/features:onos-features",
75 ":onos-karaf",
pierventre18917912020-01-07 11:28:46 -080076 ] + FEATURES + select({
77 ":minimal_profile": apps("minimal"),
78 ":seba_profile": apps("seba"),
79 ":stratum_profile": apps("stratum"),
pierventre8a95ee42020-06-30 22:04:16 +020080 ":tost_profile": apps("tost"),
Jian Li4170ab72020-07-22 17:34:55 +090081 ":sona_profile": apps("sona"),
pierventre18917912020-01-07 11:28:46 -080082 "//conditions:default": apps(),
83 }),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070084 outs = ["onos.tar.gz"],
85 cmd = "$(location tools/package/onos_stage.py) $(location onos.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070086 output_to_bindir = True,
Thomas Vachuskae7433b82018-07-24 13:57:37 -070087 tags = ["local"],
Ray Milkey15053f02018-06-13 10:00:45 -070088 tools = ["tools/package/onos_stage.py"],
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070089)
90
91# Generates the onos-admin.tar.gz file with remote admin tools
92genrule(
93 name = "onos-package-admin",
94 srcs = glob([
95 "tools/package/runtime/bin/*",
96 "tools/dev/bin/onos-create-app",
Ray Milkey15053f02018-06-13 10:00:45 -070097 "tools/test/bin/onos",
98 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070099 outs = ["onos-admin.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -0700100 cmd = "mkdir onos-admin-%s; cp $(SRCS) onos-admin-%s; tar hzcf $(location onos-admin.tar.gz) onos-admin-%s" %
Ray Milkey15053f02018-06-13 10:00:45 -0700101 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700102 output_to_bindir = True,
103)
104
105# Generates the onos-test.tar.gz file with test tools
106genrule(
107 name = "onos-package-test",
108 srcs = glob([
109 "tools/build/envDefaults",
110 "tools/dev/bash_profile",
111 "tools/dev/bin/onos-create-app",
112 "tools/test/**/*",
Ray Milkey15053f02018-06-13 10:00:45 -0700113 "tools/package/runtime/bin/*",
114 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700115 outs = ["onos-test.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -0700116 cmd = "mkdir onos-test-%s; cp -r tools onos-test-%s; tar hzcf $(location onos-test.tar.gz) onos-test-%s" %
Ray Milkey15053f02018-06-13 10:00:45 -0700117 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700118 output_to_bindir = True,
119)
120
121# Runs ONOS as a single instance from the /tmp directory
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700122alias(
Thomas Vachuska8e022a92018-07-10 14:47:38 -0700123 name = "onos-local",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700124 actual = select({
125 ":run_with_absolute_javabase": ":onos-local_absolute-javabase",
126 "//conditions:default": ":onos-local_current-jdk",
127 }),
128)
129
130config_setting(
131 name = "run_with_absolute_javabase",
132 define_values = {
133 "RUN_WITH_ABSOLUTE_JAVABASE": "true",
134 },
135)
136
137# Run onos-local with JAVA_HOME set to ABSOLUTE_JAVABASE (see .bazelrc)
138genrule(
139 name = "onos-local_absolute-javabase",
140 srcs = [":onos-local-base"],
141 outs = ["onos-runner_absolute-javabase"],
142 cmd = "sed \"s#ABSOLUTE_JAVABASE=#ABSOLUTE_JAVABASE=$(ABSOLUTE_JAVABASE)#\" " +
143 "$(location onos-local-base) > $(location onos-runner_absolute-javabase)",
144 executable = True,
145 output_to_bindir = True,
146 visibility = ["//visibility:private"],
147)
148
149# Run onos-local with the same JDK used for the build, packaged in a tarball.
150genrule(
151 name = "onos-local_current-jdk",
152 srcs = [
153 ":onos-local-base",
154 "//tools/build/jdk:current_jdk_tar",
155 ],
156 outs = ["onos-runner_current-jdk"],
157 cmd = "sed \"s#JDK_TAR=#JDK_TAR=$(location //tools/build/jdk:current_jdk_tar)#\" " +
158 "$(location :onos-local-base) > $(location onos-runner_current-jdk); ",
159 executable = True,
160 output_to_bindir = True,
161 visibility = ["//visibility:private"],
162)
163
164# Create an onos-runner script based on onos-run-karaf
165genrule(
166 name = "onos-local-base",
Ray Milkey2f380c72018-07-10 09:28:32 -0700167 srcs = [
168 ":onos-package",
169 "tools/package/onos-run-karaf",
Jian Lid486a732018-08-03 00:32:11 +0900170 ] + glob(["tools/package/config/**"]),
Thomas Vachuska510419f2018-06-28 17:05:09 -0700171 outs = ["onos-runner"],
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700172 cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " +
173 "$(location tools/package/onos-run-karaf) > $(location onos-runner); " +
Carmelo Cascone395b2312019-06-18 17:34:16 -0700174 "chmod +x $(location onos-runner)",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700175 visibility = ["//visibility:private"],
Thomas Vachuska510419f2018-06-28 17:05:09 -0700176)
Ray Milkey5063f5b2018-08-15 16:22:30 -0700177
178load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
179
180buildifier(
181 name = "buildifier_check",
Sean Condon6ea7b7b2020-01-23 09:31:18 +0000182 exclude_patterns = [
183 "./tools/build/bazel/generate_workspace.bzl",
184 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
185 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
186 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
187 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700188 mode = "check",
189)
190
191buildifier(
192 name = "buildifier_fix",
Sean Condon6ea7b7b2020-01-23 09:31:18 +0000193 exclude_patterns = [
194 "./tools/build/bazel/generate_workspace.bzl" +
195 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
196 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
197 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
198 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700199 mode = "fix",
200)