- Renamed build script for brief target descriptor generation

- Created new TargetService class
- Moved brief target descriptor mapping to new TargetService class
- Replaced CMake custom commands with custom targets, for TDF validation and brief target descriptor generation build scripts
- Moved BriefTargetDescriptor into separate header file
This commit is contained in:
Nav
2024-03-02 01:59:55 +00:00
parent e75ce8b403
commit 4aa8ed30de
12 changed files with 182 additions and 123 deletions

View File

@@ -0,0 +1,53 @@
#pragma once
#include <string>
#include <cstdint>
#include "TargetFamily.hpp"
namespace Targets
{
/**
* The BriefTargetDescriptor struct provides limited information on a particular target.
*
* This struct serves as a starting point for constructing a Target object - it provides us with all the relevant
* information to construct a TargetDescriptionFile object, and subsequently, a Target object.
*
* At build time, we generate a BriefTargetDescriptor object for every target supported by Bloom. These objects
* can be found in the TargetService::descriptorsByConfigValue member. See the TargetService class for more.
*/
struct BriefTargetDescriptor
{
/**
* Target's market name.
*/
std::string name;
/**
* Target's configuration value.
*/
std::string configValue;
/**
* Target's family (AVR8/RISC-V)
*/
TargetFamily family;
/**
* The file path to to the target's TDF, relative to Bloom's TDF directory.
*/
std::string relativeTdfPath;
constexpr BriefTargetDescriptor(
const std::string& name,
const std::string& configValue,
TargetFamily family,
const std::string& relativeTdfPath
)
: name(name)
, configValue(configValue)
, family(family)
, relativeTdfPath(relativeTdfPath)
{}
};
}

View File

@@ -1,39 +0,0 @@
#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@
};
};
}

View File

@@ -20,10 +20,6 @@ namespace Targets::TargetDescription
using Services::StringService;
const std::map<std::string, GeneratedMapping::BriefTargetDescriptor>& TargetDescriptionFile::mapping() {
return GeneratedMapping::map;
}
TargetDescriptionFile::TargetDescriptionFile(const std::string& xmlFilePath) {
this->init(xmlFilePath);
}

View File

@@ -27,8 +27,6 @@
#include "src/Targets/TargetFamily.hpp"
#include "src/Targets/TargetPhysicalInterface.hpp"
#include GENERATED_TDF_MAPPING_PATH
namespace Targets::TargetDescription
{
/**
@@ -53,19 +51,6 @@ 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.