| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 1 | # 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 | |
| 18 | PYANG:= pyang |
| 19 | PYBINDPLUGIN:=$(shell /usr/bin/env python -c \ |
| 20 | 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)') |
| 21 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 22 | YANG_DESC_MODELS := vnfd nsd |
| 23 | YANG_RECORD_MODELS := vnfr nsr |
| 24 | PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS)) |
| 25 | PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_DESC_MODELS)) |
| 26 | YANG_DESC_TREES := $(addsuffix .tree.txt, $(YANG_DESC_MODELS)) |
| 27 | YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS)) |
| 28 | YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS)) |
| 29 | YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS)) |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 30 | |
| 31 | OUT_DIR := osm_im |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 32 | TREES_DIR := osm_im_trees |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 33 | MODEL_DIR := models/yang |
| 34 | RW_PB_EXT := build/yang/rw-pb-ext.yang |
| 35 | Q?=@ |
| 36 | |
| garciadeblas | 5a20e9b | 2017-08-29 12:25:24 +0200 | [diff] [blame] | 37 | PYANG_OPTIONS := -Werror |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 38 | |
| garciadeblas | 241bd46 | 2018-06-13 13:36:43 +0200 | [diff] [blame] | 39 | all: $(PYTHON_MODELS) pyangbind trees |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 40 | $(MAKE) package |
| 41 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 42 | trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES) |
| 43 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 44 | $(OUT_DIR): |
| 45 | $(Q)mkdir -p $(OUT_DIR) |
| 46 | $(Q)touch $(OUT_DIR)/__init__.py |
| 47 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 48 | $(TREES_DIR): |
| 49 | $(Q)mkdir -p $(TREES_DIR) |
| 50 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 51 | %.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 | |
| garciadeblas | 285ed3e | 2017-08-30 14:55:49 +0200 | [diff] [blame] | 55 | %.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 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 59 | %.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 |
| garciadeblas | e06b0aa | 2017-12-19 09:21:31 +0100 | [diff] [blame] | 66 | $(Q)sed -r -i 's|data\:image/gif\;base64,R0lGODlhS.*RCAA7|https://osm.etsi.org/images/OSM-logo.png\" width=\"175\" height=\"60|g' $(TREES_DIR)/$@ |
| 67 | $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@ |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 68 | |
| 69 | %.rec.tree.txt: $(TREES_DIR) |
| 70 | $(Q)echo generating $@ from $*.yang |
| 71 | $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang |
| 72 | $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt |
| 73 | |
| 74 | %.rec.html: $(TREES_DIR) |
| 75 | $(Q)echo generating $@ from $*.yang |
| 76 | $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/rw-project.yang $(MODEL_DIR)/$*.yang |
| garciadeblas | e06b0aa | 2017-12-19 09:21:31 +0100 | [diff] [blame] | 77 | $(Q)sed -r -i 's|data\:image/gif\;base64,R0lGODlhS.*RCAA7|https://osm.etsi.org/images/OSM-logo.png\" width=\"175\" height=\"60|g' $(TREES_DIR)/$@ |
| 78 | $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@ |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 79 | $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html |
| 80 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 81 | $(RW_PB_EXT): |
| 82 | $(Q)mkdir -p $$(dirname $@) |
| 83 | $(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 $@ |
| 84 | |
| 85 | package: |
| 86 | tox -e build |
| 87 | |
| garciadeblas | de2939d | 2017-09-11 12:23:40 +0200 | [diff] [blame] | 88 | pyangbind: pyang |
| tierno | a0c88dc | 2018-01-09 18:27:32 +0100 | [diff] [blame] | 89 | git clone https://github.com/alf-tierno/pyangbind |
| 90 | cd pyangbind; git checkout issue151; python setup.py --command-packages=stdeb.command bdist_deb; cd .. |
| tierno | 55fa430 | 2017-09-28 12:02:47 +0200 | [diff] [blame] | 91 | mkdir -p deb_dist |
| 92 | cp pyangbind/deb_dist/*.deb deb_dist |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 93 | |
| garciadeblas | de2939d | 2017-09-11 12:23:40 +0200 | [diff] [blame] | 94 | pyang: |
| 95 | git clone https://github.com/mbj4668/pyang |
| 96 | cd pyang; python setup.py --command-packages=stdeb.command bdist_deb; cd .. |
| tierno | 55fa430 | 2017-09-28 12:02:47 +0200 | [diff] [blame] | 97 | mkdir -p deb_dist |
| 98 | cp pyang/deb_dist/*.deb deb_dist |
| garciadeblas | de2939d | 2017-09-11 12:23:40 +0200 | [diff] [blame] | 99 | |
| garciadeblas | 285ed3e | 2017-08-30 14:55:49 +0200 | [diff] [blame] | 100 | pyang-json-schema-plugin: |
| 101 | git clone https://github.com/cmoberg/pyang-json-schema-plugin |
| 102 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 103 | clean: |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 104 | $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang pyangbind pyang-json-schema-plugin $(OUT_DIR) $(TREES_DIR) |