aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2016-04-14 20:30:31 +0200
committerNaios <naios-dev@live.de>2016-04-14 21:30:43 +0200
commit2038c311001982dba100d33a6fbb8797f9de1c87 (patch)
tree82e0f3a1901197138aeab63621c0c4c1abf0cb22
parent48776d9ce9ecb846cc049f70ceb18176226af1bf (diff)
Core/Scripting: Disallow the build directory to contain spaces
* I wasn't able to work arround a path which contains spaces, since it seems like a CMake specific issue. * Closes #16947 (cherry picked from commit 42eeb28a8b9c1f3ae2d667e4238e956a4a95bd6c)
-rw-r--r--cmake/macros/ConfigureScripts.cmake15
-rw-r--r--cmake/showoptions.cmake2
-rw-r--r--src/server/game/Scripting/ScriptReloadMgr.cpp40
3 files changed, 38 insertions, 19 deletions
diff --git a/cmake/macros/ConfigureScripts.cmake b/cmake/macros/ConfigureScripts.cmake
index a6a39bd9306..5260d3a1afe 100644
--- a/cmake/macros/ConfigureScripts.cmake
+++ b/cmake/macros/ConfigureScripts.cmake
@@ -9,6 +9,21 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Returns the base path to the script directory in the source directory
+function(WarnAboutSpacesInBuildPath)
+ # Only check win32 since unix doesn't allow spaces in paths
+ if (WIN32)
+ string(FIND "${CMAKE_BINARY_DIR}" " " SPACE_INDEX_POS)
+
+ if (SPACE_INDEX_POS GREATER -1)
+ message("")
+ message(WARNING " *** WARNING!\n"
+ " *** Your selected build directory contains spaces!\n"
+ " *** Please note that this will cause issues!")
+ endif()
+ endif()
+endfunction()
+
+# Returns the base path to the script directory in the source directory
function(GetScriptsBasePath variable)
set(${variable} "${CMAKE_SOURCE_DIR}/src/server/scripts" PARENT_SCOPE)
endfunction()
diff --git a/cmake/showoptions.cmake b/cmake/showoptions.cmake
index 27ffe0578ef..e7f7b7ac647 100644
--- a/cmake/showoptions.cmake
+++ b/cmake/showoptions.cmake
@@ -122,6 +122,8 @@ if (BUILD_SHARED_LIBS)
message(" *** Dynamic linking was enforced through a dynamic script module!")
endif()
add_definitions(-DTRINITY_API_USE_DYNAMIC_LINKING)
+
+ WarnAboutSpacesInBuildPath()
endif()
message("")
diff --git a/src/server/game/Scripting/ScriptReloadMgr.cpp b/src/server/game/Scripting/ScriptReloadMgr.cpp
index a6a13d00aeb..f13bd16d6c6 100644
--- a/src/server/game/Scripting/ScriptReloadMgr.cpp
+++ b/src/server/game/Scripting/ScriptReloadMgr.cpp
@@ -309,15 +309,6 @@ namespace std
};
}
-/// Escapes spaces in the given path
-static std::string EscapeWindowsPath(std::string str)
-{
-#ifdef _WIN32
- boost::algorithm::replace_all(str, " ", "\\ ");
-#endif
- return str;
-}
-
/// Invokes a synchronous CMake process with the given arguments
template<typename... T>
static int InvokeCMakeCommand(T&&... args)
@@ -518,6 +509,17 @@ public:
if (!sWorld->getBoolConfig(CONFIG_HOTSWAP_ENABLED))
return;
+ if (BuiltInConfig::GetBuildDirectory().find(" ") != std::string::npos)
+ {
+ TC_LOG_ERROR("scripts.hotswap", "Your build directory path \"%s\" "
+ "contains spaces, which isn't allowed for compatibility reasons! "
+ "You need to create a build directory which doesn't contain any space character "
+ "in it's path!",
+ BuiltInConfig::GetBuildDirectory().c_str());
+
+ return;
+ }
+
{
auto const library_directory = GetLibraryDirectory();
if (!fs::exists(library_directory) || !fs::is_directory(library_directory))
@@ -1116,7 +1118,7 @@ private:
TC_LOG_INFO("scripts.hotswap", "Rerunning CMake because there were sources added or removed...");
_build_job->UpdateCurrentJob(BuildJobType::BUILD_JOB_RERUN_CMAKE,
- InvokeAsyncCMakeCommand(EscapeWindowsPath(BuiltInConfig::GetBuildDirectory())));
+ InvokeAsyncCMakeCommand(BuiltInConfig::GetBuildDirectory()));
}
/// Invokes a new build of the current active module job
@@ -1129,9 +1131,9 @@ private:
_build_job->UpdateCurrentJob(BuildJobType::BUILD_JOB_COMPILE,
InvokeAsyncCMakeCommand(
- "--build", EscapeWindowsPath(BuiltInConfig::GetBuildDirectory()),
- "--target", EscapeWindowsPath(_build_job->GetProjectName()),
- "--config", EscapeWindowsPath(_build_job->GetBuildDirective())));
+ "--build", BuiltInConfig::GetBuildDirectory(),
+ "--target", _build_job->GetProjectName(),
+ "--config", _build_job->GetBuildDirective()));
}
/// Invokes a new asynchronous install of the current active module job
@@ -1144,10 +1146,10 @@ private:
_build_job->UpdateCurrentJob(BuildJobType::BUILD_JOB_INSTALL,
InvokeAsyncCMakeCommand(
- "-DCOMPONENT=" + EscapeWindowsPath(_build_job->GetProjectName()),
- "-DBUILD_TYPE=" + EscapeWindowsPath(_build_job->GetBuildDirective()),
- "-P", EscapeWindowsPath(fs::absolute("cmake_install.cmake",
- BuiltInConfig::GetBuildDirectory()).generic_string())));
+ "-DCOMPONENT=" + _build_job->GetProjectName(),
+ "-DBUILD_TYPE=" + _build_job->GetBuildDirective(),
+ "-P", fs::absolute("cmake_install.cmake",
+ BuiltInConfig::GetBuildDirectory()).generic_string()));
}
/// Sets the CMAKE_INSTALL_PREFIX variable in the CMake cache
@@ -1258,8 +1260,8 @@ private:
TC_LOG_INFO("scripts.hotswap", "Invoking CMake cache correction...");
auto const error = InvokeCMakeCommand(
- "-DCMAKE_INSTALL_PREFIX:PATH=" + EscapeWindowsPath(fs::current_path().generic_string()),
- EscapeWindowsPath(BuiltInConfig::GetBuildDirectory()));
+ "-DCMAKE_INSTALL_PREFIX:PATH=" + fs::current_path().generic_string(),
+ BuiltInConfig::GetBuildDirectory());
if (error)
{