mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Merge pull request #14939 from unknownbrackets/debugger-assets
Serve local web debugger from assets
This commit is contained in:
6 files changed
+75
-3
No files matched your search
@@ -34,3 +34,7 @@
|
||||
[submodule "SDL/macOS"]
|
||||
path = SDL/macOS
|
||||
url = https://github.com/hrydgard/ppsspp-mac-sdl
|
||||
[submodule "ppsspp-debugger"]
|
||||
path = assets/debugger
|
||||
url = https://github.com/unknownbrackets/ppsspp-debugger.git
|
||||
branch = bundled
|
||||
+5
-2
@@ -2219,6 +2219,7 @@ endif()
|
||||
set(NativeAssets
|
||||
android/assets/ui_atlas.zim
|
||||
android/assets/ui_atlas.meta
|
||||
assets/debugger
|
||||
assets/lang
|
||||
assets/shaders
|
||||
assets/Roboto-Condensed.ttf
|
||||
@@ -2324,18 +2325,20 @@ if(TargetBin)
|
||||
file(GLOB_RECURSE FLASH0_FILES assets/flash0/*)
|
||||
file(GLOB_RECURSE LANG_FILES assets/lang/*)
|
||||
file(GLOB_RECURSE SHADER_FILES assets/shaders/*)
|
||||
file(GLOB_RECURSE DEBUGGER_FILES assets/debugger/*)
|
||||
|
||||
if(NOT IOS)
|
||||
set_source_files_properties(${NativeAssets} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets")
|
||||
set_source_files_properties(${FLASH0_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/flash0/font")
|
||||
set_source_files_properties(${LANG_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/lang")
|
||||
set_source_files_properties(${SHADER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/shaders")
|
||||
set_source_files_properties(${DEBUGGER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/debugger")
|
||||
endif()
|
||||
|
||||
if(IOS)
|
||||
add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource} "ios/Settings.bundle" "ios/Launch Screen.storyboard" "ext/vulkan/iOS/Frameworks")
|
||||
add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource} "ios/Settings.bundle" "ios/Launch Screen.storyboard" "ext/vulkan/iOS/Frameworks")
|
||||
else()
|
||||
add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource})
|
||||
add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource})
|
||||
file(INSTALL "${CMAKE_SOURCE_DIR}/ext/vulkan/macOS/Frameworks/libMoltenVK.dylib" DESTINATION "${CMAKE_BINARY_DIR}/PPSSPPSDL.app/Contents/Frameworks/")
|
||||
if(TARGET SDL2::SDL2 AND NOT USING_QT_UI)
|
||||
add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/SDL/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPSDL.app")
|
||||
|
||||
+63
-1
@@ -26,6 +26,7 @@
|
||||
#include "Common/Log.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/File/FileDescriptor.h"
|
||||
#include "Common/File/VFS/VFS.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/Config.h"
|
||||
@@ -227,6 +228,46 @@ static void HandleListing(const http::Request &request) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool ServeDebuggerFile(const http::Request &request) {
|
||||
// Skip the slash at the start of the resource path.
|
||||
const char *filename = request.resource() + 1;
|
||||
if (strstr(filename, "..") != nullptr)
|
||||
return false;
|
||||
|
||||
size_t size;
|
||||
uint8_t *data = VFSReadFile(filename, &size);
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
std::string ext = Path(filename).GetFileExtension();
|
||||
const char *mimeType = "text/plain";
|
||||
if (ext == ".html") {
|
||||
mimeType = "text/html";
|
||||
} else if (ext == ".ico") {
|
||||
mimeType = "image/x-icon";
|
||||
} else if (ext == ".js") {
|
||||
mimeType = "application/javascript";
|
||||
} else if (ext == ".svg") {
|
||||
mimeType = "image/svg";
|
||||
} else if (ext == ".png") {
|
||||
mimeType = "image/png";
|
||||
} else if (ext == ".css") {
|
||||
mimeType = "text/css";
|
||||
}
|
||||
|
||||
request.WriteHttpResponseHeader("1.0", 200, (int)size, mimeType);
|
||||
request.Out()->Push((char *)data, size);
|
||||
|
||||
delete[] data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void RedirectToDebugger(const http::Request &request) {
|
||||
static const std::string payload = "Redirecting to debugger UI...\r\n";
|
||||
request.WriteHttpResponseHeader("1.0", 301, (int)payload.size(), "text/plain", "Location: /debugger/index.html\r\n");
|
||||
request.Out()->Push(payload);
|
||||
}
|
||||
|
||||
static void HandleFallback(const http::Request &request) {
|
||||
if (serverFlags & (int)WebServerFlags::DISCS) {
|
||||
Path filename = LocalFromRemotePath(request.resource());
|
||||
@@ -236,6 +277,16 @@ static void HandleFallback(const http::Request &request) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((serverFlags & (int)WebServerFlags::DEBUGGER) != 0) {
|
||||
if (!strcmp(request.resource(), "/debugger/")) {
|
||||
RedirectToDebugger(request);
|
||||
return;
|
||||
}
|
||||
|
||||
if (startsWith(request.resource(), "/debugger/") && ServeDebuggerFile(request))
|
||||
return;
|
||||
}
|
||||
|
||||
static const std::string payload = "404 not found\r\n";
|
||||
request.WriteHttpResponseHeader("1.0", 404, (int)payload.size(), "text/plain");
|
||||
request.Out()->Push(payload);
|
||||
@@ -243,7 +294,18 @@ static void HandleFallback(const http::Request &request) {
|
||||
|
||||
static void ForwardDebuggerRequest(const http::Request &request) {
|
||||
if (serverFlags & (int)WebServerFlags::DEBUGGER) {
|
||||
HandleDebuggerRequest(request);
|
||||
// Check if this is a websocket request...
|
||||
std::string upgrade;
|
||||
if (!request.GetHeader("upgrade", &upgrade)) {
|
||||
upgrade = "";
|
||||
}
|
||||
|
||||
// Yes - proceed with the socket.
|
||||
if (strcasecmp(upgrade.c_str(), "websocket") == 0) {
|
||||
HandleDebuggerRequest(request);
|
||||
} else {
|
||||
RedirectToDebugger(request);
|
||||
}
|
||||
} else {
|
||||
HandleFallback(request);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
cp -r ../assets/flash0 assets/
|
||||
cp -r ../assets/lang assets/
|
||||
cp -r ../assets/shaders assets/
|
||||
cp -r ../assets/debugger assets/
|
||||
cp ../assets/langregion.ini assets/langregion.ini
|
||||
cp ../assets/compat.ini assets/compat.ini
|
||||
cp ../assets/Roboto-Condensed.ttf assets/Roboto-Condensed.ttf
|
||||
|
||||
Submodule
+1
Submodule assets/debugger added at 36ad6b19b2.
@@ -74,6 +74,7 @@ Source: "README.md"; DestName: "README.txt"; DestDir: "{app}"; Flags: isreadme
|
||||
Source: "notinstalled.txt"; DestName: "installed.txt"; DestDir: "{app}";
|
||||
Source: "assets\*.*"; DestDir: "{app}\assets"
|
||||
Source: "assets\shaders\*.*"; DestDir: "{app}\assets\shaders"
|
||||
Source: "assets\debugger\*"; DestDir: "{app}\assets\debugger"; Flags: recursesubdirs
|
||||
Source: "assets\lang\*.ini"; DestDir: "{app}\assets\lang"
|
||||
Source: "assets\flash0\font\*.*"; DestDir: "{app}\assets\flash0\font"
|
||||
Source: "dx9sdk\8.1\Redist\D3D\x64\d3dcompiler_47.dll"; DestDir: "{app}"
|
||||
|
||||
Reference in new issue
Block a user