blob: 626eeee34513ecad26e745e9d59dcadb0ab11151 [file] [log] [blame]
Thomas Vachuskae17756d2018-10-31 15:23:55 -07001load("//tools/build/bazel:variables.bzl", "ONOS_VERSION")
Brian O'Connorca05e1f2020-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",
23])
Thomas Vachuskaaab45d12018-06-05 16:39:46 -070024
Ray Milkey7dac7da2017-08-01 16:56:05 -070025filegroup(
26 name = "onos",
Brian O'Connorca05e1f2020-01-07 11:28:46 -080027 srcs = CORE + [
Thomas Vachuska5538d9e2018-08-14 09:59:35 -070028 "//tools/build/conf:onos-build-conf",
Ray Milkey15053f02018-06-13 10:00:45 -070029 ":onos-package-admin",
30 ":onos-package-test",
31 ":onos-package",
Brian O'Connorca05e1f2020-01-07 11:28:46 -080032 ] + select({
33 ":minimal_profile": extensions("minimal") + apps("minimal"),
34 ":seba_profile": extensions("seba") + apps("seba"),
35 ":stratum_profile": extensions("stratum") + apps("stratum"),
36 "//conditions:default": extensions() + apps(),
37 }),
Thomas Vachuska0f956032018-06-12 10:41:12 -070038 visibility = ["//visibility:public"],
39)
40
Ray Milkeya8ac7e32018-09-04 15:52:14 -070041KARAF = "@apache_karaf//:apache_karaf"
Ray Milkey15053f02018-06-13 10:00:45 -070042
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070043BRANDING = "//tools/package/branding:onos-tools-package-branding"
44
Daniele Morocc41a942020-02-03 23:33:55 -080045LOG4J_EXTRA = "//tools/package/log4j2-extra:onos-log4j2-extra"
46
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070047# Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools
48genrule(
49 name = "onos-karaf",
Ray Milkey15053f02018-06-13 10:00:45 -070050 srcs = [
51 KARAF,
Ray Milkey15053f02018-06-13 10:00:45 -070052 BRANDING,
Daniele Morocc41a942020-02-03 23:33:55 -080053 LOG4J_EXTRA,
Ray Milkey15053f02018-06-13 10:00:45 -070054 ] + glob([
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070055 "tools/package/bin/*",
56 "tools/package/etc/*",
57 "tools/package/init/*",
Ray Milkey15053f02018-06-13 10:00:45 -070058 "tools/package/runtime/bin/*",
59 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070060 outs = ["karaf.zip"],
Daniele Morocc41a942020-02-03 23:33:55 -080061 cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) '' $(location %s) tools/package" %
62 (KARAF, ONOS_VERSION, BRANDING, LOG4J_EXTRA),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070063 tools = ["tools/package/onos-prep-karaf"],
64)
65
66# Generates the principal onos.tar.gz bundle
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070067genrule(
68 name = "onos-package",
Ray Milkey15053f02018-06-13 10:00:45 -070069 srcs = [
70 "//tools/package/features:onos-features",
71 ":onos-karaf",
Brian O'Connorca05e1f2020-01-07 11:28:46 -080072 ] + FEATURES + select({
73 ":minimal_profile": apps("minimal"),
74 ":seba_profile": apps("seba"),
75 ":stratum_profile": apps("stratum"),
76 "//conditions:default": apps(),
77 }),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070078 outs = ["onos.tar.gz"],
79 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 -070080 output_to_bindir = True,
Thomas Vachuskae7433b82018-07-24 13:57:37 -070081 tags = ["local"],
Ray Milkey15053f02018-06-13 10:00:45 -070082 tools = ["tools/package/onos_stage.py"],
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070083)
84
85# Generates the onos-admin.tar.gz file with remote admin tools
86genrule(
87 name = "onos-package-admin",
88 srcs = glob([
89 "tools/package/runtime/bin/*",
90 "tools/dev/bin/onos-create-app",
Ray Milkey15053f02018-06-13 10:00:45 -070091 "tools/test/bin/onos",
92 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070093 outs = ["onos-admin.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -070094 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 -070095 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070096 output_to_bindir = True,
97)
98
99# Generates the onos-test.tar.gz file with test tools
100genrule(
101 name = "onos-package-test",
102 srcs = glob([
103 "tools/build/envDefaults",
104 "tools/dev/bash_profile",
105 "tools/dev/bin/onos-create-app",
106 "tools/test/**/*",
Ray Milkey15053f02018-06-13 10:00:45 -0700107 "tools/package/runtime/bin/*",
108 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700109 outs = ["onos-test.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -0700110 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 -0700111 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700112 output_to_bindir = True,
113)
114
115# Runs ONOS as a single instance from the /tmp directory
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700116alias(
Thomas Vachuska8e022a92018-07-10 14:47:38 -0700117 name = "onos-local",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700118 actual = select({
119 ":run_with_absolute_javabase": ":onos-local_absolute-javabase",
120 "//conditions:default": ":onos-local_current-jdk",
121 }),
122)
123
124config_setting(
125 name = "run_with_absolute_javabase",
126 define_values = {
127 "RUN_WITH_ABSOLUTE_JAVABASE": "true",
128 },
129)
130
131# Run onos-local with JAVA_HOME set to ABSOLUTE_JAVABASE (see .bazelrc)
132genrule(
133 name = "onos-local_absolute-javabase",
134 srcs = [":onos-local-base"],
135 outs = ["onos-runner_absolute-javabase"],
136 cmd = "sed \"s#ABSOLUTE_JAVABASE=#ABSOLUTE_JAVABASE=$(ABSOLUTE_JAVABASE)#\" " +
137 "$(location onos-local-base) > $(location onos-runner_absolute-javabase)",
138 executable = True,
139 output_to_bindir = True,
140 visibility = ["//visibility:private"],
141)
142
143# Run onos-local with the same JDK used for the build, packaged in a tarball.
144genrule(
145 name = "onos-local_current-jdk",
146 srcs = [
147 ":onos-local-base",
148 "//tools/build/jdk:current_jdk_tar",
149 ],
150 outs = ["onos-runner_current-jdk"],
151 cmd = "sed \"s#JDK_TAR=#JDK_TAR=$(location //tools/build/jdk:current_jdk_tar)#\" " +
152 "$(location :onos-local-base) > $(location onos-runner_current-jdk); ",
153 executable = True,
154 output_to_bindir = True,
155 visibility = ["//visibility:private"],
156)
157
158# Create an onos-runner script based on onos-run-karaf
159genrule(
160 name = "onos-local-base",
Ray Milkey2f380c72018-07-10 09:28:32 -0700161 srcs = [
162 ":onos-package",
163 "tools/package/onos-run-karaf",
Jian Lid486a732018-08-03 00:32:11 +0900164 ] + glob(["tools/package/config/**"]),
Thomas Vachuska510419f2018-06-28 17:05:09 -0700165 outs = ["onos-runner"],
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700166 cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " +
167 "$(location tools/package/onos-run-karaf) > $(location onos-runner); " +
Carmelo Cascone395b2312019-06-18 17:34:16 -0700168 "chmod +x $(location onos-runner)",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700169 visibility = ["//visibility:private"],
Thomas Vachuska510419f2018-06-28 17:05:09 -0700170)
Ray Milkey5063f5b2018-08-15 16:22:30 -0700171
172load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
173
174buildifier(
175 name = "buildifier_check",
Sean Condondfc6dba2019-11-09 11:50:23 +0000176 exclude_patterns = [
177 "./tools/build/bazel/generate_workspace.bzl",
Sean Condon98b6ddb2019-12-24 08:07:40 +0000178 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
179 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
180 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
Sean Condondfc6dba2019-11-09 11:50:23 +0000181 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700182 mode = "check",
183)
184
185buildifier(
186 name = "buildifier_fix",
Sean Condondfc6dba2019-11-09 11:50:23 +0000187 exclude_patterns = [
188 "./tools/build/bazel/generate_workspace.bzl",
Sean Condon98b6ddb2019-12-24 08:07:40 +0000189 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
190 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
191 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
Sean Condondfc6dba2019-11-09 11:50:23 +0000192 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700193 mode = "fix",
194)