diff --git a/src/ncc/CLI/Management/ProjectMenu.php b/src/ncc/CLI/Management/ProjectMenu.php index 1b7ab65..62eea2a 100644 --- a/src/ncc/CLI/Management/ProjectMenu.php +++ b/src/ncc/CLI/Management/ProjectMenu.php @@ -28,6 +28,7 @@ use ncc\Objects\CliHelpSection; use ncc\Utilities\Console; use ncc\Utilities\Functions; + use ncc\Utilities\Security; class ProjectMenu { @@ -60,16 +61,6 @@ */ private static function initializeProject(array $args): int { - if(isset($args['path']) || isset($args['p'])) - { - $project_path = $args['path'] ?? $args['p']; - } - else - { - Console::outError('Missing required option: --path|-p, please specify the path to the project', true, 1); - return 1; - } - if(isset($args['name']) || isset($args['n'])) { $project_name = $args['name'] ?? $args['n']; @@ -80,6 +71,16 @@ return 1; } + if(isset($args['path']) || isset($args['p'])) + { + $project_path = $args['path'] ?? $args['p']; + } + else + { + $project_path = Security::sanitizeFilename($project_name, false); + Console::out(sprintf('No path specified, using \'%s\'', $project_path)); + } + if(isset($args['package']) || isset($args['pkg'])) { $package_name = $args['package'] ?? $args['pkg']; diff --git a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php index 49e8244..cb54297 100644 --- a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php +++ b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php @@ -23,13 +23,17 @@ namespace ncc\Classes\PhpExtension\Templates; use ncc\Classes\NccExtension\ConstantCompiler; + use ncc\Enums\Options\BuildConfigurationOptions; use ncc\Enums\Options\ProjectOptions; use ncc\Enums\Runners; + use ncc\Enums\SpecialConstants\AssemblyConstants; + use ncc\Enums\Types\BuildOutputType; use ncc\Exceptions\ConfigurationException; use ncc\Exceptions\IOException; use ncc\Exceptions\PathNotFoundException; use ncc\Interfaces\TemplateInterface; use ncc\Managers\ProjectManager; + use ncc\Objects\ProjectConfiguration\Build\BuildConfiguration; use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Utilities\IO; @@ -51,6 +55,23 @@ $project_manager->getProjectConfiguration()->getBuild()->setMain('main_policy'); $project_manager->getProjectConfiguration()->getProject()->addOption(ProjectOptions::CREATE_SYMLINK, true); + // Create the release build configuration + $release_executable = new BuildConfiguration('release_executable', + 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME + ); + $release_executable->setBuildType(BuildOutputType::EXECUTABLE); + $release_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'release'); + $project_manager->getProjectConfiguration()->getBuild()->addBuildConfiguration($release_executable); + + // Create the debug build configuration + $debug_executable = new BuildConfiguration('debug_executable', + 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME + ); + $debug_executable->setDefinedConstant('DEBUG', '1'); + $debug_executable->setBuildType(BuildOutputType::EXECUTABLE); + $debug_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'debug'); + $project_manager->getProjectConfiguration()->getBuild()->addBuildConfiguration($debug_executable); + self::writeProgramTemplate($project_manager); self::writeMainEntryTemplate($project_manager); self::writeMakefileTemplate($project_manager); diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index e3b8d7b..390cb11 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -353,11 +353,11 @@ // Generate the Debug & Release build configurations $debug_configuration = new ProjectConfiguration\Build\BuildConfiguration('debug', - 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE + 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE . '.ncc' ); $debug_configuration->setDefinedConstant('DEBUG', '1'); $build->addBuildConfiguration(new ProjectConfiguration\Build\BuildConfiguration('release', - 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE + 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE . '.ncc' )); $build->addBuildConfiguration($debug_configuration); $build->setDefaultConfiguration('release');