diff --git a/flight/Libraries/PyMite/pymite.mk b/flight/Libraries/PyMite/pymite.mk index 02da15a5d..c009d416f 100644 --- a/flight/Libraries/PyMite/pymite.mk +++ b/flight/Libraries/PyMite/pymite.mk @@ -1,41 +1,75 @@ # -# Rules to add PYMite to a PiOS target +# Rules to add PyMite flight plan interpreter # -PYMITE = $(FLIGHTLIB)/PyMite -PYMITELIB = $(PYMITE)/lib -PYMITEPLAT = $(PYMITE)/platform/openpilot -PYMITETOOLS = $(PYMITE)/tools -PYMITEVM = $(PYMITE)/vm -PYMITEINC = $(PYMITEVM) -PYMITEINC += $(PYMITEPLAT) -PYMITEINC += $(OUTDIR) +# Paths +PYMITE := $(FLIGHTLIB)/PyMite +PYMITELIB := $(PYMITE)/lib +PYMITEPLAT := $(PYMITE)/platform/openpilot +PYMITETOOLS := $(PYMITE)/tools +PYMITEVM := $(PYMITE)/vm +PYMITEINC := $(PYMITEVM) +PYMITEINC += $(PYMITEPLAT) +PYMITEINC += $(OUTDIR) -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files +# Flight plans +FLIGHTPLANLIB ?= $(OPMODULEDIR)/FlightPlan/lib +FLIGHTPLANS ?= $(OPMODULEDIR)/FlightPlan/flightplans -## PyMite files and modules -SRC += $(OUTDIR)/pmlib_img.c -SRC += $(OUTDIR)/pmlib_nat.c -SRC += $(OUTDIR)/pmlibusr_img.c -SRC += $(OUTDIR)/pmlibusr_nat.c -PYSRC += $(wildcard ${PYMITEVM}/*.c) -PYSRC += $(wildcard ${PYMITEPLAT}/*.c) -PYSRC += ${foreach MOD, ${PYMODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -SRC += $(PYSRC) +# Extra modules +PYMODULES ?= FlightPlan -EXTRAINCDIRS += $(PYMITEINC) +# Modules +PYSRC += $(foreach mod, $(PYMODULES), $(wildcard $(OPMODULEDIR)/$(mod)/*.c)) -# Generate intermediate code -gencode: ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h +# PyMite virtual machine and platform files +PYSRC += $(wildcard $(PYMITEVM)/*.c) +PYSRC += $(wildcard $(PYMITEPLAT)/*.c) -$(PYSRC): gencode +# Autogenerated files +PYLIB += $(addprefix $(OUTDIR)/, pmlib_img.c pmlib_nat.c) +PYLIB += $(addprefix $(OUTDIR)/, pmlibusr_img.c pmlibusr_nat.c) -PYTHON = python +# Scripts +PYSCRIPTS += $(wildcard $(PYMITELIB)/*.py) +PYSCRIPTS += $(wildcard $(PYMITEPLAT)/*.py) +PYSCRIPTS += $(wildcard $(FLIGHTPLANLIB)/*.py) +PYSCRIPTS += $(wildcard $(FLIGHTPLANS)/*.py) # Generate code for PyMite -${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h: $(wildcard ${PYMITELIB}/*.py) $(wildcard ${PYMITEPLAT}/*.py) $(wildcard ${FLIGHTPLANLIB}/*.py) $(wildcard ${FLIGHTPLANS}/*.py) - @echo $(MSG_PYMITEINIT) $(call toprel, $@) - @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -s --memspace=flash -o $(OUTDIR)/pmlib_img.c --native-file=$(OUTDIR)/pmlib_nat.c $(PYMITELIB)/list.py $(PYMITELIB)/dict.py $(PYMITELIB)/__bi.py $(PYMITELIB)/sys.py $(PYMITELIB)/string.py $(wildcard $(FLIGHTPLANLIB)/*.py) - @$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h - @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py +$(PYSRC): | $(PYLIB) $(OUTDIR)/pmfeatures.h + +$(OUTDIR)/pmfeatures.h: $(PYSCRIPTS) + @$(ECHO) $(MSG_PYMITEINIT) $(call toprel, $@) + $(V1) $(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $@ + +$(OUTDIR)/pmlib_img.c: | $(OUTDIR)/pmlib_nat.c + +$(OUTDIR)/pmlib_nat.c: $(PYSCRIPTS) + @$(ECHO) $(MSG_PYMITEINIT) $(call toprel, $@) + $(V1) $(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -c -s --memspace=flash \ + -f $(PYMITEPLAT)/pmfeatures.py \ + -o $(OUTDIR)/pmlib_img.c \ + --native-file=$(OUTDIR)/pmlib_nat.c \ + $(PYMITELIB)/list.py \ + $(PYMITELIB)/dict.py \ + $(PYMITELIB)/__bi.py \ + $(PYMITELIB)/sys.py \ + $(PYMITELIB)/string.py \ + $(wildcard $(FLIGHTPLANLIB)/*.py) + +$(OUTDIR)/pmlibusr_img.c: | $(OUTDIR)/pmlibusr_nat.c + +$(OUTDIR)/pmlibusr_nat.c: $(PYSCRIPTS) + @$(ECHO) $(MSG_PYMITEINIT) $(call toprel, $@) + $(V1) $(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -c -u \ + -f $(PYMITEPLAT)/pmfeatures.py \ + -o $(OUTDIR)/pmlibusr_img.c \ + --native-file=$(OUTDIR)/pmlibusr_nat.c \ + $(FLIGHTPLANS)/test.py + +# Add to the source and include lists +SRC += $(PYSRC) +SRC += $(PYLIB) +EXTRAINCDIRS += $(PYMITEINC) +EXTRAINCDIRS += $(foreach mod, $(PYMODULES), $(OPMODULEDIR)/$(mod)/inc) diff --git a/flight/targets/RevoMini/Makefile b/flight/targets/RevoMini/Makefile index cd0eb15dc..f432a535a 100644 --- a/flight/targets/RevoMini/Makefile +++ b/flight/targets/RevoMini/Makefile @@ -92,6 +92,7 @@ endif # Optional component libraries include $(FLIGHTLIB)/rscode/library.mk +#include $(FLIGHTLIB)/PyMite/pymite.mk include $(ROOT_DIR)/make/apps-defs.mk include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/Revolution/Makefile b/flight/targets/Revolution/Makefile index 4f0ecf458..60ae27377 100644 --- a/flight/targets/Revolution/Makefile +++ b/flight/targets/Revolution/Makefile @@ -90,5 +90,8 @@ else SRC += $(OPTESTS)/$(TESTAPP).c endif +# Optional component libraries +#include $(FLIGHTLIB)/PyMite/pymite.mk + include $(ROOT_DIR)/make/apps-defs.mk include $(ROOT_DIR)/make/common-defs.mk