Skip to content

Commit

Permalink
Fixing CPack
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Atraxus committed Mar 2, 2024
1 parent 9b49bc7 commit a2c5e42
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/releaseDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update --yes
sudo apt install --yes xorg-dev cmake libgtk-3-dev libdbus-1-dev
sudo apt install --yes xorg-dev cmake libgtk-3-dev libdbus-1-dev libhdf5-dev
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DWERROR=YES -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
Expand Down
33 changes: 22 additions & 11 deletions Intern/rayx-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,34 +119,45 @@ target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC

# ---- Compile Shaders ----
if(Vulkan_FOUND)
# The following code is used to always compile the shader.
# This is most likely not an optimal solution, but it will work
# until we find a better one.
add_dependencies(${PROJECT_NAME} RAYX_CORE_COMPILE_SHADER)
set(RAYX_CORE_SHADER ${CMAKE_BINARY_DIR}/bin/shaders/comp.spv)
set(RAYX_CORE_SHADER_FAKE ${CMAKE_BINARY_DIR}/bin/___comp.spv) # this exists so file cannot be found -> always execute command

set(RAYX_CORE_SHADER ${CMAKE_BINARY_DIR}/bin/Shaders/comp.spv)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/Shaders)
add_custom_command(
OUTPUT
${RAYX_CORE_SHADER}
${RAYX_CORE_SHADER_FAKE}
COMMAND glslangValidator
ARGS -V ${PROJECT_SOURCE_DIR}/src/Shader/main-glsl.comp -o ${RAYX_CORE_SHADER}
)

add_custom_target(RAYX_CORE_COMPILE_SHADER ALL DEPENDS ${RAYX_CORE_SHADER})
endif()

# ------------------------

# ---- CPack ----
# ---- Data ----
# Define the source and destination paths
set(DATA_SRC_DIR "${CMAKE_SOURCE_DIR}/Data")
# Set the destination directory for the Data directory based on the build type
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DATA_DST_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/Data")
else()
set(DATA_DST_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/Data")
endif()

include(InstallRequiredSystemLibraries)
# Copy the Data directory to the binary output directory after building
message(STATUS "Copying Data directory from ${DATA_SRC_DIR} to ${DATA_DST_DIR}")
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${DATA_SRC_DIR} ${DATA_DST_DIR}
COMMENT "Copying Data directory to build output directory..."
)
# -----------------

set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../../LICENSE")
# ---- CPack ----
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_CONTACT "Your Name <your.email@example.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Your Project Description")
install(DIRECTORY ${DATA_SRC_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX})

include(CPack)

Expand Down
44 changes: 43 additions & 1 deletion Intern/rayx-core/src/CanonicalizePath.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
#include "CanonicalizePath.h"

#include "Debug/Debug.h"
#include <cstring>
#include <stdexcept>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#include <windows.h>
#elif defined(__linux__) || defined(__unix__) || defined(_POSIX_VERSION)
#include <unistd.h>
#include <limits.h>
#elif defined(__APPLE__)
#include <mach-o/dyld.h>
#endif

namespace RAYX {

std::filesystem::path getExecutablePath() {
char buffer[1024];
std::size_t length = sizeof(buffer);
memset(buffer, 0, length);

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
// Windows implementation
DWORD ret = GetModuleFileNameA(NULL, buffer, length);
if (ret == 0 || ret == length) {
// Handle error
throw std::runtime_error("Failed to get executable path.");
}
#elif defined(__linux__) || defined(__unix__) || defined(_POSIX_VERSION)
// Linux and Unix implementation
ssize_t ret = readlink("/proc/self/exe", buffer, length - 1);
if (ret == -1) {
// Handle error
throw std::runtime_error("Failed to get executable path.");
}
buffer[ret] = '\0'; // Ensure null-terminated string
#elif defined(__APPLE__)
// macOS implementation
if (_NSGetExecutablePath(buffer, &length) != 0) {
// Handle error
throw std::runtime_error("Buffer too small; should not happen.");
}
#else
#error "Platform not supported."
#endif

return std::filesystem::path(buffer).parent_path();
}

/// this function assumes that `base` is already an absolute path
std::filesystem::path canonicalize(const std::filesystem::path& relPath, const std::filesystem::path& base) {
if (!base.is_absolute()) {
Expand All @@ -23,5 +66,4 @@ std::filesystem::path canonicalizeRepositoryPath(const std::filesystem::path& re

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


} // namespace RAYX
3 changes: 3 additions & 0 deletions Intern/rayx-core/src/CanonicalizePath.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace RAYX {

/// Returns the path to the directory containing the executable.
std::filesystem::path RAYX_API getExecutablePath();

/// `relPath` is a path relative to the root of the RAY-X git repository (i.e.
/// where .git lies). canonicalizeRepositoryPath(relPath) yields an absolute
/// path representing the same path. Examples:
Expand Down
5 changes: 3 additions & 2 deletions Intern/rayx-core/src/Material/NffTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ bool NffTable::load(const char* element, NffTable* out) {

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

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

if (s.fail()) {
return false;
Expand Down
5 changes: 3 additions & 2 deletions Intern/rayx-core/src/Material/PalikTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ bool PalikTable::load(const char* element, PalikTable* out) {
std::string elementString = element;
std::transform(elementString.begin(), elementString.end(), elementString.begin(), [](unsigned char c) { return std::toupper(c); });

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

if (s.fail()) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion Intern/rayx-core/src/VulkanEngine/Init/ShaderModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ void VulkanEngine::createShaderModule() {

// the code in comp.spv was created by running the command:
// glslangValidator.exe -V shader.comp
std::string path = canonicalizeRepositoryPath(m_shaderFile).string();
std::string path = getExecutablePath().string() + "/Shaders/comp.spv";
RAYX_VERB << "Loading compute shader from: " << path;
std::vector<uint32_t> compShaderCode;
if (auto d = readFileAlign32(path)) {
compShaderCode = d.value();
Expand Down
8 changes: 4 additions & 4 deletions Intern/rayx-ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ if(Vulkan_FOUND)

# ---- CPack ----
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/shaders
DESTINATION ./
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/Shaders
DESTINATION ./bin
FILES_MATCHING PATTERN "*_*.spv")
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../../LICENSE")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "rayx-ui - RAYX GUI Application")
include(CPack)
Expand Down Expand Up @@ -85,7 +85,7 @@ if(Vulkan_FOUND)
string(SUBSTRING ${SHADER_EXT} 1 -1 SHADER_STAGE) # Remove the leading '.' from the extension

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

# Create a custom command for each shader file
add_custom_command(
Expand Down
4 changes: 2 additions & 2 deletions Intern/rayx-ui/src/RenderSystem/GridRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void GridRenderSystem::createPipeline(VkRenderPass renderPass) {
pipelineConfig.depthStencilInfo.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;

// Use the grid-specific shaders
const std::string vertexShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/grid_shader_vert.spv").string();
const std::string fragmentShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/grid_shader_frag.spv").string();
const std::string vertexShader = RAYX::getExecutablePath().string() + "/Shaders/grid_shader_vert.spv";
const std::string fragmentShader = RAYX::getExecutablePath().string() + "/Shaders/grid_shader_frag.spv";
m_Pipeline = std::make_unique<GraphicsPipeline>(m_Device, vertexShader, fragmentShader, pipelineConfig);
}
4 changes: 2 additions & 2 deletions Intern/rayx-ui/src/RenderSystem/ObjectRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ void ObjectRenderSystem::createPipeline(VkRenderPass renderPass) {
GraphicsPipeline::defaultPipelineConfigInfo(pipelineConfig, GraphicsPipeline::VertexMode::TEXTURED);
pipelineConfig.renderPass = renderPass;
pipelineConfig.pipelineLayout = m_PipelineLayout;
const std::string vertexShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/shader_vert.spv").string();
const std::string fragmentShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/shader_frag.spv").string();
const std::string vertexShader = RAYX::getExecutablePath().string() + "/Shaders/shader_vert.spv";
const std::string fragmentShader = RAYX::getExecutablePath().string() + "/Shaders/shader_frag.spv";
m_Pipeline = std::make_unique<GraphicsPipeline>(m_Device, vertexShader, fragmentShader, pipelineConfig);
}

Expand Down
4 changes: 2 additions & 2 deletions Intern/rayx-ui/src/RenderSystem/RayRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void RayRenderSystem::createPipeline(VkRenderPass renderPass) {
pipelineConfig.renderPass = renderPass;
pipelineConfig.pipelineLayout = m_PipelineLayout;

const std::string vertexShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/ray_shader_vert.spv").string();
const std::string fragmentShader = RAYX::canonicalizeRepositoryPath("build/bin/shaders/ray_shader_frag.spv").string();
const std::string vertexShader = RAYX::getExecutablePath().string() + "/Shaders/ray_shader_vert.spv";
const std::string fragmentShader = RAYX::getExecutablePath().string() + "/Shaders/ray_shader_frag.spv";
m_Pipeline = std::make_unique<GraphicsPipeline>(m_Device, vertexShader, fragmentShader, pipelineConfig);
}
10 changes: 5 additions & 5 deletions Intern/rayx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR})
# ----------------------

# ---- CPack ----
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/shaders
DESTINATION ./
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/Shaders
DESTINATION ./bin
FILES_MATCHING PATTERN "comp.spv")
install(DIRECTORY ${CMAKE_BINARY_DIR}/../Data
DESTINATION ./)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data
DESTINATION ./bin)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "rayx - A RAYX Beamline Simulation Tool")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "rayx")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../../LICENSE")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME})
include(CPack)
# --------------

0 comments on commit a2c5e42

Please sign in to comment.