aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/cmake-multi-platform.yml4
-rw-r--r--CMakeLists.txt1
-rw-r--r--cmake/GitVersion.cmake19
-rw-r--r--src/cli/stasis_indexer/helpers.c14
-rw-r--r--src/cli/stasis_indexer/stasis_indexer_main.c5
-rw-r--r--src/lib/delivery/delivery_postprocess.c6
6 files changed, 40 insertions, 9 deletions
diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml
index f579713..2191559 100644
--- a/.github/workflows/cmake-multi-platform.yml
+++ b/.github/workflows/cmake-multi-platform.yml
@@ -30,6 +30,8 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 0
- name: Set reusable strings
id: strings
@@ -80,7 +82,7 @@ jobs:
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
export ASAN_OPTIONS="verify_asan_link_order=0 strict_string_checks=1 detect_stack_use_after_return=1"
- if [[ "$RUNNER_OS" == "macos" ]]; then
+ if [[ "$RUNNER_OS" == "macOS" ]]; then
ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks=0"
else
ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks=1"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73f5555..817f88d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,7 @@ configure_file(
${CMAKE_SOURCE_DIR}/include/version.h.in
${CMAKE_BINARY_DIR}/include/version.h
)
+message("-- STASIS version: ${PROJECT_VERSION} (${PROJECT_VERSION_BRANCH})")
set(nix_cflags -Wall -Wextra -fPIC -D_GNU_SOURCE)
set(win_cflags /Wall)
diff --git a/cmake/GitVersion.cmake b/cmake/GitVersion.cmake
index 7280510..c9c6159 100644
--- a/cmake/GitVersion.cmake
+++ b/cmake/GitVersion.cmake
@@ -1,11 +1,16 @@
+function(set_version_fallback)
+ message(WARNING "Version information not available. Using fallback...")
+ set(PROJECT_VERSION "0.0.0")
+ set(PROJECT_VERSION ${PROJECT_VERSION} PARENT_SCOPE)
+ set(PROJECT_VERSION_BRANCH "unknown")
+ set(PROJECT_VERSION_BRANCH ${PROJECT_VERSION_BRANCH} PARENT_SCOPE)
+endfunction()
+
function(get_version_from_git)
find_package(Git QUIET)
if(NOT Git_FOUND)
- message(WARNING "Git not found. Setting fallback version.")
- set(PROJECT_VERSION "0.0.0")
- set(PROJECT_VERSION ${PROJECT_VERSION} PARENT_SCOPE)
- set(PROJECT_VERSION_BRANCH "unknown")
- set(PROJECT_VERSION_BRANCH ${PROJECT_VERSION_BRANCH} PARENT_SCOPE)
+ message(WARNING "Git not found.")
+ set_version_fallback()
return()
endif()
@@ -18,9 +23,9 @@ function(get_version_from_git)
)
if(NOT GIT_RESULT EQUAL 0)
message(WARNING "Failed to get git describe info")
+ set_version_fallback()
return()
endif()
- message(${GIT_TAG})
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
@@ -31,9 +36,9 @@ function(get_version_from_git)
)
if(NOT GIT_RESULT EQUAL 0)
message(WARNING "Failed to get git branch")
+ set_version_fallback()
return()
endif()
- message(${GIT_BRANCH})
string(REGEX REPLACE "^v" "" CLEAN_TAG "${GIT_TAG}")
set(PROJECT_VERSION ${CLEAN_TAG})
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c
index 0debfe4..23e4f5a 100644
--- a/src/cli/stasis_indexer/helpers.c
+++ b/src/cli/stasis_indexer/helpers.c
@@ -313,13 +313,22 @@ int load_metadata(struct Delivery *ctx, const char *filename) {
return -1;
}
+ // Reserved for future use.
+ // i.e. adjust values based on the version of the software that produced the input
+ char *stasis_version = NULL;
+ char *stasis_version_branch = NULL;
+
while (fgets(line, sizeof(line) - 1, fp) != NULL) {
char **parts = split(line, " ", 1);
const char *name = parts[0];
char *value = parts[1];
strip(value);
- if (!strcmp(name, "name")) {
+ if (!strcmp(name, "stasis_version")) {
+ stasis_version = strdup(value);
+ } else if (!strcmp(name, "stasis_version_branch")) {
+ stasis_version_branch = strdup(value);
+ } else if (!strcmp(name, "name")) {
ctx->meta.name = strdup(value);
} else if (!strcmp(name, "version")) {
ctx->meta.version = strdup(value);
@@ -364,6 +373,9 @@ int load_metadata(struct Delivery *ctx, const char *filename) {
}
guard_array_free(parts);
}
+
+ guard_free(stasis_version);
+ guard_free(stasis_version_branch);
fclose(fp);
return 0;
diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c
index 63fb45c..d475c15 100644
--- a/src/cli/stasis_indexer/stasis_indexer_main.c
+++ b/src/cli/stasis_indexer/stasis_indexer_main.c
@@ -320,6 +320,11 @@ int main(const int argc, char *argv[]) {
msg(STASIS_MSG_L1, "Loading metadata\n");
struct StrList *metafiles = NULL;
get_files(&metafiles, ctx.storage.meta_dir, "*.stasis");
+ if (!metafiles || !strlist_count(metafiles)) {
+ SYSERROR("%s: No metadata!", ctx.storage.meta_dir);
+ delivery_free(&ctx);
+ exit(1);
+ }
strlist_sort(metafiles, STASIS_SORT_LEN_ASCENDING);
struct Delivery **local = calloc(strlist_count(metafiles) + 1, sizeof(*local));
diff --git a/src/lib/delivery/delivery_postprocess.c b/src/lib/delivery/delivery_postprocess.c
index 8cb4e65..95bcc0a 100644
--- a/src/lib/delivery/delivery_postprocess.c
+++ b/src/lib/delivery/delivery_postprocess.c
@@ -3,6 +3,8 @@
const char *release_header = "# delivery_name: %s\n"
"# delivery_fmt: %s\n"
+ "# stasis_version: %s\n"
+ "# stasis_branch: %s\n"
"# creation_time: %s\n"
"# conda_ident: %s\n"
"# conda_build_ident: %s\n";
@@ -14,6 +16,8 @@ char *delivery_get_release_header(struct Delivery *ctx) {
snprintf(output, sizeof(output), release_header,
ctx->info.release_name,
ctx->rules.release_fmt,
+ STASIS_VERSION,
+ STASIS_VERSION_BRANCH,
stamp,
ctx->conda.tool_version,
ctx->conda.tool_build_version);
@@ -30,6 +34,8 @@ int delivery_dump_metadata(struct Delivery *ctx) {
if (globals.verbose) {
msg(STASIS_MSG_L2, "%s\n", filename);
}
+ fprintf(fp, "stasis_version %s\n", STASIS_VERSION);
+ fprintf(fp, "stasis_version_branch %s\n", STASIS_VERSION_BRANCH);
fprintf(fp, "name %s\n", ctx->meta.name);
fprintf(fp, "version %s\n", ctx->meta.version);
fprintf(fp, "rc %d\n", ctx->meta.rc);