| 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 | |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 19 | .PHONY: all clean package trees deps yang-ietf openapi_schemas yang2swagger |
| garciadeblas | d6e6ffb | 2019-04-09 15:12:05 +0200 | [diff] [blame] | 20 | JAVA:=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 21 | PYANG:= pyang |
| Mike Marchetti | ce4a73d | 2018-08-29 15:40:41 -0400 | [diff] [blame] | 22 | PYBINDPLUGIN:=$(shell /usr/bin/env python3 -c \ |
| 23 | 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))') |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 24 | |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 25 | YANG_DESC_MODELS := vnfd nsd nst nsi etsi-nfv-vnfd etsi-nfv-nsd |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 26 | YANG_RECORD_MODELS := vnfr nsr |
| 27 | PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS)) |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 28 | YANG_DESC_TREES := $(addsuffix .tree.txt, $(YANG_DESC_MODELS)) |
| 29 | YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS)) |
| 30 | YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS)) |
| 31 | YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS)) |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 32 | OPENAPI_SCHEMAS := osm.yaml |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 33 | |
| 34 | OUT_DIR := osm_im |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 35 | TREES_DIR := osm_im_trees |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 36 | MODEL_DIR := models/yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 37 | SOL006_MODEL_DIR := sol006_model/src/yang |
| 38 | SOL006_AUGMENTS_DIR := models/augments/* |
| 39 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 40 | Q?=@ |
| 41 | |
| garciadeblas | 5a20e9b | 2017-08-29 12:25:24 +0200 | [diff] [blame] | 42 | PYANG_OPTIONS := -Werror |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 43 | |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 44 | all: models trees openapi_schemas |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 45 | $(MAKE) package |
| 46 | |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 47 | models: sol006_deps $(PYTHON_MODELS) |
| 48 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 49 | trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES) |
| 50 | |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 51 | openapi_schemas: $(OPENAPI_SCHEMAS) |
| 52 | |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 53 | $(TREES_DIR): |
| 54 | $(Q)mkdir -p $(TREES_DIR) |
| 55 | |
| garciadeblas | 361145b | 2019-10-28 11:11:48 +0100 | [diff] [blame] | 56 | %.py: yang-ietf |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 57 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 58 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR))) |
| 59 | $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=)) |
| 60 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(AUGMENTS_DIR) $(DIR)/$*.yang |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 61 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 62 | %.tree.txt: $(TREES_DIR) yang-ietf |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 63 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 64 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR))) |
| garciaale | f3c839e | 2021-01-04 15:14:49 -0300 | [diff] [blame] | 65 | $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=)) |
| 66 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f tree -o $(TREES_DIR)/$@ $(DIR)/$*.yang $(AUGMENTS_DIR) |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 67 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 68 | %.html: $(TREES_DIR) yang-ietf |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 69 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 70 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR))) |
| garciaale | f3c839e | 2021-01-04 15:14:49 -0300 | [diff] [blame] | 71 | $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=)) |
| 72 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f jstree -o $(TREES_DIR)/$@ $(DIR)/$*.yang $(AUGMENTS_DIR) |
| garciadeblas | e06b0aa | 2017-12-19 09:21:31 +0100 | [diff] [blame] | 73 | $(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)/$@ |
| 74 | $(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] | 75 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 76 | %.rec.tree.txt: $(TREES_DIR) yang-ietf |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 77 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 78 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR))) |
| 79 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f tree -o $(TREES_DIR)/$@ $(DIR)/$*.yang |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 80 | $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt |
| 81 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 82 | %.rec.html: $(TREES_DIR) yang-ietf |
| garciadeblas | e4eafa8 | 2017-11-29 17:34:36 +0100 | [diff] [blame] | 83 | $(Q)echo generating $@ from $*.yang |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 84 | $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR))) |
| 85 | $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f jstree -o $(TREES_DIR)/$@ $(DIR)/osm-project.yang $(DIR)/$*.yang |
| garciadeblas | e06b0aa | 2017-12-19 09:21:31 +0100 | [diff] [blame] | 86 | $(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)/$@ |
| 87 | $(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] | 88 | $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html |
| 89 | |
| garciadeblas | 361145b | 2019-10-28 11:11:48 +0100 | [diff] [blame] | 90 | osm.yaml: yang-ietf yang2swagger |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 91 | $(Q)echo generating $@ |
| garciadeblas | d6e6ffb | 2019-04-09 15:12:05 +0200 | [diff] [blame] | 92 | $(Q)$(JAVA) -jar ${HOME}/.m2/repository/com/mrv/yangtools/swagger-generator-cli/1.1.11/swagger-generator-cli-1.1.11-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@ |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 93 | |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 94 | yang-ietf: |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 95 | $(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-yang-types%402013-07-15.yang -O $(MODEL_DIR)/ietf-yang-types.yang |
| 96 | $(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-inet-types%402013-07-15.yang -O $(MODEL_DIR)/ietf-inet-types.yang |
| 97 | $(Q)cp $(MODEL_DIR)/ietf-yang-types.yang $(SOL006_MODEL_DIR)/ietf-yang-types.yang |
| 98 | $(Q)cp $(MODEL_DIR)/ietf-inet-types.yang $(SOL006_MODEL_DIR)/ietf-inet-types.yang |
| garciadeblas | a174419 | 2018-10-28 16:05:18 +0100 | [diff] [blame] | 99 | |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 100 | yang2swagger: |
| 101 | $(Q)mkdir -p ${HOME}/.m2 |
| 102 | $(Q)wget -q -O ${HOME}/.m2/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml |
| 103 | git clone https://github.com/bartoszm/yang2swagger.git |
| garciadeblas | d6e6ffb | 2019-04-09 15:12:05 +0200 | [diff] [blame] | 104 | git -C yang2swagger checkout tags/1.1.11 |
| garciadeblas | 878dee4 | 2018-10-28 16:12:42 +0100 | [diff] [blame] | 105 | mvn -f yang2swagger/pom.xml clean install |
| 106 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 107 | package: |
| 108 | tox -e build |
| Mike Marchetti | 09a2710 | 2018-09-24 15:05:51 -0400 | [diff] [blame] | 109 | ./build-docs.sh |
| 110 | |
| garciadeblas | 4cdeebb | 2018-10-28 16:00:37 +0100 | [diff] [blame] | 111 | deps: |
| 112 | $(Q)sudo apt-get -y install git make wget python python-pip debhelper dh-make tox python3 python3-pip maven |
| 113 | $(Q)sudo -H python3 -m pip install -U pip |
| 114 | $(Q)sudo -H python2 -m pip install -U pip |
| 115 | $(Q)sudo -H python3 -m pip install -U pyang pyangbind stdeb |
| 116 | $(Q)sudo -H python2 -m pip install -U pyang pyangbind stdeb |
| 117 | $(Q)mkdir -p ~/.m2 |
| garciadeblas | fd168cd | 2020-04-06 07:01:29 +0000 | [diff] [blame] | 118 | $(Q)cp -n ~/.m2/settings.xml ~/.m2/settings.xml.orig ; wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml |
| garciadeblas | 4cdeebb | 2018-10-28 16:00:37 +0100 | [diff] [blame] | 119 | |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 120 | sol006_deps: |
| 121 | $(Q)git clone --single-branch --branch v2.6.1 https://forge.etsi.org/rep/nfv/SOL006.git sol006_model |
| 122 | $(Q)patch -p2 < patch/deref_warnings.patch |
| 123 | $(Q)patch -p2 < patch/nested_workaround.patch |
| 124 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 125 | clean: |
| garciaale | 76f6a62 | 2020-11-19 17:57:42 -0300 | [diff] [blame] | 126 | $(Q)rm -rf dist sol006_model osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR) |