blob: 02c1b1dc3877a0e670a9d372f57f6e43f45bb84c [file] [log] [blame]
Thomas Vachuskae17756d2018-10-31 15:23:55 -07001load("//tools/build/bazel:variables.bzl", "ONOS_VERSION")
Ray Milkey5a520c72018-11-01 10:35:06 -07002load("//tools/build/bazel:modules.bzl", "APPS", "CORE", "FEATURES")
Thomas Vachuskaaab45d12018-06-05 16:39:46 -07003
Ray Milkey7dac7da2017-08-01 16:56:05 -07004filegroup(
5 name = "onos",
Thomas Vachuskaf5d17202018-06-12 17:28:13 -07006 srcs = CORE + APPS + [
Thomas Vachuska5538d9e2018-08-14 09:59:35 -07007 "//tools/build/conf:onos-build-conf",
Ray Milkey15053f02018-06-13 10:00:45 -07008 ":onos-package-admin",
9 ":onos-package-test",
10 ":onos-package",
11 ],
Thomas Vachuska0f956032018-06-12 10:41:12 -070012 visibility = ["//visibility:public"],
13)
14
Ray Milkeya8ac7e32018-09-04 15:52:14 -070015KARAF = "@apache_karaf//:apache_karaf"
Ray Milkey15053f02018-06-13 10:00:45 -070016
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070017BRANDING = "//tools/package/branding:onos-tools-package-branding"
18
Daniele Moro27527592020-02-03 23:33:55 -080019LOG4J_EXTRA = "//tools/package/log4j2-extra:onos-log4j2-extra"
20
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070021# Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools
22genrule(
23 name = "onos-karaf",
Ray Milkey15053f02018-06-13 10:00:45 -070024 srcs = [
25 KARAF,
Ray Milkey15053f02018-06-13 10:00:45 -070026 BRANDING,
Daniele Moro27527592020-02-03 23:33:55 -080027 LOG4J_EXTRA,
Ray Milkey15053f02018-06-13 10:00:45 -070028 ] + glob([
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070029 "tools/package/bin/*",
30 "tools/package/etc/*",
31 "tools/package/init/*",
Ray Milkey15053f02018-06-13 10:00:45 -070032 "tools/package/runtime/bin/*",
33 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070034 outs = ["karaf.zip"],
Daniele Moro27527592020-02-03 23:33:55 -080035 cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) '' $(location %s) tools/package" %
36 (KARAF, ONOS_VERSION, BRANDING, LOG4J_EXTRA),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070037 tools = ["tools/package/onos-prep-karaf"],
38)
39
40# Generates the principal onos.tar.gz bundle
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070041genrule(
42 name = "onos-package",
Ray Milkey15053f02018-06-13 10:00:45 -070043 srcs = [
44 "//tools/package/features:onos-features",
45 ":onos-karaf",
Thomas Vachuska1ae26c62018-07-09 13:40:16 -070046 ] + APPS + FEATURES,
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070047 outs = ["onos.tar.gz"],
48 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 -070049 output_to_bindir = True,
Thomas Vachuskae7433b82018-07-24 13:57:37 -070050 tags = ["local"],
Ray Milkey15053f02018-06-13 10:00:45 -070051 tools = ["tools/package/onos_stage.py"],
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070052)
53
Thomas Vachuska1e3ed802019-02-01 14:51:30 -080054# Generates the minimal onos-minimal.tar.gz bundle
55genrule(
56 name = "onos-package-minimal",
57 srcs = [
58 "//tools/package/features:onos-features",
59 ":onos-karaf",
60 "//drivers/default:onos-drivers-default-oar",
61 ] + FEATURES,
62 outs = ["onos-minimal.tar.gz"],
63 cmd = "$(location tools/package/onos_stage.py) $(location onos-minimal.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
64 output_to_bindir = True,
65 tags = ["local"],
66 tools = ["tools/package/onos_stage.py"],
67)
68
69# Generates SEBA-specific onos-seba.tar.gz bundle
70genrule(
71 name = "onos-package-seba",
72 srcs = [
73 "//tools/package/features:onos-features",
74 ":onos-karaf",
75 "//drivers/default:onos-drivers-default-oar",
76 "//apps/optical-model:onos-apps-optical-model-oar",
77 "//providers/openflow/app:onos-providers-openflow-app-oar",
78 "//providers/openflow/base:onos-providers-openflow-base-oar",
79 "//providers/host:onos-providers-host-oar",
80 "//providers/lldp:onos-providers-lldp-oar",
81 "//apps/mcast:onos-apps-mcast-oar",
82 "//providers/netcfghost:onos-providers-netcfghost-oar",
83 "//apps/segmentrouting:onos-apps-segmentrouting-oar",
84 "//apps/route-service:onos-apps-route-service-oar",
85 ] + FEATURES,
86 outs = ["onos-seba.tar.gz"],
87 cmd = "$(location tools/package/onos_stage.py) $(location onos-seba.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
88 output_to_bindir = True,
89 tags = ["local"],
90 tools = ["tools/package/onos_stage.py"],
91)
92
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070093# Generates the onos-admin.tar.gz file with remote admin tools
94genrule(
95 name = "onos-package-admin",
96 srcs = glob([
97 "tools/package/runtime/bin/*",
98 "tools/dev/bin/onos-create-app",
Ray Milkey15053f02018-06-13 10:00:45 -070099 "tools/test/bin/onos",
100 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700101 outs = ["onos-admin.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -0700102 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 -0700103 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700104 output_to_bindir = True,
105)
106
107# Generates the onos-test.tar.gz file with test tools
108genrule(
109 name = "onos-package-test",
110 srcs = glob([
111 "tools/build/envDefaults",
112 "tools/dev/bash_profile",
113 "tools/dev/bin/onos-create-app",
114 "tools/test/**/*",
Ray Milkey15053f02018-06-13 10:00:45 -0700115 "tools/package/runtime/bin/*",
116 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700117 outs = ["onos-test.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -0700118 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 -0700119 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700120 output_to_bindir = True,
121)
122
123# Runs ONOS as a single instance from the /tmp directory
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700124alias(
Thomas Vachuska8e022a92018-07-10 14:47:38 -0700125 name = "onos-local",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700126 actual = select({
127 ":run_with_absolute_javabase": ":onos-local_absolute-javabase",
128 "//conditions:default": ":onos-local_current-jdk",
129 }),
130)
131
132config_setting(
133 name = "run_with_absolute_javabase",
134 define_values = {
135 "RUN_WITH_ABSOLUTE_JAVABASE": "true",
136 },
137)
138
139# Run onos-local with JAVA_HOME set to ABSOLUTE_JAVABASE (see .bazelrc)
140genrule(
141 name = "onos-local_absolute-javabase",
142 srcs = [":onos-local-base"],
143 outs = ["onos-runner_absolute-javabase"],
144 cmd = "sed \"s#ABSOLUTE_JAVABASE=#ABSOLUTE_JAVABASE=$(ABSOLUTE_JAVABASE)#\" " +
145 "$(location onos-local-base) > $(location onos-runner_absolute-javabase)",
146 executable = True,
147 output_to_bindir = True,
148 visibility = ["//visibility:private"],
149)
150
151# Run onos-local with the same JDK used for the build, packaged in a tarball.
152genrule(
153 name = "onos-local_current-jdk",
154 srcs = [
155 ":onos-local-base",
156 "//tools/build/jdk:current_jdk_tar",
157 ],
158 outs = ["onos-runner_current-jdk"],
159 cmd = "sed \"s#JDK_TAR=#JDK_TAR=$(location //tools/build/jdk:current_jdk_tar)#\" " +
160 "$(location :onos-local-base) > $(location onos-runner_current-jdk); ",
161 executable = True,
162 output_to_bindir = True,
163 visibility = ["//visibility:private"],
164)
165
166# Create an onos-runner script based on onos-run-karaf
167genrule(
168 name = "onos-local-base",
Ray Milkey2f380c72018-07-10 09:28:32 -0700169 srcs = [
170 ":onos-package",
171 "tools/package/onos-run-karaf",
Jian Lid486a732018-08-03 00:32:11 +0900172 ] + glob(["tools/package/config/**"]),
Thomas Vachuska510419f2018-06-28 17:05:09 -0700173 outs = ["onos-runner"],
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700174 cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " +
175 "$(location tools/package/onos-run-karaf) > $(location onos-runner); " +
Carmelo Cascone395b2312019-06-18 17:34:16 -0700176 "chmod +x $(location onos-runner)",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700177 visibility = ["//visibility:private"],
Thomas Vachuska510419f2018-06-28 17:05:09 -0700178)
Ray Milkey5063f5b2018-08-15 16:22:30 -0700179
180load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
181
182buildifier(
183 name = "buildifier_check",
Sean Condon6ea7b7b2020-01-23 09:31:18 +0000184 exclude_patterns = [
185 "./tools/build/bazel/generate_workspace.bzl",
186 "./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",
189 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700190 mode = "check",
191)
192
193buildifier(
194 name = "buildifier_fix",
Sean Condon6ea7b7b2020-01-23 09:31:18 +0000195 exclude_patterns = [
196 "./tools/build/bazel/generate_workspace.bzl" +
197 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
198 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
199 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
200 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700201 mode = "fix",
202)