clean up versioning
This commit is contained in:
parent
c109c93382
commit
2637378bf0
|
@ -11,9 +11,6 @@ tiny-AES-c/
|
||||||
mbedtls/
|
mbedtls/
|
||||||
|
|
||||||
|
|
||||||
# Auto-generated version files
|
|
||||||
nostr_core/version.h
|
|
||||||
nostr_core/version.c
|
|
||||||
mbedtls-arm64-install/
|
mbedtls-arm64-install/
|
||||||
mbedtls-install/
|
mbedtls-install/
|
||||||
secp256k1/
|
secp256k1/
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -17,7 +17,7 @@ endif
|
||||||
INCLUDES = -I. -Inostr_core -Icjson -Isecp256k1/include -Inostr_websocket -I./openssl-install/include
|
INCLUDES = -I. -Inostr_core -Icjson -Isecp256k1/include -Inostr_websocket -I./openssl-install/include
|
||||||
|
|
||||||
# Library source files
|
# Library source files
|
||||||
LIB_SOURCES = nostr_core/core.c nostr_core/core_relays.c nostr_core/nostr_crypto.c nostr_core/nostr_secp256k1.c nostr_core/nostr_aes.c nostr_core/nostr_chacha20.c nostr_core/version.c nostr_websocket/nostr_websocket_openssl.c cjson/cJSON.c
|
LIB_SOURCES = nostr_core/core.c nostr_core/core_relays.c nostr_core/nostr_crypto.c nostr_core/nostr_secp256k1.c nostr_core/nostr_aes.c nostr_core/nostr_chacha20.c nostr_websocket/nostr_websocket_openssl.c cjson/cJSON.c
|
||||||
LIB_OBJECTS = $(LIB_SOURCES:.c=.o)
|
LIB_OBJECTS = $(LIB_SOURCES:.c=.o)
|
||||||
ARM64_LIB_OBJECTS = $(LIB_SOURCES:.c=.arm64.o)
|
ARM64_LIB_OBJECTS = $(LIB_SOURCES:.c=.arm64.o)
|
||||||
|
|
||||||
|
|
61
build.sh
61
build.sh
|
@ -70,67 +70,6 @@ increment_version() {
|
||||||
# Create new git tag
|
# Create new git tag
|
||||||
if git tag "$NEW_VERSION" 2>/dev/null; then
|
if git tag "$NEW_VERSION" 2>/dev/null; then
|
||||||
print_success "Created new version tag: $NEW_VERSION"
|
print_success "Created new version tag: $NEW_VERSION"
|
||||||
|
|
||||||
# Generate version.h header file
|
|
||||||
cat > nostr_core/version.h << EOF
|
|
||||||
/*
|
|
||||||
* NOSTR Core Library - Auto-Generated Version Header
|
|
||||||
* DO NOT EDIT THIS FILE MANUALLY - Generated by build.sh
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NOSTR_VERSION_H
|
|
||||||
#define NOSTR_VERSION_H
|
|
||||||
|
|
||||||
#define VERSION_MAJOR ${MAJOR}
|
|
||||||
#define VERSION_MINOR ${MINOR}
|
|
||||||
#define VERSION_PATCH ${NEW_PATCH}
|
|
||||||
#define VERSION_STRING "${MAJOR}.${MINOR}.${NEW_PATCH}"
|
|
||||||
#define VERSION_TAG "${NEW_VERSION}"
|
|
||||||
|
|
||||||
/* Build information */
|
|
||||||
#define BUILD_DATE "$(date +%Y-%m-%d)"
|
|
||||||
#define BUILD_TIME "$(date +%H:%M:%S)"
|
|
||||||
#define BUILD_TIMESTAMP "$(date '+%Y-%m-%d %H:%M:%S')"
|
|
||||||
|
|
||||||
/* Git information */
|
|
||||||
#define GIT_HASH "$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')"
|
|
||||||
#define GIT_BRANCH "$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'unknown')"
|
|
||||||
|
|
||||||
/* Display versions */
|
|
||||||
#define VERSION_DISPLAY "${NEW_VERSION}"
|
|
||||||
#define VERSION_FULL_DISPLAY "${NEW_VERSION} ($(date '+%Y-%m-%d %H:%M:%S'), $(git rev-parse --short HEAD 2>/dev/null || echo 'unknown'))"
|
|
||||||
|
|
||||||
/* Version API functions */
|
|
||||||
const char* nostr_core_get_version(void);
|
|
||||||
const char* nostr_core_get_version_full(void);
|
|
||||||
const char* nostr_core_get_build_info(void);
|
|
||||||
|
|
||||||
#endif /* NOSTR_VERSION_H */
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Generate version.c implementation file
|
|
||||||
cat > nostr_core/version.c << EOF
|
|
||||||
/*
|
|
||||||
* NOSTR Core Library - Auto-Generated Version Implementation
|
|
||||||
* DO NOT EDIT THIS FILE MANUALLY - Generated by build.sh
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
const char* nostr_core_get_version(void) {
|
|
||||||
return VERSION_TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* nostr_core_get_version_full(void) {
|
|
||||||
return VERSION_FULL_DISPLAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* nostr_core_get_build_info(void) {
|
|
||||||
return "Built on " BUILD_DATE " at " BUILD_TIME " from commit " GIT_HASH " on branch " GIT_BRANCH;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
print_success "Generated version.h and version.c"
|
|
||||||
else
|
else
|
||||||
print_warning "Tag $NEW_VERSION already exists - using existing version"
|
print_warning "Tag $NEW_VERSION already exists - using existing version"
|
||||||
NEW_VERSION=$LATEST_TAG
|
NEW_VERSION=$LATEST_TAG
|
||||||
|
|
|
@ -1,34 +1,63 @@
|
||||||
/*
|
/*
|
||||||
* NOSTR Core Library - Version Test Example
|
* NOSTR Core Library - Version Test Example
|
||||||
* Demonstrates the automatic version increment system
|
* Simple version display using VERSION file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include "nostr_core.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() {
|
int main() {
|
||||||
printf("NOSTR Core Library Version Test\n");
|
printf("NOSTR Core Library Version Test\n");
|
||||||
printf("===============================\n\n");
|
printf("===============================\n\n");
|
||||||
|
|
||||||
// Display version information
|
// Initialize the library
|
||||||
printf("Version: %s\n", nostr_core_get_version());
|
if (nostr_init() != NOSTR_SUCCESS) {
|
||||||
printf("Full Version: %s\n", nostr_core_get_version_full());
|
printf("Failed to initialize NOSTR library\n");
|
||||||
printf("Build Info: %s\n", nostr_core_get_build_info());
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
printf("\nVersion Macros:\n");
|
// Display basic version information
|
||||||
printf("VERSION_MAJOR: %d\n", VERSION_MAJOR);
|
const char* version = get_version_from_file();
|
||||||
printf("VERSION_MINOR: %d\n", VERSION_MINOR);
|
printf("Library Version: %s\n", version);
|
||||||
printf("VERSION_PATCH: %d\n", VERSION_PATCH);
|
printf("Library Status: Initialized successfully\n");
|
||||||
printf("VERSION_STRING: %s\n", VERSION_STRING);
|
|
||||||
printf("VERSION_TAG: %s\n", VERSION_TAG);
|
|
||||||
|
|
||||||
printf("\nBuild Information:\n");
|
// Test basic functionality
|
||||||
printf("BUILD_DATE: %s\n", BUILD_DATE);
|
printf("\nLibrary Functionality Test:\n");
|
||||||
printf("BUILD_TIME: %s\n", BUILD_TIME);
|
unsigned char private_key[32];
|
||||||
printf("BUILD_TIMESTAMP: %s\n", BUILD_TIMESTAMP);
|
unsigned char public_key[32];
|
||||||
printf("GIT_HASH: %s\n", GIT_HASH);
|
|
||||||
printf("GIT_BRANCH: %s\n", GIT_BRANCH);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
BIN
libnostr_core.a
BIN
libnostr_core.a
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue