blob: 7769fe4942040aeee1c8a0c23370afaa63f67807 [file] [log] [blame]
include_defs('//onos.defs')
include_defs('//bucklets/onos.bucklet')
include_defs('//bucklets/onos_app.bucklet')
def _get_name():
base_path = get_base_path()
return ONOS_ARTIFACT_BASE + base_path.replace('/', '-') #TODO Unix-separator
YANG_TOOLS = [
'//lib:onos-yang-model',
'//lib:onos-yang-compiler-api',
'//lib:onos-yang-runtime',
'//lib:org.apache.felix.scr.annotations',
'//apps/yang:onos-apps-yang',
]
def yang_model(
name = None,
app_name = None,
model_id = None,
title = 'YANG Model',
url = 'http://onosproject.org',
description = None,
deps = [],
required_apps = [],
**kwargs
):
if name is None:
name = _get_name()
if model_id is None:
model_id = app_name
yang = name + '-yang'
yangSrcs = yang + '#srcs'
schema = name + '-schema'
registrator = name + '-registrator'
yang_library(
deps = deps,
name = yang,
srcs = glob(['src/main/yang/**/*.yang'], excludes=['**/target/**']),
model_id = model_id
)
genrule(
name = schema,
srcs = [ ':' + yangSrcs ],
cmd = '$(location //buck-tools:yang-schema) $OUT $SRCS',
out = 'yang'
)
genrule(
name = registrator,
srcs = [ ':' + yangSrcs ],
cmd = '$(location //buck-tools:yang-registrator) $OUT ' + app_name + ' $SRCS',
out = 'YangModelRegistrator.java'
)
osgi_jar(
name = name,
srcs = [ ':' + yangSrcs, ':' + registrator ],
deps = deps + YANG_TOOLS,
resources = [ ':' + schema ],
resources_root = ".",
do_checkstyle = False,
do_javadocs = False,
)
onos_app (
app_name = app_name,
title = title,
category = 'Models',
url = url,
description = description,
required_apps = required_apps + [ 'org.onosproject.yang' ],
)
def yang_osgi_jar(
name = None,
srcs = None,
model_id = None,
group_id = ONOS_GROUP_ID,
version = ONOS_VERSION,
deps = [],
visibility = ['PUBLIC'],
license = 'NONE',
**kwargs
):
if name is None:
name = _get_name()
if model_id is None:
model_id = name
yang_jar = name + '-yang'
bnd_jar = name + '-bnd'
args = { 'group':group_id, 'artifact':name, 'version':version }
yang_library(
deps = deps,
name = yang_jar,
srcs = srcs,
model_id = model_id,
visibility = [ ],
)
cmd = 'java -jar $(location //lib:bndexe) wrap -o $OUT '
cmd += '-b %(group)s.%(artifact)s ' % args
cmd += '-v ' + version.replace('-', '.') + ' '
cmd += '$(location :%s) ' % yang_jar
cmd += ' >/dev/null 2>&1'
genrule(
name = bnd_jar,
bash = cmd,
out = name + '.jar',
visibility = [],
)
prebuilt_jar(
name = name,
binary_jar = ':' + bnd_jar,
maven_coords = '%(group)s:%(artifact)s:%(version)s'%args,
visibility = visibility,
)