blob: 5746e94e963a6311302c1b4950f30ead37490170 [file] [log] [blame]
Rich Lanea06d0c32013-03-25 08:52:03 -07001# Copyright 2013, Big Switch Networks, Inc.
2#
3# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
4# the following special exception:
5#
6# LOXI Exception
7#
8# As a special exception to the terms of the EPL, you may distribute libraries
9# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
10# that copyright and licensing notices generated by LoxiGen are not altered or removed
11# from the LoxiGen Libraries and the notice provided below is (i) included in
12# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
13# documentation for the LoxiGen Libraries, if distributed in binary form.
14#
15# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
16#
17# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
18# a copy of the EPL at:
19#
20# http://www.eclipse.org/legal/epl-v10.html
21#
22# Unless required by applicable law or agreed to in writing, software
23# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
25# EPL for the specific language governing permissions and limitations
26# under the EPL.
27
28# Available targets: all, c, python, clean
29
30# This Makefile is just for convenience. Users that need to pass additional
31# options to loxigen.py are encouraged to run it directly.
32
33# Where to put the generated code.
34LOXI_OUTPUT_DIR = loxi_output
35
36# Generated files depend on all Loxi code and input files
YAMAMOTO Takashif258d0e2013-07-01 17:24:49 +090037LOXI_PY_FILES=$(shell find . \( -name loxi_output -prune \
Rich Lanea06d0c32013-03-25 08:52:03 -070038 -o -name templates -prune \
Rich Lanea2477b42013-05-02 11:00:25 -070039 -o -name tests -prune \
YAMAMOTO Takashif258d0e2013-07-01 17:24:49 +090040 -o -name '*' \
Rich Lanea06d0c32013-03-25 08:52:03 -070041 \) -a -name '*.py')
42LOXI_TEMPLATE_FILES=$(shell find */templates -type f -a \
43 \! \( -name '*.cache' -o -name '.*' \))
kjwon156fb813d2015-02-12 17:46:08 +090044JAVA_PRE_WRITTEN_FILES=$(shell find java_gen/pre-written -type f)
Rich Lanebc468702013-04-08 17:47:37 -070045INPUT_FILES = $(wildcard openflow_input/*)
Andreas Wundsam7f3c1842013-08-02 22:17:49 -070046TEST_DATA = $(shell find test_data -name '*.data')
Andreas Wundsamf83c3a72013-11-19 15:49:31 -080047OPENFLOWJ_OUTPUT_DIR = ${LOXI_OUTPUT_DIR}/openflowj
48OPENFLOWJ_ECLIPSE_WORKSPACE = openflowj-loxi
Rich Lanea06d0c32013-03-25 08:52:03 -070049
Andreas Wundsam69ef5182013-11-19 16:58:45 -080050all: c python java wireshark
Rich Lanea06d0c32013-03-25 08:52:03 -070051
52c: .loxi_ts.c
53
Andreas Wundsam5dbb82e2013-09-23 14:39:11 -070054.loxi_ts.c: ${LOXI_PY_FILES} ${LOXI_TEMPLATE_FILES} ${INPUT_FILES} ${TEST_DATA}
Murat Parlakisikf95672c2016-12-05 00:53:17 -080055 ./loxigen.py --install-dir=${LOXI_OUTPUT_DIR} --lang=c --version-list=1.0,1.1,1.2,1.3,1.4
Rich Lanea06d0c32013-03-25 08:52:03 -070056 touch $@
57
58python: .loxi_ts.python
59
Andreas Wundsam7f3c1842013-08-02 22:17:49 -070060.loxi_ts.python: ${LOXI_PY_FILES} ${LOXI_TEMPLATE_FILES} ${INPUT_FILES} ${TEST_DATA}
Rich Lanea06d0c32013-03-25 08:52:03 -070061 ./loxigen.py --install-dir=${LOXI_OUTPUT_DIR} --lang=python
62 touch $@
63
Rich Lane8e5a1f82013-06-03 20:11:01 -070064python-doc: python
65 rm -rf ${LOXI_OUTPUT_DIR}/pyloxi-doc
66 mkdir -p ${LOXI_OUTPUT_DIR}/pyloxi-doc
67 cp -a py_gen/sphinx ${LOXI_OUTPUT_DIR}/pyloxi-doc/input
68 PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi sphinx-apidoc -o ${LOXI_OUTPUT_DIR}/pyloxi-doc/input ${LOXI_OUTPUT_DIR}/pyloxi
69 sphinx-build ${LOXI_OUTPUT_DIR}/pyloxi-doc/input ${LOXI_OUTPUT_DIR}/pyloxi-doc
70 rm -rf ${LOXI_OUTPUT_DIR}/pyloxi-doc/input
71 @echo "HTML documentation output to ${LOXI_OUTPUT_DIR}/pyloxi-doc"
72
Andreas Wundsamfd67d5d2013-05-06 17:51:55 -070073java: .loxi_ts.java
Andreas Wundsamf83c3a72013-11-19 15:49:31 -080074 @rsync -rt java_gen/pre-written/ ${LOXI_OUTPUT_DIR}/openflowj/
75 @if [ -e ${OPENFLOWJ_ECLIPSE_WORKSPACE} ]; then \
76 rsync --checksum --delete -rv ${LOXI_OUTPUT_DIR}/openflowj/gen-src/ ${OPENFLOWJ_ECLIPSE_WORKSPACE}/gen-src; \
77 fi
Andreas Wundsamfd67d5d2013-05-06 17:51:55 -070078
kjwon156fb813d2015-02-12 17:46:08 +090079.loxi_ts.java: ${LOXI_PY_FILES} ${LOXI_TEMPLATE_FILES} ${INPUT_FILES} ${TEST_DATA} ${JAVA_PRE_WRITTEN_FILES}
Andreas Wundsamfd67d5d2013-05-06 17:51:55 -070080 ./loxigen.py --install-dir=${LOXI_OUTPUT_DIR} --lang=java
81 touch $@
82
Andreas Wundsamf83c3a72013-11-19 15:49:31 -080083eclipse-workspace:
84 mkdir -p ${OPENFLOWJ_ECLIPSE_WORKSPACE}
85 ln -sf ../java_gen/pre-written/pom.xml ${OPENFLOWJ_ECLIPSE_WORKSPACE}/pom.xml
86 ln -sf ../java_gen/pre-written/LICENSE.txt ${OPENFLOWJ_ECLIPSE_WORKSPACE}/LICENSE.txt
87 ln -sf ../java_gen/pre-written/src ${OPENFLOWJ_ECLIPSE_WORKSPACE}
Sovietaced3d42dbe2014-01-23 15:55:48 -080088 rsync --checksum --delete -rv ${LOXI_OUTPUT_DIR}/openflowj/gen-src/ ${OPENFLOWJ_ECLIPSE_WORKSPACE}/gen-src
Andreas Wundsamf83c3a72013-11-19 15:49:31 -080089 cd ${OPENFLOWJ_ECLIPSE_WORKSPACE} && mvn eclipse:eclipse
Andreas Wundsamd4581992013-09-11 11:12:58 -070090 # Unfortunately, mvn eclipse:eclipse resolves the symlink, which doesn't work with eclipse
Andreas Wundsamf83c3a72013-11-19 15:49:31 -080091 cd ${OPENFLOWJ_ECLIPSE_WORKSPACE} && perl -pi -e 's{<classpathentry kind="src" path="[^"]*/java_gen/pre-written/src/}{<classpathentry kind="src" path="src/}' .classpath
92
93check-java: java
94 cd ${OPENFLOWJ_OUTPUT_DIR} && mvn compile test-compile test
95
96package-java: java
97 cd ${OPENFLOWJ_OUTPUT_DIR} && mvn package
98
99deploy-java: java
100 cd ${OPENFLOWJ_OUTPUT_DIR} && mvn deploy
101
102install-java: java
103 cd ${OPENFLOWJ_OUTPUT_DIR} && mvn install
Andreas Wundsamfd67d5d2013-05-06 17:51:55 -0700104
Rich Lane45dcae12013-06-04 13:07:41 -0700105wireshark: .loxi_ts.wireshark
106
107.loxi_ts.wireshark: ${LOXI_PY_FILES} ${LOXI_TEMPLATE_FILES} ${INPUT_FILES}
108 ./loxigen.py --install-dir=${LOXI_OUTPUT_DIR} --lang=wireshark
109 touch $@
110
Rich Lanea06d0c32013-03-25 08:52:03 -0700111clean:
112 rm -rf loxi_output # only delete generated files in the default directory
Andreas Wundsam4b1de5c2013-10-23 15:27:57 -0700113 rm -f loxigen.log loxigen-test.log .loxi_ts.*
Rich Lanea06d0c32013-03-25 08:52:03 -0700114
115debug:
116 @echo "LOXI_OUTPUT_DIR=\"${LOXI_OUTPUT_DIR}\""
117 @echo
118 @echo "LOXI_PY_FILES=\"${LOXI_PY_FILES}\""
119 @echo
120 @echo "LOXI_TEMPLATE_FILES=\"${LOXI_TEMPLATE_FILES}\""
121 @echo
122 @echo "INPUT_FILES=\"${INPUT_FILES}\""
123
Andreas Wundsam990b6432013-09-19 13:08:20 -0700124check-all: check check-c check-py check-java
125
Rich Lanea06d0c32013-03-25 08:52:03 -0700126check:
Andreas Wundsam50b832c2013-11-15 13:53:30 -0800127 nosetests
Rich Lanea06d0c32013-03-25 08:52:03 -0700128
Rich Lanea22233e2013-04-25 13:18:41 -0700129check-py: python
Rich Lane9a3f1fd2013-05-10 16:29:17 -0700130 PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/generic_util.py
131 PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of10.py
132 PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of11.py
133 PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of12.py
134 PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of13.py
Rich Lane2dd8ed22014-10-03 16:17:09 -0700135 PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of14.py
Murat Parlakisikf95672c2016-12-05 00:53:17 -0800136 PYTHONPATH=${LOXI_OUTPUT_DIR}/pyloxi:. python py_gen/tests/of15.py
Rich Lanea22233e2013-04-25 13:18:41 -0700137
Rich Lane99c29c32013-05-29 17:09:21 -0700138check-c: c
Rich Lane7cb31ff2013-12-15 14:59:56 -0800139 make -j4 -C ${LOXI_OUTPUT_DIR}/locitest
Rich Lane9ff6d162013-07-21 23:32:27 -0700140 ${LOXI_OUTPUT_DIR}/locitest/locitest
Rich Lane99c29c32013-05-29 17:09:21 -0700141
Rich Lanea06d0c32013-03-25 08:52:03 -0700142pylint:
143 pylint -E ${LOXI_PY_FILES}
144
Andreas Wundsam50b832c2013-11-15 13:53:30 -0800145ctags:
146 ctags ${LOXI_PY_FILES} ${LOXI_TEMPLATE_FILES} ${INPUT_FILES} ${TEST_DATA}
147
Rich Laned2487ad2014-04-09 22:40:11 -0700148coverage:
149 find -name '*,cover' -exec rm {} \;
150 coverage erase
151 coverage run -a ./loxigen.py --lang=c
152 coverage run -a ./loxigen.py --lang=python
153 coverage run -a ./loxigen.py --lang=java
154 coverage run -a ./loxigen.py --lang=wireshark
155 coverage annotate -i --omit tenjin.py,pyparsing.py
156
157.PHONY: all clean debug check pylint c python coverage