diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a59b5c..9101958 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 This update introduces minor bug fixes & improvements +### Added + - Added new constant '%DEFAULT_BUILD_CONFIGURATION%' which points to the project's default build configuration + ### Fixed - ncc will now correctly handle package execution where the main unit is not defined in the package instead of throwing an exception. diff --git a/src/ncc/Classes/NccExtension/ConstantCompiler.php b/src/ncc/Classes/NccExtension/ConstantCompiler.php index 27829ac..3e766c3 100644 --- a/src/ncc/Classes/NccExtension/ConstantCompiler.php +++ b/src/ncc/Classes/NccExtension/ConstantCompiler.php @@ -24,6 +24,7 @@ use ncc\Enums\SpecialConstants\BuildConstants; use ncc\Enums\SpecialConstants\DateTimeConstants; + use ncc\Enums\SpecialConstants\GeneralConstants; use ncc\Enums\SpecialConstants\InstallConstants; use ncc\Enums\SpecialConstants\AssemblyConstants; use ncc\Enums\SpecialConstants\RuntimeConstants; @@ -47,10 +48,30 @@ $input = self::compileBuildConstants($input); $input = self::compileDateTimeConstants($input, time()); $input = self::compileRuntimeConstants($input); + $input = self::compileGeneralConstants($input, $project_configuration); return $input; } + public static function compileGeneralConstants(?string $input, ProjectConfiguration $project_configuration): ?string + { + if($input === null) + { + return null; + } + + return str_replace( + [ + GeneralConstants::DEFAULT_BUILD_CONFIGURATION->value + ], + [ + $project_configuration->getBuild()->getDefaultConfiguration() + ], + + $input + ); + } + /** * Compiles assembly constants about the project (Usually used during compiling time) * @@ -70,7 +91,7 @@ AssemblyConstants::ASSEMBLY_NAME->value, AssemblyConstants::ASSEMBLY_PACKAGE->value, AssemblyConstants::ASSEMBLY_VERSION->value, - AssemblyConstants::ASSEMBLY_UID->value + AssemblyConstants::ASSEMBLY_UID->value, ], [ $assembly->getName(), diff --git a/src/ncc/Enums/SpecialConstants/GeneralConstants.php b/src/ncc/Enums/SpecialConstants/GeneralConstants.php new file mode 100644 index 0000000..5a9d1b1 --- /dev/null +++ b/src/ncc/Enums/SpecialConstants/GeneralConstants.php @@ -0,0 +1,32 @@ +