blob: a4f56885a63f370a289e2cd05e7d62faac30baea [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
45# Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools
46genrule(
47 name = "onos-karaf",
Ray Milkey15053f02018-06-13 10:00:45 -070048 srcs = [
49 KARAF,
Ray Milkey15053f02018-06-13 10:00:45 -070050 BRANDING,
51 ] + glob([
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070052 "tools/package/bin/*",
53 "tools/package/etc/*",
54 "tools/package/init/*",
Ray Milkey15053f02018-06-13 10:00:45 -070055 "tools/package/runtime/bin/*",
56 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070057 outs = ["karaf.zip"],
Ray Milkey3f274d92018-09-28 14:23:34 -070058 cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) '' tools/package" %
59 (KARAF, ONOS_VERSION, BRANDING),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070060 tools = ["tools/package/onos-prep-karaf"],
61)
62
63# Generates the principal onos.tar.gz bundle
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070064genrule(
65 name = "onos-package",
Ray Milkey15053f02018-06-13 10:00:45 -070066 srcs = [
67 "//tools/package/features:onos-features",
68 ":onos-karaf",
Brian O'Connorca05e1f2020-01-07 11:28:46 -080069 ] + FEATURES + select({
70 ":minimal_profile": apps("minimal"),
71 ":seba_profile": apps("seba"),
72 ":stratum_profile": apps("stratum"),
73 "//conditions:default": apps(),
74 }),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070075 outs = ["onos.tar.gz"],
76 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 -070077 output_to_bindir = True,
Thomas Vachuskae7433b82018-07-24 13:57:37 -070078 tags = ["local"],
Ray Milkey15053f02018-06-13 10:00:45 -070079 tools = ["tools/package/onos_stage.py"],
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070080)
81
82# Generates the onos-admin.tar.gz file with remote admin tools
83genrule(
84 name = "onos-package-admin",
85 srcs = glob([
86 "tools/package/runtime/bin/*",
87 "tools/dev/bin/onos-create-app",
Ray Milkey15053f02018-06-13 10:00:45 -070088 "tools/test/bin/onos",
89 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070090 outs = ["onos-admin.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -070091 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 -070092 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070093 output_to_bindir = True,
94)
95
96# Generates the onos-test.tar.gz file with test tools
97genrule(
98 name = "onos-package-test",
99 srcs = glob([
100 "tools/build/envDefaults",
101 "tools/dev/bash_profile",
102 "tools/dev/bin/onos-create-app",
103 "tools/test/**/*",
Ray Milkey15053f02018-06-13 10:00:45 -0700104 "tools/package/runtime/bin/*",
105 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700106 outs = ["onos-test.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -0700107 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 -0700108 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700109 output_to_bindir = True,
110)
111
112# Runs ONOS as a single instance from the /tmp directory
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700113alias(
Thomas Vachuska8e022a92018-07-10 14:47:38 -0700114 name = "onos-local",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700115 actual = select({
116 ":run_with_absolute_javabase": ":onos-local_absolute-javabase",
117 "//conditions:default": ":onos-local_current-jdk",
118 }),
119)
120
121config_setting(
122 name = "run_with_absolute_javabase",
123 define_values = {
124 "RUN_WITH_ABSOLUTE_JAVABASE": "true",
125 },
126)
127
128# Run onos-local with JAVA_HOME set to ABSOLUTE_JAVABASE (see .bazelrc)
129genrule(
130 name = "onos-local_absolute-javabase",
131 srcs = [":onos-local-base"],
132 outs = ["onos-runner_absolute-javabase"],
133 cmd = "sed \"s#ABSOLUTE_JAVABASE=#ABSOLUTE_JAVABASE=$(ABSOLUTE_JAVABASE)#\" " +
134 "$(location onos-local-base) > $(location onos-runner_absolute-javabase)",
135 executable = True,
136 output_to_bindir = True,
137 visibility = ["//visibility:private"],
138)
139
140# Run onos-local with the same JDK used for the build, packaged in a tarball.
141genrule(
142 name = "onos-local_current-jdk",
143 srcs = [
144 ":onos-local-base",
145 "//tools/build/jdk:current_jdk_tar",
146 ],
147 outs = ["onos-runner_current-jdk"],
148 cmd = "sed \"s#JDK_TAR=#JDK_TAR=$(location //tools/build/jdk:current_jdk_tar)#\" " +
149 "$(location :onos-local-base) > $(location onos-runner_current-jdk); ",
150 executable = True,
151 output_to_bindir = True,
152 visibility = ["//visibility:private"],
153)
154
155# Create an onos-runner script based on onos-run-karaf
156genrule(
157 name = "onos-local-base",
Ray Milkey2f380c72018-07-10 09:28:32 -0700158 srcs = [
159 ":onos-package",
160 "tools/package/onos-run-karaf",
Jian Lid486a732018-08-03 00:32:11 +0900161 ] + glob(["tools/package/config/**"]),
Thomas Vachuska510419f2018-06-28 17:05:09 -0700162 outs = ["onos-runner"],
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700163 cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " +
164 "$(location tools/package/onos-run-karaf) > $(location onos-runner); " +
Carmelo Cascone395b2312019-06-18 17:34:16 -0700165 "chmod +x $(location onos-runner)",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700166 visibility = ["//visibility:private"],
Thomas Vachuska510419f2018-06-28 17:05:09 -0700167)
Ray Milkey5063f5b2018-08-15 16:22:30 -0700168
169load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
170
171buildifier(
172 name = "buildifier_check",
Sean Condondfc6dba2019-11-09 11:50:23 +0000173 exclude_patterns = [
174 "./tools/build/bazel/generate_workspace.bzl",
Sean Condon98b6ddb2019-12-24 08:07:40 +0000175 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
176 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
177 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
Sean Condondfc6dba2019-11-09 11:50:23 +0000178 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700179 mode = "check",
180)
181
182buildifier(
183 name = "buildifier_fix",
Sean Condondfc6dba2019-11-09 11:50:23 +0000184 exclude_patterns = [
185 "./tools/build/bazel/generate_workspace.bzl",
Sean Condon98b6ddb2019-12-24 08:07:40 +0000186 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
187 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
188 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
Sean Condondfc6dba2019-11-09 11:50:23 +0000189 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700190 mode = "fix",
191)