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