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