blob: 7bec64b351c2ac3efdb8dd4ee3ff5b41d3f1d319 [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",
pierventreaa5a3af2020-06-30 22:04:16 +020023 "tost",
Brian O'Connorca05e1f2020-01-07 11:28:46 -080024])
Thomas Vachuskaaab45d12018-06-05 16:39:46 -070025
Ray Milkey7dac7da2017-08-01 16:56:05 -070026filegroup(
27 name = "onos",
Brian O'Connorca05e1f2020-01-07 11:28:46 -080028 srcs = CORE + [
Thomas Vachuska5538d9e2018-08-14 09:59:35 -070029 "//tools/build/conf:onos-build-conf",
Ray Milkey15053f02018-06-13 10:00:45 -070030 ":onos-package-admin",
31 ":onos-package-test",
32 ":onos-package",
Brian O'Connorca05e1f2020-01-07 11:28:46 -080033 ] + select({
34 ":minimal_profile": extensions("minimal") + apps("minimal"),
35 ":seba_profile": extensions("seba") + apps("seba"),
36 ":stratum_profile": extensions("stratum") + apps("stratum"),
pierventreaa5a3af2020-06-30 22:04:16 +020037 ":tost_profile": extensions("tost") + apps("tost"),
Brian O'Connorca05e1f2020-01-07 11:28:46 -080038 "//conditions:default": extensions() + apps(),
39 }),
Thomas Vachuska0f956032018-06-12 10:41:12 -070040 visibility = ["//visibility:public"],
41)
42
Ray Milkeya8ac7e32018-09-04 15:52:14 -070043KARAF = "@apache_karaf//:apache_karaf"
Ray Milkey15053f02018-06-13 10:00:45 -070044
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070045BRANDING = "//tools/package/branding:onos-tools-package-branding"
46
Daniele Morocc41a942020-02-03 23:33:55 -080047LOG4J_EXTRA = "//tools/package/log4j2-extra:onos-log4j2-extra"
48
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070049# Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools
50genrule(
51 name = "onos-karaf",
Ray Milkey15053f02018-06-13 10:00:45 -070052 srcs = [
53 KARAF,
Ray Milkey15053f02018-06-13 10:00:45 -070054 BRANDING,
Daniele Morocc41a942020-02-03 23:33:55 -080055 LOG4J_EXTRA,
Ray Milkey15053f02018-06-13 10:00:45 -070056 ] + glob([
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070057 "tools/package/bin/*",
58 "tools/package/etc/*",
59 "tools/package/init/*",
Ray Milkey15053f02018-06-13 10:00:45 -070060 "tools/package/runtime/bin/*",
61 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070062 outs = ["karaf.zip"],
Daniele Morocc41a942020-02-03 23:33:55 -080063 cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) '' $(location %s) tools/package" %
64 (KARAF, ONOS_VERSION, BRANDING, LOG4J_EXTRA),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070065 tools = ["tools/package/onos-prep-karaf"],
66)
67
68# Generates the principal onos.tar.gz bundle
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070069genrule(
70 name = "onos-package",
Ray Milkey15053f02018-06-13 10:00:45 -070071 srcs = [
72 "//tools/package/features:onos-features",
73 ":onos-karaf",
Brian O'Connorca05e1f2020-01-07 11:28:46 -080074 ] + FEATURES + select({
75 ":minimal_profile": apps("minimal"),
76 ":seba_profile": apps("seba"),
77 ":stratum_profile": apps("stratum"),
pierventreaa5a3af2020-06-30 22:04:16 +020078 ":tost_profile": apps("tost"),
Brian O'Connorca05e1f2020-01-07 11:28:46 -080079 "//conditions:default": apps(),
80 }),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070081 outs = ["onos.tar.gz"],
82 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 -070083 output_to_bindir = True,
Thomas Vachuskae7433b82018-07-24 13:57:37 -070084 tags = ["local"],
Ray Milkey15053f02018-06-13 10:00:45 -070085 tools = ["tools/package/onos_stage.py"],
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070086)
87
88# Generates the onos-admin.tar.gz file with remote admin tools
89genrule(
90 name = "onos-package-admin",
91 srcs = glob([
92 "tools/package/runtime/bin/*",
93 "tools/dev/bin/onos-create-app",
Ray Milkey15053f02018-06-13 10:00:45 -070094 "tools/test/bin/onos",
95 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070096 outs = ["onos-admin.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -070097 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 -070098 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070099 output_to_bindir = True,
100)
101
102# Generates the onos-test.tar.gz file with test tools
103genrule(
104 name = "onos-package-test",
105 srcs = glob([
106 "tools/build/envDefaults",
107 "tools/dev/bash_profile",
108 "tools/dev/bin/onos-create-app",
109 "tools/test/**/*",
Ray Milkey15053f02018-06-13 10:00:45 -0700110 "tools/package/runtime/bin/*",
111 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700112 outs = ["onos-test.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -0700113 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 -0700114 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700115 output_to_bindir = True,
116)
117
118# Runs ONOS as a single instance from the /tmp directory
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700119alias(
Thomas Vachuska8e022a92018-07-10 14:47:38 -0700120 name = "onos-local",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700121 actual = select({
122 ":run_with_absolute_javabase": ":onos-local_absolute-javabase",
123 "//conditions:default": ":onos-local_current-jdk",
124 }),
125)
126
127config_setting(
128 name = "run_with_absolute_javabase",
129 define_values = {
130 "RUN_WITH_ABSOLUTE_JAVABASE": "true",
131 },
132)
133
134# Run onos-local with JAVA_HOME set to ABSOLUTE_JAVABASE (see .bazelrc)
135genrule(
136 name = "onos-local_absolute-javabase",
137 srcs = [":onos-local-base"],
138 outs = ["onos-runner_absolute-javabase"],
139 cmd = "sed \"s#ABSOLUTE_JAVABASE=#ABSOLUTE_JAVABASE=$(ABSOLUTE_JAVABASE)#\" " +
140 "$(location onos-local-base) > $(location onos-runner_absolute-javabase)",
141 executable = True,
142 output_to_bindir = True,
143 visibility = ["//visibility:private"],
144)
145
146# Run onos-local with the same JDK used for the build, packaged in a tarball.
147genrule(
148 name = "onos-local_current-jdk",
149 srcs = [
150 ":onos-local-base",
151 "//tools/build/jdk:current_jdk_tar",
152 ],
153 outs = ["onos-runner_current-jdk"],
154 cmd = "sed \"s#JDK_TAR=#JDK_TAR=$(location //tools/build/jdk:current_jdk_tar)#\" " +
155 "$(location :onos-local-base) > $(location onos-runner_current-jdk); ",
156 executable = True,
157 output_to_bindir = True,
158 visibility = ["//visibility:private"],
159)
160
161# Create an onos-runner script based on onos-run-karaf
162genrule(
163 name = "onos-local-base",
Ray Milkey2f380c72018-07-10 09:28:32 -0700164 srcs = [
165 ":onos-package",
166 "tools/package/onos-run-karaf",
Jian Lid486a732018-08-03 00:32:11 +0900167 ] + glob(["tools/package/config/**"]),
Thomas Vachuska510419f2018-06-28 17:05:09 -0700168 outs = ["onos-runner"],
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700169 cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " +
170 "$(location tools/package/onos-run-karaf) > $(location onos-runner); " +
Carmelo Cascone395b2312019-06-18 17:34:16 -0700171 "chmod +x $(location onos-runner)",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700172 visibility = ["//visibility:private"],
Thomas Vachuska510419f2018-06-28 17:05:09 -0700173)
Ray Milkey5063f5b2018-08-15 16:22:30 -0700174
175load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
176
177buildifier(
178 name = "buildifier_check",
Sean Condondfc6dba2019-11-09 11:50:23 +0000179 exclude_patterns = [
180 "./tools/build/bazel/generate_workspace.bzl",
Sean Condon98b6ddb2019-12-24 08:07:40 +0000181 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
182 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
183 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
Sean Condondfc6dba2019-11-09 11:50:23 +0000184 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700185 mode = "check",
186)
187
188buildifier(
189 name = "buildifier_fix",
Sean Condondfc6dba2019-11-09 11:50:23 +0000190 exclude_patterns = [
191 "./tools/build/bazel/generate_workspace.bzl",
Sean Condon98b6ddb2019-12-24 08:07:40 +0000192 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
193 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
194 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
Sean Condondfc6dba2019-11-09 11:50:23 +0000195 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700196 mode = "fix",
197)