| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 1 | # Copyright 2017 Sandvine |
| garciadeblas | e6ba40a | 2018-09-27 18:07:38 +0200 | [diff] [blame] | 2 | # Copyright 2017-2018 Telefonica |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 3 | # All Rights Reserved. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. You may obtain |
| 7 | # a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations |
| 15 | # under the License. |
| 16 | |
| 17 | # NOTE: pyang and pyangbind are required for build |
| 18 | |
| 19 | PYANG:= pyang |
| Mike Marchetti | ce4a73d | 2018-08-29 15:40:41 -0400 | [diff] [blame] | 20 | PYBINDPLUGIN:=$(shell /usr/bin/env python3 -c \ |
| 21 | 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))') |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 22 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 23 | YANG_DESC_MODELS := vnfd nsd |
| 24 | YANG_RECORD_MODELS := vnfr nsr |
| 25 | PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS)) |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 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 |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 34 | Q?=@ |
| 35 | |
| garciadeblas | 5a20e9b | 2017-08-29 12:25:24 +0200 | [diff] [blame] | 36 | PYANG_OPTIONS := -Werror |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 37 | |
| garciadeblas | e6ba40a | 2018-09-27 18:07:38 +0200 | [diff] [blame] | 38 | all: $(PYTHON_MODELS) trees |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 39 | $(MAKE) package |
| 40 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 41 | trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES) |
| 42 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 43 | $(OUT_DIR): |
| 44 | $(Q)mkdir -p $(OUT_DIR) |
| 45 | $(Q)touch $(OUT_DIR)/__init__.py |
| 46 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 47 | $(TREES_DIR): |
| 48 | $(Q)mkdir -p $(TREES_DIR) |
| 49 | |
| garciadeblas | bc0dd14 | 2018-10-28 15:54:24 +0100 | [diff] [blame^] | 50 | %.py: $(OUT_DIR) |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 51 | $(Q)echo generating $@ from $*.yang |
| garciadeblas | bc0dd14 | 2018-10-28 15:54:24 +0100 | [diff] [blame^] | 52 | $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 53 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 54 | %.tree.txt: $(TREES_DIR) |
| 55 | $(Q)echo generating $@ from $*.yang |
| garciadeblas | bc0dd14 | 2018-10-28 15:54:24 +0100 | [diff] [blame^] | 56 | $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 57 | |
| 58 | %.html: $(TREES_DIR) |
| 59 | $(Q)echo generating $@ from $*.yang |
| garciadeblas | bc0dd14 | 2018-10-28 15:54:24 +0100 | [diff] [blame^] | 60 | $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang |
| garciadeblas | e06b0aa | 2017-12-19 09:21:31 +0100 | [diff] [blame] | 61 | $(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)/$@ |
| 62 | $(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] | 63 | |
| 64 | %.rec.tree.txt: $(TREES_DIR) |
| 65 | $(Q)echo generating $@ from $*.yang |
| garciadeblas | bc0dd14 | 2018-10-28 15:54:24 +0100 | [diff] [blame^] | 66 | $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 67 | $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt |
| 68 | |
| 69 | %.rec.html: $(TREES_DIR) |
| 70 | $(Q)echo generating $@ from $*.yang |
| garciadeblas | bc0dd14 | 2018-10-28 15:54:24 +0100 | [diff] [blame^] | 71 | $(Q)pyang $(PYANG_OPTIONS) --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] | 72 | $(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)/$@ |
| 73 | $(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] | 74 | $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html |
| 75 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 76 | package: |
| 77 | tox -e build |
| Mike Marchetti | ce4a73d | 2018-08-29 15:40:41 -0400 | [diff] [blame] | 78 | tox -e build3 |
| Mike Marchetti | 09a2710 | 2018-09-24 15:05:51 -0400 | [diff] [blame] | 79 | ./build-docs.sh |
| 80 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 81 | clean: |
| garciadeblas | bc0dd14 | 2018-10-28 15:54:24 +0100 | [diff] [blame^] | 82 | $(Q)rm -rf dist osm_im.egg-info deb deb_dist *.gz $(OUT_DIR) $(TREES_DIR) |