blob: 5f3b235210f0334709355805459967ff5c500500 [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
garciadeblase4eafa82017-11-29 17:34:36 +010022YANG_DESC_MODELS := vnfd nsd
23YANG_RECORD_MODELS := vnfr nsr
24PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS))
25PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_DESC_MODELS))
26YANG_DESC_TREES := $(addsuffix .tree.txt, $(YANG_DESC_MODELS))
27YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS))
28YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS))
29YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS))
Mike Marchetti94b645e2017-08-04 14:33:54 -040030
31OUT_DIR := osm_im
garciadeblase4eafa82017-11-29 17:34:36 +010032TREES_DIR := osm_im_trees
Mike Marchetti94b645e2017-08-04 14:33:54 -040033MODEL_DIR := models/yang
34RW_PB_EXT := build/yang/rw-pb-ext.yang
35Q?=@
36
garciadeblas5a20e9b2017-08-29 12:25:24 +020037PYANG_OPTIONS := -Werror
Mike Marchetti94b645e2017-08-04 14:33:54 -040038
garciadeblasd1ca2bd2017-09-06 12:45:19 +020039all: $(PYTHON_MODELS) pyangbind
Mike Marchetti94b645e2017-08-04 14:33:54 -040040 $(MAKE) package
41
garciadeblase4eafa82017-11-29 17:34:36 +010042trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES)
43
Mike Marchetti94b645e2017-08-04 14:33:54 -040044$(OUT_DIR):
45 $(Q)mkdir -p $(OUT_DIR)
46 $(Q)touch $(OUT_DIR)/__init__.py
47
garciadeblase4eafa82017-11-29 17:34:36 +010048$(TREES_DIR):
49 $(Q)mkdir -p $(TREES_DIR)
50
Mike Marchetti94b645e2017-08-04 14:33:54 -040051%.py: $(OUT_DIR) $(RW_PB_EXT)
52 $(Q)echo generating $@ from $*.yang
53 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
54
garciadeblas285ed3e2017-08-30 14:55:49 +020055%.jsonschema: $(OUT_DIR) $(RW_PB_EXT) pyang-json-schema-plugin
56 $(Q)echo generating $@ from $*.yang
57 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir pyang-json-schema-plugin -f json-schema -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
58
garciadeblase4eafa82017-11-29 17:34:36 +010059%.tree.txt: $(TREES_DIR)
60 $(Q)echo generating $@ from $*.yang
61 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
62
63%.html: $(TREES_DIR)
64 $(Q)echo generating $@ from $*.yang
65 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
66
67%.rec.tree.txt: $(TREES_DIR)
68 $(Q)echo generating $@ from $*.yang
69 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
70 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt
71
72%.rec.html: $(TREES_DIR)
73 $(Q)echo generating $@ from $*.yang
74 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/rw-project.yang $(MODEL_DIR)/$*.yang
75 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html
76
Mike Marchetti94b645e2017-08-04 14:33:54 -040077$(RW_PB_EXT):
78 $(Q)mkdir -p $$(dirname $@)
79 $(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 $@
80
81package:
82 tox -e build
83
garciadeblasde2939d2017-09-11 12:23:40 +020084pyangbind: pyang
Mike Marchetti94b645e2017-08-04 14:33:54 -040085 git clone https://github.com/robshakir/pyangbind
86 cd pyangbind; python setup.py --command-packages=stdeb.command bdist_deb; cd ..
tierno55fa4302017-09-28 12:02:47 +020087 mkdir -p deb_dist
88 cp pyangbind/deb_dist/*.deb deb_dist
Mike Marchetti94b645e2017-08-04 14:33:54 -040089
garciadeblasde2939d2017-09-11 12:23:40 +020090pyang:
91 git clone https://github.com/mbj4668/pyang
92 cd pyang; python setup.py --command-packages=stdeb.command bdist_deb; cd ..
tierno55fa4302017-09-28 12:02:47 +020093 mkdir -p deb_dist
94 cp pyang/deb_dist/*.deb deb_dist
garciadeblasde2939d2017-09-11 12:23:40 +020095
garciadeblas285ed3e2017-08-30 14:55:49 +020096pyang-json-schema-plugin:
97 git clone https://github.com/cmoberg/pyang-json-schema-plugin
98
Mike Marchetti94b645e2017-08-04 14:33:54 -040099clean:
garciadeblase4eafa82017-11-29 17:34:36 +0100100 $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang pyangbind pyang-json-schema-plugin $(OUT_DIR) $(TREES_DIR)