mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Compute fallback version string at compile time
This commit is contained in:
@@ -9,9 +9,9 @@
|
|||||||
#ifndef EXTERN_VERSION_H
|
#ifndef EXTERN_VERSION_H
|
||||||
#define EXTERN_VERSION_H
|
#define EXTERN_VERSION_H
|
||||||
|
|
||||||
#define PACKAGE_VERSION_MAJOR (0)
|
#define PACKAGE_VERSION_MAJOR 0
|
||||||
#define PACKAGE_VERSION_MINOR (4)
|
#define PACKAGE_VERSION_MINOR 4
|
||||||
#define PACKAGE_VERSION_PATCH (2)
|
#define PACKAGE_VERSION_PATCH 2
|
||||||
|
|
||||||
const char *get_package_version_string(void);
|
const char *get_package_version_string(void);
|
||||||
|
|
||||||
|
|||||||
@@ -9,17 +9,17 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "helpers.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
const char *get_package_version_string(void)
|
const char *get_package_version_string(void)
|
||||||
{
|
{
|
||||||
static char s[50];
|
// The following conditional should be simplified by the compiler.
|
||||||
|
|
||||||
/* The following conditional should be simplified by the compiler. */
|
|
||||||
if (strlen(BUILD_VERSION_STRING) == 0) {
|
if (strlen(BUILD_VERSION_STRING) == 0) {
|
||||||
snprintf(s, sizeof(s), "v%d.%d.%d", PACKAGE_VERSION_MAJOR,
|
// Fallback if version string can't be obtained from Git
|
||||||
PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCH);
|
return "v" EXPAND_AND_STR(PACKAGE_VERSION_MAJOR)
|
||||||
return s;
|
"." EXPAND_AND_STR(PACKAGE_VERSION_MINOR)
|
||||||
|
"." EXPAND_AND_STR(PACKAGE_VERSION_PATCH);
|
||||||
} else {
|
} else {
|
||||||
return BUILD_VERSION_STRING;
|
return BUILD_VERSION_STRING;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user