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