| 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)) |
| 24 | |
| 25 | OUT_DIR := osm_im |
| 26 | MODEL_DIR := models/yang |
| 27 | RW_PB_EXT := build/yang/rw-pb-ext.yang |
| 28 | Q?=@ |
| 29 | |
| garciadeblas | 5a20e9b | 2017-08-29 12:25:24 +0200 | [diff] [blame^] | 30 | PYANG_OPTIONS := -Werror |
| Mike Marchetti | 94b645e | 2017-08-04 14:33:54 -0400 | [diff] [blame] | 31 | |
| 32 | all: $(PYTHON_MODELS) pyangbind |
| 33 | $(MAKE) package |
| 34 | |
| 35 | $(OUT_DIR): |
| 36 | $(Q)mkdir -p $(OUT_DIR) |
| 37 | $(Q)touch $(OUT_DIR)/__init__.py |
| 38 | |
| 39 | %.py: $(OUT_DIR) $(RW_PB_EXT) |
| 40 | $(Q)echo generating $@ from $*.yang |
| 41 | $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang |
| 42 | |
| 43 | $(RW_PB_EXT): |
| 44 | $(Q)mkdir -p $$(dirname $@) |
| 45 | $(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 $@ |
| 46 | |
| 47 | package: |
| 48 | tox -e build |
| 49 | |
| 50 | pyangbind: |
| 51 | git clone https://github.com/robshakir/pyangbind |
| 52 | cd pyangbind; python setup.py --command-packages=stdeb.command bdist_deb; cd .. |
| 53 | |
| 54 | clean: |
| 55 | $(Q)rm -rf build deb deb_dist *.gz pyangbind $(OUT_DIR) |