Thomas Vachuska | e17756d | 2018-10-31 15:23:55 -0700 | [diff] [blame] | 1 | load("//tools/build/bazel:variables.bzl", "ONOS_VERSION") |
Ray Milkey | 5a520c7 | 2018-11-01 10:35:06 -0700 | [diff] [blame] | 2 | load("//tools/build/bazel:modules.bzl", "APPS", "CORE", "FEATURES") |
Thomas Vachuska | aab45d1 | 2018-06-05 16:39:46 -0700 | [diff] [blame] | 3 | |
Ray Milkey | 7dac7da | 2017-08-01 16:56:05 -0700 | [diff] [blame] | 4 | filegroup( |
| 5 | name = "onos", |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 6 | srcs = CORE + APPS + [ |
Thomas Vachuska | 5538d9e | 2018-08-14 09:59:35 -0700 | [diff] [blame] | 7 | "//tools/build/conf:onos-build-conf", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 8 | ":onos-package-admin", |
| 9 | ":onos-package-test", |
| 10 | ":onos-package", |
| 11 | ], |
Thomas Vachuska | 0f95603 | 2018-06-12 10:41:12 -0700 | [diff] [blame] | 12 | visibility = ["//visibility:public"], |
| 13 | ) |
| 14 | |
Ray Milkey | a8ac7e3 | 2018-09-04 15:52:14 -0700 | [diff] [blame] | 15 | KARAF = "@apache_karaf//:apache_karaf" |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 16 | |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 17 | BRANDING = "//tools/package/branding:onos-tools-package-branding" |
| 18 | |
Daniele Moro | 2752759 | 2020-02-03 23:33:55 -0800 | [diff] [blame] | 19 | LOG4J_EXTRA = "//tools/package/log4j2-extra:onos-log4j2-extra" |
| 20 | |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 21 | # Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools |
| 22 | genrule( |
| 23 | name = "onos-karaf", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 24 | srcs = [ |
| 25 | KARAF, |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 26 | BRANDING, |
Daniele Moro | 2752759 | 2020-02-03 23:33:55 -0800 | [diff] [blame] | 27 | LOG4J_EXTRA, |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 28 | ] + glob([ |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 29 | "tools/package/bin/*", |
| 30 | "tools/package/etc/*", |
| 31 | "tools/package/init/*", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 32 | "tools/package/runtime/bin/*", |
| 33 | ]), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 34 | outs = ["karaf.zip"], |
Daniele Moro | 2752759 | 2020-02-03 23:33:55 -0800 | [diff] [blame] | 35 | 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 Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 37 | tools = ["tools/package/onos-prep-karaf"], |
| 38 | ) |
| 39 | |
| 40 | # Generates the principal onos.tar.gz bundle |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 41 | genrule( |
| 42 | name = "onos-package", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 43 | srcs = [ |
| 44 | "//tools/package/features:onos-features", |
| 45 | ":onos-karaf", |
Thomas Vachuska | 1ae26c6 | 2018-07-09 13:40:16 -0700 | [diff] [blame] | 46 | ] + APPS + FEATURES, |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 47 | outs = ["onos.tar.gz"], |
| 48 | cmd = "$(location tools/package/onos_stage.py) $(location onos.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION, |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 49 | output_to_bindir = True, |
Thomas Vachuska | e7433b8 | 2018-07-24 13:57:37 -0700 | [diff] [blame] | 50 | tags = ["local"], |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 51 | tools = ["tools/package/onos_stage.py"], |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 52 | ) |
| 53 | |
Thomas Vachuska | 1e3ed80 | 2019-02-01 14:51:30 -0800 | [diff] [blame] | 54 | # Generates the minimal onos-minimal.tar.gz bundle |
| 55 | genrule( |
| 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 |
| 70 | genrule( |
| 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 Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 93 | # Generates the onos-admin.tar.gz file with remote admin tools |
| 94 | genrule( |
| 95 | name = "onos-package-admin", |
| 96 | srcs = glob([ |
| 97 | "tools/package/runtime/bin/*", |
| 98 | "tools/dev/bin/onos-create-app", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 99 | "tools/test/bin/onos", |
| 100 | ]), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 101 | outs = ["onos-admin.tar.gz"], |
Thomas Vachuska | 1506abb | 2018-07-31 16:28:37 -0700 | [diff] [blame] | 102 | cmd = "mkdir onos-admin-%s; cp $(SRCS) onos-admin-%s; tar hzcf $(location onos-admin.tar.gz) onos-admin-%s" % |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 103 | (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 104 | output_to_bindir = True, |
| 105 | ) |
| 106 | |
| 107 | # Generates the onos-test.tar.gz file with test tools |
| 108 | genrule( |
| 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 Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 115 | "tools/package/runtime/bin/*", |
| 116 | ]), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 117 | outs = ["onos-test.tar.gz"], |
Thomas Vachuska | 1506abb | 2018-07-31 16:28:37 -0700 | [diff] [blame] | 118 | cmd = "mkdir onos-test-%s; cp -r tools onos-test-%s; tar hzcf $(location onos-test.tar.gz) onos-test-%s" % |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 119 | (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 120 | output_to_bindir = True, |
| 121 | ) |
| 122 | |
| 123 | # Runs ONOS as a single instance from the /tmp directory |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 124 | alias( |
Thomas Vachuska | 8e022a9 | 2018-07-10 14:47:38 -0700 | [diff] [blame] | 125 | name = "onos-local", |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 126 | actual = select({ |
| 127 | ":run_with_absolute_javabase": ":onos-local_absolute-javabase", |
| 128 | "//conditions:default": ":onos-local_current-jdk", |
| 129 | }), |
| 130 | ) |
| 131 | |
| 132 | config_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) |
| 140 | genrule( |
| 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. |
| 152 | genrule( |
| 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 |
| 167 | genrule( |
| 168 | name = "onos-local-base", |
Ray Milkey | 2f380c7 | 2018-07-10 09:28:32 -0700 | [diff] [blame] | 169 | srcs = [ |
| 170 | ":onos-package", |
| 171 | "tools/package/onos-run-karaf", |
Jian Li | d486a73 | 2018-08-03 00:32:11 +0900 | [diff] [blame] | 172 | ] + glob(["tools/package/config/**"]), |
Thomas Vachuska | 510419f | 2018-06-28 17:05:09 -0700 | [diff] [blame] | 173 | outs = ["onos-runner"], |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 174 | cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " + |
| 175 | "$(location tools/package/onos-run-karaf) > $(location onos-runner); " + |
Carmelo Cascone | 395b231 | 2019-06-18 17:34:16 -0700 | [diff] [blame] | 176 | "chmod +x $(location onos-runner)", |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 177 | visibility = ["//visibility:private"], |
Thomas Vachuska | 510419f | 2018-06-28 17:05:09 -0700 | [diff] [blame] | 178 | ) |
Ray Milkey | 5063f5b | 2018-08-15 16:22:30 -0700 | [diff] [blame] | 179 | |
| 180 | load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") |
| 181 | |
| 182 | buildifier( |
| 183 | name = "buildifier_check", |
Sean Condon | 6ea7b7b | 2020-01-23 09:31:18 +0000 | [diff] [blame] | 184 | 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 Milkey | 5063f5b | 2018-08-15 16:22:30 -0700 | [diff] [blame] | 190 | mode = "check", |
| 191 | ) |
| 192 | |
| 193 | buildifier( |
| 194 | name = "buildifier_fix", |
Sean Condon | 6ea7b7b | 2020-01-23 09:31:18 +0000 | [diff] [blame] | 195 | 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 Milkey | 5063f5b | 2018-08-15 16:22:30 -0700 | [diff] [blame] | 201 | mode = "fix", |
| 202 | ) |