Thomas Vachuska | e17756d | 2018-10-31 15:23:55 -0700 | [diff] [blame] | 1 | load("//tools/build/bazel:variables.bzl", "ONOS_VERSION") |
Brian O'Connor | ca05e1f | 2020-01-07 11:28:46 -0800 | [diff] [blame] | 2 | load( |
| 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 | # |
| 19 | profiles([ |
| 20 | "minimal", |
| 21 | "seba", |
| 22 | "stratum", |
pierventre | aa5a3af | 2020-06-30 22:04:16 +0200 | [diff] [blame] | 23 | "tost", |
Jian Li | 7ffa8bd | 2020-07-22 17:34:55 +0900 | [diff] [blame] | 24 | "sona", |
Brian O'Connor | ca05e1f | 2020-01-07 11:28:46 -0800 | [diff] [blame] | 25 | ]) |
Thomas Vachuska | aab45d1 | 2018-06-05 16:39:46 -0700 | [diff] [blame] | 26 | |
Ray Milkey | 7dac7da | 2017-08-01 16:56:05 -0700 | [diff] [blame] | 27 | filegroup( |
| 28 | name = "onos", |
Brian O'Connor | ca05e1f | 2020-01-07 11:28:46 -0800 | [diff] [blame] | 29 | srcs = CORE + [ |
Thomas Vachuska | 5538d9e | 2018-08-14 09:59:35 -0700 | [diff] [blame] | 30 | "//tools/build/conf:onos-build-conf", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 31 | ":onos-package-admin", |
| 32 | ":onos-package-test", |
| 33 | ":onos-package", |
Brian O'Connor | ca05e1f | 2020-01-07 11:28:46 -0800 | [diff] [blame] | 34 | ] + select({ |
| 35 | ":minimal_profile": extensions("minimal") + apps("minimal"), |
| 36 | ":seba_profile": extensions("seba") + apps("seba"), |
| 37 | ":stratum_profile": extensions("stratum") + apps("stratum"), |
pierventre | aa5a3af | 2020-06-30 22:04:16 +0200 | [diff] [blame] | 38 | ":tost_profile": extensions("tost") + apps("tost"), |
Jian Li | 7ffa8bd | 2020-07-22 17:34:55 +0900 | [diff] [blame] | 39 | ":sona_profile": extensions("sona") + apps("sona"), |
Brian O'Connor | ca05e1f | 2020-01-07 11:28:46 -0800 | [diff] [blame] | 40 | "//conditions:default": extensions() + apps(), |
| 41 | }), |
Thomas Vachuska | 0f95603 | 2018-06-12 10:41:12 -0700 | [diff] [blame] | 42 | visibility = ["//visibility:public"], |
| 43 | ) |
| 44 | |
Ray Milkey | a8ac7e3 | 2018-09-04 15:52:14 -0700 | [diff] [blame] | 45 | KARAF = "@apache_karaf//:apache_karaf" |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 46 | |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 47 | BRANDING = "//tools/package/branding:onos-tools-package-branding" |
| 48 | |
Daniele Moro | cc41a94 | 2020-02-03 23:33:55 -0800 | [diff] [blame] | 49 | LOG4J_EXTRA = "//tools/package/log4j2-extra:onos-log4j2-extra" |
| 50 | |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 51 | # Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools |
| 52 | genrule( |
| 53 | name = "onos-karaf", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 54 | srcs = [ |
| 55 | KARAF, |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 56 | BRANDING, |
Daniele Moro | cc41a94 | 2020-02-03 23:33:55 -0800 | [diff] [blame] | 57 | LOG4J_EXTRA, |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 58 | ] + glob([ |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 59 | "tools/package/bin/*", |
| 60 | "tools/package/etc/*", |
| 61 | "tools/package/init/*", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 62 | "tools/package/runtime/bin/*", |
| 63 | ]), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 64 | outs = ["karaf.zip"], |
Daniele Moro | cc41a94 | 2020-02-03 23:33:55 -0800 | [diff] [blame] | 65 | cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) '' $(location %s) tools/package" % |
| 66 | (KARAF, ONOS_VERSION, BRANDING, LOG4J_EXTRA), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 67 | tools = ["tools/package/onos-prep-karaf"], |
| 68 | ) |
| 69 | |
| 70 | # Generates the principal onos.tar.gz bundle |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 71 | genrule( |
| 72 | name = "onos-package", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 73 | srcs = [ |
| 74 | "//tools/package/features:onos-features", |
| 75 | ":onos-karaf", |
Brian O'Connor | ca05e1f | 2020-01-07 11:28:46 -0800 | [diff] [blame] | 76 | ] + FEATURES + select({ |
| 77 | ":minimal_profile": apps("minimal"), |
| 78 | ":seba_profile": apps("seba"), |
| 79 | ":stratum_profile": apps("stratum"), |
pierventre | aa5a3af | 2020-06-30 22:04:16 +0200 | [diff] [blame] | 80 | ":tost_profile": apps("tost"), |
Jian Li | 7ffa8bd | 2020-07-22 17:34:55 +0900 | [diff] [blame] | 81 | ":sona_profile": apps("sona"), |
Brian O'Connor | ca05e1f | 2020-01-07 11:28:46 -0800 | [diff] [blame] | 82 | "//conditions:default": apps(), |
| 83 | }), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 84 | outs = ["onos.tar.gz"], |
| 85 | 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] | 86 | output_to_bindir = True, |
Thomas Vachuska | e7433b8 | 2018-07-24 13:57:37 -0700 | [diff] [blame] | 87 | tags = ["local"], |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 88 | tools = ["tools/package/onos_stage.py"], |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 89 | ) |
| 90 | |
| 91 | # Generates the onos-admin.tar.gz file with remote admin tools |
| 92 | genrule( |
| 93 | name = "onos-package-admin", |
| 94 | srcs = glob([ |
| 95 | "tools/package/runtime/bin/*", |
| 96 | "tools/dev/bin/onos-create-app", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 97 | "tools/test/bin/onos", |
| 98 | ]), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 99 | outs = ["onos-admin.tar.gz"], |
Thomas Vachuska | 1506abb | 2018-07-31 16:28:37 -0700 | [diff] [blame] | 100 | 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] | 101 | (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 102 | output_to_bindir = True, |
| 103 | ) |
| 104 | |
| 105 | # Generates the onos-test.tar.gz file with test tools |
| 106 | genrule( |
| 107 | name = "onos-package-test", |
| 108 | srcs = glob([ |
| 109 | "tools/build/envDefaults", |
| 110 | "tools/dev/bash_profile", |
| 111 | "tools/dev/bin/onos-create-app", |
| 112 | "tools/test/**/*", |
Ray Milkey | 15053f0 | 2018-06-13 10:00:45 -0700 | [diff] [blame] | 113 | "tools/package/runtime/bin/*", |
| 114 | ]), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 115 | outs = ["onos-test.tar.gz"], |
Thomas Vachuska | 1506abb | 2018-07-31 16:28:37 -0700 | [diff] [blame] | 116 | 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] | 117 | (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION), |
Thomas Vachuska | f5d1720 | 2018-06-12 17:28:13 -0700 | [diff] [blame] | 118 | output_to_bindir = True, |
| 119 | ) |
| 120 | |
| 121 | # Runs ONOS as a single instance from the /tmp directory |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 122 | alias( |
Thomas Vachuska | 8e022a9 | 2018-07-10 14:47:38 -0700 | [diff] [blame] | 123 | name = "onos-local", |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 124 | actual = select({ |
| 125 | ":run_with_absolute_javabase": ":onos-local_absolute-javabase", |
| 126 | "//conditions:default": ":onos-local_current-jdk", |
| 127 | }), |
| 128 | ) |
| 129 | |
| 130 | config_setting( |
| 131 | name = "run_with_absolute_javabase", |
| 132 | define_values = { |
| 133 | "RUN_WITH_ABSOLUTE_JAVABASE": "true", |
| 134 | }, |
| 135 | ) |
| 136 | |
| 137 | # Run onos-local with JAVA_HOME set to ABSOLUTE_JAVABASE (see .bazelrc) |
| 138 | genrule( |
| 139 | name = "onos-local_absolute-javabase", |
| 140 | srcs = [":onos-local-base"], |
| 141 | outs = ["onos-runner_absolute-javabase"], |
| 142 | cmd = "sed \"s#ABSOLUTE_JAVABASE=#ABSOLUTE_JAVABASE=$(ABSOLUTE_JAVABASE)#\" " + |
| 143 | "$(location onos-local-base) > $(location onos-runner_absolute-javabase)", |
| 144 | executable = True, |
| 145 | output_to_bindir = True, |
| 146 | visibility = ["//visibility:private"], |
| 147 | ) |
| 148 | |
| 149 | # Run onos-local with the same JDK used for the build, packaged in a tarball. |
| 150 | genrule( |
| 151 | name = "onos-local_current-jdk", |
| 152 | srcs = [ |
| 153 | ":onos-local-base", |
| 154 | "//tools/build/jdk:current_jdk_tar", |
| 155 | ], |
| 156 | outs = ["onos-runner_current-jdk"], |
| 157 | cmd = "sed \"s#JDK_TAR=#JDK_TAR=$(location //tools/build/jdk:current_jdk_tar)#\" " + |
| 158 | "$(location :onos-local-base) > $(location onos-runner_current-jdk); ", |
| 159 | executable = True, |
| 160 | output_to_bindir = True, |
| 161 | visibility = ["//visibility:private"], |
| 162 | ) |
| 163 | |
| 164 | # Create an onos-runner script based on onos-run-karaf |
| 165 | genrule( |
| 166 | name = "onos-local-base", |
Ray Milkey | 2f380c7 | 2018-07-10 09:28:32 -0700 | [diff] [blame] | 167 | srcs = [ |
| 168 | ":onos-package", |
| 169 | "tools/package/onos-run-karaf", |
Jian Li | d486a73 | 2018-08-03 00:32:11 +0900 | [diff] [blame] | 170 | ] + glob(["tools/package/config/**"]), |
Thomas Vachuska | 510419f | 2018-06-28 17:05:09 -0700 | [diff] [blame] | 171 | outs = ["onos-runner"], |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 172 | cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" " + |
| 173 | "$(location tools/package/onos-run-karaf) > $(location onos-runner); " + |
Carmelo Cascone | 395b231 | 2019-06-18 17:34:16 -0700 | [diff] [blame] | 174 | "chmod +x $(location onos-runner)", |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 175 | visibility = ["//visibility:private"], |
Thomas Vachuska | 510419f | 2018-06-28 17:05:09 -0700 | [diff] [blame] | 176 | ) |
Ray Milkey | 5063f5b | 2018-08-15 16:22:30 -0700 | [diff] [blame] | 177 | |
| 178 | load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") |
| 179 | |
| 180 | buildifier( |
| 181 | name = "buildifier_check", |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 182 | exclude_patterns = [ |
| 183 | "./tools/build/bazel/generate_workspace.bzl", |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 184 | "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl", |
| 185 | "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl", |
| 186 | "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl", |
Sean Condon | 436c60a | 2021-01-01 14:23:29 +0000 | [diff] [blame^] | 187 | "./web/gui2/node_modules/@bazel/rollup/rollup_bundle.bzl", |
| 188 | "./web/gui2/node_modules/@bazel/typescript/internal/ts_project.bzl", |
| 189 | "./web/gui2/node_modules/@bazel/typescript/internal/build_defs.bzl", |
| 190 | "./web/gui2/node_modules/@bazel/protractor/protractor_web_test.bzl", |
| 191 | "./web/gui2/node_modules/@bazel/typescript/third_party/github.com/bazelbuild/bazel/src/main/protobuf/BUILD.bazel", |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 192 | ], |
Ray Milkey | 5063f5b | 2018-08-15 16:22:30 -0700 | [diff] [blame] | 193 | mode = "check", |
| 194 | ) |
| 195 | |
| 196 | buildifier( |
| 197 | name = "buildifier_fix", |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 198 | exclude_patterns = [ |
| 199 | "./tools/build/bazel/generate_workspace.bzl", |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 200 | "./web/gui2/node_modules/@angular/bazel/src/esm5.bzl", |
| 201 | "./web/gui2/node_modules/@bazel/typescript/internal/common/tsconfig.bzl", |
| 202 | "./web/gui2/node_modules/@bazel/typescript/internal/common/compilation.bzl", |
Sean Condon | 436c60a | 2021-01-01 14:23:29 +0000 | [diff] [blame^] | 203 | "./web/gui2/node_modules/@bazel/typescript/internal/ts_project.bzl", |
| 204 | "./web/gui2/node_modules/@bazel/typescript/internal/build_defs.bzl", |
| 205 | "./web/gui2/node_modules/@bazel/protractor/protractor_web_test.bzl", |
| 206 | "./web/gui2/node_modules/@bazel/typescript/third_party/github.com/bazelbuild/bazel/src/main/protobuf/BUILD.bazel", |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 207 | ], |
Ray Milkey | 5063f5b | 2018-08-15 16:22:30 -0700 | [diff] [blame] | 208 | mode = "fix", |
| 209 | ) |