blob: b606e30fe4672b89ddb3f461ba1e7763e98ace31 [file] [log] [blame]
Mike Marchetti94b645e2017-08-04 14:33:54 -04001# Copyright 2017 Sandvine
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16# NOTE: pyang and pyangbind are required for build
17
18PYANG:= pyang
19PYBINDPLUGIN:=$(shell /usr/bin/env python -c \
20 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)')
21
22YANG_MODELS := vnfd nsd
23PYTHON_MODELS := $(addsuffix .py, $(YANG_MODELS))
garciadeblas285ed3e2017-08-30 14:55:49 +020024PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_MODELS))
Mike Marchetti94b645e2017-08-04 14:33:54 -040025
26OUT_DIR := osm_im
27MODEL_DIR := models/yang
28RW_PB_EXT := build/yang/rw-pb-ext.yang
29Q?=@
30
garciadeblas5a20e9b2017-08-29 12:25:24 +020031PYANG_OPTIONS := -Werror
Mike Marchetti94b645e2017-08-04 14:33:54 -040032
garciadeblasd1ca2bd2017-09-06 12:45:19 +020033all: $(PYTHON_MODELS) pyangbind
Mike Marchetti94b645e2017-08-04 14:33:54 -040034 $(MAKE) package
35
36$(OUT_DIR):
37 $(Q)mkdir -p $(OUT_DIR)
38 $(Q)touch $(OUT_DIR)/__init__.py
39
40%.py: $(OUT_DIR) $(RW_PB_EXT)
41 $(Q)echo generating $@ from $*.yang
42 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
43
garciadeblas285ed3e2017-08-30 14:55:49 +020044%.jsonschema: $(OUT_DIR) $(RW_PB_EXT) pyang-json-schema-plugin
45 $(Q)echo generating $@ from $*.yang
46 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir pyang-json-schema-plugin -f json-schema -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
47
Mike Marchetti94b645e2017-08-04 14:33:54 -040048$(RW_PB_EXT):
49 $(Q)mkdir -p $$(dirname $@)
50 $(Q)wget -q https://raw.githubusercontent.com/RIFTIO/RIFT.ware/RIFT.ware-4.4.1/modules/core/util/yangtools/yang/rw-pb-ext.yang -O $@
51
52package:
53 tox -e build
54
garciadeblasde2939d2017-09-11 12:23:40 +020055pyangbind: pyang
Mike Marchetti94b645e2017-08-04 14:33:54 -040056 git clone https://github.com/robshakir/pyangbind
57 cd pyangbind; python setup.py --command-packages=stdeb.command bdist_deb; cd ..
58
garciadeblasde2939d2017-09-11 12:23:40 +020059pyang:
60 git clone https://github.com/mbj4668/pyang
61 cd pyang; python setup.py --command-packages=stdeb.command bdist_deb; cd ..
62
garciadeblas285ed3e2017-08-30 14:55:49 +020063pyang-json-schema-plugin:
64 git clone https://github.com/cmoberg/pyang-json-schema-plugin
65
Mike Marchetti94b645e2017-08-04 14:33:54 -040066clean:
garciadeblasde2939d2017-09-11 12:23:40 +020067 $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang pyangbind pyang-json-schema-plugin $(OUT_DIR)