1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-19 09: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"
endif
# Set up misc host tools
RM=rm
@ -55,8 +56,10 @@ areyousureyoushouldberunningthis:
@echo " gcs - Build the Ground Control System application"
@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_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_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 " Note: All tools will be installed into $(TOOLS_DIR)"
@echo " All build output will be placed in $(BUILD_DIR)"
@ -209,31 +212,22 @@ uavobjgenerator:
$(MAKE) -w ; \
)
.PHONY: uavobjects-synthetics
uavobject-synthetics:
mkdir -p $(BUILD_DIR)/$@
.PHONY:uavobjects
uavobjects: uavobjects_gcs uavobjects_flight uavobjects_python uavobjects_matlab
uavobjects_gcs: uavobject-synthetics uavobjgenerator
mkdir -p $(BUILD_DIR)/uavobject-synthetics/gcs
$(UAVOBJGENERATOR) -gcs "$(ROOT_DIR)/"
UAVOBJ_XML_DIR := $(ROOT_DIR)/shared/uavobjectdefinition
UAVOBJ_OUT_DIR := $(BUILD_DIR)/uavobject-synthetics
uavobjects_flight: uavobject-synthetics uavobjgenerator
mkdir -p $(BUILD_DIR)/uavobject-synthetics/flight
$(UAVOBJGENERATOR) -flight "$(ROOT_DIR)/"
$(UAVOBJ_OUT_DIR):
mkdir -p $@
uavobjects_python: uavobject-synthetics uavobjgenerator
mkdir -p $(BUILD_DIR)/uavobject-synthetics/python
$(UAVOBJGENERATOR) -python "$(ROOT_DIR)/"
uavobjects_%: $(UAVOBJ_OUT_DIR) uavobjgenerator
( cd $(UAVOBJ_OUT_DIR) ; \
$(UAVOBJGENERATOR) -$* $(UAVOBJ_XML_DIR) $(ROOT_DIR) ; \
)
uavobjects_matlab: uavobject-synthetics uavobjgenerator
mkdir -p $(BUILD_DIR)/uavobject-synthetics/matlab
$(UAVOBJGENERATOR) -matlab "$(ROOT_DIR)/"
uavobjects_test: uavobject-synthetics uavobjgenerator
$(UAVOBJGENERATOR) -v -none "$(ROOT_DIR)/"
uavobjects_test: $(UAVOBJ_OUT_DIR) uavobjgenerator
$(UAVOBJGENERATOR) -v -none $(UAVOBJ_XML_DIR) $(ROOT_DIR)
##############################
#

View File

@ -28,14 +28,15 @@
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"
<<"uint16_t" << "uint32_t" << "float" << "uint8_t";
QString flightObjInit,objInc;
flightCodePath = QDir( basepath + QString("flight/UAVObjects"));
flightOutputPath = QDir( outputpath + QString("flight"));
flightCodePath = QDir( templatepath + QString("flight/UAVObjects"));
flightOutputPath = QDir( outputpath + QString("flight") );
flightOutputPath.mkpath(flightOutputPath.absolutePath());
flightCodeTemplate = readFile( flightCodePath.absoluteFilePath("uavobjecttemplate.c") );
flightIncludeTemplate = readFile( flightCodePath.absoluteFilePath("inc/uavobjecttemplate.h") );

View File

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

View File

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

View File

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

View File

@ -28,13 +28,14 @@
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"
<< "uint8" << "uint16" << "uint32" << "float32" << "uint8";
QDir matlabTemplatePath = QDir( basepath + QString("ground/src/plugins/uavobjects"));
QDir matlabOutputPath = QDir( outputpath + QString("matlab"));
QDir matlabTemplatePath = QDir( templatepath + QString("ground/src/plugins/uavobjects"));
QDir matlabOutputPath = QDir( outputpath + QString("matlab") );
matlabOutputPath.mkpath(matlabOutputPath.absolutePath());
QString matlabCodeTemplate = readFile( matlabTemplatePath.absoluteFilePath( "uavobjecttemplate.m") );

View File

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

View File

@ -27,12 +27,13 @@
#include "uavobjectgeneratorpython.h"
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";
pythonCodePath = QDir( basepath + QString("ground/src/plugins/uavobjects"));
pythonOutputPath = QDir( outputpath + QString("python"));
pythonCodePath = QDir( templatepath + QString("ground/src/plugins/uavobjects"));
pythonOutputPath = QDir( outputpath + QString("python") );
pythonOutputPath.mkpath(pythonOutputPath.absolutePath());
pythonCodeTemplate = readFile( pythonCodePath.absoluteFilePath("uavobjecttemplate.py") );

View File

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

View File

@ -45,7 +45,7 @@ using namespace std;
* print usage info
*/
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 << "\t-gcs build groundstation 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-h this help" << 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;
QString basepath;
QString inputpath;
QString templatepath;
QString outputpath;
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);
if (arguments_stringlist.length() == 0) // if we have no param left - make up a basepath
basepath =QString("../../../../../");
else if (arguments_stringlist.length() == 1) // if we have one param left it is the basepath
basepath = arguments_stringlist.at(0);
else // too many arguments
if (arguments_stringlist.length() == 2) {
inputpath = arguments_stringlist.at(0);
templatepath = arguments_stringlist.at(1);
} else {
// wrong number of arguments
return usage_err();
}
if (!basepath.endsWith("/"))
basepath.append("/"); // append a slash if it is not there
if (!inputpath.endsWith("/"))
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();
QStringList filters=QStringList("*.xml");
@ -169,35 +176,35 @@ int main(int argc, char *argv[])
if (do_flight|do_all) {
cout << "generating flight code" << endl ;
UAVObjectGeneratorFlight flightgen;
flightgen.generate(parser,basepath,outputpath);
flightgen.generate(parser,templatepath,outputpath);
}
// generate gcs code if wanted
if (do_gcs|do_all) {
cout << "generating gcs code" << endl ;
UAVObjectGeneratorGCS gcsgen;
gcsgen.generate(parser,basepath,outputpath);
gcsgen.generate(parser,templatepath,outputpath);
}
// generate java code if wanted
if (do_java|do_all) {
cout << "generating java code" << endl ;
UAVObjectGeneratorJava javagen;
javagen.generate(parser,basepath);
javagen.generate(parser,templatepath);
}
// generate python code if wanted
if (do_python|do_all) {
cout << "generating python code" << endl ;
UAVObjectGeneratorPython pygen;
pygen.generate(parser,basepath,outputpath);
pygen.generate(parser,templatepath,outputpath);
}
// generate matlab code if wanted
if (do_matlab|do_all) {
cout << "generating matlab code" << endl ;
UAVObjectGeneratorMatlab matlabgen;
matlabgen.generate(parser,basepath,outputpath);
matlabgen.generate(parser,templatepath,outputpath);
}
return RETURN_OK;