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