blob: ba766499961b7237bcb3b8a7b9c0036c3aa25365 [file] [log] [blame]
Brian O'Connor1f165982016-04-06 21:36:09 -07001ONOS_ORIGIN = 'ON.Lab'
2ONOS_VERSION = '1.6.0-SNAPSHOT'
3DEFAULT_APP_CATEGORY = 'Utility'
4
5def onos_app(
6 app_name,
7 title,
8 version = ONOS_VERSION,
9 origin = ONOS_ORIGIN,
10 category = DEFAULT_APP_CATEGORY,
11 url = None,
12 description = None, #TODO make this a file
13 #TODO icon,
Brian O'Connore124f3d2016-04-06 23:54:26 -070014 feature_coords = None,
Brian O'Connor1f165982016-04-06 21:36:09 -070015 required_features = [ 'onos-api' ],
16 required_apps = [],
17 included_bundles = [],
18 excluded_bundles = [],
19 **kwargs):
20
Brian O'Connore124f3d2016-04-06 23:54:26 -070021 if not feature_coords and len(included_bundles) == 1:
22 feature_coords = '$(maven_coords %s)' % included_bundles[0]
Brian O'Connor1f165982016-04-06 21:36:09 -070023
Brian O'Connore124f3d2016-04-06 23:54:26 -070024 args = [ '-n %s' % feature_coords,
Brian O'Connor1f165982016-04-06 21:36:09 -070025 '-v %s' % version,
26 '-t "%s"' % title,
27 '-o "%s"' % origin,
28 '-c "%s"' % category,
29 '-a "%s"' % app_name,
30 '-u %s' % url,
31 ]
32 args += [ '-f %s' % f for f in required_features ]
Brian O'Connore124f3d2016-04-06 23:54:26 -070033 args += [ '-b $(maven_coords %s)' % b for b in included_bundles ]
34 args += [ '-e $(maven_coords %s)' % b for b in excluded_bundles ]
Brian O'Connor1f165982016-04-06 21:36:09 -070035 args += [ '-d %s' % a for a in required_apps ]
36
37 cmd = '$(exe //buck-tools:onos-app-writer) -F ' + ' '.join(args) + ' > $OUT'
38 genrule(
39 name = 'app-features',
40 bash = cmd,
Brian O'Connore124f3d2016-04-06 23:54:26 -070041 out = 'features.xml',
Brian O'Connor1f165982016-04-06 21:36:09 -070042 visibility = [],
43 )
44 cmd = '$(exe //buck-tools:onos-app-writer) -A ' + ' '.join(args) + ' > $OUT'
45 genrule(
46 name = 'app-xml',
47 bash = cmd,
48 out = 'app.xml',
49 visibility = [],
50 )
51
52 sources = [
Brian O'Connore124f3d2016-04-06 23:54:26 -070053 '$(location :app-features) %s' % feature_coords,
Brian O'Connor1f165982016-04-06 21:36:09 -070054 '$(location :app-xml) NONE',
55 ]
Brian O'Connore124f3d2016-04-06 23:54:26 -070056 sources += ['$(location %s) $(maven_coords %s)' % (i, i) for i in included_bundles]
Brian O'Connor1f165982016-04-06 21:36:09 -070057 genrule(
58 name = 'app-oar',
59 out = 'app.oar',
60 bash = '$(exe //buck-tools:onos-app-oar) $OUT ' + ' '.join(sources)
61 )