Resolve Studio assets path dynamically.

PiperOrigin-RevId: 931162732
Change-Id: Ib44a74790facfa797ca2c4f107edb0062a89c117
This commit is contained in:
Michael Moss
2026-06-12 08:25:48 -07:00
committed by Copybara-Service
parent 2c125dd447
commit 4bb02e299d
5 changed files with 107 additions and 3 deletions
+7 -1
View File
@@ -16,6 +16,7 @@
#include <cstdlib>
#include <cstring>
#include <filesystem> // NOLINT(build/c++17)
#include <fstream>
#include <ios>
#include <iosfwd>
@@ -27,6 +28,7 @@
#include <absl/flags/parse.h>
#include <mujoco/mujoco.h>
#include "experimental/platform/hal/graphics_mode.h"
#include "experimental/platform/sys_utils.h"
#include "experimental/studio/app.h"
ABSL_FLAG(int, window_width, 1400, "Window width");
@@ -36,7 +38,11 @@ ABSL_FLAG(std::string, gfx, "", "Graphics API");
std::string Resolve(std::string_view path) {
std::string_view subpath = path.substr(path.find(':') + 1);
return std::string("assets/") + std::string(subpath);
std::filesystem::path exe_dir = mujoco::platform::GetModuleDir((void*)&Resolve);
if (exe_dir.empty()) {
return std::string("assets/") + std::string(subpath);
}
return (exe_dir / "assets" / subpath).string();
}
class FileResource {