Skip to content

Commit a2c5e42

Browse files
committed
Fixing CPack
Update version to v0.19.12 Update version to v0.19.13 Fixing CPack Update version to v0.19.14 Update version to v0.19.15 Update version to v0.19.16 Update version to v0.19.17 Update version to v0.19.18 Update version to v0.19.19 Update version to v0.19.20 Update version to v0.19.21 cleanup
1 parent 9b49bc7 commit a2c5e42

File tree

12 files changed

+92
-33
lines changed

12 files changed

+92
-33
lines changed

.github/workflows/releaseDeploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
if: matrix.os == 'ubuntu-latest'
4949
run: |
5050
sudo apt update --yes
51-
sudo apt install --yes xorg-dev cmake libgtk-3-dev libdbus-1-dev
51+
sudo apt install --yes xorg-dev cmake libgtk-3-dev libdbus-1-dev libhdf5-dev
5252
5353
- name: Configure CMake
5454
run: cmake -B ${{github.workspace}}/build -DWERROR=YES -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}

Intern/rayx-core/CMakeLists.txt

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,34 +119,45 @@ target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
119119

120120
# ---- Compile Shaders ----
121121
if(Vulkan_FOUND)
122-
# The following code is used to always compile the shader.
123-
# This is most likely not an optimal solution, but it will work
124-
# until we find a better one.
125122
add_dependencies(${PROJECT_NAME} RAYX_CORE_COMPILE_SHADER)
126-
set(RAYX_CORE_SHADER ${CMAKE_BINARY_DIR}/bin/shaders/comp.spv)
127-
set(RAYX_CORE_SHADER_FAKE ${CMAKE_BINARY_DIR}/bin/___comp.spv) # this exists so file cannot be found -> always execute command
128-
123+
set(RAYX_CORE_SHADER ${CMAKE_BINARY_DIR}/bin/Shaders/comp.spv)
124+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/Shaders)
129125
add_custom_command(
130126
OUTPUT
131127
${RAYX_CORE_SHADER}
132-
${RAYX_CORE_SHADER_FAKE}
133128
COMMAND glslangValidator
134129
ARGS -V ${PROJECT_SOURCE_DIR}/src/Shader/main-glsl.comp -o ${RAYX_CORE_SHADER}
135130
)
136-
137131
add_custom_target(RAYX_CORE_COMPILE_SHADER ALL DEPENDS ${RAYX_CORE_SHADER})
138132
endif()
139133

140134
# ------------------------
141135

142-
# ---- CPack ----
136+
# ---- Data ----
137+
# Define the source and destination paths
138+
set(DATA_SRC_DIR "${CMAKE_SOURCE_DIR}/Data")
139+
# Set the destination directory for the Data directory based on the build type
140+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
141+
set(DATA_DST_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/Data")
142+
else()
143+
set(DATA_DST_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/Data")
144+
endif()
143145

144-
include(InstallRequiredSystemLibraries)
146+
# Copy the Data directory to the binary output directory after building
147+
message(STATUS "Copying Data directory from ${DATA_SRC_DIR} to ${DATA_DST_DIR}")
148+
add_custom_command(
149+
TARGET ${PROJECT_NAME} POST_BUILD
150+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${DATA_SRC_DIR} ${DATA_DST_DIR}
151+
COMMENT "Copying Data directory to build output directory..."
152+
)
153+
# -----------------
145154

146-
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../../LICENSE")
155+
# ---- CPack ----
156+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
147157
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
148158
set(CPACK_PACKAGE_CONTACT "Your Name <[email protected]>")
149159
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Your Project Description")
160+
install(DIRECTORY ${DATA_SRC_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX})
150161

151162
include(CPack)
152163

Intern/rayx-core/src/CanonicalizePath.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,52 @@
11
#include "CanonicalizePath.h"
22

33
#include "Debug/Debug.h"
4+
#include <cstring>
5+
#include <stdexcept>
6+
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
7+
#include <windows.h>
8+
#elif defined(__linux__) || defined(__unix__) || defined(_POSIX_VERSION)
9+
#include <unistd.h>
10+
#include <limits.h>
11+
#elif defined(__APPLE__)
12+
#include <mach-o/dyld.h>
13+
#endif
414

515
namespace RAYX {
616

17+
std::filesystem::path getExecutablePath() {
18+
char buffer[1024];
19+
std::size_t length = sizeof(buffer);
20+
memset(buffer, 0, length);
21+
22+
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
23+
// Windows implementation
24+
DWORD ret = GetModuleFileNameA(NULL, buffer, length);
25+
if (ret == 0 || ret == length) {
26+
// Handle error
27+
throw std::runtime_error("Failed to get executable path.");
28+
}
29+
#elif defined(__linux__) || defined(__unix__) || defined(_POSIX_VERSION)
30+
// Linux and Unix implementation
31+
ssize_t ret = readlink("/proc/self/exe", buffer, length - 1);
32+
if (ret == -1) {
33+
// Handle error
34+
throw std::runtime_error("Failed to get executable path.");
35+
}
36+
buffer[ret] = '\0'; // Ensure null-terminated string
37+
#elif defined(__APPLE__)
38+
// macOS implementation
39+
if (_NSGetExecutablePath(buffer, &length) != 0) {
40+
// Handle error
41+
throw std::runtime_error("Buffer too small; should not happen.");
42+
}
43+
#else
44+
#error "Platform not supported."
45+
#endif
46+
47+
return std::filesystem::path(buffer).parent_path();
48+
}
49+
750
/// this function assumes that `base` is already an absolute path
851
std::filesystem::path canonicalize(const std::filesystem::path& relPath, const std::filesystem::path& base) {
952
if (!base.is_absolute()) {
@@ -23,5 +66,4 @@ std::filesystem::path canonicalizeRepositoryPath(const std::filesystem::path& re
2366

2467
std::filesystem::path canonicalizeUserPath(const std::filesystem::path& relPath) { return canonicalize(relPath, std::filesystem::current_path()); }
2568

26-
2769
} // namespace RAYX

Intern/rayx-core/src/CanonicalizePath.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
namespace RAYX {
1111

12+
/// Returns the path to the directory containing the executable.
13+
std::filesystem::path RAYX_API getExecutablePath();
14+
1215
/// `relPath` is a path relative to the root of the RAY-X git repository (i.e.
1316
/// where .git lies). canonicalizeRepositoryPath(relPath) yields an absolute
1417
/// path representing the same path. Examples:

Intern/rayx-core/src/Material/NffTable.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ bool NffTable::load(const char* element, NffTable* out) {
1414

1515
std::transform(elementString.begin(), elementString.end(), elementString.begin(), [](unsigned char c) { return std::tolower(c); });
1616

17-
std::string f = "Data/nff/" + elementString + ".nff";
18-
std::ifstream s(canonicalizeRepositoryPath(f));
17+
std::string f = getExecutablePath().string() + "/Data/nff/" + elementString + ".nff";
18+
RAYX_VERB << "Loading NffTable from " << f;
19+
std::ifstream s(f);
1920

2021
if (s.fail()) {
2122
return false;

Intern/rayx-core/src/Material/PalikTable.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ bool PalikTable::load(const char* element, PalikTable* out) {
1212
std::string elementString = element;
1313
std::transform(elementString.begin(), elementString.end(), elementString.begin(), [](unsigned char c) { return std::toupper(c); });
1414

15-
std::string f = "Data/PALIK/" + elementString + ".NKP";
16-
std::ifstream s(canonicalizeRepositoryPath(f));
15+
std::string f = getExecutablePath().string() + "/Data/PALIK/" + elementString + ".NKP";
16+
RAYX_VERB << "Loading PalikTable from " << f;
17+
std::ifstream s(f);
1718

1819
if (s.fail()) {
1920
return false;

Intern/rayx-core/src/VulkanEngine/Init/ShaderModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ void VulkanEngine::createShaderModule() {
1818

1919
// the code in comp.spv was created by running the command:
2020
// glslangValidator.exe -V shader.comp
21-
std::string path = canonicalizeRepositoryPath(m_shaderFile).string();
21+
std::string path = getExecutablePath().string() + "/Shaders/comp.spv";
22+
RAYX_VERB << "Loading compute shader from: " << path;
2223
std::vector<uint32_t> compShaderCode;
2324
if (auto d = readFileAlign32(path)) {
2425
compShaderCode = d.value();

Intern/rayx-ui/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ if(Vulkan_FOUND)
3737

3838
# ---- CPack ----
3939
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
40-
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/shaders
41-
DESTINATION ./
40+
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/Shaders
41+
DESTINATION ./bin
4242
FILES_MATCHING PATTERN "*_*.spv")
4343
include(InstallRequiredSystemLibraries)
44-
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../../LICENSE")
44+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
4545
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
4646
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "rayx-ui - RAYX GUI Application")
4747
include(CPack)
@@ -85,7 +85,7 @@ if(Vulkan_FOUND)
8585
string(SUBSTRING ${SHADER_EXT} 1 -1 SHADER_STAGE) # Remove the leading '.' from the extension
8686

8787
# Set output file name
88-
set(OUTPUT_FILE "${CMAKE_BINARY_DIR}/bin/shaders/${SHADER_NAME}_${SHADER_STAGE}.spv")
88+
set(OUTPUT_FILE "${CMAKE_BINARY_DIR}/bin/Shaders/${SHADER_NAME}_${SHADER_STAGE}.spv")
8989

9090
# Create a custom command for each shader file
9191
add_custom_command(

Intern/rayx-ui/src/RenderSystem/GridRenderSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void GridRenderSystem::createPipeline(VkRenderPass renderPass) {
4949
pipelineConfig.depthStencilInfo.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;
5050

5151
// Use the grid-specific shaders
52-
const std::string vertexShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/grid_shader_vert.spv").string();
53-
const std::string fragmentShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/grid_shader_frag.spv").string();
52+
const std::string vertexShader = RAYX::getExecutablePath().string() + "/Shaders/grid_shader_vert.spv";
53+
const std::string fragmentShader = RAYX::getExecutablePath().string() + "/Shaders/grid_shader_frag.spv";
5454
m_Pipeline = std::make_unique<GraphicsPipeline>(m_Device, vertexShader, fragmentShader, pipelineConfig);
5555
}

Intern/rayx-ui/src/RenderSystem/ObjectRenderSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ void ObjectRenderSystem::createPipeline(VkRenderPass renderPass) {
4747
GraphicsPipeline::defaultPipelineConfigInfo(pipelineConfig, GraphicsPipeline::VertexMode::TEXTURED);
4848
pipelineConfig.renderPass = renderPass;
4949
pipelineConfig.pipelineLayout = m_PipelineLayout;
50-
const std::string vertexShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/shader_vert.spv").string();
51-
const std::string fragmentShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/shader_frag.spv").string();
50+
const std::string vertexShader = RAYX::getExecutablePath().string() + "/Shaders/shader_vert.spv";
51+
const std::string fragmentShader = RAYX::getExecutablePath().string() + "/Shaders/shader_frag.spv";
5252
m_Pipeline = std::make_unique<GraphicsPipeline>(m_Device, vertexShader, fragmentShader, pipelineConfig);
5353
}
5454

0 commit comments

Comments
 (0)