Skip to content

Commit 4980219

Browse files
committed
Fixing asset and script distribution
1 parent ae08957 commit 4980219

File tree

6 files changed

+44
-7
lines changed

6 files changed

+44
-7
lines changed

Intern/rayx-core/CMakeLists.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,31 @@ add_custom_command(
158158
)
159159
# -----------------
160160

161+
# ---- Scripts ----
162+
# Define the source and destination paths
163+
set(SCRIPT_SRC_DIR "${CMAKE_SOURCE_DIR}/Scripts/plot.py")
164+
# Set the destination directory for the Scripts directory based on the build type
165+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
166+
set(SCRIPT_DST_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/Scripts/plot.py")
167+
else()
168+
set(SCRIPT_DST_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/Scripts/plot.py")
169+
endif()
170+
171+
# Copy the Scripts directory to the binary output directory after building
172+
message(STATUS "Copying Scripts directory from ${SCRIPT_SRC_DIR} to ${SCRIPT_DST_DIR}")
173+
add_custom_command(
174+
TARGET ${PROJECT_NAME} POST_BUILD
175+
COMMAND ${CMAKE_COMMAND} -E copy ${SCRIPT_SRC_DIR} ${SCRIPT_DST_DIR}
176+
COMMENT "Copying Scripts directory to build output directory..."
177+
)
178+
# -----------------
179+
161180
# ---- CPack ----
162181
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
163182
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
164183
set(CPACK_PACKAGE_CONTACT "Your Name <[email protected]>")
165184
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Your Project Description")
166-
install(DIRECTORY ${DATA_SRC_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX})
185+
install(FILES ${SCRIPT_SRC_DIR} DESTINATION bin/Scripts)
167186

168187
include(CPack)
169188

Intern/rayx-ui/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ if(Vulkan_FOUND)
3232
target_compile_definitions(${PROJECT_NAME} PRIVATE
3333
GLM_FORCE_RADIANS
3434
GLM_FORCE_DEPTH_ZERO_TO_ONE)
35+
36+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
37+
set(RESOURCE_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/Assets)
38+
else()
39+
set(RESOURCE_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/Assets)
40+
endif()
41+
42+
message(STATUS "Resource directory: ${RESOURCE_DIR}")
43+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
44+
COMMAND ${CMAKE_COMMAND} -E copy_directory
45+
${PROJECT_SOURCE_DIR}/res
46+
${RESOURCE_DIR}
47+
)
3548
# -----------------
3649

3750

@@ -42,10 +55,16 @@ if(Vulkan_FOUND)
4255
install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/Shaders
4356
DESTINATION ./bin
4457
FILES_MATCHING PATTERN "*_*.spv")
58+
install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/Assets
59+
DESTINATION ./bin
60+
FILES_MATCHING PATTERN "*")
4561
else()
4662
install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/Shaders
4763
DESTINATION ./bin
4864
FILES_MATCHING PATTERN "*_*.spv")
65+
install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/Assets
66+
DESTINATION ./bin
67+
FILES_MATCHING PATTERN "*")
4968
endif()
5069
include(InstallRequiredSystemLibraries)
5170
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
-78.8 KB
Binary file not shown.

Intern/rayx-ui/src/GraphicsCore/Texture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Texture::Texture(Device& device) : m_Device{device} {
2626
// Read in image
2727
int texWidth, texHeight, _;
2828
// STBI_rgb_alpha hopefully always forces 4 channels
29-
std::filesystem::path path = RAYX::canonicalizeRepositoryPath("Intern/rayx-ui/res/textures/default.png");
29+
std::filesystem::path path = getExecutablePath() / "Assets" / "textures" / "default.png";
3030
stbi_uc* pixels = stbi_load(path.string().c_str(), &texWidth, &texHeight, &_, STBI_rgb_alpha);
3131
if (!pixels) {
3232
RAYX_ERR << "Failed to load texture image";

Intern/rayx-ui/src/UserInterface/UIHandler.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,9 @@ UIHandler::UIHandler(const Window& window, const Device& device, VkFormat imageF
127127
// Upload fonts
128128
{
129129
// Setup style
130-
m_smallFont =
131-
m_IO.Fonts->AddFontFromFileTTF(RAYX::canonicalizeRepositoryPath("./Intern/rayx-ui/res/fonts/Roboto-Regular.ttf").string().c_str(), 16.0f);
132-
m_largeFont =
133-
m_IO.Fonts->AddFontFromFileTTF(RAYX::canonicalizeRepositoryPath("./Intern/rayx-ui/res/fonts/Roboto-Regular.ttf").string().c_str(), 24.0f);
130+
const std::filesystem::path fontPath = getExecutablePath() / "Assets/fonts/Roboto-Regular.ttf";
131+
m_smallFont = m_IO.Fonts->AddFontFromFileTTF(fontPath.string().c_str(), 16.0f);
132+
m_largeFont = m_IO.Fonts->AddFontFromFileTTF(fontPath.string().c_str(), 24.0f);
134133

135134
ImGui_ImplVulkan_CreateFontsTexture();
136135
}

Intern/rayx/src/TerminalApp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void TerminalApp::tracePath(const std::filesystem::path& path) {
111111
RAYX_ERR << "Have you selected .csv exporting?";
112112
}
113113

114-
auto cmd = std::string("python ") + RAYX::canonicalizeRepositoryPath(std::string("Scripts/plot.py")).string() + " " + file;
114+
auto cmd = std::string("python ") + getExecutablePath().string() + "/Scripts/plot.py " + file;
115115
auto ret = system(cmd.c_str());
116116
if (ret != 0) {
117117
RAYX_WARN << "received error code while printing";

0 commit comments

Comments
 (0)