mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
UAVObjectgenerator: Autogenerate Make include-file for flight UAVObjects to be used in firmware Makefiles.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2702 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
8de340b5a8
commit
16eef53f02
@ -130,7 +130,7 @@ PYMITEINC += $(OUTDIR)
|
|||||||
FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib
|
FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib
|
||||||
FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans
|
FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans
|
||||||
|
|
||||||
OPUAVSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight
|
UAVOBJSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight
|
||||||
|
|
||||||
# List C source files here. (C dependencies are automatically generated.)
|
# List C source files here. (C dependencies are automatically generated.)
|
||||||
# use file-extension c for "c-only"-files
|
# use file-extension c for "c-only"-files
|
||||||
@ -170,7 +170,8 @@ endif
|
|||||||
|
|
||||||
## UAVOBJECTS
|
## UAVOBJECTS
|
||||||
ifndef TESTAPP
|
ifndef TESTAPP
|
||||||
SRC += $(wildcard $(OPUAVSYNTHDIR)/*.c )
|
include $(UAVOBJSYNTHDIR)/Makefile.inc
|
||||||
|
SRC += $(UAVOBJSRC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
## PIOS Hardware (STM32F10x)
|
## PIOS Hardware (STM32F10x)
|
||||||
@ -308,7 +309,7 @@ EXTRAINCDIRS += $(OPUAVTALK)
|
|||||||
EXTRAINCDIRS += $(OPUAVTALKINC)
|
EXTRAINCDIRS += $(OPUAVTALKINC)
|
||||||
EXTRAINCDIRS += $(OPUAVOBJ)
|
EXTRAINCDIRS += $(OPUAVOBJ)
|
||||||
EXTRAINCDIRS += $(OPUAVOBJINC)
|
EXTRAINCDIRS += $(OPUAVOBJINC)
|
||||||
EXTRAINCDIRS += $(OPUAVSYNTHDIR)
|
EXTRAINCDIRS += $(UAVOBJSYNTHDIR)
|
||||||
EXTRAINCDIRS += $(PIOS)
|
EXTRAINCDIRS += $(PIOS)
|
||||||
EXTRAINCDIRS += $(PIOSINC)
|
EXTRAINCDIRS += $(PIOSINC)
|
||||||
EXTRAINCDIRS += $(FLIGHTLIBINC)
|
EXTRAINCDIRS += $(FLIGHTLIBINC)
|
||||||
|
@ -114,7 +114,7 @@ PYMITEINC += $(OUTDIR)
|
|||||||
FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib
|
FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib
|
||||||
FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans
|
FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans
|
||||||
|
|
||||||
OPUAVSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight
|
UAVOBJSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight
|
||||||
|
|
||||||
# List C source files here. (C dependencies are automatically generated.)
|
# List C source files here. (C dependencies are automatically generated.)
|
||||||
# use file-extension c for "c-only"-files
|
# use file-extension c for "c-only"-files
|
||||||
@ -143,7 +143,7 @@ SRC += $(OPSYSTEM)/taskmonitor.c
|
|||||||
SRC += $(OPUAVTALK)/uavtalk.c
|
SRC += $(OPUAVTALK)/uavtalk.c
|
||||||
SRC += $(OPUAVOBJ)/uavobjectmanager.c
|
SRC += $(OPUAVOBJ)/uavobjectmanager.c
|
||||||
SRC += $(OPUAVOBJ)/eventdispatcher.c
|
SRC += $(OPUAVOBJ)/eventdispatcher.c
|
||||||
SRC += $(OPUAVSYNTHDIR)/init/uavobjectsinit.c
|
SRC += $(UAVOBJSYNTHDIR)/uavobjectsinit.c
|
||||||
else
|
else
|
||||||
## TESTCODE
|
## TESTCODE
|
||||||
SRC += $(OPTESTS)/test_common.c
|
SRC += $(OPTESTS)/test_common.c
|
||||||
@ -154,7 +154,8 @@ endif
|
|||||||
|
|
||||||
## UAVOBJECTS
|
## UAVOBJECTS
|
||||||
ifndef TESTAPP
|
ifndef TESTAPP
|
||||||
SRC += $(wildcard $(OPUAVSYNTHDIR)/*.c)
|
include $(UAVOBJSYNTHDIR)/Makefile.inc
|
||||||
|
SRC += $(UAVOBJSRC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
## PIOS Hardware (posix)
|
## PIOS Hardware (posix)
|
||||||
@ -209,7 +210,7 @@ EXTRAINCDIRS += $(OPUAVTALK)
|
|||||||
EXTRAINCDIRS += $(OPUAVTALKINC)
|
EXTRAINCDIRS += $(OPUAVTALKINC)
|
||||||
EXTRAINCDIRS += $(OPUAVOBJ)
|
EXTRAINCDIRS += $(OPUAVOBJ)
|
||||||
EXTRAINCDIRS += $(OPUAVOBJINC)
|
EXTRAINCDIRS += $(OPUAVOBJINC)
|
||||||
EXTRAINCDIRS += $(OPUAVSYNTHDIR)
|
EXTRAINCDIRS += $(UAVOBJSYNTHDIR)
|
||||||
EXTRAINCDIRS += $(PIOS)
|
EXTRAINCDIRS += $(PIOS)
|
||||||
EXTRAINCDIRS += $(PIOSINC)
|
EXTRAINCDIRS += $(PIOSINC)
|
||||||
EXTRAINCDIRS += $(FLIGHTLIBINC)
|
EXTRAINCDIRS += $(FLIGHTLIBINC)
|
||||||
|
@ -33,16 +33,15 @@ bool UAVObjectGeneratorFlight::generate(UAVObjectParser* parser,QString template
|
|||||||
fieldTypeStrC << "int8_t" << "int16_t" << "int32_t" <<"uint8_t"
|
fieldTypeStrC << "int8_t" << "int16_t" << "int32_t" <<"uint8_t"
|
||||||
<<"uint16_t" << "uint32_t" << "float" << "uint8_t";
|
<<"uint16_t" << "uint32_t" << "float" << "uint8_t";
|
||||||
|
|
||||||
QString flightObjInit,objInc;
|
QString flightObjInit,objInc,objFileNames,objNames;
|
||||||
flightCodePath = QDir( templatepath + QString("flight/UAVObjects"));
|
flightCodePath = QDir( templatepath + QString("flight/UAVObjects"));
|
||||||
flightOutputPath = QDir( outputpath + QString("flight") );
|
flightOutputPath = QDir( outputpath + QString("flight") );
|
||||||
flightOutputPath.mkpath(flightOutputPath.absolutePath());
|
flightOutputPath.mkpath(flightOutputPath.absolutePath());
|
||||||
flightInitOutputPath = QDir( outputpath + QString("flight/init") );
|
|
||||||
flightInitOutputPath.mkpath(flightInitOutputPath.absolutePath());
|
|
||||||
|
|
||||||
flightCodeTemplate = readFile( flightCodePath.absoluteFilePath("uavobjecttemplate.c") );
|
flightCodeTemplate = readFile( flightCodePath.absoluteFilePath("uavobjecttemplate.c") );
|
||||||
flightIncludeTemplate = readFile( flightCodePath.absoluteFilePath("inc/uavobjecttemplate.h") );
|
flightIncludeTemplate = readFile( flightCodePath.absoluteFilePath("inc/uavobjecttemplate.h") );
|
||||||
flightInitTemplate = readFile( flightCodePath.absoluteFilePath("uavobjectsinittemplate.c") );
|
flightInitTemplate = readFile( flightCodePath.absoluteFilePath("uavobjectsinittemplate.c") );
|
||||||
|
flightMakeTemplate = readFile( flightCodePath.absoluteFilePath("Makefiletemplate.inc") );
|
||||||
|
|
||||||
if ( flightCodeTemplate.isNull() || flightIncludeTemplate.isNull() || flightInitTemplate.isNull()) {
|
if ( flightCodeTemplate.isNull() || flightIncludeTemplate.isNull() || flightInitTemplate.isNull()) {
|
||||||
cerr << "Error: Could not open flight template files." << endl;
|
cerr << "Error: Could not open flight template files." << endl;
|
||||||
@ -54,18 +53,30 @@ bool UAVObjectGeneratorFlight::generate(UAVObjectParser* parser,QString template
|
|||||||
process_object(info);
|
process_object(info);
|
||||||
flightObjInit.append(" " + info->name + "Initialize();\n");
|
flightObjInit.append(" " + info->name + "Initialize();\n");
|
||||||
objInc.append("#include \"" + info->namelc + ".h\"\n");
|
objInc.append("#include \"" + info->namelc + ".h\"\n");
|
||||||
|
objFileNames.append(" " + info->namelc);
|
||||||
|
objNames.append(" " + info->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the flight object inialization files
|
// Write the flight object inialization files
|
||||||
flightInitTemplate.replace( QString("$(OBJINC)"), objInc);
|
flightInitTemplate.replace( QString("$(OBJINC)"), objInc);
|
||||||
flightInitTemplate.replace( QString("$(OBJINIT)"), flightObjInit);
|
flightInitTemplate.replace( QString("$(OBJINIT)"), flightObjInit);
|
||||||
bool res = writeFileIfDiffrent( flightInitOutputPath.absolutePath() + "/uavobjectsinit.c",
|
bool res = writeFileIfDiffrent( flightOutputPath.absolutePath() + "/uavobjectsinit.c",
|
||||||
flightInitTemplate );
|
flightInitTemplate );
|
||||||
if (!res) {
|
if (!res) {
|
||||||
cout << "Error: Could not write flight object init files" << endl;
|
cout << "Error: Could not write flight object init files" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write the flight object Makefile
|
||||||
|
flightMakeTemplate.replace( QString("$(UAVOBJFILENAMES)"), objFileNames);
|
||||||
|
flightMakeTemplate.replace( QString("$(UAVOBJNAMES)"), objNames);
|
||||||
|
res = writeFileIfDiffrent( flightOutputPath.absolutePath() + "/Makefile.inc",
|
||||||
|
flightMakeTemplate );
|
||||||
|
if (!res) {
|
||||||
|
cout << "Error: Could not write flight Makefile" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true; // if we come here everything should be fine
|
return true; // if we come here everything should be fine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +34,9 @@ class UAVObjectGeneratorFlight
|
|||||||
public:
|
public:
|
||||||
bool generate(UAVObjectParser* gen,QString templatepath,QString outputpath);
|
bool generate(UAVObjectParser* gen,QString templatepath,QString outputpath);
|
||||||
QStringList fieldTypeStrC;
|
QStringList fieldTypeStrC;
|
||||||
QString flightCodeTemplate, flightIncludeTemplate, flightInitTemplate;
|
QString flightCodeTemplate, flightIncludeTemplate, flightInitTemplate, flightMakeTemplate;
|
||||||
QDir flightCodePath;
|
QDir flightCodePath;
|
||||||
QDir flightOutputPath;
|
QDir flightOutputPath;
|
||||||
QDir flightInitOutputPath;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool process_object(ObjectInfo* info);
|
bool process_object(ObjectInfo* info);
|
||||||
|
Loading…
Reference in New Issue
Block a user