From b20fa2287264ab02463ba0fa65b9c7101cdfb084 Mon Sep 17 00:00:00 2001 From: Ryo Suzuki Date: Tue, 4 Jun 2024 23:37:33 +0900 Subject: [PATCH] =?UTF-8?q?[Windows,=20macOS,=20Linux]=20=E3=83=97?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=83=A9=E3=83=A0=E3=81=8C=20IDE=20=E3=81=A7?= =?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E3=81=8B=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E9=96=A2?= =?UTF-8?q?=E6=95=B0=20#1230?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Siv3D/include/Siv3D/System.hpp | 10 ++++++ .../Linux/Siv3D/System/SivSystem_Linux.cpp | 10 ++++++ .../Web/Siv3D/System/SivSystem_Web.cpp | 10 ++++++ .../Siv3D/System/SivSystem_Windows.cpp | 32 +++++++++++++++++++ .../macOS/Siv3D/System/SivSystem_macOS.mm | 18 +++++++++++ 5 files changed, 80 insertions(+) diff --git a/Siv3D/include/Siv3D/System.hpp b/Siv3D/include/Siv3D/System.hpp index ccc7659c2..6da9e082d 100644 --- a/Siv3D/include/Siv3D/System.hpp +++ b/Siv3D/include/Siv3D/System.hpp @@ -104,6 +104,16 @@ namespace s3d /// @param fileName ファイル名 | File name /// @return テキストエディタの起動に成功した場合 true, それ以外の場合は false | Returns true if the text editor was launched successfully, otherwise false. bool LaunchFileWithTextEditor(FilePathView fileName); + + /// @brief プログラムが Visual Studio で実行されているかを返します。 | Returns whether the program is running in Visual Studio. + /// @return プログラムが Visual Studio で実行されている場合 true, それ以外の場合は false | Returns true if the program is running in Visual Studio, false otherwise + [[nodiscard]] + bool IsRunningInVisualStudio(); + + /// @brief プログラムが Xcode で実行されているかを返します。 | Returns whether the program is running in Xcode. + /// @return プログラムが Xcode で実行されている場合 true, それ以外の場合は false | Returns true if the program is running in Xcode, false otherwise + [[nodiscard]] + bool IsRunningInXcode(); } # if SIV3D_PLATFORM(WEB) diff --git a/Siv3D/src/Siv3D-Platform/Linux/Siv3D/System/SivSystem_Linux.cpp b/Siv3D/src/Siv3D-Platform/Linux/Siv3D/System/SivSystem_Linux.cpp index c57d77de9..1cc2b9f11 100644 --- a/Siv3D/src/Siv3D-Platform/Linux/Siv3D/System/SivSystem_Linux.cpp +++ b/Siv3D/src/Siv3D-Platform/Linux/Siv3D/System/SivSystem_Linux.cpp @@ -231,5 +231,15 @@ namespace s3d return (std::system(command.c_str()) == 0); } + + bool IsRunningInVisualStudio() + { + return false; + } + + bool IsRunningInXcode() + { + return false; + } } } diff --git a/Siv3D/src/Siv3D-Platform/Web/Siv3D/System/SivSystem_Web.cpp b/Siv3D/src/Siv3D-Platform/Web/Siv3D/System/SivSystem_Web.cpp index 0af909d7f..5c68d5741 100644 --- a/Siv3D/src/Siv3D-Platform/Web/Siv3D/System/SivSystem_Web.cpp +++ b/Siv3D/src/Siv3D-Platform/Web/Siv3D/System/SivSystem_Web.cpp @@ -52,6 +52,16 @@ namespace s3d { return false; } + + bool IsRunningInVisualStudio() + { + return false; + } + + bool IsRunningInXcode() + { + return false; + } } namespace Platform::Web::System diff --git a/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/System/SivSystem_Windows.cpp b/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/System/SivSystem_Windows.cpp index eb3cb5668..009e1f5c6 100644 --- a/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/System/SivSystem_Windows.cpp +++ b/Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/System/SivSystem_Windows.cpp @@ -19,6 +19,26 @@ namespace s3d { + namespace + { + [[nodiscard]] + static bool IsRunningInVisualStudio_impl() + { + wchar_t* pValue; + size_t len; + errno_t err = ::_wdupenv_s(&pValue, &len, L"VisualStudioVersion"); + + if (err || (not pValue)) + { + return false; + } + + std::free(pValue); + + return true; + } + } + namespace System { void Sleep(const int32 milliseconds) @@ -177,5 +197,17 @@ namespace s3d return (::ShellExecuteExW(&sei) != 0); } + + bool IsRunningInVisualStudio() + { + static const bool result = IsRunningInVisualStudio_impl(); + + return result; + } + + bool IsRunningInXcode() + { + return false; + } } } diff --git a/Siv3D/src/Siv3D-Platform/macOS/Siv3D/System/SivSystem_macOS.mm b/Siv3D/src/Siv3D-Platform/macOS/Siv3D/System/SivSystem_macOS.mm index f053eee05..6a37d8f58 100644 --- a/Siv3D/src/Siv3D-Platform/macOS/Siv3D/System/SivSystem_macOS.mm +++ b/Siv3D/src/Siv3D-Platform/macOS/Siv3D/System/SivSystem_macOS.mm @@ -47,6 +47,12 @@ static bool MacOS_OpenHTMLInBrowser(const char* _path) } } + + [[nodiscard]] + static bool IsRunningInXcode_impl() + { + return (std::getenv("__XCODE_BUILT_PRODUCTS_DIR_PATHS") != nullptr); + } } namespace System @@ -190,5 +196,17 @@ bool LaunchFileWithTextEditor(const FilePathView fileName) return (std::system(command.c_str()) == 0); } + + bool IsRunningInVisualStudio() + { + return false; + } + + bool IsRunningInXcode() + { + static const bool result = detail::IsRunningInXcode_impl(); + + return result; + } } }