blob: 93c9000e42becff20df0e536f0e2bb982fbfeb86 [file] [log] [blame]
Ray Milkeye88d69b2016-12-16 17:09:13 -08001include_defs('//onos.defs')
Thomas Vachuska22f731c2017-03-23 15:00:08 -07002include_defs('//bucklets/onos.bucklet')
3include_defs('//bucklets/onos_app.bucklet')
Ray Milkeye88d69b2016-12-16 17:09:13 -08004
5def _get_name():
6 base_path = get_base_path()
7 return ONOS_ARTIFACT_BASE + base_path.replace('/', '-') #TODO Unix-separator
8
Thomas Vachuska22f731c2017-03-23 15:00:08 -07009YANG_TOOLS = [
Thomas Vachuska315ff1c2017-03-28 18:23:00 -070010 '//lib:guava',
11 '//lib:onos-yang-model',
12 '//lib:onos-yang-compiler-api',
Thomas Vachuska22f731c2017-03-23 15:00:08 -070013 '//lib:onos-yang-runtime',
Thomas Vachuska315ff1c2017-03-28 18:23:00 -070014 '//lib:org.apache.felix.scr.annotations',
15 '//apps/yang:onos-apps-yang',
16 # FIXME: This following dependencies MUST be removed for the long-run; they are a violation of the design principle.
17 '//core/api:onos-api',
18 '//apps/config:onos-apps-config',
Thomas Vachuska22f731c2017-03-23 15:00:08 -070019]
20
21def yang_model(
22 name = None,
23 app_name = None,
24 title = 'YANG Model',
25 url = 'http://onosproject.org',
26 description = None,
27 deps = [],
28 **kwargs
29 ):
30
31 if name is None:
32 name = _get_name()
33
34 yang = name + '-yang'
35 yangSrcs = yang + '#srcs'
36 schema = name + '-schema'
37 registrator = name + '-registrator'
38
39 yang_library(
40 name = yang,
Thomas Vachuskad92f6eb2017-03-27 13:48:18 -070041 srcs = glob(['**/*.yang']),
Thomas Vachuska22f731c2017-03-23 15:00:08 -070042 )
43
44 genrule(
45 name = schema,
46 srcs = [ ':' + yangSrcs ],
47 cmd = '$(location //buck-tools:yang-schema) $OUT $SRCS',
48 out = 'yang'
49 )
50
51 genrule(
52 name = registrator,
53 srcs = [ ':' + yangSrcs ],
54 cmd = '$(location //buck-tools:yang-registrator) $OUT app_name $SRCS',
55 out = 'YangModelRegistrator.java'
56 )
57
58 osgi_jar(
Thomas Vachuskad92f6eb2017-03-27 13:48:18 -070059 name = name,
Thomas Vachuska22f731c2017-03-23 15:00:08 -070060 srcs = [ ':' + yangSrcs, ':' + registrator ],
61 deps = deps + YANG_TOOLS,
62 resources = [ ':' + schema ],
63 resources_root = ".",
64 do_checkstyle = False,
65 do_javadocs = False,
66 )
67
68 onos_app (
69 app_name = app_name,
70 title = title,
71 category = 'Model',
72 url = url,
73 description = description,
74 required_apps = [ 'org.onosproject.yang' ],
75 )
76
77
Ray Milkeye88d69b2016-12-16 17:09:13 -080078def yang_osgi_jar(
79 name = None,
80 srcs = None,
81 group_id = ONOS_GROUP_ID,
82 version = ONOS_VERSION,
83 deps = [],
84 visibility = ['PUBLIC'],
85 license = 'NONE',
86 **kwargs
87 ):
88
89 if name is None:
90 name = _get_name()
91
92 yang_jar = name + '-yang'
93 bnd_jar = name + '-bnd'
94
95 args = { 'group':group_id, 'artifact':name, 'version':version }
96
97 yang_library(
98 deps = deps,
99 name = yang_jar,
100 srcs = srcs,
101 visibility = [ ],
102 )
103
104 cmd = 'java -jar $(location //lib:bndexe) wrap -o $OUT '
105 cmd += '-b %(group)s.%(artifact)s ' % args
106 cmd += '-v ' + version.replace('-', '.') + ' '
107 cmd += '$(location :%s) ' % yang_jar
108 cmd += ' >/dev/null 2>&1'
109
110 genrule(
111 name = bnd_jar,
112 bash = cmd,
113 out = name + '.jar',
114 visibility = [],
115 )
116
117 prebuilt_jar(
118 name = name,
119 binary_jar = ':' + bnd_jar,
120 maven_coords = '%(group)s:%(artifact)s:%(version)s'%args,
121 visibility = visibility,
122 )