Convert BuildOutputType constants to enum cases

This commit is contained in:
netkas 2024-09-14 08:28:04 -04:00
parent e11f95a22a
commit 12f0ff2ffa
4 changed files with 13 additions and 13 deletions

View file

@ -59,7 +59,7 @@
$release_executable = new BuildConfiguration('release_executable',
'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME
);
$release_executable->setBuildType(BuildOutputType::EXECUTABLE);
$release_executable->setBuildType(BuildOutputType::EXECUTABLE->value);
$release_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'release');
$project_manager->getProjectConfiguration()->getBuild()->addBuildConfiguration($release_executable);
@ -68,7 +68,7 @@
'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME
);
$debug_executable->setDefinedConstant('DEBUG', '1');
$debug_executable->setBuildType(BuildOutputType::EXECUTABLE);
$debug_executable->setBuildType(BuildOutputType::EXECUTABLE->value);
$debug_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'debug');
$project_manager->getProjectConfiguration()->getBuild()->addBuildConfiguration($debug_executable);

View file

@ -22,8 +22,8 @@
namespace ncc\Enums\Types;
final class BuildOutputType
enum BuildOutputType : string
{
public const NCC_PACKAGE = 'ncc';
public const EXECUTABLE = 'executable';
case NCC_PACKAGE = 'ncc';
case EXECUTABLE = 'executable';
}

View file

@ -162,8 +162,8 @@
{
CompilerExtensions::PHP->value => match (strtolower($configuration->getBuildType()))
{
BuildOutputType::NCC_PACKAGE => (new NccCompiler($this))->build($build_configuration, $options),
BuildOutputType::EXECUTABLE => (new ExecutableCompiler($this))->build($build_configuration, $options),
BuildOutputType::NCC_PACKAGE->value => (new NccCompiler($this))->build($build_configuration, $options),
BuildOutputType::EXECUTABLE->value => (new ExecutableCompiler($this))->build($build_configuration, $options),
default => throw new BuildException(sprintf('php cannot produce the build type \'%s\'', $configuration->getBuildType())),
},
@ -618,14 +618,14 @@
$ncc_debug_configuration = new ProjectConfiguration\Build\BuildConfiguration('debug_ncc',
'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE
);
$ncc_debug_configuration->setBuildType(BuildOutputType::NCC_PACKAGE);
$ncc_debug_configuration->setBuildType(BuildOutputType::NCC_PACKAGE->value);
$ncc_debug_configuration->setDependencies($require_dev);
$build->addBuildConfiguration($ncc_debug_configuration);
$executable_debug_configuration = new ProjectConfiguration\Build\BuildConfiguration('debug_executable',
'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME
);
$executable_debug_configuration->setBuildType(BuildOutputType::EXECUTABLE);
$executable_debug_configuration->setBuildType(BuildOutputType::EXECUTABLE->value);
$executable_debug_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'debug_ncc');
$executable_debug_configuration->setDependencies($require_dev);
$build->addBuildConfiguration($executable_debug_configuration);
@ -634,14 +634,14 @@
$ncc_release_configuration = new ProjectConfiguration\Build\BuildConfiguration('release_ncc',
'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE . 'ncc'
);
$ncc_release_configuration->setBuildType(BuildOutputType::NCC_PACKAGE);
$ncc_release_configuration->setBuildType(BuildOutputType::NCC_PACKAGE->value);
$build->addBuildConfiguration($ncc_release_configuration);
$executable_release_configuration = new ProjectConfiguration\Build\BuildConfiguration('release_executable',
'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME
);
$executable_release_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'release_ncc');
$executable_release_configuration->setBuildType(BuildOutputType::EXECUTABLE);
$executable_release_configuration->setBuildType(BuildOutputType::EXECUTABLE->value);
$build->addBuildConfiguration($executable_release_configuration);
// Create an update source for the project

View file

@ -107,7 +107,7 @@
public function __construct(string $name, string $output)
{
$this->name = $name;
$this->build_type = BuildOutputType::NCC_PACKAGE;
$this->build_type = BuildOutputType::NCC_PACKAGE->value;
$this->output = $output;
$this->options = [];
$this->define_constants = [];
@ -462,7 +462,7 @@
$object = new BuildConfiguration($name, $output);
$object->build_type = Functions::array_bc($data, 'build_type') ?? BuildOutputType::NCC_PACKAGE;
$object->build_type = Functions::array_bc($data, 'build_type') ?? BuildOutputType::NCC_PACKAGE->value;
$object->options = Functions::array_bc($data, 'options') ?? [];
$object->define_constants = Functions::array_bc($data, 'define_constants') ?? [];
$object->exclude_files = Functions::array_bc($data, 'exclude_files') ?? [];