Added scripting quality of life features #299
|
@ -20,10 +20,11 @@ echo "M - SDL"
|
|||
echo "N - dotnet"
|
||||
echo "O - tinyddsloader"
|
||||
echo "P - fmod"
|
||||
echo "Q - vswhere"
|
||||
echo ---------------------------------------------------
|
||||
echo.
|
||||
|
||||
choice /C ABCDEFGHIJKLMNOP /T 10 /D A
|
||||
choice /C ABCDEFGHIJKLMNOPQ /T 10 /D A
|
||||
set _e=%ERRORLEVEL%
|
||||
|
||||
if %_e%==1 goto VMA
|
||||
|
@ -42,6 +43,7 @@ if %_e%==13 goto SDL
|
|||
if %_e%==14 goto dotnet
|
||||
if %_e%==15 goto tinyddsloader
|
||||
if %_e%==16 goto fmod
|
||||
if %_e%==17 goto vswhere
|
||||
|
||||
:VMA
|
||||
echo -----------------------VMA----------------------------
|
||||
|
@ -155,6 +157,13 @@ if %_e%==15 (goto :done) else (goto :fmod)
|
|||
echo --------------------fmod-------------------------
|
||||
rmdir "Dependencies/fmod" /S /Q
|
||||
git clone https://github.com/SHADE-DP/FMOD.git "Dependencies/fmod"
|
||||
if %_e%==16 (goto :done) else (goto :vswhere)
|
||||
|
||||
:vswhere
|
||||
echo -----------------------vswhere----------------------------
|
||||
rmdir "Dependencies/vswhere" /S /Q
|
||||
mkdir "Dependencies/vswhere"
|
||||
powershell -Command "& {wget https://github.com/microsoft/vswhere/releases/download/3.1.1/vswhere.exe -OutFile "Dependencies/vswhere/vswhere.exe"}"
|
||||
|
||||
:done
|
||||
echo DONE!
|
||||
|
|
|
@ -16,4 +16,5 @@ IncludeDir["SDL"] = "%{wks.location}\\Dependencies\\SDL"
|
|||
IncludeDir["VULKAN"] = "$(VULKAN_SDK)"
|
||||
IncludeDir["dotnet"] = "%{wks.location}\\Dependencies\\dotnet"
|
||||
IncludeDir["tinyddsloader"] = "%{wks.location}\\Dependencies\\tinyddsloader"
|
||||
IncludeDir["fmod"] = "%{wks.location}\\Dependencies\\fmod"
|
||||
IncludeDir["fmod"] = "%{wks.location}\\Dependencies\\fmod"
|
||||
IncludeDir["vswhere"] = "%{wks.location}\\Dependencies\\vswhere"
|
|
@ -124,7 +124,8 @@ project "SHADE_Engine"
|
|||
"xcopy /r /y /q \"%{IncludeDir.ModelCompiler}\\bin\\Debug\\ModelCompiler.exe\" \"$(OutDir)\"",
|
||||
"xcopy /r /y /q \"%{IncludeDir.FontCompiler}\\bin\\Debug\\FontCompiler.exe\" \"$(OutDir)\"",
|
||||
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodL.dll\" \"$(OutDir)\"",
|
||||
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudioL.dll\" \"$(OutDir)\""
|
||||
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudioL.dll\" \"$(OutDir)\"",
|
||||
"xcopy /r /y /q \"%{IncludeDir.vswhere}\\vswhere.exe\" \"$(OutDir)\""
|
||||
}
|
||||
|
||||
filter "configurations:Release"
|
||||
|
@ -134,7 +135,8 @@ project "SHADE_Engine"
|
|||
"xcopy /r /y /q \"%{IncludeDir.ModelCompiler}\\bin\\Release\\ModelCompiler.exe\" \"$(OutDir)\"",
|
||||
"xcopy /r /y /q \"%{IncludeDir.FontCompiler}\\bin\\Release\\FontCompiler.exe\" \"$(OutDir)\"",
|
||||
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmod.dll\" \"$(OutDir)\"",
|
||||
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudio.dll\" \"$(OutDir)\""
|
||||
"xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudio.dll\" \"$(OutDir)\"",
|
||||
"xcopy /r /y /q \"%{IncludeDir.vswhere}\\vswhere.exe\" \"$(OutDir)\""
|
||||
}
|
||||
|
||||
filter "configurations:Publish"
|
||||
|
|
|
@ -28,9 +28,9 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "Physics/System/SHPhysicsSystem.h"
|
||||
#include "Physics/SHPhysicsEvents.h"
|
||||
#include "Scene/SHSceneEvents.h"
|
||||
|
||||
#include "Assets/SHAssetMacros.h"
|
||||
#include "Tools/Utilities/SHExecUtilities.h"
|
||||
#include "SHVSUtilities.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -313,11 +313,15 @@ namespace SHADE
|
|||
}
|
||||
|
||||
// Open it
|
||||
SHExecUtilties::ExecProcess
|
||||
(
|
||||
L"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\devenv.exe",
|
||||
L"/Edit " + SHStringUtilities::StrToWstr(CSPROJ_PATH)
|
||||
);
|
||||
try
|
||||
{
|
||||
SHVSUtilties::OpenFile(CSPROJ_PATH);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
SHLOG_ERROR("{}", e.what());
|
||||
SHLOG_ERROR("[SHScriptEngine] Failed to open project csproj file.");
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -13,14 +13,51 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include <SHpch.h>
|
||||
// Primary Header
|
||||
#include "SHVSUtilities.h"
|
||||
// Project Headers
|
||||
#include "Tools/Utilities/SHExecUtilities.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Static Data Members */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
std::filesystem::path SHVSUtilties::devEnvPath;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Usage Functions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void SHVSUtilties::OpenFile(const std::filesystem::path& path)
|
||||
try
|
||||
{
|
||||
if (devEnvPath.empty())
|
||||
{
|
||||
devEnvPath = SHVSUtilties::getDevEnvPath();
|
||||
}
|
||||
SHExecUtilties::ExecProcess(devEnvPath.generic_wstring(), L"/Edit " + path.generic_wstring());
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
SHLOG_ERROR("{}", e.what());
|
||||
SHLOG_ERROR("[SHVSUtilities] Failed to launch Visual Studio.");
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Helper Functions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
std::filesystem::path SHVSUtilties::getDevEnvPath()
|
||||
{
|
||||
return {};
|
||||
#ifdef _PUBLISH
|
||||
return {}; // Don't do anything if it's a published build
|
||||
#else
|
||||
static constexpr int EXCESS_CHARS_COUNT = 2;
|
||||
|
||||
const auto RESULT = SHExecUtilties::ExecBlockingPowerShellCommand(L"./vswhere -version \"[15.0,19.0]\" -requires Microsoft.NetCore.Component.DevelopmentTools -find Common7\\\\IDE\\\\devenv.exe | Select-Object -last 1", true, true);
|
||||
if (RESULT.StdOutput.size() < EXCESS_CHARS_COUNT)
|
||||
{
|
||||
SHLOG_ERROR("[SHVSUtilities] Unable to get path to Visual Studio installation. SHVSUtilities will not work.");
|
||||
return {};
|
||||
}
|
||||
return RESULT.StdOutput.substr(0, RESULT.StdOutput.size() - EXCESS_CHARS_COUNT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,14 @@ namespace SHADE
|
|||
class SH_API SHVSUtilties final
|
||||
{
|
||||
public:
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Usage Functions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Opens the file at the specified path with a new instance of Visual Studio.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to the file to open.</param>
|
||||
static void OpenFile(const std::filesystem::path& path);
|
||||
|
||||
private:
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -15,6 +15,7 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "SHExecUtilities.h"
|
||||
// Project Includes
|
||||
#include "SHStringUtilities.h"
|
||||
#include "SHFileUtilties.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -104,6 +105,26 @@ namespace SHADE
|
|||
);
|
||||
}
|
||||
|
||||
PROCESS_INFORMATION SHExecUtilties::ExecPowerShellCommand(const std::wstring& command)
|
||||
{
|
||||
return ExecProcess
|
||||
(
|
||||
L"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
|
||||
L"-Command \"& {" + command + L"} \""
|
||||
);
|
||||
}
|
||||
|
||||
ExecResult SHExecUtilties::ExecBlockingPowerShellCommand(const std::wstring& command, bool output, bool errorOutput)
|
||||
{
|
||||
return ExecBlockingProcess
|
||||
(
|
||||
L"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
|
||||
L"-Command \"& { cd \"" + SHFileUtilities::GetExecDir().generic_wstring() + L"\";" + command + L"} \"",
|
||||
output,
|
||||
errorOutput
|
||||
);
|
||||
}
|
||||
|
||||
PROCESS_INFORMATION SHExecUtilties::execProcess(const std::wstring& path, const std::wstring& args, HANDLE outputWritePipe, HANDLE errorOutputWritePipe)
|
||||
{
|
||||
STARTUPINFOW startInfo;
|
||||
|
@ -183,7 +204,7 @@ namespace SHADE
|
|||
{
|
||||
std::array<char, 256> buffer{};
|
||||
DWORD bytesRead = 0;
|
||||
const auto RESULT = ReadFile(readPipe, buffer.data(), buffer.size(), &bytesRead, nullptr); // Blocking call here?
|
||||
const auto RESULT = ReadFile(readPipe, buffer.data(), buffer.size(), &bytesRead, nullptr);
|
||||
if (!RESULT || bytesRead <= 0)
|
||||
break;
|
||||
output.insert(output.end(), buffer.data(), buffer.data() + bytesRead);
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace SHADE
|
|||
/// <param name="args">Arguments to pass to the process.</param>
|
||||
/// <param name="output">If true, stdout will be routed to return.</param>
|
||||
/// <param name="errorOutput">If true, outstderr will be routed to return.</param>
|
||||
/// <returns>Return value of the process.</returns>
|
||||
/// <returns>Information about the process's execution.</returns>
|
||||
/// <exception cref="std::runtime_error">
|
||||
/// Thrown if failed to start the process.
|
||||
/// </exception>
|
||||
|
@ -83,7 +83,7 @@ namespace SHADE
|
|||
/// <param name="command">Command to execute.</param>
|
||||
/// <param name="output">If true, stdout will be routed to return.</param>
|
||||
/// <param name="errorOutput">If true, outstderr will be routed to return.</param>
|
||||
/// <returns>Return value of the process.</returns>
|
||||
/// <returns>Information about the process's execution.</returns>
|
||||
/// <exception cref="std::runtime_error">
|
||||
/// Thrown if failed to start the process.
|
||||
/// </exception>
|
||||
|
@ -109,11 +109,13 @@ namespace SHADE
|
|||
/// executing.
|
||||
/// </summary>
|
||||
/// <param name="command">Command to execute.</param>
|
||||
/// <returns>Return value of the process.</returns>
|
||||
/// <param name="output">If true, stdout will be routed to return.</param>
|
||||
/// <param name="errorOutput">If true, outstderr will be routed to return.</param>
|
||||
/// <returns>Information about the process's execution.</returns>
|
||||
/// <exception cref="std::runtime_error">
|
||||
/// Thrown if failed to start the process.
|
||||
/// </exception>
|
||||
static DWORD ExecBlockingPowerShellCommand(const std::wstring& command);
|
||||
static ExecResult ExecBlockingPowerShellCommand(const std::wstring& command, bool output, bool errorOutput);
|
||||
|
||||
private:
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -22,9 +22,21 @@ namespace SHADE
|
|||
{
|
||||
void SHFileUtilities::SetWorkDirToExecDir()
|
||||
{
|
||||
TCHAR currentExecFilePath[MAX_PATH] = { '\0' };
|
||||
GetModuleFileName(nullptr, currentExecFilePath, MAX_PATH);
|
||||
PathRemoveFileSpec(currentExecFilePath);
|
||||
std::filesystem::current_path(currentExecFilePath);
|
||||
std::filesystem::current_path(GetExecDir());
|
||||
}
|
||||
|
||||
std::filesystem::path SHFileUtilities::GetExecDir()
|
||||
{
|
||||
TCHAR currentExecFilePath[MAX_PATH] = { '\0' };
|
||||
GetModuleFileName(nullptr, currentExecFilePath, MAX_PATH);
|
||||
PathRemoveFileSpec(currentExecFilePath);
|
||||
return std::filesystem::path(currentExecFilePath);
|
||||
}
|
||||
|
||||
std::filesystem::path SHFileUtilities::GetExecPath()
|
||||
{
|
||||
TCHAR currentExecFilePath[MAX_PATH] = { '\0' };
|
||||
GetModuleFileName(nullptr, currentExecFilePath, MAX_PATH);
|
||||
return std::filesystem::path(currentExecFilePath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,24 +15,29 @@ of DigiPen Institute of Technology is prohibited.
|
|||
|
||||
namespace SHADE
|
||||
{
|
||||
/*!************************************************************************************
|
||||
|
||||
\class SHFileUtilities
|
||||
|
||||
\brief
|
||||
Static class that contains functions for working with files and directories.
|
||||
|
||||
**************************************************************************************/
|
||||
/// <summary>
|
||||
/// Static class that contains functions for working with files and directories.
|
||||
/// </summary>
|
||||
class SH_API SHFileUtilities
|
||||
{
|
||||
public:
|
||||
/*!**********************************************************************************
|
||||
|
||||
\brief
|
||||
Sets the application's current working directory to the application executable's
|
||||
directory.
|
||||
|
||||
************************************************************************************/
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Executable Directory Functions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Sets the application's current working directory to the application executable's
|
||||
/// directory.
|
||||
/// </summary>
|
||||
static void SetWorkDirToExecDir();
|
||||
/// <summary>
|
||||
/// Retrieves the file path to the executable's directory.
|
||||
/// </summary>
|
||||
/// <returns>File path to the executable's directory.</returns>
|
||||
static std::filesystem::path GetExecDir();
|
||||
/// <summary>
|
||||
/// Retrieves the file path to the executable.
|
||||
/// </summary>
|
||||
/// <returns>File path to the executable.</returns>
|
||||
static std::filesystem::path GetExecPath();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue