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 | |
| 19 | # Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools |
| 20 | genrule( |
| 21 | name = "onos-karaf", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 22 | srcs = [ |
| 23 | KARAF, |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 24 | BRANDING, |
| 25 | ] + glob([ |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 26 | "tools/package/bin/*", |
| 27 | "tools/package/etc/*", |
| 28 | "tools/package/init/*", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 29 | "tools/package/runtime/bin/*", |
| 30 | ]), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 31 | outs = ["karaf.zip"], |
Ray Milkey | 3f274d9 | 2018-09-28 14:23:34 -0700 | [diff] [blame] | 32 | cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) '' tools/package" % |
| 33 | (KARAF, ONOS_VERSION, BRANDING), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 34 | tools = ["tools/package/onos-prep-karaf"], |
| 35 | ) |
| 36 | |
| 37 | # Generates the principal onos.tar.gz bundle |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 38 | genrule( |
| 39 | name = "onos-package", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 40 | srcs = [ |
| 41 | "//tools/package/features:onos-features", |
| 42 | ":onos-karaf", |
Thomas Vachuska | 1ae26c6 | 2018-07-09 13:40:16 -0700 | [diff] [blame] | 43 | ] + APPS + FEATURES, |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 44 | outs = ["onos.tar.gz"], |
| 45 | 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] | 46 | output_to_bindir = True, |
Thomas Vachuska | e7433b8 | 2018-07-24 13:57:37 -0700 | [diff] [blame] | 47 | tags = ["local"], |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 48 | tools = ["tools/package/onos_stage.py"], |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 49 | ) |
| 50 | |
Thomas Vachuska | 1e3ed80 | 2019-02-01 14:51:30 -0800 | [diff] [blame] | 51 | # Generates the minimal onos-minimal.tar.gz bundle |
| 52 | genrule( |
| 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 |
| 67 | genrule( |
| 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 Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 90 | # Generates the onos-admin.tar.gz file with remote admin tools |
| 91 | genrule( |
| 92 | name = "onos-package-admin", |
| 93 | srcs = glob([ |
| 94 | "tools/package/runtime/bin/*", |
| 95 | "tools/dev/bin/onos-create-app", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 96 | "tools/test/bin/onos", |
| 97 | ]), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 98 | outs = ["onos-admin.tar.gz"], |
Thomas Vachuska | 1506abb | 2018-07-31 16:28:37 -0700 | [diff] [blame] | 99 | 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] | 100 | (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 101 | output_to_bindir = True, |
| 102 | ) |
| 103 | |
| 104 | # Generates the onos-test.tar.gz file with test tools |
| 105 | genrule( |
| 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 Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 112 | "tools/package/runtime/bin/*", |
| 113 | ]), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 114 | outs = ["onos-test.tar.gz"], |
Thomas Vachuska | 1506abb | 2018-07-31 16:28:37 -0700 | [diff] [blame] | 115 | 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] | 116 | (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 117 | output_to_bindir = True, |
| 118 | ) |
| 119 | |
| 120 | # Runs ONOS as a single instance from the /tmp directory |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 121 | alias( |
Thomas Vachuska | 8e022a9 | 2018-07-10 14:47:38 -0700 | [diff] [blame] | 122 | name = "onos-local", |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 123 | actual = select({ |
| 124 | ":run_with_absolute_javabase": ":onos-local_absolute-javabase", |
| 125 | "//conditions:default": ":onos-local_current-jdk", |
| 126 | }), |
| 127 | ) |
| 128 | |
| 129 | config_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) |
| 137 | genrule( |
| 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. |
| 149 | genrule( |
| 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 |
| 164 | genrule( |
| 165 | name = "onos-local-base", |
Ray Milkey | 2f380c7 | 2018-07-10 09:28:32 -0700 | [diff] [blame] | 166 | srcs = [ |
| 167 | ":onos-package", |
| 168 | "tools/package/onos-run-karaf", |
Jian Li | d486a73 | 2018-08-03 00:32:11 +0900 | [diff] [blame] | 169 | ] + glob(["tools/package/config/**"]), |
Thomas Vachuska | 510419f | 2018-06-28 17:05:09 -0700 | [diff] [blame] | 170 | outs = ["onos-runner"], |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 171 | cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " + |
| 172 | "$(location tools/package/onos-run-karaf) > $(location onos-runner); " + |
Carmelo Cascone | 395b231 | 2019-06-18 17:34:16 -0700 | [diff] [blame] | 173 | "chmod +x $(location onos-runner)", |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 174 | visibility = ["//visibility:private"], |
Thomas Vachuska | 510419f | 2018-06-28 17:05:09 -0700 | [diff] [blame] | 175 | ) |
Ray Milkey | 5063f5b | 2018-08-15 16:22:30 -0700 | [diff] [blame] | 176 | |
| 177 | load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") |
| 178 | |
| 179 | buildifier( |
| 180 | name = "buildifier_check", |
Sean Condon | 6ea7b7b | 2020-01-23 09:31:18 +0000 | [diff] [blame] | 181 | 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 Milkey | 5063f5b | 2018-08-15 16:22:30 -0700 | [diff] [blame] | 187 | mode = "check", |
| 188 | ) |
| 189 | |
| 190 | buildifier( |
| 191 | name = "buildifier_fix", |
Sean Condon | 6ea7b7b | 2020-01-23 09:31:18 +0000 | [diff] [blame] | 192 | 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 Milkey | 5063f5b | 2018-08-15 16:22:30 -0700 | [diff] [blame] | 198 | mode = "fix", |
| 199 | ) |