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