From ef7908fdb690cec5fc4d515c564d512f74b38e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 12 Jan 2025 11:44:48 -0300 Subject: [PATCH] Added ${current_doc_dir} build variable (issue SpartanJ/ecode#383). --- bin/assets/i18n/en.xml | 2 +- src/tools/ecode/projectbuild.cpp | 3 +++ src/tools/ecode/uibuildsettings.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/assets/i18n/en.xml b/bin/assets/i18n/en.xml index f409ec037..89a79acba 100644 --- a/bin/assets/i18n/en.xml +++ b/bin/assets/i18n/en.xml @@ -156,7 +156,7 @@ File path is: Custom Variables Custom Variables allow to simplify the build commands steps adding custom variables that can be used over the build settings in commands, arguments, and working directories. Custom Variables can be invoked using ${variable_name} in any of the commands. - There are predefined custom variables available to use:
${project_root}: The folder / project root directory.
${build_type}: The build type selected to build the project.
${os}: The current operating system name.
${nproc}: The number of logical processing units.
${current_doc}: The last or current focused document path.
${current_doc_name}: The last or current focused document name (without extension + There are predefined custom variables available to use: ${project_root}: The folder / project root directory. ${build_type}: The build type selected to build the project. ${os}: The current operating system name. ${arch}: The current operating architecture. ${nproc}: The number of logical processing units. ${current_doc}: The last or current focused document path. ${current_doc_name}: The last or current focused document name (without extension). ${current_doc_dir}: The last or current focused document directory. Cut Dark Date diff --git a/src/tools/ecode/projectbuild.cpp b/src/tools/ecode/projectbuild.cpp index 7e828402e..e44222d2f 100644 --- a/src/tools/ecode/projectbuild.cpp +++ b/src/tools/ecode/projectbuild.cpp @@ -28,6 +28,7 @@ static const char* VAR_ARCH = "${arch}"; static const char* VAR_NPROC = "${nproc}"; static const char* VAR_CURRENT_DOC = "${current_doc}"; static const char* VAR_CURRENT_DOC_NAME = "${current_doc_name}"; +static const char* VAR_CURRENT_DOC_DIR = "${current_doc_dir}"; static void replaceVar( ProjectBuildStep& s, const std::string& var, const std::string& val ) { static std::string slashDup = FileSystem::getOSSlash() + FileSystem::getOSSlash(); @@ -382,11 +383,13 @@ void ProjectBuildManager::replaceDynamicVars( ProjectBuildCommand& cmd ) { std::string curDoc = getCurrentDocument(); std::string curDocName = FileSystem::fileRemoveExtension( FileSystem::fileNameFromPath( curDoc ) ); + std::string curDocDir = FileSystem::fileRemoveFileName( curDoc ); replaceVar( cmd, VAR_OS, currentOS ); replaceVar( cmd, VAR_ARCH, Sys::getOSArchitecture() ); replaceVar( cmd, VAR_NPROC, nproc ); replaceVar( cmd, VAR_CURRENT_DOC, curDoc ); replaceVar( cmd, VAR_CURRENT_DOC_NAME, curDocName ); + replaceVar( cmd, VAR_CURRENT_DOC_DIR, curDocDir ); if ( cmd.workingDir.empty() ) cmd.workingDir = mProjectRoot; } diff --git a/src/tools/ecode/uibuildsettings.cpp b/src/tools/ecode/uibuildsettings.cpp index c671c8148..8fe6fcecf 100644 --- a/src/tools/ecode/uibuildsettings.cpp +++ b/src/tools/ecode/uibuildsettings.cpp @@ -409,7 +409,7 @@ static const auto SETTINGS_PANEL_XML = R"xml( - +