blob: 3d68180e6e8736fab1e81a9cd925c1f590fbf4ab [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 = [
10 '//apps/yang:onos-apps-yang',
11 '//lib:onos-yang-runtime',
12]
13
14def yang_model(
15 name = None,
16 app_name = None,
17 title = 'YANG Model',
18 url = 'http://onosproject.org',
19 description = None,
20 deps = [],
21 **kwargs
22 ):
23
24 if name is None:
25 name = _get_name()
26
27 yang = name + '-yang'
28 yangSrcs = yang + '#srcs'
29 schema = name + '-schema'
30 registrator = name + '-registrator'
31
32 yang_library(
33 name = yang,
34 srcs = glob(['src/**/*.yang']),
35 )
36
37 genrule(
38 name = schema,
39 srcs = [ ':' + yangSrcs ],
40 cmd = '$(location //buck-tools:yang-schema) $OUT $SRCS',
41 out = 'yang'
42 )
43
44 genrule(
45 name = registrator,
46 srcs = [ ':' + yangSrcs ],
47 cmd = '$(location //buck-tools:yang-registrator) $OUT app_name $SRCS',
48 out = 'YangModelRegistrator.java'
49 )
50
51 osgi_jar(
52 name = 'onos-models-demo',
53 srcs = [ ':' + yangSrcs, ':' + registrator ],
54 deps = deps + YANG_TOOLS,
55 resources = [ ':' + schema ],
56 resources_root = ".",
57 do_checkstyle = False,
58 do_javadocs = False,
59 )
60
61 onos_app (
62 app_name = app_name,
63 title = title,
64 category = 'Model',
65 url = url,
66 description = description,
67 required_apps = [ 'org.onosproject.yang' ],
68 )
69
70
Ray Milkeye88d69b2016-12-16 17:09:13 -080071def yang_osgi_jar(
72 name = None,
73 srcs = None,
74 group_id = ONOS_GROUP_ID,
75 version = ONOS_VERSION,
76 deps = [],
77 visibility = ['PUBLIC'],
78 license = 'NONE',
79 **kwargs
80 ):
81
82 if name is None:
83 name = _get_name()
84
85 yang_jar = name + '-yang'
86 bnd_jar = name + '-bnd'
87
88 args = { 'group':group_id, 'artifact':name, 'version':version }
89
90 yang_library(
91 deps = deps,
92 name = yang_jar,
93 srcs = srcs,
94 visibility = [ ],
95 )
96
97 cmd = 'java -jar $(location //lib:bndexe) wrap -o $OUT '
98 cmd += '-b %(group)s.%(artifact)s ' % args
99 cmd += '-v ' + version.replace('-', '.') + ' '
100 cmd += '$(location :%s) ' % yang_jar
101 cmd += ' >/dev/null 2>&1'
102
103 genrule(
104 name = bnd_jar,
105 bash = cmd,
106 out = name + '.jar',
107 visibility = [],
108 )
109
110 prebuilt_jar(
111 name = name,
112 binary_jar = ':' + bnd_jar,
113 maven_coords = '%(group)s:%(artifact)s:%(version)s'%args,
114 visibility = visibility,
115 )