blob: 81858eb53a2528184a15d63ff1ca8dab74e4add4 [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))
garciadeblase4eafa82017-11-29 17:34:36 +010026YANG_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
Mike Marchetti94b645e2017-08-04 14:33:54 -040034Q?=@
35
garciadeblas5a20e9b2017-08-29 12:25:24 +020036PYANG_OPTIONS := -Werror
Mike Marchetti94b645e2017-08-04 14:33:54 -040037
garciadeblase6ba40a2018-09-27 18:07:38 +020038all: $(PYTHON_MODELS) trees
Mike Marchetti94b645e2017-08-04 14:33:54 -040039 $(MAKE) package
40
garciadeblase4eafa82017-11-29 17:34:36 +010041trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES)
42
Mike Marchetti94b645e2017-08-04 14:33:54 -040043$(OUT_DIR):
44 $(Q)mkdir -p $(OUT_DIR)
45 $(Q)touch $(OUT_DIR)/__init__.py
46
garciadeblase4eafa82017-11-29 17:34:36 +010047$(TREES_DIR):
48 $(Q)mkdir -p $(TREES_DIR)
49
garciadeblasbc0dd142018-10-28 15:54:24 +010050%.py: $(OUT_DIR)
Mike Marchetti94b645e2017-08-04 14:33:54 -040051 $(Q)echo generating $@ from $*.yang
garciadeblasbc0dd142018-10-28 15:54:24 +010052 $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
Mike Marchetti94b645e2017-08-04 14:33:54 -040053
garciadeblase4eafa82017-11-29 17:34:36 +010054%.tree.txt: $(TREES_DIR)
55 $(Q)echo generating $@ from $*.yang
garciadeblasbc0dd142018-10-28 15:54:24 +010056 $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
garciadeblase4eafa82017-11-29 17:34:36 +010057
58%.html: $(TREES_DIR)
59 $(Q)echo generating $@ from $*.yang
garciadeblasbc0dd142018-10-28 15:54:24 +010060 $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
garciadeblase06b0aa2017-12-19 09:21:31 +010061 $(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)/$@
garciadeblase4eafa82017-11-29 17:34:36 +010063
64%.rec.tree.txt: $(TREES_DIR)
65 $(Q)echo generating $@ from $*.yang
garciadeblasbc0dd142018-10-28 15:54:24 +010066 $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
garciadeblase4eafa82017-11-29 17:34:36 +010067 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt
68
69%.rec.html: $(TREES_DIR)
70 $(Q)echo generating $@ from $*.yang
garciadeblasbc0dd142018-10-28 15:54:24 +010071 $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/rw-project.yang $(MODEL_DIR)/$*.yang
garciadeblase06b0aa2017-12-19 09:21:31 +010072 $(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)/$@
garciadeblase4eafa82017-11-29 17:34:36 +010074 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html
75
Mike Marchetti94b645e2017-08-04 14:33:54 -040076package:
77 tox -e build
Mike Marchettice4a73d2018-08-29 15:40:41 -040078 tox -e build3
Mike Marchetti09a27102018-09-24 15:05:51 -040079 ./build-docs.sh
80
Mike Marchetti94b645e2017-08-04 14:33:54 -040081clean:
garciadeblasbc0dd142018-10-28 15:54:24 +010082 $(Q)rm -rf dist osm_im.egg-info deb deb_dist *.gz $(OUT_DIR) $(TREES_DIR)