- 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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user