1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

UAVObjects-xml: Move UAVObject definitions outside of gcs dir

The UAVObject definition (.xml) files are used by both the
GCS build as well as the flight software builds.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2526 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
stac 2011-01-22 17:38:43 +00:00 committed by stac
parent 205e09a8d1
commit 5e6d87b2db
52 changed files with 58 additions and 53 deletions

View File

@ -18,6 +18,7 @@ ifeq ($(UNAME), Darwin)
UAVOBJGENERATOR="$(BUILD_DIR)/uavobjgenerator/uavobjgenerator" UAVOBJGENERATOR="$(BUILD_DIR)/uavobjgenerator/uavobjgenerator"
endif endif
# Set up misc host tools # Set up misc host tools
RM=rm RM=rm
@ -55,8 +56,10 @@ areyousureyoushouldberunningthis:
@echo " gcs - Build the Ground Control System application" @echo " gcs - Build the Ground Control System application"
@echo " uavobjects - Generate source files from the UAVObject definition XML files" @echo " uavobjects - Generate source files from the UAVObject definition XML files"
@echo " uavobjects_test - parse xml-files - check for valid, duplicate ObjId's, ... " @echo " uavobjects_test - parse xml-files - check for valid, duplicate ObjId's, ... "
@echo " uavobjects_gcs - Generate groundstation source files from the UAVObject definition XML files"
@echo " uavobjects_flight - Generate flight source files from the UAVObject definition XML files" @echo " uavobjects_flight - Generate flight source files from the UAVObject definition XML files"
@echo " uavobjects_gcs - Generate groundstation source files from the UAVObject definition XML files"
@echo " uavobjects_python - Generate python source files from the UAVObject definition XML files"
@echo " uavobjects_matlab - Generate matlab source files from the UAVObject definition XML files"
@echo @echo
@echo " Note: All tools will be installed into $(TOOLS_DIR)" @echo " Note: All tools will be installed into $(TOOLS_DIR)"
@echo " All build output will be placed in $(BUILD_DIR)" @echo " All build output will be placed in $(BUILD_DIR)"
@ -209,31 +212,22 @@ uavobjgenerator:
$(MAKE) -w ; \ $(MAKE) -w ; \
) )
.PHONY: uavobjects-synthetics
uavobject-synthetics:
mkdir -p $(BUILD_DIR)/$@
.PHONY:uavobjects .PHONY:uavobjects
uavobjects: uavobjects_gcs uavobjects_flight uavobjects_python uavobjects_matlab uavobjects: uavobjects_gcs uavobjects_flight uavobjects_python uavobjects_matlab
uavobjects_gcs: uavobject-synthetics uavobjgenerator UAVOBJ_XML_DIR := $(ROOT_DIR)/shared/uavobjectdefinition
mkdir -p $(BUILD_DIR)/uavobject-synthetics/gcs UAVOBJ_OUT_DIR := $(BUILD_DIR)/uavobject-synthetics
$(UAVOBJGENERATOR) -gcs "$(ROOT_DIR)/"
uavobjects_flight: uavobject-synthetics uavobjgenerator $(UAVOBJ_OUT_DIR):
mkdir -p $(BUILD_DIR)/uavobject-synthetics/flight mkdir -p $@
$(UAVOBJGENERATOR) -flight "$(ROOT_DIR)/"
uavobjects_python: uavobject-synthetics uavobjgenerator uavobjects_%: $(UAVOBJ_OUT_DIR) uavobjgenerator
mkdir -p $(BUILD_DIR)/uavobject-synthetics/python ( cd $(UAVOBJ_OUT_DIR) ; \
$(UAVOBJGENERATOR) -python "$(ROOT_DIR)/" $(UAVOBJGENERATOR) -$* $(UAVOBJ_XML_DIR) $(ROOT_DIR) ; \
)
uavobjects_matlab: uavobject-synthetics uavobjgenerator uavobjects_test: $(UAVOBJ_OUT_DIR) uavobjgenerator
mkdir -p $(BUILD_DIR)/uavobject-synthetics/matlab $(UAVOBJGENERATOR) -v -none $(UAVOBJ_XML_DIR) $(ROOT_DIR)
$(UAVOBJGENERATOR) -matlab "$(ROOT_DIR)/"
uavobjects_test: uavobject-synthetics uavobjgenerator
$(UAVOBJGENERATOR) -v -none "$(ROOT_DIR)/"
############################## ##############################
# #

View File

@ -28,14 +28,15 @@
using namespace std; using namespace std;
bool UAVObjectGeneratorFlight::generate(UAVObjectParser* parser,QString basepath,QString outputpath) { bool UAVObjectGeneratorFlight::generate(UAVObjectParser* parser,QString templatepath,QString outputpath) {
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;
flightCodePath = QDir( basepath + QString("flight/UAVObjects")); flightCodePath = QDir( templatepath + QString("flight/UAVObjects"));
flightOutputPath = QDir( outputpath + QString("flight")); flightOutputPath = QDir( outputpath + QString("flight") );
flightOutputPath.mkpath(flightOutputPath.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") );

View File

@ -32,7 +32,7 @@
class UAVObjectGeneratorFlight class UAVObjectGeneratorFlight
{ {
public: public:
bool generate(UAVObjectParser* gen,QString basepath,QString outputpath); bool generate(UAVObjectParser* gen,QString templatepath,QString outputpath);
QStringList fieldTypeStrC; QStringList fieldTypeStrC;
QString flightCodeTemplate, flightIncludeTemplate, flightInitTemplate; QString flightCodeTemplate, flightIncludeTemplate, flightInitTemplate;
QDir flightCodePath; QDir flightCodePath;

View File

@ -27,7 +27,7 @@
#include "uavobjectgeneratorgcs.h" #include "uavobjectgeneratorgcs.h"
using namespace std; using namespace std;
bool UAVObjectGeneratorGCS::generate(UAVObjectParser* parser,QString basepath,QString outputpath) { bool UAVObjectGeneratorGCS::generate(UAVObjectParser* parser,QString templatepath,QString outputpath) {
fieldTypeStrCPP << "qint8" << "qint16" << "qint32" << fieldTypeStrCPP << "qint8" << "qint16" << "qint32" <<
"quint8" << "quint16" << "quint32" << "float" << "quint8"; "quint8" << "quint16" << "quint32" << "float" << "quint8";
@ -35,8 +35,9 @@ bool UAVObjectGeneratorGCS::generate(UAVObjectParser* parser,QString basepath,QS
fieldTypeStrCPPClass << "INT8" << "INT16" << "INT32" fieldTypeStrCPPClass << "INT8" << "INT16" << "INT32"
<< "UINT8" << "UINT16" << "UINT32" << "FLOAT32" << "ENUM"; << "UINT8" << "UINT16" << "UINT32" << "FLOAT32" << "ENUM";
gcsCodePath = QDir( basepath + QString(GCS_CODE_DIR)); gcsCodePath = QDir( templatepath + QString(GCS_CODE_DIR));
gcsOutputPath = QDir( outputpath + QString("gcs")); gcsOutputPath = QDir( outputpath + QString("gcs") );
gcsOutputPath.mkpath(gcsOutputPath.absolutePath());
gcsCodeTemplate = readFile( gcsCodePath.absoluteFilePath("uavobjecttemplate.cpp") ); gcsCodeTemplate = readFile( gcsCodePath.absoluteFilePath("uavobjecttemplate.cpp") );
gcsIncludeTemplate = readFile( gcsCodePath.absoluteFilePath("uavobjecttemplate.h") ); gcsIncludeTemplate = readFile( gcsCodePath.absoluteFilePath("uavobjecttemplate.h") );

View File

@ -34,7 +34,7 @@
class UAVObjectGeneratorGCS class UAVObjectGeneratorGCS
{ {
public: public:
bool generate(UAVObjectParser* gen,QString basepath,QString outputpath); bool generate(UAVObjectParser* gen,QString templatepath,QString outputpath);
private: private:
bool process_object(ObjectInfo* info); bool process_object(ObjectInfo* info);

View File

@ -28,13 +28,14 @@
using namespace std; using namespace std;
bool UAVObjectGeneratorMatlab::generate(UAVObjectParser* parser,QString basepath,QString outputpath) { bool UAVObjectGeneratorMatlab::generate(UAVObjectParser* parser,QString templatepath,QString outputpath) {
fieldTypeStrMatlab << "int8" << "int16" << "int32" fieldTypeStrMatlab << "int8" << "int16" << "int32"
<< "uint8" << "uint16" << "uint32" << "float32" << "uint8"; << "uint8" << "uint16" << "uint32" << "float32" << "uint8";
QDir matlabTemplatePath = QDir( basepath + QString("ground/src/plugins/uavobjects")); QDir matlabTemplatePath = QDir( templatepath + QString("ground/src/plugins/uavobjects"));
QDir matlabOutputPath = QDir( outputpath + QString("matlab")); QDir matlabOutputPath = QDir( outputpath + QString("matlab") );
matlabOutputPath.mkpath(matlabOutputPath.absolutePath());
QString matlabCodeTemplate = readFile( matlabTemplatePath.absoluteFilePath( "uavobjecttemplate.m") ); QString matlabCodeTemplate = readFile( matlabTemplatePath.absoluteFilePath( "uavobjecttemplate.m") );

View File

@ -32,7 +32,7 @@
class UAVObjectGeneratorMatlab class UAVObjectGeneratorMatlab
{ {
public: public:
bool generate(UAVObjectParser* gen,QString basepath,QString outputpath); bool generate(UAVObjectParser* gen,QString templatepath,QString outputpath);
private: private:
bool process_object(ObjectInfo* info); bool process_object(ObjectInfo* info);

View File

@ -27,12 +27,13 @@
#include "uavobjectgeneratorpython.h" #include "uavobjectgeneratorpython.h"
using namespace std; using namespace std;
bool UAVObjectGeneratorPython::generate(UAVObjectParser* parser,QString basepath,QString outputpath) { bool UAVObjectGeneratorPython::generate(UAVObjectParser* parser,QString templatepath,QString outputpath) {
fieldTypeStrPython << "b" << "h" << "i" << "B" << "H" << "I" << "f" << "b"; fieldTypeStrPython << "b" << "h" << "i" << "B" << "H" << "I" << "f" << "b";
pythonCodePath = QDir( basepath + QString("ground/src/plugins/uavobjects")); pythonCodePath = QDir( templatepath + QString("ground/src/plugins/uavobjects"));
pythonOutputPath = QDir( outputpath + QString("python")); pythonOutputPath = QDir( outputpath + QString("python") );
pythonOutputPath.mkpath(pythonOutputPath.absolutePath());
pythonCodeTemplate = readFile( pythonCodePath.absoluteFilePath("uavobjecttemplate.py") ); pythonCodeTemplate = readFile( pythonCodePath.absoluteFilePath("uavobjecttemplate.py") );

View File

@ -32,7 +32,7 @@
class UAVObjectGeneratorPython class UAVObjectGeneratorPython
{ {
public: public:
bool generate(UAVObjectParser* gen,QString basepath,QString outputpath); bool generate(UAVObjectParser* gen,QString templatepath,QString outputpath);
private: private:
bool process_object(ObjectInfo* info); bool process_object(ObjectInfo* info);

View File

@ -45,7 +45,7 @@ using namespace std;
* print usage info * print usage info
*/ */
void usage() { void usage() {
cout << "Usage: uavobjectgenerator [-gcs] [-flight] [-java] [-python] [-matlab] [-none] [-v] [base_path]" << endl; cout << "Usage: uavobjectgenerator [-gcs] [-flight] [-java] [-python] [-matlab] [-none] [-v] xml_path template_base" << endl;
cout << "Languages: "<< endl; cout << "Languages: "<< endl;
cout << "\t-gcs build groundstation code" << endl; cout << "\t-gcs build groundstation code" << endl;
cout << "\t-flight build flight code" << endl; cout << "\t-flight build flight code" << endl;
@ -57,7 +57,8 @@ void usage() {
cout << "\t-none build no language - just parse xml's" << endl; cout << "\t-none build no language - just parse xml's" << endl;
cout << "\t-h this help" << endl; cout << "\t-h this help" << endl;
cout << "\t-v verbose" << endl; cout << "\t-v verbose" << endl;
cout << "\tbase_path base path to gcs and flight directories (as in svn)." << endl; cout << "\tinput_path path to UAVObject definition (.xml) files." << endl;
cout << "\ttemplate_path path to the root of the OpenPilot source tree." << endl;
} }
/** /**
@ -78,7 +79,8 @@ int main(int argc, char *argv[])
cout << "- OpenPilot UAVObject Generator -" << endl; cout << "- OpenPilot UAVObject Generator -" << endl;
QString basepath; QString inputpath;
QString templatepath;
QString outputpath; QString outputpath;
QStringList arguments_stringlist; QStringList arguments_stringlist;
@ -101,19 +103,24 @@ int main(int argc, char *argv[])
bool do_all=((do_gcs||do_flight||do_java||do_python||do_matlab)==false); bool do_all=((do_gcs||do_flight||do_java||do_python||do_matlab)==false);
if (arguments_stringlist.length() == 0) // if we have no param left - make up a basepath if (arguments_stringlist.length() == 2) {
basepath =QString("../../../../../"); inputpath = arguments_stringlist.at(0);
else if (arguments_stringlist.length() == 1) // if we have one param left it is the basepath templatepath = arguments_stringlist.at(1);
basepath = arguments_stringlist.at(0); } else {
else // too many arguments // wrong number of arguments
return usage_err(); return usage_err();
}
if (!basepath.endsWith("/")) if (!inputpath.endsWith("/"))
basepath.append("/"); // append a slash if it is not there inputpath.append("/"); // append a slash if it is not there
outputpath = basepath + QString("build/uavobject-synthetics/"); if (!templatepath.endsWith("/"))
templatepath.append("/"); // append a slash if it is not there
QDir xmlPath = QDir( basepath + QString("ground/src/shared/uavobjectdefinition")); // put all output files in the current directory
outputpath = QString("./");
QDir xmlPath = QDir(inputpath);
UAVObjectParser* parser = new UAVObjectParser(); UAVObjectParser* parser = new UAVObjectParser();
QStringList filters=QStringList("*.xml"); QStringList filters=QStringList("*.xml");
@ -169,35 +176,35 @@ int main(int argc, char *argv[])
if (do_flight|do_all) { if (do_flight|do_all) {
cout << "generating flight code" << endl ; cout << "generating flight code" << endl ;
UAVObjectGeneratorFlight flightgen; UAVObjectGeneratorFlight flightgen;
flightgen.generate(parser,basepath,outputpath); flightgen.generate(parser,templatepath,outputpath);
} }
// generate gcs code if wanted // generate gcs code if wanted
if (do_gcs|do_all) { if (do_gcs|do_all) {
cout << "generating gcs code" << endl ; cout << "generating gcs code" << endl ;
UAVObjectGeneratorGCS gcsgen; UAVObjectGeneratorGCS gcsgen;
gcsgen.generate(parser,basepath,outputpath); gcsgen.generate(parser,templatepath,outputpath);
} }
// generate java code if wanted // generate java code if wanted
if (do_java|do_all) { if (do_java|do_all) {
cout << "generating java code" << endl ; cout << "generating java code" << endl ;
UAVObjectGeneratorJava javagen; UAVObjectGeneratorJava javagen;
javagen.generate(parser,basepath); javagen.generate(parser,templatepath);
} }
// generate python code if wanted // generate python code if wanted
if (do_python|do_all) { if (do_python|do_all) {
cout << "generating python code" << endl ; cout << "generating python code" << endl ;
UAVObjectGeneratorPython pygen; UAVObjectGeneratorPython pygen;
pygen.generate(parser,basepath,outputpath); pygen.generate(parser,templatepath,outputpath);
} }
// generate matlab code if wanted // generate matlab code if wanted
if (do_matlab|do_all) { if (do_matlab|do_all) {
cout << "generating matlab code" << endl ; cout << "generating matlab code" << endl ;
UAVObjectGeneratorMatlab matlabgen; UAVObjectGeneratorMatlab matlabgen;
matlabgen.generate(parser,basepath,outputpath); matlabgen.generate(parser,templatepath,outputpath);
} }
return RETURN_OK; return RETURN_OK;