clean up versioning

This commit is contained in:
2025-08-14 16:26:37 -04:00
parent c109c93382
commit 2637378bf0
7 changed files with 49 additions and 84 deletions

View File

@@ -1,34 +1,63 @@
/*
* NOSTR Core Library - Version Test Example
* Demonstrates the automatic version increment system
* Simple version display using VERSION file
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nostr_core.h"
#include "version.h"
// Simple function to read VERSION file if it exists
static const char* get_version_from_file(void) {
static char version_buf[64] = {0};
FILE* f = fopen("VERSION", "r");
if (f) {
if (fgets(version_buf, sizeof(version_buf), f)) {
// Remove trailing newline
size_t len = strlen(version_buf);
if (len > 0 && version_buf[len-1] == '\n') {
version_buf[len-1] = '\0';
}
}
fclose(f);
return version_buf;
}
return "unknown";
}
int main() {
printf("NOSTR Core Library Version Test\n");
printf("===============================\n\n");
// Display version information
printf("Version: %s\n", nostr_core_get_version());
printf("Full Version: %s\n", nostr_core_get_version_full());
printf("Build Info: %s\n", nostr_core_get_build_info());
// Initialize the library
if (nostr_init() != NOSTR_SUCCESS) {
printf("Failed to initialize NOSTR library\n");
return 1;
}
printf("\nVersion Macros:\n");
printf("VERSION_MAJOR: %d\n", VERSION_MAJOR);
printf("VERSION_MINOR: %d\n", VERSION_MINOR);
printf("VERSION_PATCH: %d\n", VERSION_PATCH);
printf("VERSION_STRING: %s\n", VERSION_STRING);
printf("VERSION_TAG: %s\n", VERSION_TAG);
// Display basic version information
const char* version = get_version_from_file();
printf("Library Version: %s\n", version);
printf("Library Status: Initialized successfully\n");
printf("\nBuild Information:\n");
printf("BUILD_DATE: %s\n", BUILD_DATE);
printf("BUILD_TIME: %s\n", BUILD_TIME);
printf("BUILD_TIMESTAMP: %s\n", BUILD_TIMESTAMP);
printf("GIT_HASH: %s\n", GIT_HASH);
printf("GIT_BRANCH: %s\n", GIT_BRANCH);
// Test basic functionality
printf("\nLibrary Functionality Test:\n");
unsigned char private_key[32];
unsigned char public_key[32];
if (nostr_generate_keypair(private_key, public_key) == NOSTR_SUCCESS) {
printf("✓ Key generation works\n");
} else {
printf("✗ Key generation failed\n");
}
// Cleanup
nostr_cleanup();
printf("\nVersion test completed successfully.\n");
printf("Note: This library no longer includes runtime version functions\n");
printf(" to avoid build issues when used as a submodule.\n");
return 0;
}