- Implemented Bytecode compiling properly into \ncc\Objects > ProjectConfiguration
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Installer` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > ExecutionPolicy` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Dependecy` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Compiler` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Build` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > UpdateSource` - Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Project`
This commit is contained in:
parent
352faa0b23
commit
15fd06d2d0
31 changed files with 726 additions and 645 deletions
|
@ -91,6 +91,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Corrected code-smell and code style issues in `\ncc\Objects\Vault\Password > UsernamePassword`
|
- Corrected code-smell and code style issues in `\ncc\Objects\Vault\Password > UsernamePassword`
|
||||||
- Extended `PasswordInterface` with `BytecodeObjectInterface`
|
- Extended `PasswordInterface` with `BytecodeObjectInterface`
|
||||||
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\SymlinkDictionary > SymlinkEntry`
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\SymlinkDictionary > SymlinkEntry`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > UpdateSource`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Project`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Installer`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > ExecutionPolicy`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Dependecy`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Compiler`
|
||||||
|
- Implemented interface `BytecodeObjectInterface` into `\ncc\Objects\ProjectConfiguration > Build`
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
|
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
|
||||||
|
|
|
@ -316,7 +316,7 @@
|
||||||
Console::out(sprintf('%s=%s (%s)',
|
Console::out(sprintf('%s=%s (%s)',
|
||||||
Console::formatColor($package, ConsoleColors::LIGHT_GREEN),
|
Console::formatColor($package, ConsoleColors::LIGHT_GREEN),
|
||||||
Console::formatColor($version, ConsoleColors::LIGHT_MAGENTA),
|
Console::formatColor($version, ConsoleColors::LIGHT_MAGENTA),
|
||||||
$package_manager->getPackageVersion($package, $version)->Compiler->Extension
|
$package_manager->getPackageVersion($package, $version)->Compiler->extension
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
|
@ -505,7 +505,7 @@
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$dependency_package = $package_manager->getPackage($dependency->Name);
|
$dependency_package = $package_manager->getPackage($dependency->name);
|
||||||
}
|
}
|
||||||
catch (PackageLockException $e)
|
catch (PackageLockException $e)
|
||||||
{
|
{
|
||||||
|
@ -517,7 +517,7 @@
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$dependency_version = $dependency_package->getVersion($dependency->Version);
|
$dependency_version = $dependency_package->getVersion($dependency->version);
|
||||||
}
|
}
|
||||||
catch (VersionNotFoundException $e)
|
catch (VersionNotFoundException $e)
|
||||||
{
|
{
|
||||||
|
@ -535,8 +535,8 @@
|
||||||
if($require_dependency)
|
if($require_dependency)
|
||||||
{
|
{
|
||||||
$dependencies[] = sprintf(' %s %s',
|
$dependencies[] = sprintf(' %s %s',
|
||||||
Console::formatColor($dependency->Name, ConsoleColors::GREEN),
|
Console::formatColor($dependency->name, ConsoleColors::GREEN),
|
||||||
Console::formatColor($dependency->Version, ConsoleColors::LIGHT_MAGENTA)
|
Console::formatColor($dependency->version, ConsoleColors::LIGHT_MAGENTA)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,21 +549,21 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::out(sprintf('Extension: %s',
|
Console::out(sprintf('Extension: %s',
|
||||||
Console::formatColor($package->header->CompilerExtension->Extension, ConsoleColors::GREEN)
|
Console::formatColor($package->header->CompilerExtension->extension, ConsoleColors::GREEN)
|
||||||
));
|
));
|
||||||
|
|
||||||
if($package->header->CompilerExtension->MaximumVersion !== null)
|
if($package->header->CompilerExtension->maximum_version !== null)
|
||||||
{
|
{
|
||||||
Console::out(sprintf('Maximum Version: %s',
|
Console::out(sprintf('Maximum Version: %s',
|
||||||
Console::formatColor($package->header->CompilerExtension->MaximumVersion, ConsoleColors::LIGHT_MAGENTA)
|
Console::formatColor($package->header->CompilerExtension->maximum_version, ConsoleColors::LIGHT_MAGENTA)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($package->header->CompilerExtension->MinimumVersion !== null)
|
if($package->header->CompilerExtension->minimum_version !== null)
|
||||||
{
|
{
|
||||||
Console::out(sprintf('Minimum Version: %s',
|
Console::out(sprintf('Minimum Version: %s',
|
||||||
Console::formatColor($package->header->CompilerExtension->MinimumVersion, ConsoleColors::LIGHT_MAGENTA)
|
Console::formatColor($package->header->CompilerExtension->minimum_version, ConsoleColors::LIGHT_MAGENTA)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@
|
||||||
|
|
||||||
if(in_array($compiler_extension, CompilerExtensions::ALL))
|
if(in_array($compiler_extension, CompilerExtensions::ALL))
|
||||||
{
|
{
|
||||||
$Compiler->Extension = $compiler_extension;
|
$Compiler->extension = $compiler_extension;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Default PHP Extension
|
// Default PHP Extension
|
||||||
$Compiler->Extension = CompilerExtensions::PHP;
|
$Compiler->extension = CompilerExtensions::PHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a minimum and maximum version is specified
|
// If a minimum and maximum version is specified
|
||||||
|
@ -145,28 +145,28 @@
|
||||||
$max_version = strtolower($args['max-version'] ?? $args['max-ver']);
|
$max_version = strtolower($args['max-version'] ?? $args['max-ver']);
|
||||||
$min_version = strtolower($args['min-version'] ?? $args['min-ver']);
|
$min_version = strtolower($args['min-version'] ?? $args['min-ver']);
|
||||||
|
|
||||||
switch($Compiler->Extension)
|
switch($Compiler->extension)
|
||||||
{
|
{
|
||||||
case CompilerExtensions::PHP:
|
case CompilerExtensions::PHP:
|
||||||
|
|
||||||
if(!in_array($max_version, CompilerExtensionSupportedVersions::PHP))
|
if(!in_array($max_version, CompilerExtensionSupportedVersions::PHP))
|
||||||
{
|
{
|
||||||
Console::outError('The extension \'' . $Compiler->Extension . '\' does not support version ' . $max_version, true, 1);
|
Console::outError('The extension \'' . $Compiler->extension . '\' does not support version ' . $max_version, true, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!in_array($min_version, CompilerExtensionSupportedVersions::PHP))
|
if(!in_array($min_version, CompilerExtensionSupportedVersions::PHP))
|
||||||
{
|
{
|
||||||
Console::outError('The extension \'' . $Compiler->Extension . '\' does not support version ' . $min_version, true, 1);
|
Console::outError('The extension \'' . $Compiler->extension . '\' does not support version ' . $min_version, true, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Compiler->MaximumVersion = $max_version;
|
$Compiler->maximum_version = $max_version;
|
||||||
$Compiler->MinimumVersion = $min_version;
|
$Compiler->minimum_version = $min_version;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Console::outError('Unsupported extension: ' . $Compiler->Extension, true, 1);
|
Console::outError('Unsupported extension: ' . $Compiler->extension, true, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,37 +174,37 @@
|
||||||
elseif(isset($args['version']) || isset($args['ver']))
|
elseif(isset($args['version']) || isset($args['ver']))
|
||||||
{
|
{
|
||||||
$version = strtolower($args['version'] ?? $args['ver']);
|
$version = strtolower($args['version'] ?? $args['ver']);
|
||||||
switch($Compiler->Extension)
|
switch($Compiler->extension)
|
||||||
{
|
{
|
||||||
case CompilerExtensions::PHP:
|
case CompilerExtensions::PHP:
|
||||||
if(!in_array($version, CompilerExtensionSupportedVersions::PHP))
|
if(!in_array($version, CompilerExtensionSupportedVersions::PHP))
|
||||||
{
|
{
|
||||||
Console::outError('The extension \'' . $Compiler->Extension . '\' does not support version ' . $version, true, 1);
|
Console::outError('The extension \'' . $Compiler->extension . '\' does not support version ' . $version, true, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Compiler->MaximumVersion = $version;
|
$Compiler->maximum_version = $version;
|
||||||
$Compiler->MinimumVersion = $version;
|
$Compiler->minimum_version = $version;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Console::outError('Unsupported extension: ' . $Compiler->Extension, true, 1);
|
Console::outError('Unsupported extension: ' . $Compiler->extension, true, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If no version is specified, use the default version
|
// If no version is specified, use the default version
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch($Compiler->Extension)
|
switch($Compiler->extension)
|
||||||
{
|
{
|
||||||
case CompilerExtensions::PHP:
|
case CompilerExtensions::PHP:
|
||||||
$Compiler->MinimumVersion = CompilerExtensionDefaultVersions::PHP[0];
|
$Compiler->minimum_version = CompilerExtensionDefaultVersions::PHP[0];
|
||||||
$Compiler->MaximumVersion = CompilerExtensionDefaultVersions::PHP[1];
|
$Compiler->maximum_version = CompilerExtensionDefaultVersions::PHP[1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Console::outError('Unsupported extension: ' . $Compiler->Extension, true, 1);
|
Console::outError('Unsupported extension: ' . $Compiler->extension, true, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace ncc\Classes\BashExtension;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
$policy->Execute->Target = null;
|
$policy->execute->Target = null;
|
||||||
|
|
||||||
return $execution_unit;
|
return $execution_unit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,9 +363,9 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
$project_configuration->assembly->Package = self::toPackageName($composer_package->Name);
|
$project_configuration->assembly->Package = self::toPackageName($composer_package->Name);
|
||||||
|
|
||||||
// Add the update source
|
// Add the update source
|
||||||
$project_configuration->project->UpdateSource = new ProjectConfiguration\UpdateSource();
|
$project_configuration->project->update_source = new ProjectConfiguration\UpdateSource();
|
||||||
$project_configuration->project->UpdateSource->Source = sprintf('%s@composer', str_ireplace('\\', '/', $composer_package->Name));
|
$project_configuration->project->update_source->source = sprintf('%s@composer', str_ireplace('\\', '/', $composer_package->Name));
|
||||||
$project_configuration->project->UpdateSource->Repository = null;
|
$project_configuration->project->update_source->repository = null;
|
||||||
|
|
||||||
// Process the dependencies
|
// Process the dependencies
|
||||||
if($composer_package->Require !== null && count($composer_package->Require) > 0)
|
if($composer_package->Require !== null && count($composer_package->Require) > 0)
|
||||||
|
@ -381,10 +381,10 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dependency = new ProjectConfiguration\Dependency();
|
$dependency = new ProjectConfiguration\Dependency();
|
||||||
$dependency->Name = $package_name;
|
$dependency->name = $package_name;
|
||||||
$dependency->SourceType = DependencySourceType::LOCAL;
|
$dependency->source_type = DependencySourceType::LOCAL;
|
||||||
$dependency->Version = self::versionMap($item->PackageName, $version_map);
|
$dependency->version = self::versionMap($item->PackageName, $version_map);
|
||||||
$dependency->Source = $package_name . '.ncc';
|
$dependency->source = $package_name . '.ncc';
|
||||||
$project_configuration->build->addDependency($dependency);
|
$project_configuration->build->addDependency($dependency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -395,14 +395,14 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
$build_configuration->OutputPath = 'build';
|
$build_configuration->OutputPath = 'build';
|
||||||
|
|
||||||
// Apply the final properties
|
// Apply the final properties
|
||||||
$project_configuration->build->Configurations[] = $build_configuration;
|
$project_configuration->build->build_configurations[] = $build_configuration;
|
||||||
$project_configuration->build->DefaultConfiguration = 'default';
|
$project_configuration->build->default_configuration = 'default';
|
||||||
$project_configuration->build->SourcePath = '.src';
|
$project_configuration->build->source_path = '.src';
|
||||||
|
|
||||||
// Apply a compiler extension
|
// Apply a compiler extension
|
||||||
$project_configuration->project->Compiler->Extension = CompilerExtensions::PHP;
|
$project_configuration->project->compiler->extension = CompilerExtensions::PHP;
|
||||||
$project_configuration->project->Compiler->MinimumVersion = CompilerExtensionSupportedVersions::PHP[0];
|
$project_configuration->project->compiler->minimum_version = CompilerExtensionSupportedVersions::PHP[0];
|
||||||
$project_configuration->project->Compiler->MaximumVersion = CompilerExtensionSupportedVersions::PHP[(count(CompilerExtensionSupportedVersions::PHP) - 1)];
|
$project_configuration->project->compiler->maximum_version = CompilerExtensionSupportedVersions::PHP[(count(CompilerExtensionSupportedVersions::PHP) - 1)];
|
||||||
|
|
||||||
return $project_configuration;
|
return $project_configuration;
|
||||||
}
|
}
|
||||||
|
@ -793,7 +793,7 @@ namespace ncc\Classes\ComposerExtension;
|
||||||
|
|
||||||
if (count($static_files) > 0)
|
if (count($static_files) > 0)
|
||||||
{
|
{
|
||||||
$project_configuration->project->Options['static_files'] = $static_files;
|
$project_configuration->project->options['static_files'] = $static_files;
|
||||||
|
|
||||||
foreach ($static_files as $file)
|
foreach ($static_files as $file)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace ncc\Classes\LuaExtension;
|
||||||
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
|
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
|
||||||
{
|
{
|
||||||
$execution_unit = new ExecutionUnit();
|
$execution_unit = new ExecutionUnit();
|
||||||
$policy->Execute->Target = null;
|
$policy->execute->Target = null;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
|
|
|
@ -79,21 +79,21 @@
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('assembly.%s: %s', $prop, ($value ?? 'n/a')));
|
Console::outDebug(sprintf('assembly.%s: %s', $prop, ($value ?? 'n/a')));
|
||||||
}
|
}
|
||||||
foreach($configuration->project->Compiler->toArray() as $prop => $value)
|
foreach($configuration->project->compiler->toArray() as $prop => $value)
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('compiler.%s: %s', $prop, ($value ?? 'n/a')));
|
Console::outDebug(sprintf('compiler.%s: %s', $prop, ($value ?? 'n/a')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select the correct compiler for the specified extension
|
// Select the correct compiler for the specified extension
|
||||||
if (strtolower($configuration->project->Compiler->Extension) === CompilerExtensions::PHP)
|
if (strtolower($configuration->project->compiler->extension) === CompilerExtensions::PHP)
|
||||||
{
|
{
|
||||||
/** @var CompilerInterface $Compiler */
|
/** @var CompilerInterface $Compiler */
|
||||||
$Compiler = new PhpCompiler($configuration, $manager->getProjectPath());
|
$Compiler = new PhpCompiler($configuration, $manager->getProjectPath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $configuration->project->Compiler->Extension . '\' is not supported');
|
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $configuration->project->compiler->extension . '\' is not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
$build_configuration = $configuration->build->getBuildConfiguration($build_configuration)->Name;
|
$build_configuration = $configuration->build->getBuildConfiguration($build_configuration)->Name;
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
/** @var ProjectConfiguration\ExecutionPolicy $policy */
|
/** @var ProjectConfiguration\ExecutionPolicy $policy */
|
||||||
foreach($configuration->execution_policies as $policy)
|
foreach($configuration->execution_policies as $policy)
|
||||||
{
|
{
|
||||||
Console::outVerbose(sprintf('Compiling Execution Policy %s', $policy->Name));
|
Console::outVerbose(sprintf('Compiling Execution Policy %s', $policy->name));
|
||||||
|
|
||||||
/** @noinspection DisconnectedForeachInstructionInspection */
|
/** @noinspection DisconnectedForeachInstructionInspection */
|
||||||
if($total_items > 5)
|
if($total_items > 5)
|
||||||
|
@ -186,7 +186,7 @@
|
||||||
Console::inlineProgressBar($processed_items, $total_items);
|
Console::inlineProgressBar($processed_items, $total_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
$unit_path = Functions::correctDirectorySeparator($path . $policy->Execute->Target);
|
$unit_path = Functions::correctDirectorySeparator($path . $policy->execute->Target);
|
||||||
$execution_units[] = Functions::compileRunner($unit_path, $policy);
|
$execution_units[] = Functions::compileRunner($unit_path, $policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@
|
||||||
$units = [];
|
$units = [];
|
||||||
foreach($package->execution_units as $executionUnit)
|
foreach($package->execution_units as $executionUnit)
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('compiling execution unit constant %s (%s)', $executionUnit->execution_policy->Name, implode(', ', array_keys($refs))));
|
Console::outDebug(sprintf('compiling execution unit constant %s (%s)', $executionUnit->execution_policy->name, implode(', ', array_keys($refs))));
|
||||||
$units[] = self::compileExecutionUnitConstants($executionUnit, $refs);
|
$units[] = self::compileExecutionUnitConstants($executionUnit, $refs);
|
||||||
}
|
}
|
||||||
$package->execution_units = $units;
|
$package->execution_units = $units;
|
||||||
|
@ -323,46 +323,46 @@
|
||||||
*/
|
*/
|
||||||
public static function compileExecutionUnitConstants(Package\ExecutionUnit $unit, array $refs): Package\ExecutionUnit
|
public static function compileExecutionUnitConstants(Package\ExecutionUnit $unit, array $refs): Package\ExecutionUnit
|
||||||
{
|
{
|
||||||
$unit->execution_policy->Message = self::compileConstants($unit->execution_policy->Message, $refs);
|
$unit->execution_policy->message = self::compileConstants($unit->execution_policy->message, $refs);
|
||||||
|
|
||||||
if($unit->execution_policy->ExitHandlers !== null)
|
if($unit->execution_policy->exit_handlers !== null)
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->ExitHandlers->Success !== null)
|
if($unit->execution_policy->exit_handlers->Success !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->ExitHandlers->Success->Message = self::compileConstants($unit->execution_policy->ExitHandlers->Success->Message, $refs);
|
$unit->execution_policy->exit_handlers->Success->Message = self::compileConstants($unit->execution_policy->exit_handlers->Success->Message, $refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->ExitHandlers->Error !== null)
|
if($unit->execution_policy->exit_handlers->Error !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->ExitHandlers->Error->Message = self::compileConstants($unit->execution_policy->ExitHandlers->Error->Message, $refs);
|
$unit->execution_policy->exit_handlers->Error->Message = self::compileConstants($unit->execution_policy->exit_handlers->Error->Message, $refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->ExitHandlers->Warning !== null)
|
if($unit->execution_policy->exit_handlers->Warning !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->ExitHandlers->Warning->Message = self::compileConstants($unit->execution_policy->ExitHandlers->Warning->Message, $refs);
|
$unit->execution_policy->exit_handlers->Warning->Message = self::compileConstants($unit->execution_policy->exit_handlers->Warning->Message, $refs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->Execute !== null)
|
if($unit->execution_policy->execute !== null)
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->Execute->Target !== null)
|
if($unit->execution_policy->execute->Target !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->Execute->Target = self::compileConstants($unit->execution_policy->Execute->Target, $refs);
|
$unit->execution_policy->execute->Target = self::compileConstants($unit->execution_policy->execute->Target, $refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->Execute->WorkingDirectory !== null)
|
if($unit->execution_policy->execute->WorkingDirectory !== null)
|
||||||
{
|
{
|
||||||
$unit->execution_policy->Execute->WorkingDirectory = self::compileConstants($unit->execution_policy->Execute->WorkingDirectory, $refs);
|
$unit->execution_policy->execute->WorkingDirectory = self::compileConstants($unit->execution_policy->execute->WorkingDirectory, $refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->Execute->Options !== null && count($unit->execution_policy->Execute->Options) > 0)
|
if($unit->execution_policy->execute->Options !== null && count($unit->execution_policy->execute->Options) > 0)
|
||||||
{
|
{
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach($unit->execution_policy->Execute->Options as $key=> $value)
|
foreach($unit->execution_policy->execute->Options as $key=> $value)
|
||||||
{
|
{
|
||||||
$options[self::compileConstants($key, $refs)] = self::compileConstants($value, $refs);
|
$options[self::compileConstants($key, $refs)] = self::compileConstants($value, $refs);
|
||||||
}
|
}
|
||||||
$unit->execution_policy->Execute->Options = $options;
|
$unit->execution_policy->execute->Options = $options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
$ExecutionPointerManager = new ExecutionPointerManager();
|
$ExecutionPointerManager = new ExecutionPointerManager();
|
||||||
$ExecutionPointerManager->addUnit($package, $version, $unit, true);
|
$ExecutionPointerManager->addUnit($package, $version, $unit, true);
|
||||||
$ExecutionPointerManager->executeUnit($package, $version, $unit->execution_policy->Name);
|
$ExecutionPointerManager->executeUnit($package, $version, $unit->execution_policy->name);
|
||||||
$ExecutionPointerManager->cleanTemporaryUnits();
|
$ExecutionPointerManager->cleanTemporaryUnits();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,7 +45,7 @@
|
||||||
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
|
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
|
||||||
{
|
{
|
||||||
$execution_unit = new ExecutionUnit();
|
$execution_unit = new ExecutionUnit();
|
||||||
$policy->Execute->Target = null;
|
$policy->execute->Target = null;
|
||||||
|
|
||||||
if(!file_exists($path) && !is_file($path))
|
if(!file_exists($path) && !is_file($path))
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,11 +108,11 @@
|
||||||
// Create the package object
|
// Create the package object
|
||||||
$this->package = new Package();
|
$this->package = new Package();
|
||||||
$this->package->assembly = $this->project->assembly;
|
$this->package->assembly = $this->project->assembly;
|
||||||
$this->package->dependencies = $this->project->build->Dependencies;
|
$this->package->dependencies = $this->project->build->dependencies;
|
||||||
$this->package->main_execution_policy = $this->project->build->Main;
|
$this->package->main_execution_policy = $this->project->build->main;
|
||||||
|
|
||||||
// Add the option to create a symbolic link to the package
|
// Add the option to create a symbolic link to the package
|
||||||
if(isset($this->project->project->Options['create_symlink']) && $this->project->project->Options['create_symlink'] === True)
|
if(isset($this->project->project->options['create_symlink']) && $this->project->project->options['create_symlink'] === True)
|
||||||
{
|
{
|
||||||
$this->package->header->Options['create_symlink'] = true;
|
$this->package->header->Options['create_symlink'] = true;
|
||||||
}
|
}
|
||||||
|
@ -122,17 +122,17 @@
|
||||||
$this->package->header->RuntimeConstants = [];
|
$this->package->header->RuntimeConstants = [];
|
||||||
$this->package->header->RuntimeConstants = array_merge(
|
$this->package->header->RuntimeConstants = array_merge(
|
||||||
($selected_build_configuration->DefineConstants ?? []),
|
($selected_build_configuration->DefineConstants ?? []),
|
||||||
($this->project->build->DefineConstants ?? []),
|
($this->project->build->define_constants ?? []),
|
||||||
($this->package->header->RuntimeConstants ?? [])
|
($this->package->header->RuntimeConstants ?? [])
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->package->header->CompilerExtension = $this->project->project->Compiler;
|
$this->package->header->CompilerExtension = $this->project->project->compiler;
|
||||||
$this->package->header->CompilerVersion = NCC_VERSION_NUMBER;
|
$this->package->header->CompilerVersion = NCC_VERSION_NUMBER;
|
||||||
$this->package->header->Options = $this->project->project->Options;
|
$this->package->header->Options = $this->project->project->options;
|
||||||
|
|
||||||
if($this->project->project->UpdateSource !== null)
|
if($this->project->project->update_source !== null)
|
||||||
{
|
{
|
||||||
$this->package->header->UpdateSource = $this->project->project->UpdateSource;
|
$this->package->header->UpdateSource = $this->project->project->update_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::outDebug('scanning project files');
|
Console::outDebug('scanning project files');
|
||||||
|
@ -158,7 +158,7 @@
|
||||||
$DirectoryScanner->setExcludes($selected_build_configuration->ExcludeFiles);
|
$DirectoryScanner->setExcludes($selected_build_configuration->ExcludeFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
$source_path = $this->path . $this->project->build->SourcePath;
|
$source_path = $this->path . $this->project->build->source_path;
|
||||||
|
|
||||||
// TODO: Re-implement the scanning process outside the compiler, as this is will be redundant
|
// TODO: Re-implement the scanning process outside the compiler, as this is will be redundant
|
||||||
// Scan for components first.
|
// Scan for components first.
|
||||||
|
@ -238,9 +238,9 @@
|
||||||
|
|
||||||
$selected_dependencies = [];
|
$selected_dependencies = [];
|
||||||
|
|
||||||
if($this->project->build->Dependencies !== null && count($this->project->build->Dependencies) > 0)
|
if($this->project->build->dependencies !== null && count($this->project->build->dependencies) > 0)
|
||||||
{
|
{
|
||||||
$selected_dependencies = array_merge($selected_dependencies, $this->project->build->Dependencies);
|
$selected_dependencies = array_merge($selected_dependencies, $this->project->build->dependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($selected_build_configuration->Dependencies !== null && count($selected_build_configuration->Dependencies) > 0)
|
if($selected_build_configuration->Dependencies !== null && count($selected_build_configuration->Dependencies) > 0)
|
||||||
|
@ -393,7 +393,7 @@
|
||||||
// Get the data and
|
// Get the data and
|
||||||
$resource->Data = IO::fread(Functions::correctDirectorySeparator($this->path . $resource->Name));
|
$resource->Data = IO::fread(Functions::correctDirectorySeparator($this->path . $resource->Name));
|
||||||
$resource->Data = Base64::encode($resource->Data);
|
$resource->Data = Base64::encode($resource->Data);
|
||||||
$resource->Name = str_replace($this->project->build->SourcePath, (string)null, $resource->Name);
|
$resource->Name = str_replace($this->project->build->source_path, (string)null, $resource->Name);
|
||||||
$resource->updateChecksum();
|
$resource->updateChecksum();
|
||||||
$resources[] = $resource;
|
$resources[] = $resource;
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@
|
||||||
|
|
||||||
unset($parser);
|
unset($parser);
|
||||||
|
|
||||||
$component->name = str_replace($this->project->build->SourcePath, (string)null, $component->name);
|
$component->name = str_replace($this->project->build->source_path, (string)null, $component->name);
|
||||||
$component->updateChecksum();
|
$component->updateChecksum();
|
||||||
$components[] = $component;
|
$components[] = $component;
|
||||||
++$processed_items;
|
++$processed_items;
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
throw new PathNotFoundException($path);
|
throw new PathNotFoundException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy->Execute->Target = null;
|
$policy->execute->Target = null;
|
||||||
|
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
throw new PathNotFoundException($path);
|
throw new PathNotFoundException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy->Execute->Target = null;
|
$policy->execute->Target = null;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
throw new PathNotFoundException($path);
|
throw new PathNotFoundException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy->Execute->Target = null;
|
$policy->execute->Target = null;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
throw new PathNotFoundException($path);
|
throw new PathNotFoundException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$policy->Execute->Target = null;
|
$policy->execute->Target = null;
|
||||||
$execution_unit->execution_policy = $policy;
|
$execution_unit->execution_policy = $policy;
|
||||||
$execution_unit->Data = IO::fread($path);
|
$execution_unit->Data = IO::fread($path);
|
||||||
|
|
||||||
|
|
|
@ -174,15 +174,15 @@
|
||||||
{
|
{
|
||||||
if(Resolver::resolveScope() !== Scopes::SYSTEM)
|
if(Resolver::resolveScope() !== Scopes::SYSTEM)
|
||||||
{
|
{
|
||||||
throw new AccessDeniedException('Cannot add new ExecutionUnit \'' . $unit->execution_policy->Name .'\' for ' . $package . ', insufficient permissions');
|
throw new AccessDeniedException('Cannot add new ExecutionUnit \'' . $unit->execution_policy->name .'\' for ' . $package . ', insufficient permissions');
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::outVerbose(sprintf('Adding new ExecutionUnit \'%s\' for %s', $unit->execution_policy->Name, $package));
|
Console::outVerbose(sprintf('Adding new ExecutionUnit \'%s\' for %s', $unit->execution_policy->name, $package));
|
||||||
|
|
||||||
$package_id = $this->getPackageId($package, $version);
|
$package_id = $this->getPackageId($package, $version);
|
||||||
$package_config_path = $this->runner_path . DIRECTORY_SEPARATOR . $package_id . '.inx';
|
$package_config_path = $this->runner_path . DIRECTORY_SEPARATOR . $package_id . '.inx';
|
||||||
$package_bin_path = $this->runner_path . DIRECTORY_SEPARATOR . $package_id;
|
$package_bin_path = $this->runner_path . DIRECTORY_SEPARATOR . $package_id;
|
||||||
$entry_point_path = $package_bin_path . DIRECTORY_SEPARATOR . hash('haval128,4', $unit->execution_policy->Name) . '.entrypoint';
|
$entry_point_path = $package_bin_path . DIRECTORY_SEPARATOR . hash('haval128,4', $unit->execution_policy->name) . '.entrypoint';
|
||||||
|
|
||||||
Console::outDebug(sprintf('package_id=%s', $package_id));
|
Console::outDebug(sprintf('package_id=%s', $package_id));
|
||||||
Console::outDebug(sprintf('package_config_path=%s', $package_config_path));
|
Console::outDebug(sprintf('package_config_path=%s', $package_config_path));
|
||||||
|
@ -201,8 +201,8 @@
|
||||||
$execution_pointers = ExecutionPointers::fromArray(ZiProto::decode(IO::fread($package_config_path)));
|
$execution_pointers = ExecutionPointers::fromArray(ZiProto::decode(IO::fread($package_config_path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$bin_file = $package_bin_path . DIRECTORY_SEPARATOR . hash('haval128,4', $unit->execution_policy->Name);
|
$bin_file = $package_bin_path . DIRECTORY_SEPARATOR . hash('haval128,4', $unit->execution_policy->name);
|
||||||
$bin_file .= match ($unit->execution_policy->Runner)
|
$bin_file .= match ($unit->execution_policy->runner)
|
||||||
{
|
{
|
||||||
Runners::BASH => BashRunner::getFileExtension(),
|
Runners::BASH => BashRunner::getFileExtension(),
|
||||||
Runners::PHP => PhpRunner::getFileExtension(),
|
Runners::PHP => PhpRunner::getFileExtension(),
|
||||||
|
@ -211,7 +211,7 @@
|
||||||
Runners::PYTHON_2 => Python2Runner::getFileExtension(),
|
Runners::PYTHON_2 => Python2Runner::getFileExtension(),
|
||||||
Runners::PYTHON_3 => Python3Runner::getFileExtension(),
|
Runners::PYTHON_3 => Python3Runner::getFileExtension(),
|
||||||
Runners::LUA => LuaRunner::getFileExtension(),
|
Runners::LUA => LuaRunner::getFileExtension(),
|
||||||
default => throw new RunnerExecutionException('The runner \'' . $unit->execution_policy->Runner . '\' is not supported'),
|
default => throw new RunnerExecutionException('The runner \'' . $unit->execution_policy->runner . '\' is not supported'),
|
||||||
};
|
};
|
||||||
|
|
||||||
Console::outDebug(sprintf('bin_file=%s', $bin_file));
|
Console::outDebug(sprintf('bin_file=%s', $bin_file));
|
||||||
|
@ -237,7 +237,7 @@
|
||||||
|
|
||||||
$entry_point = sprintf("#!%s\nncc exec --package=\"%s\" --exec-version=\"%s\" --exec-unit=\"%s\" --exec-args \"$@\"",
|
$entry_point = sprintf("#!%s\nncc exec --package=\"%s\" --exec-version=\"%s\" --exec-unit=\"%s\" --exec-args \"$@\"",
|
||||||
'/bin/bash',
|
'/bin/bash',
|
||||||
$package, $version, $unit->execution_policy->Name
|
$package, $version, $unit->execution_policy->name
|
||||||
);
|
);
|
||||||
|
|
||||||
if(file_exists($entry_point_path))
|
if(file_exists($entry_point_path))
|
||||||
|
@ -250,11 +250,11 @@
|
||||||
|
|
||||||
if($temporary)
|
if($temporary)
|
||||||
{
|
{
|
||||||
Console::outVerbose(sprintf('Adding temporary ExecutionUnit \'%s\' for %s', $unit->execution_policy->Name, $package));
|
Console::outVerbose(sprintf('Adding temporary ExecutionUnit \'%s\' for %s', $unit->execution_policy->name, $package));
|
||||||
$this->temporary_units[] = [
|
$this->temporary_units[] = [
|
||||||
'package' => $package,
|
'package' => $package,
|
||||||
'version' => $version,
|
'version' => $version,
|
||||||
'unit' => $unit->execution_policy->Name
|
'unit' => $unit->execution_policy->name
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,8 +350,8 @@
|
||||||
$results = [];
|
$results = [];
|
||||||
foreach($execution_pointers->getPointers() as $pointer)
|
foreach($execution_pointers->getPointers() as $pointer)
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('unit %s', $pointer->execution_policy->Name));
|
Console::outDebug(sprintf('unit %s', $pointer->execution_policy->name));
|
||||||
$results[] = $pointer->execution_policy->Name;
|
$results[] = $pointer->execution_policy->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
@ -390,34 +390,34 @@
|
||||||
throw new RunnerExecutionException('The execution unit \'' . $name . '\' was not found for \'' . $package . '=' .$version .'\'');
|
throw new RunnerExecutionException('The execution unit \'' . $name . '\' was not found for \'' . $package . '=' .$version .'\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::outDebug(sprintf('unit=%s', $unit->execution_policy->Name));
|
Console::outDebug(sprintf('unit=%s', $unit->execution_policy->name));
|
||||||
Console::outDebug(sprintf('runner=%s', $unit->execution_policy->Runner));
|
Console::outDebug(sprintf('runner=%s', $unit->execution_policy->runner));
|
||||||
Console::outDebug(sprintf('file=%s', $unit->file_pointer));
|
Console::outDebug(sprintf('file=%s', $unit->file_pointer));
|
||||||
Console::outDebug(sprintf('pass_thru_args=%s', implode(' ', $args)));
|
Console::outDebug(sprintf('pass_thru_args=%s', implode(' ', $args)));
|
||||||
|
|
||||||
// Handle the arguments
|
// Handle the arguments
|
||||||
if($unit->execution_policy->Execute->Options !== null && count($unit->execution_policy->Execute->Options) > 0)
|
if($unit->execution_policy->execute->Options !== null && count($unit->execution_policy->execute->Options) > 0)
|
||||||
{
|
{
|
||||||
$args = array_merge($args, $unit->execution_policy->Execute->Options);
|
$args = array_merge($args, $unit->execution_policy->execute->Options);
|
||||||
|
|
||||||
foreach($unit->execution_policy->Execute->Options as $option)
|
foreach($unit->execution_policy->execute->Options as $option)
|
||||||
{
|
{
|
||||||
$args[] = ConstantCompiler::compileRuntimeConstants($option);
|
$args[] = ConstantCompiler::compileRuntimeConstants($option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$process = new Process(array_merge(
|
$process = new Process(array_merge(
|
||||||
[PathFinder::findRunner(strtolower($unit->execution_policy->Runner)), $unit->file_pointer], $args)
|
[PathFinder::findRunner(strtolower($unit->execution_policy->runner)), $unit->file_pointer], $args)
|
||||||
);
|
);
|
||||||
|
|
||||||
if($unit->execution_policy->Execute->WorkingDirectory !== null)
|
if($unit->execution_policy->execute->WorkingDirectory !== null)
|
||||||
{
|
{
|
||||||
$process->setWorkingDirectory(ConstantCompiler::compileRuntimeConstants($unit->execution_policy->Execute->WorkingDirectory));
|
$process->setWorkingDirectory(ConstantCompiler::compileRuntimeConstants($unit->execution_policy->execute->WorkingDirectory));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->Execute->Timeout !== null)
|
if($unit->execution_policy->execute->Timeout !== null)
|
||||||
{
|
{
|
||||||
$process->setTimeout((float)$unit->execution_policy->Execute->Timeout);
|
$process->setTimeout((float)$unit->execution_policy->execute->Timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -427,12 +427,12 @@
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->Execute->Silent)
|
if($unit->execution_policy->execute->Silent)
|
||||||
{
|
{
|
||||||
$process->disableOutput();
|
$process->disableOutput();
|
||||||
$process->setTty(false);
|
$process->setTty(false);
|
||||||
}
|
}
|
||||||
elseif($unit->execution_policy->Execute->Tty)
|
elseif($unit->execution_policy->execute->Tty)
|
||||||
{
|
{
|
||||||
$process->enableOutput();
|
$process->enableOutput();
|
||||||
$process->setTty(true);
|
$process->setTty(true);
|
||||||
|
@ -460,16 +460,16 @@
|
||||||
|
|
||||||
Console::outDebug(sprintf('working_directory=%s', $process->getWorkingDirectory()));
|
Console::outDebug(sprintf('working_directory=%s', $process->getWorkingDirectory()));
|
||||||
Console::outDebug(sprintf('timeout=%s', (int)$process->getTimeout()));
|
Console::outDebug(sprintf('timeout=%s', (int)$process->getTimeout()));
|
||||||
Console::outDebug(sprintf('silent=%s', ($unit->execution_policy->Execute->Silent ? 'true' : 'false')));
|
Console::outDebug(sprintf('silent=%s', ($unit->execution_policy->execute->Silent ? 'true' : 'false')));
|
||||||
Console::outDebug(sprintf('tty=%s', ($unit->execution_policy->Execute->Tty ? 'true' : 'false')));
|
Console::outDebug(sprintf('tty=%s', ($unit->execution_policy->execute->Tty ? 'true' : 'false')));
|
||||||
Console::outDebug(sprintf('options=%s', implode(' ', $args)));
|
Console::outDebug(sprintf('options=%s', implode(' ', $args)));
|
||||||
Console::outDebug(sprintf('cmd=%s', $process->getCommandLine()));
|
Console::outDebug(sprintf('cmd=%s', $process->getCommandLine()));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->Message !== null)
|
if($unit->execution_policy->message !== null)
|
||||||
{
|
{
|
||||||
Console::out($unit->execution_policy->Message);
|
Console::out($unit->execution_policy->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$process->run(function ($type, $buffer)
|
$process->run(function ($type, $buffer)
|
||||||
|
@ -481,33 +481,33 @@
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->ExitHandlers !== null && $unit->execution_policy->ExitHandlers->Error !== null)
|
if($unit->execution_policy->exit_handlers !== null && $unit->execution_policy->exit_handlers->Error !== null)
|
||||||
{
|
{
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->ExitHandlers->Error);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::outException(sprintf('An error occurred while executing the unit \'%s\' for \'%s\' (exit code %s)', $unit->execution_policy->Name, $package, $process->getExitCode()), $e);
|
Console::outException(sprintf('An error occurred while executing the unit \'%s\' for \'%s\' (exit code %s)', $unit->execution_policy->name, $package, $process->getExitCode()), $e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('exit_code=%s', $process->getExitCode()));
|
Console::outDebug(sprintf('exit_code=%s', $process->getExitCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit->execution_policy->ExitHandlers !== null)
|
if($unit->execution_policy->exit_handlers !== null)
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->ExitHandlers->Success !== null && $process->isSuccessful())
|
if($unit->execution_policy->exit_handlers->Success !== null && $process->isSuccessful())
|
||||||
{
|
{
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->ExitHandlers->Success);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Success);
|
||||||
}
|
}
|
||||||
elseif($unit->execution_policy->ExitHandlers->Error !== null && $process->isSuccessful())
|
elseif($unit->execution_policy->exit_handlers->Error !== null && $process->isSuccessful())
|
||||||
{
|
{
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->ExitHandlers->Error);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->ExitHandlers->Success, $process);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Success, $process);
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->ExitHandlers->Warning, $process);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Warning, $process);
|
||||||
$this->handleExit($package, $version, $unit->execution_policy->ExitHandlers->Error, $process);
|
$this->handleExit($package, $version, $unit->execution_policy->exit_handlers->Error, $process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,21 +538,21 @@
|
||||||
|
|
||||||
// Get the required units
|
// Get the required units
|
||||||
$required_units = [];
|
$required_units = [];
|
||||||
if($unit->execution_policy->ExitHandlers !== null)
|
if($unit->execution_policy->exit_handlers !== null)
|
||||||
{
|
{
|
||||||
$required_unit = $unit->execution_policy?->ExitHandlers?->Success?->Run;
|
$required_unit = $unit->execution_policy?->exit_handlers?->Success?->Run;
|
||||||
if($required_unit !== null)
|
if($required_unit !== null)
|
||||||
{
|
{
|
||||||
$required_units[] = $required_unit;
|
$required_units[] = $required_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$required_unit = $unit->execution_policy?->ExitHandlers?->Warning?->Run;
|
$required_unit = $unit->execution_policy?->exit_handlers?->Warning?->Run;
|
||||||
if($required_unit !== null)
|
if($required_unit !== null)
|
||||||
{
|
{
|
||||||
$required_units[] = $required_unit;
|
$required_units[] = $required_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$required_unit = $unit->execution_policy?->ExitHandlers?->Error?->Run;
|
$required_unit = $unit->execution_policy?->exit_handlers?->Error?->Run;
|
||||||
if($required_unit !== null)
|
if($required_unit !== null)
|
||||||
{
|
{
|
||||||
$required_units = $required_unit;
|
$required_units = $required_unit;
|
||||||
|
|
|
@ -143,7 +143,7 @@
|
||||||
return $package->assembly->Package;
|
return $package->assembly->Package;
|
||||||
}
|
}
|
||||||
|
|
||||||
$extension = $package->header->CompilerExtension->Extension;
|
$extension = $package->header->CompilerExtension->extension;
|
||||||
$installation_paths = new InstallationPaths($this->packages_path . DIRECTORY_SEPARATOR . $package->assembly->Package . '=' . $package->assembly->Version);
|
$installation_paths = new InstallationPaths($this->packages_path . DIRECTORY_SEPARATOR . $package->assembly->Package . '=' . $package->assembly->Version);
|
||||||
|
|
||||||
$installer = match ($extension)
|
$installer = match ($extension)
|
||||||
|
@ -180,15 +180,15 @@
|
||||||
foreach($package->dependencies as $dependency)
|
foreach($package->dependencies as $dependency)
|
||||||
{
|
{
|
||||||
// Uninstall the dependency if the option Reinstall is passed on
|
// Uninstall the dependency if the option Reinstall is passed on
|
||||||
if(in_array(InstallPackageOptions::REINSTALL, $options, true) && $this->getPackageLockManager()?->getPackageLock()?->packageExists($dependency->Name, $dependency->Version))
|
if(in_array(InstallPackageOptions::REINSTALL, $options, true) && $this->getPackageLockManager()?->getPackageLock()?->packageExists($dependency->name, $dependency->version))
|
||||||
{
|
{
|
||||||
if($dependency->Version === null)
|
if($dependency->version === null)
|
||||||
{
|
{
|
||||||
$this->uninstallPackage($dependency->Name);
|
$this->uninstallPackage($dependency->name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->uninstallPackageVersion($dependency->Name, $dependency->Version);
|
$this->uninstallPackageVersion($dependency->name, $dependency->version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@
|
||||||
/** @var Package\ExecutionUnit $executionUnit */
|
/** @var Package\ExecutionUnit $executionUnit */
|
||||||
foreach($package->execution_units as $executionUnit)
|
foreach($package->execution_units as $executionUnit)
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('processing execution unit %s', $executionUnit->execution_policy->Name));
|
Console::outDebug(sprintf('processing execution unit %s', $executionUnit->execution_policy->name));
|
||||||
$execution_pointer_manager->addUnit($package->assembly->Package, $package->assembly->Version, $executionUnit);
|
$execution_pointer_manager->addUnit($package->assembly->Package, $package->assembly->Version, $executionUnit);
|
||||||
++$current_steps;
|
++$current_steps;
|
||||||
Console::inlineProgressBar($current_steps, $steps);
|
Console::inlineProgressBar($current_steps, $steps);
|
||||||
|
@ -434,17 +434,17 @@
|
||||||
Console::outDebug('no post-installation units to execute');
|
Console::outDebug('no post-installation units to execute');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($package->header->UpdateSource !== null && $package->header->UpdateSource->Repository !== null)
|
if($package->header->UpdateSource !== null && $package->header->UpdateSource->repository !== null)
|
||||||
{
|
{
|
||||||
$sources_manager = new RemoteSourcesManager();
|
$sources_manager = new RemoteSourcesManager();
|
||||||
if($sources_manager->getRemoteSource($package->header->UpdateSource->Repository->Name) === null)
|
if($sources_manager->getRemoteSource($package->header->UpdateSource->repository->Name) === null)
|
||||||
{
|
{
|
||||||
Console::outVerbose('Adding remote source ' . $package->header->UpdateSource->Repository->Name);
|
Console::outVerbose('Adding remote source ' . $package->header->UpdateSource->repository->Name);
|
||||||
$defined_remote_source = new DefinedRemoteSource();
|
$defined_remote_source = new DefinedRemoteSource();
|
||||||
$defined_remote_source->name = $package->header->UpdateSource->Repository->Name;
|
$defined_remote_source->name = $package->header->UpdateSource->repository->Name;
|
||||||
$defined_remote_source->host = $package->header->UpdateSource->Repository->Host;
|
$defined_remote_source->host = $package->header->UpdateSource->repository->Host;
|
||||||
$defined_remote_source->type = $package->header->UpdateSource->Repository->Type;
|
$defined_remote_source->type = $package->header->UpdateSource->repository->Type;
|
||||||
$defined_remote_source->ssl = $package->header->UpdateSource->Repository->SSL;
|
$defined_remote_source->ssl = $package->header->UpdateSource->repository->SSL;
|
||||||
|
|
||||||
$sources_manager->addRemoteSource($defined_remote_source);
|
$sources_manager->addRemoteSource($defined_remote_source);
|
||||||
}
|
}
|
||||||
|
@ -673,67 +673,67 @@
|
||||||
*/
|
*/
|
||||||
private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null, array $options=[]): void
|
private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null, array $options=[]): void
|
||||||
{
|
{
|
||||||
if(RuntimeCache::get(sprintf('dependency_installed.%s=%s', $dependency->Name, $dependency->Version ?? 'null')))
|
if(RuntimeCache::get(sprintf('dependency_installed.%s=%s', $dependency->name, $dependency->version ?? 'null')))
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('dependency %s=%s already processed, skipping', $dependency->Name, $dependency->Version ?? 'null'));
|
Console::outDebug(sprintf('dependency %s=%s already processed, skipping', $dependency->name, $dependency->version ?? 'null'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::outVerbose('processing dependency ' . $dependency->Name . ' (' . $dependency->Version . ')');
|
Console::outVerbose('processing dependency ' . $dependency->name . ' (' . $dependency->version . ')');
|
||||||
$dependent_package = $this->getPackage($dependency->Name);
|
$dependent_package = $this->getPackage($dependency->name);
|
||||||
$dependency_met = false;
|
$dependency_met = false;
|
||||||
|
|
||||||
if ($dependent_package !== null && $dependency->Version !== null && Validate::version($dependency->Version))
|
if ($dependent_package !== null && $dependency->version !== null && Validate::version($dependency->version))
|
||||||
{
|
{
|
||||||
Console::outDebug('dependency has version constraint, checking if package is installed');
|
Console::outDebug('dependency has version constraint, checking if package is installed');
|
||||||
$dependent_version = $this->getPackageVersion($dependency->Name, $dependency->Version);
|
$dependent_version = $this->getPackageVersion($dependency->name, $dependency->version);
|
||||||
if ($dependent_version !== null)
|
if ($dependent_version !== null)
|
||||||
{
|
{
|
||||||
$dependency_met = true;
|
$dependency_met = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($dependent_package !== null && $dependency->Version === null)
|
elseif ($dependent_package !== null && $dependency->version === null)
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('dependency %s has no version specified, assuming dependency is met', $dependency->Name));
|
Console::outDebug(sprintf('dependency %s has no version specified, assuming dependency is met', $dependency->name));
|
||||||
$dependency_met = true;
|
$dependency_met = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::outDebug('dependency met: ' . ($dependency_met ? 'true' : 'false'));
|
Console::outDebug('dependency met: ' . ($dependency_met ? 'true' : 'false'));
|
||||||
|
|
||||||
if ($dependency->SourceType !== null && !$dependency_met)
|
if ($dependency->source_type !== null && !$dependency_met)
|
||||||
{
|
{
|
||||||
Console::outVerbose(sprintf('Installing dependency %s=%s for %s=%s', $dependency->Name, $dependency->Version, $package->assembly->Package, $package->assembly->Version));
|
Console::outVerbose(sprintf('Installing dependency %s=%s for %s=%s', $dependency->name, $dependency->version, $package->assembly->Package, $package->assembly->Version));
|
||||||
switch ($dependency->SourceType)
|
switch ($dependency->source_type)
|
||||||
{
|
{
|
||||||
case DependencySourceType::LOCAL:
|
case DependencySourceType::LOCAL:
|
||||||
Console::outDebug('installing from local source ' . $dependency->Source);
|
Console::outDebug('installing from local source ' . $dependency->source);
|
||||||
$basedir = dirname($package_path);
|
$basedir = dirname($package_path);
|
||||||
|
|
||||||
if (!file_exists($basedir . DIRECTORY_SEPARATOR . $dependency->Source))
|
if (!file_exists($basedir . DIRECTORY_SEPARATOR . $dependency->source))
|
||||||
{
|
{
|
||||||
throw new PathNotFoundException($basedir . DIRECTORY_SEPARATOR . $dependency->Source);
|
throw new PathNotFoundException($basedir . DIRECTORY_SEPARATOR . $dependency->source);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->install($basedir . DIRECTORY_SEPARATOR . $dependency->Source, null, $options);
|
$this->install($basedir . DIRECTORY_SEPARATOR . $dependency->source, null, $options);
|
||||||
RuntimeCache::set(sprintf('dependency_installed.%s=%s', $dependency->Name, $dependency->Version), true);
|
RuntimeCache::set(sprintf('dependency_installed.%s=%s', $dependency->name, $dependency->version), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DependencySourceType::STATIC:
|
case DependencySourceType::STATIC:
|
||||||
throw new PackageNotFoundException('Static linking not possible, package ' . $dependency->Name . ' is not installed');
|
throw new PackageNotFoundException('Static linking not possible, package ' . $dependency->name . ' is not installed');
|
||||||
|
|
||||||
case DependencySourceType::REMOTE:
|
case DependencySourceType::REMOTE:
|
||||||
Console::outDebug('installing from remote source ' . $dependency->Source);
|
Console::outDebug('installing from remote source ' . $dependency->source);
|
||||||
$this->installFromSource($dependency->Source, $entry, $options);
|
$this->installFromSource($dependency->source, $entry, $options);
|
||||||
RuntimeCache::set(sprintf('dependency_installed.%s=%s', $dependency->Name, $dependency->Version), true);
|
RuntimeCache::set(sprintf('dependency_installed.%s=%s', $dependency->name, $dependency->version), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException('Dependency source type ' . $dependency->SourceType . ' is not implemented');
|
throw new NotImplementedException('Dependency source type ' . $dependency->source_type . ' is not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif(!$dependency_met)
|
elseif(!$dependency_met)
|
||||||
{
|
{
|
||||||
throw new MissingDependencyException(sprintf('The dependency %s=%s for %s=%s is not met', $dependency->Name, $dependency->Version, $package->assembly->Package, $package->assembly->Version));
|
throw new MissingDependencyException(sprintf('The dependency %s=%s for %s=%s is not met', $dependency->name, $dependency->version, $package->assembly->Package, $package->assembly->Version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,9 +962,9 @@
|
||||||
$execution_pointer_manager = new ExecutionPointerManager();
|
$execution_pointer_manager = new ExecutionPointerManager();
|
||||||
foreach($version_entry->ExecutionUnits as $executionUnit)
|
foreach($version_entry->ExecutionUnits as $executionUnit)
|
||||||
{
|
{
|
||||||
if(!$execution_pointer_manager->removeUnit($package, $version, $executionUnit->execution_policy->Name))
|
if(!$execution_pointer_manager->removeUnit($package, $version, $executionUnit->execution_policy->name))
|
||||||
{
|
{
|
||||||
Console::outDebug(sprintf('warning: removing execution unit %s failed', $executionUnit->execution_policy->Name));
|
Console::outDebug(sprintf('warning: removing execution unit %s failed', $executionUnit->execution_policy->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
$this->project_configuration = new ProjectConfiguration();
|
$this->project_configuration = new ProjectConfiguration();
|
||||||
|
|
||||||
// Set the compiler information
|
// Set the compiler information
|
||||||
$this->project_configuration->project->Compiler = $compiler;
|
$this->project_configuration->project->compiler = $compiler;
|
||||||
|
|
||||||
// Set the assembly information
|
// Set the assembly information
|
||||||
$this->project_configuration->assembly->Name = $name;
|
$this->project_configuration->assembly->Name = $name;
|
||||||
|
@ -145,32 +145,32 @@
|
||||||
$this->project_configuration->assembly->UUID = Uuid::v1()->toRfc4122();
|
$this->project_configuration->assembly->UUID = Uuid::v1()->toRfc4122();
|
||||||
|
|
||||||
// Set the build information
|
// Set the build information
|
||||||
$this->project_configuration->build->SourcePath = $src;
|
$this->project_configuration->build->source_path = $src;
|
||||||
|
|
||||||
if($this->project_configuration->build->SourcePath === null)
|
if($this->project_configuration->build->source_path === null)
|
||||||
{
|
{
|
||||||
$this->project_configuration->build->SourcePath = $this->project_path;
|
$this->project_configuration->build->source_path = $this->project_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->project_configuration->build->DefaultConfiguration = 'debug';
|
$this->project_configuration->build->default_configuration = 'debug';
|
||||||
|
|
||||||
// Assembly constants if the program wishes to check for this
|
// Assembly constants if the program wishes to check for this
|
||||||
$this->project_configuration->build->DefineConstants['ASSEMBLY_NAME'] = '%ASSEMBLY.NAME%';
|
$this->project_configuration->build->define_constants['ASSEMBLY_NAME'] = '%ASSEMBLY.NAME%';
|
||||||
$this->project_configuration->build->DefineConstants['ASSEMBLY_PACKAGE'] = '%ASSEMBLY.PACKAGE%';
|
$this->project_configuration->build->define_constants['ASSEMBLY_PACKAGE'] = '%ASSEMBLY.PACKAGE%';
|
||||||
$this->project_configuration->build->DefineConstants['ASSEMBLY_VERSION'] = '%ASSEMBLY.VERSION%';
|
$this->project_configuration->build->define_constants['ASSEMBLY_VERSION'] = '%ASSEMBLY.VERSION%';
|
||||||
$this->project_configuration->build->DefineConstants['ASSEMBLY_UID'] = '%ASSEMBLY.UID%';
|
$this->project_configuration->build->define_constants['ASSEMBLY_UID'] = '%ASSEMBLY.UID%';
|
||||||
|
|
||||||
// Generate configurations
|
// Generate configurations
|
||||||
$DebugConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
|
$DebugConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
|
||||||
$DebugConfiguration->Name = 'debug';
|
$DebugConfiguration->Name = 'debug';
|
||||||
$DebugConfiguration->OutputPath = 'build/debug';
|
$DebugConfiguration->OutputPath = 'build/debug';
|
||||||
$DebugConfiguration->DefineConstants["DEBUG"] = '1'; // Debugging constant if the program wishes to check for this
|
$DebugConfiguration->DefineConstants["DEBUG"] = '1'; // Debugging constant if the program wishes to check for this
|
||||||
$this->project_configuration->build->Configurations[] = $DebugConfiguration;
|
$this->project_configuration->build->build_configurations[] = $DebugConfiguration;
|
||||||
$ReleaseConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
|
$ReleaseConfiguration = new ProjectConfiguration\Build\BuildConfiguration();
|
||||||
$ReleaseConfiguration->Name = 'release';
|
$ReleaseConfiguration->Name = 'release';
|
||||||
$ReleaseConfiguration->OutputPath = 'build/release';
|
$ReleaseConfiguration->OutputPath = 'build/release';
|
||||||
$ReleaseConfiguration->DefineConstants["DEBUG"] = '0'; // Debugging constant if the program wishes to check for this
|
$ReleaseConfiguration->DefineConstants["DEBUG"] = '0'; // Debugging constant if the program wishes to check for this
|
||||||
$this->project_configuration->build->Configurations[] = $ReleaseConfiguration;
|
$this->project_configuration->build->build_configurations[] = $ReleaseConfiguration;
|
||||||
|
|
||||||
// Finally, create project.json
|
// Finally, create project.json
|
||||||
$this->project_configuration->toFile($this->project_path . DIRECTORY_SEPARATOR . 'project.json');
|
$this->project_configuration->toFile($this->project_path . DIRECTORY_SEPARATOR . 'project.json');
|
||||||
|
@ -195,8 +195,8 @@
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
$option === InitializeProjectOptions::CREATE_SOURCE_DIRECTORY &&
|
$option === InitializeProjectOptions::CREATE_SOURCE_DIRECTORY &&
|
||||||
!file_exists($this->project_configuration->build->SourcePath) &&
|
!file_exists($this->project_configuration->build->source_path) &&
|
||||||
!mkdir($concurrentDirectory = $this->project_configuration->build->SourcePath) &&
|
!mkdir($concurrentDirectory = $this->project_configuration->build->source_path) &&
|
||||||
!is_dir($concurrentDirectory)
|
!is_dir($concurrentDirectory)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,9 +82,9 @@
|
||||||
|
|
||||||
if($overwrite)
|
if($overwrite)
|
||||||
{
|
{
|
||||||
$this->deleteUnit($unit->execution_policy->Name);
|
$this->deleteUnit($unit->execution_policy->name);
|
||||||
}
|
}
|
||||||
elseif($this->getUnit($unit->execution_policy->Name) !== null)
|
elseif($this->getUnit($unit->execution_policy->name) !== null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
$new_pointers = [];
|
$new_pointers = [];
|
||||||
foreach($this->pointers as $pointer)
|
foreach($this->pointers as $pointer)
|
||||||
{
|
{
|
||||||
if($pointer->execution_policy->Name !== $name)
|
if($pointer->execution_policy->name !== $name)
|
||||||
{
|
{
|
||||||
$new_pointers[] = $pointer;
|
$new_pointers[] = $pointer;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
/** @var ExecutionPointer $pointer */
|
/** @var ExecutionPointer $pointer */
|
||||||
foreach($this->pointers as $pointer)
|
foreach($this->pointers as $pointer)
|
||||||
{
|
{
|
||||||
if($pointer->execution_policy->Name === $name)
|
if($pointer->execution_policy->name === $name)
|
||||||
{
|
{
|
||||||
return $pointer;
|
return $pointer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,9 +134,9 @@
|
||||||
{
|
{
|
||||||
foreach($this->dependencies as $dep)
|
foreach($this->dependencies as $dep)
|
||||||
{
|
{
|
||||||
if($dep->Name === $dependency->Name)
|
if($dep->name === $dependency->name)
|
||||||
{
|
{
|
||||||
$this->removeDependency($dep->Name);
|
$this->removeDependency($dep->name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@
|
||||||
{
|
{
|
||||||
foreach($this->dependencies as $key => $dep)
|
foreach($this->dependencies as $key => $dep)
|
||||||
{
|
{
|
||||||
if($dep->Name === $name)
|
if($dep->name === $name)
|
||||||
{
|
{
|
||||||
unset($this->dependencies[$key]);
|
unset($this->dependencies[$key]);
|
||||||
return;
|
return;
|
||||||
|
@ -216,7 +216,7 @@
|
||||||
{
|
{
|
||||||
foreach($this->execution_units as $unit)
|
foreach($this->execution_units as $unit)
|
||||||
{
|
{
|
||||||
if($unit->execution_policy->Name === $name)
|
if($unit->execution_policy->name === $name)
|
||||||
{
|
{
|
||||||
return $unit;
|
return $unit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
public function getId(): string
|
public function getId(): string
|
||||||
{
|
{
|
||||||
if($this->id == null)
|
if($this->id == null)
|
||||||
$this->id = hash('sha1', $this->execution_policy->Name);
|
$this->id = hash('sha1', $this->execution_policy->name);
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,8 @@
|
||||||
{
|
{
|
||||||
if($dependency !== null)
|
if($dependency !== null)
|
||||||
{
|
{
|
||||||
$this->PackageName = $dependency->Name;
|
$this->PackageName = $dependency->name;
|
||||||
$this->Version = $dependency->Version;
|
$this->Version = $dependency->version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,13 +149,13 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->build->Main !== null)
|
if($this->build->main !== null)
|
||||||
{
|
{
|
||||||
if($this->execution_policies === null || count($this->execution_policies) === 0)
|
if($this->execution_policies === null || count($this->execution_policies) === 0)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException(sprintf('Build configuration build.main uses an execution policy "%s" but no policies are defined', $this->build->Main));
|
throw new UndefinedExecutionPolicyException(sprintf('Build configuration build.main uses an execution policy "%s" but no policies are defined', $this->build->main));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -165,7 +165,7 @@
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach($this->execution_policies as $policy)
|
foreach($this->execution_policies as $policy)
|
||||||
{
|
{
|
||||||
if($policy->Name === $this->build->Main)
|
if($policy->name === $this->build->main)
|
||||||
{
|
{
|
||||||
$found = true;
|
$found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -176,12 +176,12 @@
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException(sprintf('Build configuration build.main points to a undefined execution policy "%s"', $this->build->Main));
|
throw new UndefinedExecutionPolicyException(sprintf('Build configuration build.main points to a undefined execution policy "%s"', $this->build->main));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->build->Main === BuildConfigurationValues::ALL)
|
if($this->build->main === BuildConfigurationValues::ALL)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@
|
||||||
{
|
{
|
||||||
foreach($this->execution_policies as $executionPolicy)
|
foreach($this->execution_policies as $executionPolicy)
|
||||||
{
|
{
|
||||||
if($executionPolicy->Name === $name)
|
if($executionPolicy->name === $name)
|
||||||
{
|
{
|
||||||
return $executionPolicy;
|
return $executionPolicy;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@
|
||||||
/** @var ExecutionPolicy $execution_policy */
|
/** @var ExecutionPolicy $execution_policy */
|
||||||
foreach($this->execution_policies as $execution_policy)
|
foreach($this->execution_policies as $execution_policy)
|
||||||
{
|
{
|
||||||
$defined_polices[] = $execution_policy->Name;
|
$defined_polices[] = $execution_policy->name;
|
||||||
//$execution_policy->validate();
|
//$execution_policy->validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,9 +264,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->build->PreBuild !== null && count($this->build->PostBuild) > 0)
|
if($this->build->pre_build !== null && count($this->build->post_build) > 0)
|
||||||
{
|
{
|
||||||
foreach($this->build->PostBuild as $unit)
|
foreach($this->build->post_build as $unit)
|
||||||
{
|
{
|
||||||
if(!in_array($unit, $defined_polices, true))
|
if(!in_array($unit, $defined_polices, true))
|
||||||
{
|
{
|
||||||
|
@ -280,9 +280,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->build->PostBuild !== null && count($this->build->PostBuild) > 0)
|
if($this->build->post_build !== null && count($this->build->post_build) > 0)
|
||||||
{
|
{
|
||||||
foreach($this->build->PostBuild as $unit)
|
foreach($this->build->post_build as $unit)
|
||||||
{
|
{
|
||||||
if(!in_array($unit, $defined_polices, true))
|
if(!in_array($unit, $defined_polices, true))
|
||||||
{
|
{
|
||||||
|
@ -301,7 +301,7 @@
|
||||||
{
|
{
|
||||||
case BuildConfigurationValues::ALL:
|
case BuildConfigurationValues::ALL:
|
||||||
/** @var BuildConfiguration $configuration */
|
/** @var BuildConfiguration $configuration */
|
||||||
foreach($this->build->Configurations as $configuration)
|
foreach($this->build->build_configurations as $configuration)
|
||||||
{
|
{
|
||||||
foreach($this->processBuildPolicies($configuration, $defined_polices) as $policy)
|
foreach($this->processBuildPolicies($configuration, $defined_polices) as $policy)
|
||||||
{
|
{
|
||||||
|
@ -328,47 +328,47 @@
|
||||||
foreach($required_policies as $policy)
|
foreach($required_policies as $policy)
|
||||||
{
|
{
|
||||||
$execution_policy = $this->getExecutionPolicy($policy);
|
$execution_policy = $this->getExecutionPolicy($policy);
|
||||||
if($execution_policy?->ExitHandlers !== null)
|
if($execution_policy?->exit_handlers !== null)
|
||||||
{
|
{
|
||||||
if(
|
if(
|
||||||
$execution_policy?->ExitHandlers->Success !== null &&
|
$execution_policy?->exit_handlers->Success !== null &&
|
||||||
$execution_policy?->ExitHandlers->Success->Run !== null
|
$execution_policy?->exit_handlers->Success->Run !== null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(!in_array($execution_policy?->ExitHandlers->Success->Run, $defined_polices, true))
|
if(!in_array($execution_policy?->exit_handlers->Success->Run, $defined_polices, true))
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->Name . '\' Success exit handler points to a undefined execution policy \'' . $execution_policy?->ExitHandlers->Success->Run . '\'');
|
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Success exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->Success->Run . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($execution_policy?->ExitHandlers->Success->Run, $required_policies, true))
|
if(!in_array($execution_policy?->exit_handlers->Success->Run, $required_policies, true))
|
||||||
{
|
{
|
||||||
$required_policies[] = $execution_policy?->ExitHandlers->Success->Run;
|
$required_policies[] = $execution_policy?->exit_handlers->Success->Run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($execution_policy?->ExitHandlers->Warning !== null && $execution_policy?->ExitHandlers->Warning->Run !== null)
|
if($execution_policy?->exit_handlers->Warning !== null && $execution_policy?->exit_handlers->Warning->Run !== null)
|
||||||
{
|
{
|
||||||
if(!in_array($execution_policy?->ExitHandlers->Warning->Run, $defined_polices, true))
|
if(!in_array($execution_policy?->exit_handlers->Warning->Run, $defined_polices, true))
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->Name . '\' Warning exit handler points to a undefined execution policy \'' . $execution_policy?->ExitHandlers->Warning->Run . '\'');
|
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Warning exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->Warning->Run . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($execution_policy?->ExitHandlers->Warning->Run, $required_policies, true))
|
if(!in_array($execution_policy?->exit_handlers->Warning->Run, $required_policies, true))
|
||||||
{
|
{
|
||||||
$required_policies[] = $execution_policy?->ExitHandlers->Warning->Run;
|
$required_policies[] = $execution_policy?->exit_handlers->Warning->Run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($execution_policy?->ExitHandlers->Error !== null && $execution_policy?->ExitHandlers->Error->Run !== null)
|
if($execution_policy?->exit_handlers->Error !== null && $execution_policy?->exit_handlers->Error->Run !== null)
|
||||||
{
|
{
|
||||||
if(!in_array($execution_policy?->ExitHandlers->Error->Run, $defined_polices, true))
|
if(!in_array($execution_policy?->exit_handlers->Error->Run, $defined_polices, true))
|
||||||
{
|
{
|
||||||
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->Name . '\' Error exit handler points to a undefined execution policy \'' . $execution_policy?->ExitHandlers->Error->Run . '\'');
|
throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Error exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->Error->Run . '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($execution_policy?->ExitHandlers->Error->Run, $required_policies, true))
|
if(!in_array($execution_policy?->exit_handlers->Error->Run, $required_policies, true))
|
||||||
{
|
{
|
||||||
$required_policies[] = $execution_policy?->ExitHandlers->Error->Run;
|
$required_policies[] = $execution_policy?->exit_handlers->Error->Run;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@
|
||||||
$execution_policies = [];
|
$execution_policies = [];
|
||||||
foreach($this->execution_policies as $executionPolicy)
|
foreach($this->execution_policies as $executionPolicy)
|
||||||
{
|
{
|
||||||
$execution_policies[$executionPolicy->Name] = $executionPolicy->toArray($bytecode);
|
$execution_policies[$executionPolicy->name] = $executionPolicy->toArray($bytecode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@
|
||||||
|
|
||||||
if($this->assembly !== null)
|
if($this->assembly !== null)
|
||||||
{
|
{
|
||||||
$results['assembly'] = $this->assembly->toArray($bytecode);
|
$results[($bytecode ? Functions::cbc('assembly') : 'assembly')] = $this->assembly->toArray($bytecode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->build !== null)
|
if($this->build !== null)
|
||||||
|
@ -503,30 +503,16 @@
|
||||||
{
|
{
|
||||||
$object = new self();
|
$object = new self();
|
||||||
|
|
||||||
if(isset($data['project']))
|
$object->project = Project::fromArray(Functions::array_bc($data, 'project'));
|
||||||
{
|
$object->assembly = Assembly::fromArray(Functions::array_bc($data, 'assembly'));
|
||||||
$object->project = Project::fromArray($data['project']);
|
$object->build = Build::fromArray(Functions::array_bc($data, 'build'));
|
||||||
}
|
$object->installer = Installer::fromArray(Functions::array_bc($data, 'installer'));
|
||||||
|
|
||||||
if(isset($data['assembly']))
|
$execution_policies = Functions::array_bc($data, 'execution_policies');
|
||||||
{
|
if(!is_null($execution_policies))
|
||||||
$object->assembly = Assembly::fromArray($data['assembly']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($data['build']))
|
|
||||||
{
|
|
||||||
$object->build = Build::fromArray($data['build']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($data['installer']))
|
|
||||||
{
|
|
||||||
$object->installer = Installer::fromArray($data['installer']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($data['execution_policies']))
|
|
||||||
{
|
{
|
||||||
$object->execution_policies = [];
|
$object->execution_policies = [];
|
||||||
foreach($data['execution_policies'] as $execution_policy)
|
foreach(Functions::array_bc($data, 'execution_policies') as $execution_policy)
|
||||||
{
|
{
|
||||||
$object->execution_policies[] = ExecutionPolicy::fromArray($execution_policy);
|
$object->execution_policies[] = ExecutionPolicy::fromArray($execution_policy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
use ncc\Exceptions\InvalidBuildConfigurationException;
|
use ncc\Exceptions\InvalidBuildConfigurationException;
|
||||||
use ncc\Exceptions\InvalidConstantNameException;
|
use ncc\Exceptions\InvalidConstantNameException;
|
||||||
use ncc\Exceptions\InvalidProjectBuildConfiguration;
|
use ncc\Exceptions\InvalidProjectBuildConfiguration;
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Objects\ProjectConfiguration\Build\BuildConfiguration;
|
use ncc\Objects\ProjectConfiguration\Build\BuildConfiguration;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
use ncc\Utilities\Validate;
|
use ncc\Utilities\Validate;
|
||||||
|
@ -37,115 +38,115 @@
|
||||||
* @author Zi Xing Narrakas
|
* @author Zi Xing Narrakas
|
||||||
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
class Build
|
class Build implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The source directory that the compiler will target to generate a build
|
* The source directory that the compiler will target to generate a build
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $SourcePath;
|
public $source_path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default configuration to use when building
|
* The default configuration to use when building
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $DefaultConfiguration;
|
public $default_configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of files to exclude from processing/bundling into the build output
|
* An array of files to exclude from processing/bundling into the build output
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $ExcludeFiles;
|
public $exclude_files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build options to pass on to the compiler
|
* Build options to pass on to the compiler
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $Options;
|
public $options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The installation scope for the package (System/User/Shared)
|
* The installation scope for the package (System/User/Shared)
|
||||||
*
|
*
|
||||||
* @var [type]
|
* @var [type]
|
||||||
*/
|
*/
|
||||||
public $Scope;
|
public $scope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The execution policy to use as the main execution point
|
* The execution policy to use as the main execution point
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Main;
|
public $main;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of constants to define by default
|
* An array of constants to define by default
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $DefineConstants;
|
public $define_constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of execution policies to execute pre build
|
* An array of execution policies to execute pre build
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $PreBuild;
|
public $pre_build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of execution policies to execute post build
|
* An array of execution policies to execute post build
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $PostBuild;
|
public $post_build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of dependencies that are required by default
|
* An array of dependencies that are required by default
|
||||||
*
|
*
|
||||||
* @var Dependency[]
|
* @var Dependency[]
|
||||||
*/
|
*/
|
||||||
public $Dependencies;
|
public $dependencies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of build configurations
|
* An array of build configurations
|
||||||
*
|
*
|
||||||
* @var BuildConfiguration[]
|
* @var BuildConfiguration[]
|
||||||
*/
|
*/
|
||||||
public $Configurations;
|
public $build_configurations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Constructor
|
* Public Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->ExcludeFiles = [];
|
$this->exclude_files = [];
|
||||||
$this->Options = [];
|
$this->options = [];
|
||||||
$this->DefineConstants = [];
|
$this->define_constants = [];
|
||||||
$this->Dependencies = [];
|
$this->dependencies = [];
|
||||||
$this->Configurations = [];
|
$this->build_configurations = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new dependency to the build, if it doesn't already exist
|
* Adds a new dependency to the build if it doesn't already exist
|
||||||
*
|
*
|
||||||
* @param Dependency $dependency
|
* @param Dependency $dependency
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addDependency(Dependency $dependency): void
|
public function addDependency(Dependency $dependency): void
|
||||||
{
|
{
|
||||||
foreach($this->Dependencies as $dep)
|
foreach($this->dependencies as $dep)
|
||||||
{
|
{
|
||||||
if($dep->Name == $dependency->Name)
|
if($dep->name === $dependency->name)
|
||||||
{
|
{
|
||||||
$this->removeDependency($dep->Name);
|
$this->removeDependency($dep->name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Dependencies[] = $dependency;
|
$this->dependencies[] = $dependency;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,11 +157,11 @@
|
||||||
*/
|
*/
|
||||||
private function removeDependency(string $name): void
|
private function removeDependency(string $name): void
|
||||||
{
|
{
|
||||||
foreach($this->Dependencies as $key => $dep)
|
foreach($this->dependencies as $key => $dep)
|
||||||
{
|
{
|
||||||
if($dep->Name == $name)
|
if($dep->name === $name)
|
||||||
{
|
{
|
||||||
unset($this->Dependencies[$key]);
|
unset($this->dependencies[$key]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +180,7 @@
|
||||||
public function validate(bool $throw_exception=True): bool
|
public function validate(bool $throw_exception=True): bool
|
||||||
{
|
{
|
||||||
// Check the defined constants
|
// Check the defined constants
|
||||||
foreach($this->DefineConstants as $name => $value)
|
foreach($this->define_constants as $name => $value)
|
||||||
{
|
{
|
||||||
if(!Validate::constantName($name))
|
if(!Validate::constantName($name))
|
||||||
{
|
{
|
||||||
|
@ -189,47 +190,55 @@
|
||||||
|
|
||||||
// Check for duplicate configuration names
|
// Check for duplicate configuration names
|
||||||
$build_configurations = [];
|
$build_configurations = [];
|
||||||
foreach($this->Configurations as $configuration)
|
foreach($this->build_configurations as $configuration)
|
||||||
{
|
{
|
||||||
if(in_array($configuration->Name, $build_configurations))
|
if(in_array($configuration->Name, $build_configurations, true))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectBuildConfiguration('The build configuration \'' . $configuration->Name . '\' is already defined, build configuration names must be unique');
|
throw new InvalidProjectBuildConfiguration('The build configuration \'' . $configuration->Name . '\' is already defined, build configuration names must be unique');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->Configurations as $configuration)
|
foreach($this->build_configurations as $configuration)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!$configuration->validate($throw_exception))
|
if (!$configuration->validate($throw_exception))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (InvalidBuildConfigurationException $e)
|
catch (InvalidBuildConfigurationException $e)
|
||||||
{
|
{
|
||||||
throw new InvalidBuildConfigurationException(sprintf('Error in build configuration \'%s\'', $configuration->Name), $e);
|
throw new InvalidBuildConfigurationException(sprintf('Error in build configuration \'%s\'', $configuration->Name), $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->DefaultConfiguration == null)
|
if($this->default_configuration === null)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidProjectBuildConfiguration('The default build configuration is not set');
|
throw new InvalidProjectBuildConfiguration('The default build configuration is not set');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Validate::nameFriendly($this->DefaultConfiguration))
|
if(!Validate::nameFriendly($this->default_configuration))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidProjectBuildConfiguration('The default build configuration name \'' . $this->DefaultConfiguration . '\' is not valid');
|
{
|
||||||
|
throw new InvalidProjectBuildConfiguration('The default build configuration name \'' . $this->default_configuration . '\' is not valid');
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getBuildConfiguration($this->DefaultConfiguration);
|
$this->getBuildConfiguration($this->default_configuration);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -244,7 +253,7 @@
|
||||||
{
|
{
|
||||||
$build_configurations = [];
|
$build_configurations = [];
|
||||||
|
|
||||||
foreach($this->Configurations as $configuration)
|
foreach($this->build_configurations as $configuration)
|
||||||
{
|
{
|
||||||
$build_configurations[] = $configuration->Name;
|
$build_configurations[] = $configuration->Name;
|
||||||
}
|
}
|
||||||
|
@ -262,12 +271,14 @@
|
||||||
*/
|
*/
|
||||||
public function getBuildConfiguration(string $name): BuildConfiguration
|
public function getBuildConfiguration(string $name): BuildConfiguration
|
||||||
{
|
{
|
||||||
if($name == BuildConfigurationValues::DEFAULT)
|
if($name === BuildConfigurationValues::DEFAULT)
|
||||||
$name = $this->DefaultConfiguration;
|
|
||||||
|
|
||||||
foreach($this->Configurations as $configuration)
|
|
||||||
{
|
{
|
||||||
if($configuration->Name == $name)
|
$name = $this->default_configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($this->build_configurations as $configuration)
|
||||||
|
{
|
||||||
|
if($configuration->Name === $name)
|
||||||
{
|
{
|
||||||
return $configuration;
|
return $configuration;
|
||||||
}
|
}
|
||||||
|
@ -284,46 +295,71 @@
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
$ReturnResults = [];
|
$results = [];
|
||||||
|
|
||||||
if($this->SourcePath !== null)
|
if($this->source_path !== null)
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('source_path') : 'source_path')] = $this->SourcePath;
|
{
|
||||||
if($this->DefaultConfiguration !== null)
|
$results[($bytecode ? Functions::cbc('source_path') : 'source_path')] = $this->source_path;
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('default_configuration') : 'default_configuration')] = $this->DefaultConfiguration;
|
}
|
||||||
if($this->ExcludeFiles !== null && count($this->ExcludeFiles) > 0)
|
if($this->default_configuration !== null)
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('exclude_files') : 'exclude_files')] = $this->ExcludeFiles;
|
{
|
||||||
if($this->Options !== null && count($this->Options) > 0)
|
$results[($bytecode ? Functions::cbc('default_configuration') : 'default_configuration')] = $this->default_configuration;
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('options') : 'options')] = $this->Options;
|
}
|
||||||
if($this->Scope !== null)
|
if($this->exclude_files !== null && count($this->exclude_files) > 0)
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('scope') : 'scope')] = $this->Scope;
|
{
|
||||||
if($this->Main !== null)
|
$results[($bytecode ? Functions::cbc('exclude_files') : 'exclude_files')] = $this->exclude_files;
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('main') : 'main')] = $this->Main;
|
}
|
||||||
if($this->DefineConstants !== null && count($this->DefineConstants) > 0)
|
if($this->options !== null && count($this->options) > 0)
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('define_constants') : 'define_constants')] = $this->DefineConstants;
|
{
|
||||||
if($this->PreBuild !== null && count($this->PreBuild) > 0)
|
$results[($bytecode ? Functions::cbc('options') : 'options')] = $this->options;
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('pre_build') : 'pre_build')] = $this->PreBuild;
|
}
|
||||||
if($this->PostBuild !== null && count($this->PostBuild) > 0)
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('post_build') : 'post_build')] = $this->PostBuild;
|
if($this->scope !== null)
|
||||||
if($this->Dependencies !== null && count($this->Dependencies) > 0)
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('scope') : 'scope')] = $this->scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->main !== null)
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('main') : 'main')] = $this->main;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->define_constants !== null && count($this->define_constants) > 0)
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('define_constants') : 'define_constants')] = $this->define_constants;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->pre_build !== null && count($this->pre_build) > 0)
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('pre_build') : 'pre_build')] = $this->pre_build;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->post_build !== null && count($this->post_build) > 0)
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('post_build') : 'post_build')] = $this->post_build;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->dependencies !== null && count($this->dependencies) > 0)
|
||||||
{
|
{
|
||||||
$dependencies = [];
|
$dependencies = [];
|
||||||
foreach($this->Dependencies as $dependency)
|
foreach($this->dependencies as $dependency)
|
||||||
{
|
{
|
||||||
$dependencies[] = $dependency->toArray($bytecode);
|
$dependencies[] = $dependency->toArray($bytecode);
|
||||||
}
|
}
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('dependencies') : 'dependencies')] = $dependencies;
|
$results[($bytecode ? Functions::cbc('dependencies') : 'dependencies')] = $dependencies;
|
||||||
}
|
}
|
||||||
if($this->Configurations !== null && count($this->Configurations) > 0)
|
|
||||||
|
if($this->build_configurations !== null && count($this->build_configurations) > 0)
|
||||||
{
|
{
|
||||||
$configurations = [];
|
$configurations = [];
|
||||||
foreach($this->Configurations as $configuration)
|
foreach($this->build_configurations as $configuration)
|
||||||
{
|
{
|
||||||
$configurations[] = $configuration->toArray($bytecode);
|
$configurations[] = $configuration->toArray($bytecode);
|
||||||
}
|
}
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('configurations') : 'configurations')] = $configurations;
|
$results[($bytecode ? Functions::cbc('configurations') : 'configurations')] = $configurations;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ReturnResults;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,23 +370,23 @@
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): Build
|
public static function fromArray(array $data): Build
|
||||||
{
|
{
|
||||||
$BuildObject = new Build();
|
$object = new self();
|
||||||
|
|
||||||
$BuildObject->SourcePath = Functions::array_bc($data, 'source_path');
|
$object->source_path = Functions::array_bc($data, 'source_path');
|
||||||
$BuildObject->DefaultConfiguration = Functions::array_bc($data, 'default_configuration');
|
$object->default_configuration = Functions::array_bc($data, 'default_configuration');
|
||||||
$BuildObject->ExcludeFiles = (Functions::array_bc($data, 'exclude_files') ?? []);
|
$object->exclude_files = (Functions::array_bc($data, 'exclude_files') ?? []);
|
||||||
$BuildObject->Options = (Functions::array_bc($data, 'options') ?? []);
|
$object->options = (Functions::array_bc($data, 'options') ?? []);
|
||||||
$BuildObject->Scope = Functions::array_bc($data, 'scope');
|
$object->scope = Functions::array_bc($data, 'scope');
|
||||||
$BuildObject->Main = Functions::array_bc($data, 'main');
|
$object->main = Functions::array_bc($data, 'main');
|
||||||
$BuildObject->DefineConstants = (Functions::array_bc($data, 'define_constants') ?? []);
|
$object->define_constants = (Functions::array_bc($data, 'define_constants') ?? []);
|
||||||
$BuildObject->PreBuild = (Functions::array_bc($data, 'pre_build') ?? []);
|
$object->pre_build = (Functions::array_bc($data, 'pre_build') ?? []);
|
||||||
$BuildObject->PostBuild = (Functions::array_bc($data, 'post_build') ?? []);
|
$object->post_build = (Functions::array_bc($data, 'post_build') ?? []);
|
||||||
|
|
||||||
if(Functions::array_bc($data, 'dependencies') !== null)
|
if(Functions::array_bc($data, 'dependencies') !== null)
|
||||||
{
|
{
|
||||||
foreach(Functions::array_bc($data, 'dependencies') as $dependency)
|
foreach(Functions::array_bc($data, 'dependencies') as $dependency)
|
||||||
{
|
{
|
||||||
$BuildObject->Dependencies[] = Dependency::fromArray($dependency);
|
$object->dependencies[] = Dependency::fromArray($dependency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,10 +394,10 @@
|
||||||
{
|
{
|
||||||
foreach(Functions::array_bc($data, 'configurations') as $configuration)
|
foreach(Functions::array_bc($data, 'configurations') as $configuration)
|
||||||
{
|
{
|
||||||
$BuildObject->Configurations[] = BuildConfiguration::fromArray($configuration);
|
$object->build_configurations[] = BuildConfiguration::fromArray($configuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $BuildObject;
|
return $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -32,6 +32,7 @@
|
||||||
use ncc\Exceptions\RuntimeException;
|
use ncc\Exceptions\RuntimeException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
||||||
use ncc\Exceptions\UnsupportedExtensionVersionException;
|
use ncc\Exceptions\UnsupportedExtensionVersionException;
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\ThirdParty\jelix\Version\VersionComparator;
|
use ncc\ThirdParty\jelix\Version\VersionComparator;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
|
@ -39,28 +40,28 @@
|
||||||
* @author Zi Xing Narrakas
|
* @author Zi Xing Narrakas
|
||||||
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
class Compiler
|
class Compiler implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The compiler extension that the project uses
|
* The compiler extension that the project uses
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Extension;
|
public $extension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum version that is supported
|
* The minimum version that is supported
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $MinimumVersion;
|
public $minimum_version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum version that is supported
|
* The maximum version that is supported
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $MaximumVersion;
|
public $maximum_version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the compiler object
|
* Validates the compiler object
|
||||||
|
@ -74,34 +75,45 @@
|
||||||
*/
|
*/
|
||||||
public function validate(bool $throw_exception=True): bool
|
public function validate(bool $throw_exception=True): bool
|
||||||
{
|
{
|
||||||
if($this->Extension == null)
|
if($this->extension === null)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidPropertyValueException('The property \'extension\' must not be null.');
|
throw new InvalidPropertyValueException('The property \'extension\' must not be null.');
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->MinimumVersion == null)
|
if($this->minimum_version === null)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidPropertyValueException('The property \'minimum_version\' must not be null.');
|
throw new InvalidPropertyValueException('The property \'minimum_version\' must not be null.');
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->MaximumVersion == null)
|
if($this->maximum_version === null)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidPropertyValueException('The property \'maximum_version\' must not be null.');
|
throw new InvalidPropertyValueException('The property \'maximum_version\' must not be null.');
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(VersionComparator::compareVersion($this->MinimumVersion, $this->MaximumVersion) == 1)
|
if(VersionComparator::compareVersion($this->minimum_version, $this->maximum_version) === 1)
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
|
{
|
||||||
throw new InvalidVersionConfigurationException('The minimum version cannot be greater version number than the maximum version');
|
throw new InvalidVersionConfigurationException('The minimum version cannot be greater version number than the maximum version');
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,72 +122,80 @@
|
||||||
throw new RuntimeException('Version comparison failed: ' . $e->getMessage());
|
throw new RuntimeException('Version comparison failed: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($this->Extension, CompilerExtensions::ALL))
|
if(!in_array($this->extension, CompilerExtensions::ALL))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $this->Extension . '\' is not supported');
|
{
|
||||||
|
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $this->extension . '\' is not supported');
|
||||||
|
}
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($this->Extension)
|
switch($this->extension)
|
||||||
{
|
{
|
||||||
case CompilerExtensions::PHP:
|
case CompilerExtensions::PHP:
|
||||||
if(!in_array($this->MaximumVersion, CompilerExtensionSupportedVersions::PHP))
|
if(!in_array($this->maximum_version, CompilerExtensionSupportedVersions::PHP))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new UnsupportedExtensionVersionException('The MaximumVersion does not support version ' . $this->MaximumVersion . ' for the extension ' . $this->Extension);
|
{
|
||||||
|
throw new UnsupportedExtensionVersionException('The MaximumVersion does not support version ' . $this->maximum_version . ' for the extension ' . $this->extension);
|
||||||
|
}
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($this->MinimumVersion, CompilerExtensionSupportedVersions::PHP))
|
if(!in_array($this->minimum_version, CompilerExtensionSupportedVersions::PHP))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new UnsupportedExtensionVersionException('The MinimumVersion does not support version ' . $this->MinimumVersion . ' for the extension ' . $this->Extension);
|
{
|
||||||
|
throw new UnsupportedExtensionVersionException('The MinimumVersion does not support version ' . $this->minimum_version . ' for the extension ' . $this->extension);
|
||||||
|
}
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $this->Extension . '\' is not supported');
|
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $this->extension . '\' is not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(): array
|
public function toArray(bool $bytecode = false): array
|
||||||
{
|
{
|
||||||
$return_results = [];
|
$results = [];
|
||||||
if($this->Extension !== null && strlen($this->Extension) > 0)
|
if($this->extension !== null && $this->extension !== '')
|
||||||
$return_results['extension'] = $this->Extension;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('extension') : 'extension')] = $this->extension;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->MinimumVersion !== null && strlen($this->MinimumVersion) > 0)
|
if($this->minimum_version !== null && $this->minimum_version !== '')
|
||||||
$return_results['minimum_version'] = $this->MinimumVersion;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('minimum_version') : 'minimum_version')] = $this->minimum_version;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->MaximumVersion !== null && strlen($this->MaximumVersion) > 0)
|
if($this->maximum_version !== null && $this->maximum_version !== '')
|
||||||
$return_results['maximum_version'] = $this->MaximumVersion;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('maximum_version') : 'maximum_version')] = $this->maximum_version;
|
||||||
|
}
|
||||||
|
|
||||||
return $return_results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs object from an array representation
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return Compiler
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): Compiler
|
public static function fromArray(array $data): Compiler
|
||||||
{
|
{
|
||||||
$CompilerObject = new Compiler();
|
$object = new self();
|
||||||
|
|
||||||
$CompilerObject->MaximumVersion = Functions::array_bc($data, 'maximum_version');
|
$object->maximum_version = Functions::array_bc($data, 'maximum_version');
|
||||||
$CompilerObject->Extension = Functions::array_bc($data, 'extension');
|
$object->extension = Functions::array_bc($data, 'extension');
|
||||||
$CompilerObject->MinimumVersion = Functions::array_bc($data, 'minimum_version');
|
$object->minimum_version = Functions::array_bc($data, 'minimum_version');
|
||||||
|
|
||||||
return $CompilerObject;
|
return $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
namespace ncc\Objects\ProjectConfiguration;
|
namespace ncc\Objects\ProjectConfiguration;
|
||||||
|
|
||||||
use ncc\Exceptions\InvalidDependencyConfiguration;
|
use ncc\Exceptions\InvalidDependencyConfiguration;
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
use ncc\Utilities\Validate;
|
use ncc\Utilities\Validate;
|
||||||
|
|
||||||
|
@ -32,79 +33,35 @@
|
||||||
* @author Zi Xing Narrakas
|
* @author Zi Xing Narrakas
|
||||||
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
class Dependency
|
class Dependency implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name of the dependency
|
* The name of the dependency
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Name;
|
public $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional. The type of source from where ncc can fetch the dependency from
|
* Optional. The type of source from where ncc can fetch the dependency from
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $SourceType;
|
public $source_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional. The actual source where NCC can fetch the dependency from
|
* Optional. The actual source where NCC can fetch the dependency from
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Source;
|
public $source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional. The required version of the dependency or "latest"
|
* Optional. The required version of the dependency or "latest"
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Version;
|
public $version;
|
||||||
|
|
||||||
// TODO: Add validation function here
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array representation of the object
|
|
||||||
*
|
|
||||||
* @param bool $bytecode
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function toArray(bool $bytecode=false): array
|
|
||||||
{
|
|
||||||
$ReturnResults = [];
|
|
||||||
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('name') : 'name')] = $this->Name;
|
|
||||||
|
|
||||||
if($this->SourceType !== null && strlen($this->SourceType) > 0)
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('source_type') : 'source_type')] = $this->SourceType;
|
|
||||||
|
|
||||||
if($this->Source !== null && strlen($this->Source) > 0)
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('source') : 'source')] = $this->Source;
|
|
||||||
|
|
||||||
if($this->Version !== null && strlen($this->Version) > 0)
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('version') : 'version')] = $this->Version;
|
|
||||||
|
|
||||||
return $ReturnResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs the object from an array representation
|
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return Dependency
|
|
||||||
*/
|
|
||||||
public static function fromArray(array $data): Dependency
|
|
||||||
{
|
|
||||||
$DependencyObject = new Dependency();
|
|
||||||
|
|
||||||
$DependencyObject->Name = Functions::array_bc($data, 'name');
|
|
||||||
$DependencyObject->SourceType = Functions::array_bc($data, 'source_type');
|
|
||||||
$DependencyObject->Source = Functions::array_bc($data, 'source');
|
|
||||||
$DependencyObject->Version = Functions::array_bc($data, 'version');
|
|
||||||
|
|
||||||
return $DependencyObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the dependency configuration
|
* Validates the dependency configuration
|
||||||
|
@ -115,22 +72,68 @@
|
||||||
*/
|
*/
|
||||||
public function validate(bool $throw_exception): bool
|
public function validate(bool $throw_exception): bool
|
||||||
{
|
{
|
||||||
if(!Validate::packageName($this->Name))
|
if(!Validate::packageName($this->name))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidDependencyConfiguration(sprintf('Invalid dependency name "%s"', $this->Name));
|
{
|
||||||
|
throw new InvalidDependencyConfiguration(sprintf('Invalid dependency name "%s"', $this->name));
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Version !== null && !Validate::version($this->Version))
|
if($this->version !== null && !Validate::version($this->version))
|
||||||
{
|
{
|
||||||
if($throw_exception)
|
if($throw_exception)
|
||||||
throw new InvalidDependencyConfiguration(sprintf('Invalid dependency version "%s"', $this->Version));
|
{
|
||||||
|
throw new InvalidDependencyConfiguration(sprintf('Invalid dependency version "%s"', $this->version));
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function toArray(bool $bytecode=false): array
|
||||||
|
{
|
||||||
|
$results = [];
|
||||||
|
|
||||||
|
$results[($bytecode ? Functions::cbc('name') : 'name')] = $this->name;
|
||||||
|
|
||||||
|
if($this->source_type !== null && $this->source_type !== '')
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('source_type') : 'source_type')] = $this->source_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->source !== null && $this->source !== '')
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('source') : 'source')] = $this->source;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->version !== null && $this->version !== '')
|
||||||
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('version') : 'version')] = $this->version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function fromArray(array $data): Dependency
|
||||||
|
{
|
||||||
|
$object = new self();
|
||||||
|
|
||||||
|
$object->name = Functions::array_bc($data, 'name');
|
||||||
|
$object->source_type = Functions::array_bc($data, 'source_type');
|
||||||
|
$object->source = Functions::array_bc($data, 'source');
|
||||||
|
$object->version = Functions::array_bc($data, 'version');
|
||||||
|
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -24,46 +24,47 @@
|
||||||
|
|
||||||
namespace ncc\Objects\ProjectConfiguration;
|
namespace ncc\Objects\ProjectConfiguration;
|
||||||
|
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Objects\ProjectConfiguration\ExecutionPolicy\Execute;
|
use ncc\Objects\ProjectConfiguration\ExecutionPolicy\Execute;
|
||||||
use ncc\Objects\ProjectConfiguration\ExecutionPolicy\ExitHandlers;
|
use ncc\Objects\ProjectConfiguration\ExecutionPolicy\ExitHandlers;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
class ExecutionPolicy
|
class ExecutionPolicy implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The unique name of the execution policy
|
* The unique name of the execution policy
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Name;
|
public $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of a supported runner instance
|
* The name of a supported runner instance
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Runner;
|
public $runner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message to display when the policy is invoked
|
* The message to display when the policy is invoked
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
public $Message;
|
public $message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The execution process of the policy
|
* The execution process of the policy
|
||||||
*
|
*
|
||||||
* @var Execute
|
* @var Execute
|
||||||
*/
|
*/
|
||||||
public $Execute;
|
public $execute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The configuration for exit handling
|
* The configuration for exit handling
|
||||||
*
|
*
|
||||||
* @var ExitHandlers
|
* @var ExitHandlers
|
||||||
*/
|
*/
|
||||||
public $ExitHandlers;
|
public $exit_handlers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -75,52 +76,62 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param bool $bytecode
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
if ($this->Name !== null && strlen($this->Name) > 0)
|
if ($this->name !== null && $this->name !== '')
|
||||||
$results[($bytecode ? Functions::cbc('name') : 'name')] = $this->Name;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('name') : 'name')] = $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->Runner !== null && strlen($this->Runner) > 0)
|
if ($this->runner !== null && $this->runner !== '')
|
||||||
$results[($bytecode ? Functions::cbc('runner') : 'runner')] = $this->Runner;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('runner') : 'runner')] = $this->runner;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->Message !== null && strlen($this->Message) > 0)
|
if ($this->message !== null && $this->message !== '')
|
||||||
$results[($bytecode ? Functions::cbc('message') : 'message')] = $this->Message;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('message') : 'message')] = $this->message;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->Execute !== null)
|
if ($this->execute !== null)
|
||||||
$results[($bytecode ? Functions::cbc('execute') : 'execute')] = $this->Execute->toArray($bytecode);
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('execute') : 'execute')] = $this->execute->toArray($bytecode);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->ExitHandlers !== null)
|
if ($this->exit_handlers !== null)
|
||||||
$results[($bytecode ? Functions::cbc('exit_handlers') : 'exit_handlers')] = $this->ExitHandlers->toArray($bytecode);
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('exit_handlers') : 'exit_handlers')] = $this->exit_handlers->toArray($bytecode);
|
||||||
|
|
||||||
|
}
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @inheritDoc
|
||||||
* @return ExecutionPolicy
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): self
|
public static function fromArray(array $data): ExecutionPolicy
|
||||||
{
|
{
|
||||||
$object = new self();
|
$object = new self();
|
||||||
|
|
||||||
$object->Name = Functions::array_bc($data, 'name');
|
$object->name = Functions::array_bc($data, 'name');
|
||||||
$object->Runner = Functions::array_bc($data, 'runner');
|
$object->runner = Functions::array_bc($data, 'runner');
|
||||||
$object->Message = Functions::array_bc($data, 'message');
|
$object->message = Functions::array_bc($data, 'message');
|
||||||
$object->Execute = Functions::array_bc($data, 'execute');
|
$object->execute = Functions::array_bc($data, 'execute');
|
||||||
$object->ExitHandlers = Functions::array_bc($data, 'exit_handlers');
|
$object->exit_handlers = Functions::array_bc($data, 'exit_handlers');
|
||||||
|
|
||||||
if($object->Execute !== null)
|
if($object->execute !== null)
|
||||||
$object->Execute = Execute::fromArray($object->Execute);
|
{
|
||||||
|
$object->execute = Execute::fromArray($object->execute);
|
||||||
|
}
|
||||||
|
|
||||||
if($object->ExitHandlers !== null)
|
if($object->exit_handlers !== null)
|
||||||
$object->ExitHandlers = ExitHandlers::fromArray($object->ExitHandlers);
|
{
|
||||||
|
$object->exit_handlers = ExitHandlers::fromArray($object->exit_handlers);
|
||||||
|
}
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -24,97 +24,106 @@
|
||||||
|
|
||||||
namespace ncc\Objects\ProjectConfiguration;
|
namespace ncc\Objects\ProjectConfiguration;
|
||||||
|
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
class Installer
|
class Installer implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* An array of execution policies to execute pre-installation
|
* An array of execution policies to execute pre-installation
|
||||||
*
|
*
|
||||||
* @var string[]|null
|
* @var string[]|null
|
||||||
*/
|
*/
|
||||||
public $PreInstall;
|
public $pre_install;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of execution policies to execute post-installation
|
* An array of execution policies to execute post-installation
|
||||||
*
|
*
|
||||||
* @var string[]|null
|
* @var string[]|null
|
||||||
*/
|
*/
|
||||||
public $PostInstall;
|
public $post_install;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of execution policies to execute pre-uninstallation
|
* An array of execution policies to execute pre-uninstallation
|
||||||
*
|
*
|
||||||
* @var string[]|null
|
* @var string[]|null
|
||||||
*/
|
*/
|
||||||
public $PreUninstall;
|
public $pre_uninstall;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of execution policies to execute post-uninstallation
|
* An array of execution policies to execute post-uninstallation
|
||||||
*
|
*
|
||||||
* @var string[]|null
|
* @var string[]|null
|
||||||
*/
|
*/
|
||||||
public $PostUninstall;
|
public $post_uninstall;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of execution policies to execute pre-update
|
* An array of execution policies to execute pre-update
|
||||||
*
|
*
|
||||||
* @var string[]|null
|
* @var string[]|null
|
||||||
*/
|
*/
|
||||||
public $PreUpdate;
|
public $pre_update;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of execution policies to execute post-update
|
* An array of execution policies to execute post-update
|
||||||
*
|
*
|
||||||
* @var string[]|null
|
* @var string[]|null
|
||||||
*/
|
*/
|
||||||
public $PostUpdate;
|
public $post_update;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param bool $bytecode
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
if($this->PreInstall !== null && count($this->PreInstall) > 0)
|
if($this->pre_install !== null && count($this->pre_install) > 0)
|
||||||
$results[($bytecode ? Functions::cbc('pre_install') : 'pre_install')] = $this->PreInstall;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('pre_install') : 'pre_install')] = $this->pre_install;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->PostInstall !== null && count($this->PostInstall) > 0)
|
if($this->post_install !== null && count($this->post_install) > 0)
|
||||||
$results[($bytecode ? Functions::cbc('post_install') : 'post_install')] = $this->PostInstall;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('post_install') : 'post_install')] = $this->post_install;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->PreUninstall !== null && count($this->PreUninstall) > 0)
|
if($this->pre_uninstall !== null && count($this->pre_uninstall) > 0)
|
||||||
$results[($bytecode ? Functions::cbc('pre_uninstall') : 'pre_uninstall')] = $this->PreUninstall;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('pre_uninstall') : 'pre_uninstall')] = $this->pre_uninstall;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->PostUninstall !== null && count($this->PostUninstall) > 0)
|
if($this->post_uninstall !== null && count($this->post_uninstall) > 0)
|
||||||
$results[($bytecode ? Functions::cbc('post_uninstall') : 'post_uninstall')] = $this->PostUninstall;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('post_uninstall') : 'post_uninstall')] = $this->post_uninstall;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->PreUpdate !== null && count($this->PreUpdate) > 0)
|
if($this->pre_update !== null && count($this->pre_update) > 0)
|
||||||
$results[($bytecode ? Functions::cbc('pre_update') : 'pre_update')] = $this->PreUpdate;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('pre_update') : 'pre_update')] = $this->pre_update;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->PostUpdate !== null && count($this->PostUpdate) > 0)
|
if($this->post_update !== null && count($this->post_update) > 0)
|
||||||
$results[($bytecode ? Functions::cbc('post_update') : 'post_update')] = $this->PostUpdate;
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('post_update') : 'post_update')] = $this->post_update;
|
||||||
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @inheritDoc
|
||||||
* @return Installer
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): self
|
public static function fromArray(array $data): Installer
|
||||||
{
|
{
|
||||||
$object = new self();
|
$object = new self();
|
||||||
|
|
||||||
$object->PreInstall = Functions::array_bc($data, 'pre_install');
|
$object->pre_install = Functions::array_bc($data, 'pre_install');
|
||||||
$object->PostInstall = Functions::array_bc($data, 'post_install');
|
$object->post_install = Functions::array_bc($data, 'post_install');
|
||||||
$object->PreUninstall = Functions::array_bc($data, 'pre_uninstall');
|
$object->pre_uninstall = Functions::array_bc($data, 'pre_uninstall');
|
||||||
$object->PostUninstall = Functions::array_bc($data, 'post_uninstall');
|
$object->post_uninstall = Functions::array_bc($data, 'post_uninstall');
|
||||||
$object->PreUpdate = Functions::array_bc($data, 'pre_update');
|
$object->pre_update = Functions::array_bc($data, 'pre_update');
|
||||||
$object->PostUpdate = Functions::array_bc($data, 'post_update');
|
$object->post_update = Functions::array_bc($data, 'post_update');
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -28,36 +28,37 @@
|
||||||
use ncc\Exceptions\RuntimeException;
|
use ncc\Exceptions\RuntimeException;
|
||||||
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
use ncc\Exceptions\UnsupportedCompilerExtensionException;
|
||||||
use ncc\Exceptions\UnsupportedExtensionVersionException;
|
use ncc\Exceptions\UnsupportedExtensionVersionException;
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zi Xing Narrakas
|
* @author Zi Xing Narrakas
|
||||||
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
* @copyright Copyright (C) 2022-2022. Nosial - All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
class Project
|
class Project implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Compiler
|
* @var Compiler
|
||||||
*/
|
*/
|
||||||
public $Compiler;
|
public $compiler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $Options;
|
public $options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var UpdateSource|null
|
* @var UpdateSource|null
|
||||||
*/
|
*/
|
||||||
public $UpdateSource;
|
public $update_source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Constructor
|
* Public Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->Compiler = new Compiler();
|
$this->compiler = new Compiler();
|
||||||
$this->Options = [];
|
$this->options = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,8 +73,10 @@
|
||||||
*/
|
*/
|
||||||
public function validate(bool $throw_exception=True): bool
|
public function validate(bool $throw_exception=True): bool
|
||||||
{
|
{
|
||||||
if(!$this->Compiler->validate($throw_exception))
|
if(!$this->compiler->validate($throw_exception))
|
||||||
|
{
|
||||||
return False;
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
@ -86,15 +89,17 @@
|
||||||
*/
|
*/
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
$ReturnResults = [];
|
$results = [];
|
||||||
|
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('compiler') : 'compiler')] = $this->Compiler->toArray();
|
$results[($bytecode ? Functions::cbc('compiler') : 'compiler')] = $this->compiler->toArray();
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('options') : 'options')] = $this->Options;
|
$results[($bytecode ? Functions::cbc('options') : 'options')] = $this->options;
|
||||||
|
|
||||||
if($this->UpdateSource !== null)
|
if($this->update_source !== null)
|
||||||
$ReturnResults[($bytecode ? Functions::cbc('update_source') : 'update_source')] = $this->UpdateSource->toArray($bytecode);
|
{
|
||||||
|
$results[($bytecode ? Functions::cbc('update_source') : 'update_source')] = $this->update_source->toArray($bytecode);
|
||||||
|
}
|
||||||
|
|
||||||
return $ReturnResults;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,23 +110,23 @@
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): Project
|
public static function fromArray(array $data): Project
|
||||||
{
|
{
|
||||||
$ProjectObject = new Project();
|
$object = new self();
|
||||||
|
|
||||||
if(Functions::array_bc($data, 'compiler') !== null)
|
if(Functions::array_bc($data, 'compiler') !== null)
|
||||||
{
|
{
|
||||||
$ProjectObject->Compiler = Compiler::fromArray(Functions::array_bc($data, 'compiler'));
|
$object->compiler = Compiler::fromArray(Functions::array_bc($data, 'compiler'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Functions::array_bc($data, 'options') !== null)
|
if(Functions::array_bc($data, 'options') !== null)
|
||||||
{
|
{
|
||||||
$ProjectObject->Options = Functions::array_bc($data, 'options');
|
$object->options = Functions::array_bc($data, 'options');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Functions::array_bc($data, 'update_source') !== null)
|
if(Functions::array_bc($data, 'update_source') !== null)
|
||||||
{
|
{
|
||||||
$ProjectObject->UpdateSource = UpdateSource::fromArray(Functions::array_bc($data, 'update_source'));
|
$object->update_source = UpdateSource::fromArray(Functions::array_bc($data, 'update_source'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ProjectObject;
|
return $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
@ -24,24 +24,25 @@
|
||||||
|
|
||||||
namespace ncc\Objects\ProjectConfiguration;
|
namespace ncc\Objects\ProjectConfiguration;
|
||||||
|
|
||||||
|
use ncc\Interfaces\BytecodeObjectInterface;
|
||||||
use ncc\Objects\ProjectConfiguration\UpdateSource\Repository;
|
use ncc\Objects\ProjectConfiguration\UpdateSource\Repository;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
|
||||||
class UpdateSource
|
class UpdateSource implements BytecodeObjectInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The string format of where the source is located.
|
* The string format of where the source is located.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $Source;
|
public $source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The repository to use for the source
|
* The repository to use for the source
|
||||||
*
|
*
|
||||||
* @var Repository|null
|
* @var Repository|null
|
||||||
*/
|
*/
|
||||||
public $Repository;
|
public $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* Returns an array representation of the object
|
||||||
|
@ -52,8 +53,8 @@
|
||||||
public function toArray(bool $bytecode=false): array
|
public function toArray(bool $bytecode=false): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
($bytecode ? Functions::cbc('source') : 'source') => $this->Source,
|
($bytecode ? Functions::cbc('source') : 'source') => $this->source,
|
||||||
($bytecode ? Functions::cbc('repository') : 'repository') => ($this->Repository?->toArray($bytecode))
|
($bytecode ? Functions::cbc('repository') : 'repository') => ($this->repository?->toArray($bytecode))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,13 +67,16 @@
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): UpdateSource
|
public static function fromArray(array $data): UpdateSource
|
||||||
{
|
{
|
||||||
$obj = new UpdateSource();
|
$object = new self();
|
||||||
$obj->Source = Functions::array_bc($data, 'source');
|
|
||||||
$obj->Repository = Functions::array_bc($data, 'repository');
|
|
||||||
|
|
||||||
if($obj->Repository !== null)
|
$object->source = Functions::array_bc($data, 'source');
|
||||||
$obj->Repository = Repository::fromArray($obj->Repository);
|
$object->repository = Functions::array_bc($data, 'repository');
|
||||||
|
|
||||||
return $obj;
|
if($object->repository !== null)
|
||||||
|
{
|
||||||
|
$object->repository = Repository::fromArray($object->repository);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -136,19 +136,19 @@
|
||||||
// Import all dependencies first
|
// Import all dependencies first
|
||||||
/** @var Dependency $dependency */
|
/** @var Dependency $dependency */
|
||||||
foreach($version_entry->Dependencies as $dependency)
|
foreach($version_entry->Dependencies as $dependency)
|
||||||
self::import($dependency->PackageName, $dependency->Version, $options);
|
self::import($dependency->PackageName, $dependency->version, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch($version_entry->Compiler->Extension)
|
switch($version_entry->Compiler->extension)
|
||||||
{
|
{
|
||||||
case CompilerExtensions::PHP:
|
case CompilerExtensions::PHP:
|
||||||
PhpRuntime::import($version_entry, $options);
|
PhpRuntime::import($version_entry, $options);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ImportException(sprintf('Compiler extension %s is not supported in this runtime', $version_entry->Compiler->Extension));
|
throw new ImportException(sprintf('Compiler extension %s is not supported in this runtime', $version_entry->Compiler->extension));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
|
|
|
@ -301,7 +301,7 @@
|
||||||
*/
|
*/
|
||||||
public static function compileRunner(string $path, ExecutionPolicy $policy): ExecutionUnit
|
public static function compileRunner(string $path, ExecutionPolicy $policy): ExecutionUnit
|
||||||
{
|
{
|
||||||
return match (strtolower($policy->Runner))
|
return match (strtolower($policy->runner))
|
||||||
{
|
{
|
||||||
Runners::BASH => BashRunner::processUnit($path, $policy),
|
Runners::BASH => BashRunner::processUnit($path, $policy),
|
||||||
Runners::PHP => PhpRunner::processUnit($path, $policy),
|
Runners::PHP => PhpRunner::processUnit($path, $policy),
|
||||||
|
@ -310,7 +310,7 @@
|
||||||
Runners::PYTHON_2 => Python2Runner::processUnit($path, $policy),
|
Runners::PYTHON_2 => Python2Runner::processUnit($path, $policy),
|
||||||
Runners::PYTHON_3 => Python3Runner::processUnit($path, $policy),
|
Runners::PYTHON_3 => Python3Runner::processUnit($path, $policy),
|
||||||
Runners::LUA => LuaRunner::processUnit($path, $policy),
|
Runners::LUA => LuaRunner::processUnit($path, $policy),
|
||||||
default => throw new RunnerExecutionException('The runner \'' . $policy->Runner . '\' is not supported'),
|
default => throw new RunnerExecutionException('The runner \'' . $policy->runner . '\' is not supported'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue