blob: 18d867bb03598de11575505c6a560de9aff0c70d [file] [log] [blame]
Thomas Vachuskaf5d17202018-06-12 17:28:13 -07001load("//tools/build/bazel:generate_workspace.bzl", "ONOS_VERSION")
Thomas Vachuska1ae26c62018-07-09 13:40:16 -07002load(":modules.bzl", "APPS", "CORE", "FEATURES")
Thomas Vachuskaaab45d12018-06-05 16:39:46 -07003
Ray Milkey7dac7da2017-08-01 16:56:05 -07004filegroup(
5 name = "onos",
Thomas Vachuskaf5d17202018-06-12 17:28:13 -07006 srcs = CORE + APPS + [
Thomas Vachuska5538d9e2018-08-14 09:59:35 -07007 "//tools/build/conf:onos-build-conf",
Ray Milkey15053f02018-06-13 10:00:45 -07008 ":onos-package-admin",
9 ":onos-package-test",
10 ":onos-package",
11 ],
Thomas Vachuska0f956032018-06-12 10:41:12 -070012 visibility = ["//visibility:public"],
13)
14
Ray Milkeya8ac7e32018-09-04 15:52:14 -070015KARAF = "@apache_karaf//:apache_karaf"
Ray Milkey15053f02018-06-13 10:00:45 -070016
Ray Milkeya8ac7e32018-09-04 15:52:14 -070017PATCHES = "@apache_karaf_patches//:apache_karaf_patches"
Ray Milkey15053f02018-06-13 10:00:45 -070018
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070019BRANDING = "//tools/package/branding:onos-tools-package-branding"
20
21# Generates auxiliary karaf.zip file; branded and augmented with ONOS runtime tools
22genrule(
23 name = "onos-karaf",
Ray Milkey15053f02018-06-13 10:00:45 -070024 srcs = [
25 KARAF,
26 PATCHES,
27 BRANDING,
28 ] + glob([
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070029 "tools/package/bin/*",
30 "tools/package/etc/*",
31 "tools/package/init/*",
Ray Milkey15053f02018-06-13 10:00:45 -070032 "tools/package/runtime/bin/*",
33 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070034 outs = ["karaf.zip"],
Ray Milkey15053f02018-06-13 10:00:45 -070035 cmd = "$(location tools/package/onos-prep-karaf) $(location karaf.zip) $(location %s) %s $(location %s) $(location %s) tools/package" %
36 (KARAF, ONOS_VERSION, BRANDING, PATCHES),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070037 tools = ["tools/package/onos-prep-karaf"],
38)
39
40# Generates the principal onos.tar.gz bundle
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070041genrule(
42 name = "onos-package",
Ray Milkey15053f02018-06-13 10:00:45 -070043 srcs = [
44 "//tools/package/features:onos-features",
45 ":onos-karaf",
Thomas Vachuska1ae26c62018-07-09 13:40:16 -070046 ] + APPS + FEATURES,
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070047 outs = ["onos.tar.gz"],
48 cmd = "$(location tools/package/onos_stage.py) $(location onos.tar.gz) %s $(location :onos-karaf) $(SRCS)" % ONOS_VERSION,
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070049 output_to_bindir = True,
Thomas Vachuskae7433b82018-07-24 13:57:37 -070050 tags = ["local"],
Ray Milkey15053f02018-06-13 10:00:45 -070051 tools = ["tools/package/onos_stage.py"],
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070052)
53
54# Generates the onos-admin.tar.gz file with remote admin tools
55genrule(
56 name = "onos-package-admin",
57 srcs = glob([
58 "tools/package/runtime/bin/*",
59 "tools/dev/bin/onos-create-app",
Ray Milkey15053f02018-06-13 10:00:45 -070060 "tools/test/bin/onos",
61 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070062 outs = ["onos-admin.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -070063 cmd = "mkdir onos-admin-%s; cp $(SRCS) onos-admin-%s; tar hzcf $(location onos-admin.tar.gz) onos-admin-%s" %
Ray Milkey15053f02018-06-13 10:00:45 -070064 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070065 output_to_bindir = True,
66)
67
68# Generates the onos-test.tar.gz file with test tools
69genrule(
70 name = "onos-package-test",
71 srcs = glob([
72 "tools/build/envDefaults",
73 "tools/dev/bash_profile",
74 "tools/dev/bin/onos-create-app",
75 "tools/test/**/*",
Ray Milkey15053f02018-06-13 10:00:45 -070076 "tools/package/runtime/bin/*",
77 ]),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070078 outs = ["onos-test.tar.gz"],
Thomas Vachuska1506abb2018-07-31 16:28:37 -070079 cmd = "mkdir onos-test-%s; cp -r tools onos-test-%s; tar hzcf $(location onos-test.tar.gz) onos-test-%s" %
Ray Milkey15053f02018-06-13 10:00:45 -070080 (ONOS_VERSION, ONOS_VERSION, ONOS_VERSION),
Thomas Vachuskaf5d17202018-06-12 17:28:13 -070081 output_to_bindir = True,
82)
83
84# Runs ONOS as a single instance from the /tmp directory
Thomas Vachuska510419f2018-06-28 17:05:09 -070085genrule(
Thomas Vachuska8e022a92018-07-10 14:47:38 -070086 name = "onos-local",
Ray Milkey2f380c72018-07-10 09:28:32 -070087 srcs = [
88 ":onos-package",
89 "tools/package/onos-run-karaf",
Jian Lid486a732018-08-03 00:32:11 +090090 ] + glob(["tools/package/config/**"]),
Thomas Vachuska510419f2018-06-28 17:05:09 -070091 outs = ["onos-runner"],
Thomas Vachuska510419f2018-06-28 17:05:09 -070092 cmd = "sed \"s#ONOS_TAR=#ONOS_TAR=$(location :onos-package)#\" $(location tools/package/onos-run-karaf) > $(location onos-runner); chmod +x $(location onos-runner)",
93 executable = True,
94 output_to_bindir = True,
95 visibility = ["//visibility:public"],
96)
Ray Milkey5063f5b2018-08-15 16:22:30 -070097
98load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
99
100buildifier(
101 name = "buildifier_check",
Ray Milkey678767f2018-08-27 17:38:33 -0700102 exclude_patterns = ["./tools/build/bazel/generate_workspace.bzl"],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700103 mode = "check",
104)
105
106buildifier(
107 name = "buildifier_fix",
Ray Milkey678767f2018-08-27 17:38:33 -0700108 exclude_patterns = ["./tools/build/bazel/generate_workspace.bzl"],
Ray Milkey5063f5b2018-08-15 16:22:30 -0700109 mode = "fix",
110)