| 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 | |
| 22 | YANG_MODELS := vnfd nsd |
| 23 | PYTHON_MODELS := $(addsuffix .py, $(YANG_MODELS)) |
| garciadeblas | 285ed3e | 2017-08-30 14:55:49 +0200 | [diff] [blame] | 24 | PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_MODELS)) |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 25 | |
| 26 | OUT_DIR := osm_im |
| 27 | MODEL_DIR := models/yang |
| 28 | RW_PB_EXT := build/yang/rw-pb-ext.yang |
| 29 | Q?=@ |
| 30 | |
| garciadeblas | 5a20e9b | 2017-08-29 12:25:24 +0200 | [diff] [blame] | 31 | PYANG_OPTIONS := -Werror |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 32 | |
| garciadeblas | d1ca2bd | 2017-09-06 12:45:19 +0200 | [diff] [blame] | 33 | all: $(PYTHON_MODELS) pyangbind |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 34 | $(MAKE) package |
| 35 | |
| 36 | $(OUT_DIR): |
| 37 | $(Q)mkdir -p $(OUT_DIR) |
| 38 | $(Q)touch $(OUT_DIR)/__init__.py |
| 39 | |
| 40 | %.py: $(OUT_DIR) $(RW_PB_EXT) |
| 41 | $(Q)echo generating $@ from $*.yang |
| 42 | $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang |
| 43 | |
| garciadeblas | 285ed3e | 2017-08-30 14:55:49 +0200 | [diff] [blame] | 44 | %.jsonschema: $(OUT_DIR) $(RW_PB_EXT) pyang-json-schema-plugin |
| 45 | $(Q)echo generating $@ from $*.yang |
| 46 | $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir pyang-json-schema-plugin -f json-schema -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang |
| 47 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 48 | $(RW_PB_EXT): |
| 49 | $(Q)mkdir -p $$(dirname $@) |
| 50 | $(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 $@ |
| 51 | |
| 52 | package: |
| 53 | tox -e build |
| 54 | |
| garciadeblas | de2939d | 2017-09-11 12:23:40 +0200 | [diff] [blame^] | 55 | pyangbind: pyang |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 56 | git clone https://github.com/robshakir/pyangbind |
| 57 | cd pyangbind; python setup.py --command-packages=stdeb.command bdist_deb; cd .. |
| 58 | |
| garciadeblas | de2939d | 2017-09-11 12:23:40 +0200 | [diff] [blame^] | 59 | pyang: |
| 60 | git clone https://github.com/mbj4668/pyang |
| 61 | cd pyang; python setup.py --command-packages=stdeb.command bdist_deb; cd .. |
| 62 | |
| garciadeblas | 285ed3e | 2017-08-30 14:55:49 +0200 | [diff] [blame] | 63 | pyang-json-schema-plugin: |
| 64 | git clone https://github.com/cmoberg/pyang-json-schema-plugin |
| 65 | |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 66 | clean: |
| garciadeblas | de2939d | 2017-09-11 12:23:40 +0200 | [diff] [blame^] | 67 | $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang pyangbind pyang-json-schema-plugin $(OUT_DIR) |