- Began refactoring TDF build scripts
- Separated TDF validation and mapping generation - Moving away from the JSON mapping file, to a generated header file containing the TDF mapping. - Other bits of tidying
This commit is contained in:
39
src/Targets/TargetDescription/GeneratedMapping.hpp.in
Normal file
39
src/Targets/TargetDescription/GeneratedMapping.hpp.in
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "src/Targets/TargetFamily.hpp"
|
||||
|
||||
namespace Targets::TargetDescription
|
||||
{
|
||||
struct GeneratedMapping
|
||||
{
|
||||
struct BriefTargetDescriptor
|
||||
{
|
||||
std::string targetName;
|
||||
std::string configValue;
|
||||
TargetFamily targetFamily;
|
||||
std::string relativeTdfPath;
|
||||
|
||||
constexpr BriefTargetDescriptor(
|
||||
const std::string& targetName,
|
||||
const std::string& configValue,
|
||||
TargetFamily targetFamily,
|
||||
const std::string& relativeTdfPath
|
||||
)
|
||||
: targetName(targetName)
|
||||
, configValue(configValue)
|
||||
, targetFamily(targetFamily)
|
||||
, relativeTdfPath(relativeTdfPath)
|
||||
{}
|
||||
};
|
||||
|
||||
/*
|
||||
* The @MAPPING_PLACEHOLDER@ comment below will be replaced with the TDF mapping
|
||||
*/
|
||||
static const inline std::map<std::string, BriefTargetDescriptor> map = {
|
||||
//@MAPPING_PLACEHOLDER@
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -11,6 +11,18 @@ namespace Targets::TargetDescription
|
||||
{
|
||||
using namespace Exceptions;
|
||||
|
||||
const std::map<std::string, GeneratedMapping::BriefTargetDescriptor>& TargetDescriptionFile::mapping() {
|
||||
return GeneratedMapping::map;
|
||||
}
|
||||
|
||||
TargetDescriptionFile::TargetDescriptionFile(const QString& xmlFilePath) {
|
||||
this->init(xmlFilePath);
|
||||
}
|
||||
|
||||
TargetDescriptionFile::TargetDescriptionFile(const QDomDocument& xml) {
|
||||
this->init(xml);
|
||||
}
|
||||
|
||||
const std::string& TargetDescriptionFile::getTargetName() const {
|
||||
return this->targetName;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "Pinout.hpp"
|
||||
#include "Interface.hpp"
|
||||
|
||||
#include GENERATED_TDF_MAPPING_PATH
|
||||
|
||||
namespace Targets::TargetDescription
|
||||
{
|
||||
/**
|
||||
@@ -36,24 +38,33 @@ namespace Targets::TargetDescription
|
||||
class TargetDescriptionFile
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Returns a mapping of target configuration values to instances of the GeneratedMapping::BriefTargetDescriptor
|
||||
* struct.
|
||||
*
|
||||
* The mapping is generated pre-build.
|
||||
*
|
||||
* The GeneratedMapping::BriefTargetDescriptor struct holds some brief info about a particular target, such as
|
||||
* target name, family and TDF path. See the GeneratedMapping.hpp.in template for more.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static const std::map<std::string, GeneratedMapping::BriefTargetDescriptor>& mapping();
|
||||
|
||||
/**
|
||||
* Will construct a TargetDescriptionFile instance from the XML of a target description file, the path to which
|
||||
* is given via xmlFilePath.
|
||||
*
|
||||
* @param xmlFilePath
|
||||
*/
|
||||
explicit TargetDescriptionFile(const QString& xmlFilePath) {
|
||||
this->init(xmlFilePath);
|
||||
}
|
||||
explicit TargetDescriptionFile(const QString& xmlFilePath);
|
||||
|
||||
/**
|
||||
* Will construct a TargetDescriptionFile instance from pre-loaded XML.
|
||||
*
|
||||
* @param xml
|
||||
*/
|
||||
explicit TargetDescriptionFile(const QDomDocument& xml) {
|
||||
this->init(xml);
|
||||
}
|
||||
explicit TargetDescriptionFile(const QDomDocument& xml);
|
||||
|
||||
/**
|
||||
* Returns the target name extracted from the TDF.
|
||||
|
||||
Reference in New Issue
Block a user