blob: 22df56d6566b318270c6c551762449a57f798a98 [file] [log] [blame]
Mike Marchetti94b645e2017-08-04 14:33:54 -04001# Copyright 2017 Sandvine
garciadeblase6ba40a2018-09-27 18:07:38 +02002# Copyright 2017-2018 Telefonica
Mike Marchetti94b645e2017-08-04 14:33:54 -04003# 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
19PYANG:= pyang
Mike Marchettice4a73d2018-08-29 15:40:41 -040020PYBINDPLUGIN:=$(shell /usr/bin/env python3 -c \
21 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))')
Mike Marchetti94b645e2017-08-04 14:33:54 -040022
garciadeblase4eafa82017-11-29 17:34:36 +010023YANG_DESC_MODELS := vnfd nsd
24YANG_RECORD_MODELS := vnfr nsr
25PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS))
26PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_DESC_MODELS))
27YANG_DESC_TREES := $(addsuffix .tree.txt, $(YANG_DESC_MODELS))
28YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS))
29YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS))
30YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS))
Mike Marchetti94b645e2017-08-04 14:33:54 -040031
32OUT_DIR := osm_im
garciadeblase4eafa82017-11-29 17:34:36 +010033TREES_DIR := osm_im_trees
Mike Marchetti94b645e2017-08-04 14:33:54 -040034MODEL_DIR := models/yang
35RW_PB_EXT := build/yang/rw-pb-ext.yang
36Q?=@
37
garciadeblas5a20e9b2017-08-29 12:25:24 +020038PYANG_OPTIONS := -Werror
Mike Marchetti94b645e2017-08-04 14:33:54 -040039
garciadeblase6ba40a2018-09-27 18:07:38 +020040all: $(PYTHON_MODELS) trees
Mike Marchetti94b645e2017-08-04 14:33:54 -040041 $(MAKE) package
42
garciadeblase4eafa82017-11-29 17:34:36 +010043trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES)
44
Mike Marchetti94b645e2017-08-04 14:33:54 -040045$(OUT_DIR):
46 $(Q)mkdir -p $(OUT_DIR)
47 $(Q)touch $(OUT_DIR)/__init__.py
48
garciadeblase4eafa82017-11-29 17:34:36 +010049$(TREES_DIR):
50 $(Q)mkdir -p $(TREES_DIR)
51
Mike Marchetti94b645e2017-08-04 14:33:54 -040052%.py: $(OUT_DIR) $(RW_PB_EXT)
53 $(Q)echo generating $@ from $*.yang
54 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
55
garciadeblas285ed3e2017-08-30 14:55:49 +020056%.jsonschema: $(OUT_DIR) $(RW_PB_EXT) pyang-json-schema-plugin
57 $(Q)echo generating $@ from $*.yang
58 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir pyang-json-schema-plugin -f json-schema -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
59
garciadeblase4eafa82017-11-29 17:34:36 +010060%.tree.txt: $(TREES_DIR)
61 $(Q)echo generating $@ from $*.yang
62 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
63
64%.html: $(TREES_DIR)
65 $(Q)echo generating $@ from $*.yang
66 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
garciadeblase06b0aa2017-12-19 09:21:31 +010067 $(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)/$@
68 $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@
garciadeblase4eafa82017-11-29 17:34:36 +010069
70%.rec.tree.txt: $(TREES_DIR)
71 $(Q)echo generating $@ from $*.yang
72 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
73 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt
74
75%.rec.html: $(TREES_DIR)
76 $(Q)echo generating $@ from $*.yang
77 $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/rw-project.yang $(MODEL_DIR)/$*.yang
garciadeblase06b0aa2017-12-19 09:21:31 +010078 $(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)/$@
79 $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@
garciadeblase4eafa82017-11-29 17:34:36 +010080 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html
81
Mike Marchetti94b645e2017-08-04 14:33:54 -040082$(RW_PB_EXT):
83 $(Q)mkdir -p $$(dirname $@)
84 $(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 $@
85
86package:
87 tox -e build
Mike Marchettice4a73d2018-08-29 15:40:41 -040088 tox -e build3
Mike Marchetti09a27102018-09-24 15:05:51 -040089 ./build-docs.sh
90
garciadeblas285ed3e2017-08-30 14:55:49 +020091pyang-json-schema-plugin:
92 git clone https://github.com/cmoberg/pyang-json-schema-plugin
93
Mike Marchetti94b645e2017-08-04 14:33:54 -040094clean:
garciadeblase6ba40a2018-09-27 18:07:38 +020095 $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang-json-schema-plugin $(OUT_DIR) $(TREES_DIR)