blob: 476bdaceee28c152a759328f738b26fef6cf1c3b [file] [log] [blame]
Brian O'Connor1f165982016-04-06 21:36:09 -07001ONOS_ORIGIN = 'ON.Lab'
Ray Milkey24439fe2016-04-08 21:50:55 -07002ONOS_GROUP_ID = 'org.onosproject'
Brian O'Connor1f165982016-04-06 21:36:09 -07003ONOS_VERSION = '1.6.0-SNAPSHOT'
4DEFAULT_APP_CATEGORY = 'Utility'
Brian O'Connore4da59d2016-04-08 00:32:18 -07005ONOS_ARTIFACT_BASE = 'onos-'
Ray Milkey24439fe2016-04-08 21:50:55 -07006APP_PREFIX = ONOS_GROUP_ID + '.'
Brian O'Connore4da59d2016-04-08 00:32:18 -07007
8import os.path
9
10# FIXME Factor this into common place
11def _get_name():
12 base_path = get_base_path()
13 return ONOS_ARTIFACT_BASE + base_path.replace('/', '-') #TODO Unix-separator
14
15def _get_app_name():
16 base_path = get_base_path()
17 return APP_PREFIX + os.path.basename(base_path)
Brian O'Connor1f165982016-04-06 21:36:09 -070018
19def onos_app(
Brian O'Connore4da59d2016-04-08 00:32:18 -070020 app_name = None,
21 name = None,
22 title = None,
Brian O'Connor1f165982016-04-06 21:36:09 -070023 version = ONOS_VERSION,
24 origin = ONOS_ORIGIN,
25 category = DEFAULT_APP_CATEGORY,
26 url = None,
27 description = None, #TODO make this a file
28 #TODO icon,
Brian O'Connore124f3d2016-04-06 23:54:26 -070029 feature_coords = None,
Brian O'Connor1f165982016-04-06 21:36:09 -070030 required_features = [ 'onos-api' ],
31 required_apps = [],
Brian O'Connore4da59d2016-04-08 00:32:18 -070032 included_bundles = None,
Brian O'Connor1f165982016-04-06 21:36:09 -070033 excluded_bundles = [],
Brian O'Connore4da59d2016-04-08 00:32:18 -070034 visibility = [ 'PUBLIC' ],
Brian O'Connor1f165982016-04-06 21:36:09 -070035 **kwargs):
Brian O'Connore4da59d2016-04-08 00:32:18 -070036 if name is None:
37 name = _get_name()
38
39 if app_name is None:
40 app_name = _get_app_name()
41
42 if title is None:
43 print "Missing title for %s" % _get_name()
44 title = _get_app_name()
45
46 if included_bundles is None:
47 target = ':' + _get_name()
48 included_bundles = [ target ]
Brian O'Connor1f165982016-04-06 21:36:09 -070049
Brian O'Connore124f3d2016-04-06 23:54:26 -070050 if not feature_coords and len(included_bundles) == 1:
51 feature_coords = '$(maven_coords %s)' % included_bundles[0]
Brian O'Connor1f165982016-04-06 21:36:09 -070052
Brian O'Connore4da59d2016-04-08 00:32:18 -070053 if not feature_coords:
Ray Milkey24439fe2016-04-08 21:50:55 -070054 feature_coords = '%s:%s:%s' % ( ONOS_GROUP_ID, _get_name(), ONOS_VERSION )
Brian O'Connore4da59d2016-04-08 00:32:18 -070055
Brian O'Connore124f3d2016-04-06 23:54:26 -070056 args = [ '-n %s' % feature_coords,
Brian O'Connor1f165982016-04-06 21:36:09 -070057 '-v %s' % version,
58 '-t "%s"' % title,
59 '-o "%s"' % origin,
60 '-c "%s"' % category,
61 '-a "%s"' % app_name,
62 '-u %s' % url,
63 ]
64 args += [ '-f %s' % f for f in required_features ]
Brian O'Connore124f3d2016-04-06 23:54:26 -070065 args += [ '-b $(maven_coords %s)' % b for b in included_bundles ]
66 args += [ '-e $(maven_coords %s)' % b for b in excluded_bundles ]
Brian O'Connor1f165982016-04-06 21:36:09 -070067 args += [ '-d %s' % a for a in required_apps ]
68
69 cmd = '$(exe //buck-tools:onos-app-writer) -F ' + ' '.join(args) + ' > $OUT'
70 genrule(
Brian O'Connore4da59d2016-04-08 00:32:18 -070071 name = name + '-features',
Brian O'Connor1f165982016-04-06 21:36:09 -070072 bash = cmd,
Brian O'Connore124f3d2016-04-06 23:54:26 -070073 out = 'features.xml',
Brian O'Connor1f165982016-04-06 21:36:09 -070074 visibility = [],
75 )
76 cmd = '$(exe //buck-tools:onos-app-writer) -A ' + ' '.join(args) + ' > $OUT'
77 genrule(
Brian O'Connore4da59d2016-04-08 00:32:18 -070078 name = name + '-app-xml',
Brian O'Connor1f165982016-04-06 21:36:09 -070079 bash = cmd,
80 out = 'app.xml',
81 visibility = [],
82 )
83
84 sources = [
Brian O'Connore4da59d2016-04-08 00:32:18 -070085 '$(location :%s-features) %s' % (name, feature_coords),
86 '$(location :%s-app-xml) NONE' % name,
Brian O'Connor1f165982016-04-06 21:36:09 -070087 ]
Brian O'Connore124f3d2016-04-06 23:54:26 -070088 sources += ['$(location %s) $(maven_coords %s)' % (i, i) for i in included_bundles]
Brian O'Connor1f165982016-04-06 21:36:09 -070089 genrule(
Brian O'Connore4da59d2016-04-08 00:32:18 -070090 name = name + '-oar',
Brian O'Connor1f165982016-04-06 21:36:09 -070091 out = 'app.oar',
Brian O'Connore4da59d2016-04-08 00:32:18 -070092 bash = '$(exe //buck-tools:onos-app-oar) $OUT ' + ' '.join(sources),
93 visibility = visibility,
Brian O'Connor1f165982016-04-06 21:36:09 -070094 )