Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
OPTIX_VERSION=${{ matrix.optix_version }}
GEANT4_VERSION=${{ matrix.geant4_version }}
CMAKE_VERSION=${{ matrix.cmake_version }}
PROJECT_VERSION=${{ github.ref_name }}
cache-from: type=local,src=/home/runner/.buildx-cache
cache-to: type=local,dest=/home/runner/.buildx-cache-new,mode=max

Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type")
endif()

project(eic-opticks VERSION 0.1.0 LANGUAGES CXX CUDA)
project(eic-opticks VERSION 0.3.0 LANGUAGES CXX CUDA)

include(GitVersion)

# Allow CI/Docker to override the derived version string via -DPROJECT_VERSION_OVERRIDE=...
if(DEFINED PROJECT_VERSION_OVERRIDE AND NOT "${PROJECT_VERSION_OVERRIDE}" STREQUAL "")
set(PROJECT_VERSION_STRING "${PROJECT_VERSION_OVERRIDE}")
message(STATUS "Version overridden to: ${PROJECT_VERSION_STRING}")
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,23 @@ RUN uv sync

FROM base AS release

ARG PROJECT_VERSION

COPY . $OPTICKS_HOME

RUN cmake -S $OPTICKS_HOME -B $OPTICKS_BUILD -DCMAKE_INSTALL_PREFIX=$OPTICKS_PREFIX -DCMAKE_BUILD_TYPE=Release \
${PROJECT_VERSION:+-DPROJECT_VERSION_OVERRIDE=$PROJECT_VERSION} \
&& cmake --build $OPTICKS_BUILD --parallel --target install


FROM base AS develop

ARG PROJECT_VERSION

RUN apt update && apt install -y x11-apps mesa-utils vim

COPY . $OPTICKS_HOME

RUN cmake -S $OPTICKS_HOME -B $OPTICKS_BUILD -DCMAKE_INSTALL_PREFIX=$OPTICKS_PREFIX -DCMAKE_BUILD_TYPE=Debug \
${PROJECT_VERSION:+-DPROJECT_VERSION_OVERRIDE=$PROJECT_VERSION} \
&& cmake --build $OPTICKS_BUILD --parallel --target install
45 changes: 45 additions & 0 deletions cmake/GitVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# GitVersion.cmake
#
# Derives PROJECT_VERSION_STRING and PROJECT_GIT_REVISION from git when available.
# Falls back to PROJECT_VERSION when git is not present (e.g. Docker builds).
#
# Sets in the caller's scope:
# PROJECT_VERSION_STRING - Version string: exact tag ("0.3.0") or
# tag+distance+sha ("0.3.0-2-gabcdef-dirty").
# Falls back to PROJECT_VERSION.
# PROJECT_GIT_REVISION - Short commit hash, or empty string if git is unavailable.

find_package(Git QUIET)

if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --match "[0-9]*" --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE _git_describe
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
RESULT_VARIABLE _git_result
)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE PROJECT_GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
RESULT_VARIABLE _git_rev_result
)
if(_git_rev_result)
set(PROJECT_GIT_REVISION "")
endif()
else()
set(_git_result 1)
set(PROJECT_GIT_REVISION "")
endif()

if(_git_result EQUAL 0 AND _git_describe)
set(PROJECT_VERSION_STRING "${_git_describe}")
message(STATUS "Version from git: ${PROJECT_VERSION_STRING}")
else()
set(PROJECT_VERSION_STRING "${PROJECT_VERSION}")
message(STATUS "Version from project(): ${PROJECT_VERSION_STRING} (git not available)")
endif()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "optiphy"
version = "0.0.0"
version = "0.3.0"
description = ""
authors = [ { name = "Dmitri Smirnov", email = "dmixsmi@gmail.com" } ]
requires-python = ">=3.10"
Expand Down
10 changes: 10 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ namespace gphox {

using namespace std;

const char *Config::Version()
{
return PROJECT_VERSION;
}

const char *Config::GitRevision()
{
return PROJECT_GIT_REVISION;
}

constexpr const char *GPHOX_PTX_PATH_ENV = "CSGOptiX__optixpath";

bool FileExists(const std::string &path)
Expand Down
6 changes: 6 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class Config

static std::string PtxPath(const std::string &ptx_name = "CSGOptiX7.ptx");

/// Returns the project version (e.g. "0.3.0" or "0.3.0-2-gabcdef-dirty")
static const char *Version();

/// Returns the short git commit hash, or empty string if unavailable
static const char *GitRevision();

/// A unique name associated with this Config
std::string name;

Expand Down
6 changes: 6 additions & 0 deletions src/config_path.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

#define GPHOX_CONFIG_SEARCH_PATHS ".:config:@GPHOX_INSTALL_FULL_DATADIR@/config"
#define GPHOX_PTX_DIR "@CMAKE_INSTALL_FULL_LIBDIR@"

#define PROJECT_VERSION "@PROJECT_VERSION_STRING@"
#define PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define PROJECT_GIT_REVISION "@PROJECT_GIT_REVISION@"
Loading