blob: 58895947fa11d03e1b193fcf824fe44d0df684d8 [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
19# Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools
20genrule(
21 name = "onos-karaf",
Ray Milkey15053f02018-06-13 10:00:45 -070022 srcs = [
23 KARAF,
Ray Milkey15053f02018-06-13 10:00:45 -070024 BRANDING,
25 ] + glob([
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070026 "tools/package/bin/*",
27 "tools/package/etc/*",
28 "tools/package/init/*",
Ray Milkey15053f02018-06-13 10:00:45 -070029 "tools/package/runtime/bin/*",
30 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070031 outs = ["karaf.zip"],
Ray Milkey3f274d92018-09-28 14:23:34 -070032 cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) '' tools/package" %
33 (KARAF, ONOS_VERSION, BRANDING),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070034 tools = ["tools/package/onos-prep-karaf"],
35)
36
37# Generates the principal onos.tar.gz bundle
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070038genrule(
39 name = "onos-package",
Ray Milkey15053f02018-06-13 10:00:45 -070040 srcs = [
41 "//tools/package/features:onos-features",
42 ":onos-karaf",
Thomas Vachuska1ae26c62018-07-09 13:40:16 -070043 ] + APPS + FEATURES,
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070044 outs = ["onos.tar.gz"],
45 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 -070046 output_to_bindir = True,
Thomas Vachuskae7433b82018-07-24 13:57:37 -070047 tags = ["local"],
Ray Milkey15053f02018-06-13 10:00:45 -070048 tools = ["tools/package/onos_stage.py"],
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070049)
50
Thomas Vachuska1e3ed802019-02-01 14:51:30 -080051# Generates the minimal onos-minimal.tar.gz bundle
52genrule(
53 name = "onos-package-minimal",
54 srcs = [
55 "//tools/package/features:onos-features",
56 ":onos-karaf",
57 "//drivers/default:onos-drivers-default-oar",
58 ] + FEATURES,
59 outs = ["onos-minimal.tar.gz"],
60 cmd = "$(location tools/package/onos_stage.py) $(location onos-minimal.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
61 output_to_bindir = True,
62 tags = ["local"],
63 tools = ["tools/package/onos_stage.py"],
64)
65
66# Generates SEBA-specific onos-seba.tar.gz bundle
67genrule(
68 name = "onos-package-seba",
69 srcs = [
70 "//tools/package/features:onos-features",
71 ":onos-karaf",
72 "//drivers/default:onos-drivers-default-oar",
73 "//apps/optical-model:onos-apps-optical-model-oar",
74 "//providers/openflow/app:onos-providers-openflow-app-oar",
75 "//providers/openflow/base:onos-providers-openflow-base-oar",
76 "//providers/host:onos-providers-host-oar",
77 "//providers/lldp:onos-providers-lldp-oar",
78 "//apps/mcast:onos-apps-mcast-oar",
79 "//providers/netcfghost:onos-providers-netcfghost-oar",
80 "//apps/segmentrouting:onos-apps-segmentrouting-oar",
81 "//apps/route-service:onos-apps-route-service-oar",
82 ] + FEATURES,
83 outs = ["onos-seba.tar.gz"],
84 cmd = "$(location tools/package/onos_stage.py) $(location onos-seba.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
85 output_to_bindir = True,
86 tags = ["local"],
87 tools = ["tools/package/onos_stage.py"],
88)
89
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070090# Generates the onos-admin.tar.gz file with remote admin tools
91genrule(
92 name = "onos-package-admin",
93 srcs = glob([
94 "tools/package/runtime/bin/*",
95 "tools/dev/bin/onos-create-app",
Ray Milkey15053f02018-06-13 10:00:45 -070096 "tools/test/bin/onos",
97 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070098 outs = ["onos-admin.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -070099 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 -0700100 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700101 output_to_bindir = True,
102)
103
104# Generates the onos-test.tar.gz file with test tools
105genrule(
106 name = "onos-package-test",
107 srcs = glob([
108 "tools/build/envDefaults",
109 "tools/dev/bash_profile",
110 "tools/dev/bin/onos-create-app",
111 "tools/test/**/*",
Ray Milkey15053f02018-06-13 10:00:45 -0700112 "tools/package/runtime/bin/*",
113 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700114 outs = ["onos-test.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -0700115 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 -0700116 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -0700117 output_to_bindir = True,
118)
119
120# Runs ONOS as a single instance from the /tmp directory
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700121alias(
Thomas Vachuska8e022a92018-07-10 14:47:38 -0700122 name = "onos-local",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700123 actual = select({
124 ":run_with_absolute_javabase": ":onos-local_absolute-javabase",
125 "//conditions:default": ":onos-local_current-jdk",
126 }),
127)
128
129config_setting(
130 name = "run_with_absolute_javabase",
131 define_values = {
132 "RUN_WITH_ABSOLUTE_JAVABASE": "true",
133 },
134)
135
136# Run onos-local with JAVA_HOME set to ABSOLUTE_JAVABASE (see .bazelrc)
137genrule(
138 name = "onos-local_absolute-javabase",
139 srcs = [":onos-local-base"],
140 outs = ["onos-runner_absolute-javabase"],
141 cmd = "sed \"s#ABSOLUTE_JAVABASE=#ABSOLUTE_JAVABASE=$(ABSOLUTE_JAVABASE)#\" " +
142 "$(location onos-local-base) > $(location onos-runner_absolute-javabase)",
143 executable = True,
144 output_to_bindir = True,
145 visibility = ["//visibility:private"],
146)
147
148# Run onos-local with the same JDK used for the build, packaged in a tarball.
149genrule(
150 name = "onos-local_current-jdk",
151 srcs = [
152 ":onos-local-base",
153 "//tools/build/jdk:current_jdk_tar",
154 ],
155 outs = ["onos-runner_current-jdk"],
156 cmd = "sed \"s#JDK_TAR=#JDK_TAR=$(location //tools/build/jdk:current_jdk_tar)#\" " +
157 "$(location :onos-local-base) > $(location onos-runner_current-jdk); ",
158 executable = True,
159 output_to_bindir = True,
160 visibility = ["//visibility:private"],
161)
162
163# Create an onos-runner script based on onos-run-karaf
164genrule(
165 name = "onos-local-base",
Ray Milkey2f380c72018-07-10 09:28:32 -0700166 srcs = [
167 ":onos-package",
168 "tools/package/onos-run-karaf",
Jian Lid486a732018-08-03 00:32:11 +0900169 ] + glob(["tools/package/config/**"]),
Thomas Vachuska510419f2018-06-28 17:05:09 -0700170 outs = ["onos-runner"],
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700171 cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " +
172 "$(location tools/package/onos-run-karaf) > $(location onos-runner); " +
Carmelo Cascone395b2312019-06-18 17:34:16 -0700173 "chmod +x $(location onos-runner)",
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -0700174 visibility = ["//visibility:private"],
Thomas Vachuska510419f2018-06-28 17:05:09 -0700175)
Ray Milkey5063f5b2018-08-15 16:22:30 -0700176
177load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
178
179buildifier(
180 name = "buildifier_check",
Sean Condon6ea7b7b2020-01-23 09:31:18 +0000181 exclude_patterns = [
182 "./tools/build/bazel/generate_workspace.bzl",
183 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
184 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
185 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
186 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700187 mode = "check",
188)
189
190buildifier(
191 name = "buildifier_fix",
Sean Condon6ea7b7b2020-01-23 09:31:18 +0000192 exclude_patterns = [
193 "./tools/build/bazel/generate_workspace.bzl" +
194 "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl",
195 "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl",
196 "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl",
197 ],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700198 mode = "fix",
199)