- 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:
@@ -8,9 +8,6 @@ require_once __DIR__ . "/AVR8/Avr8TargetDescriptionFile.php";
|
||||
|
||||
class Factory
|
||||
{
|
||||
private const TDF_PATH = __DIR__ . '/../../../src/Targets/TargetDescriptionFiles';
|
||||
private const AVR8_TDF_PATH = self::TDF_PATH . '/AVR8';
|
||||
|
||||
/**
|
||||
* Loads a target description file with the appropriate class.
|
||||
*
|
||||
@@ -22,36 +19,19 @@ class Factory
|
||||
$tdf = new TargetDescriptionFile($filePath);
|
||||
|
||||
if ($tdf->targetArchitecture == TargetDescriptionFile::ARCHITECTURE_AVR8) {
|
||||
$tdf = new Avr8TargetDescriptionFile($filePath);
|
||||
return new Avr8TargetDescriptionFile($filePath);
|
||||
}
|
||||
|
||||
return $tdf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all AVR8 target description files.
|
||||
*
|
||||
* @return Avr8TargetDescriptionFile[]
|
||||
*/
|
||||
public static function loadAvr8Tdfs(): array
|
||||
{
|
||||
/** @var Avr8TargetDescriptionFile[] $output */
|
||||
$output = [];
|
||||
|
||||
foreach (self::loadXmlFiles(self::AVR8_TDF_PATH) as $xmlFile) {
|
||||
$output[] = new Avr8TargetDescriptionFile($xmlFile->getPathname());
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively loads all XML files from a given directory.
|
||||
* Recursively finds all XML files within a given directory.
|
||||
*
|
||||
* @param string $dirPath
|
||||
* @return \SplFileInfo[]
|
||||
*/
|
||||
private static function loadXmlFiles(string $dirPath): array
|
||||
public static function findXmlFiles(string $dirPath): array
|
||||
{
|
||||
$output = [];
|
||||
|
||||
@@ -61,7 +41,7 @@ class Factory
|
||||
$output[] = clone $entry;
|
||||
|
||||
} else if ($entry->isDir() && !$entry->isDot()) {
|
||||
$output = array_merge($output, self::loadXmlFiles($entry->getPathname()));
|
||||
$output = array_merge($output, self::findXmlFiles($entry->getPathname()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ class TargetDescriptionFile
|
||||
public ?SimpleXMLElement $xml = null;
|
||||
|
||||
public ?string $targetName = null;
|
||||
public ?string $configurationValue = null;
|
||||
public ?string $targetArchitecture = null;
|
||||
|
||||
/** @var string[] */
|
||||
@@ -71,6 +72,7 @@ class TargetDescriptionFile
|
||||
|
||||
if (!empty($this->deviceAttributesByName['name'])) {
|
||||
$this->targetName = $device['name'];
|
||||
$this->configurationValue = strtolower($device['name']);
|
||||
}
|
||||
|
||||
if (!empty($this->deviceAttributesByName['architecture'])) {
|
||||
@@ -480,6 +482,10 @@ class TargetDescriptionFile
|
||||
$failures[] = 'Target name not found';
|
||||
}
|
||||
|
||||
if (str_contains($this->targetName, ' ')) {
|
||||
$failures[] = 'Target name cannot contain whitespaces';
|
||||
}
|
||||
|
||||
if (empty($this->targetArchitecture)) {
|
||||
$failures[] = 'Target architecture not found';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user