2021-12-04 21:53:56 +10:30
|
|
|
#include "config.h"
|
2021-09-16 14:30:42 +09:30
|
|
|
#include <ccan/compiler/compiler.h>
|
2023-06-02 12:06:04 +09:30
|
|
|
#include <common/configvar.h>
|
2021-12-04 21:53:56 +10:30
|
|
|
#include <common/version.h>
|
2015-08-08 20:45:49 +09:30
|
|
|
#include <stdio.h>
|
2021-09-16 14:30:42 +09:30
|
|
|
#include <stdlib.h>
|
2023-01-06 15:09:55 +01:00
|
|
|
#include <string.h>
|
2015-08-08 20:45:49 +09:30
|
|
|
|
2020-08-05 22:26:16 +08:00
|
|
|
/* Only common/version.c can safely include this. */
|
2020-10-22 10:21:08 +10:30
|
|
|
# include "version_gen.h"
|
2020-08-05 22:26:16 +08:00
|
|
|
|
2016-09-14 05:22:41 +09:30
|
|
|
const char *version(void)
|
|
|
|
{
|
|
|
|
return VERSION;
|
|
|
|
}
|
|
|
|
|
2023-06-02 12:06:04 +09:30
|
|
|
static char *version_and_exit(const void *unused UNUSED)
|
2015-08-08 20:45:49 +09:30
|
|
|
{
|
2018-04-03 14:16:06 +02:00
|
|
|
printf("%s\n", VERSION);
|
|
|
|
if (BUILD_FEATURES[0]) {
|
|
|
|
printf("Built with features: %s\n", BUILD_FEATURES);
|
|
|
|
}
|
2015-08-08 20:45:49 +09:30
|
|
|
exit(0);
|
|
|
|
}
|
2023-01-06 15:09:55 +01:00
|
|
|
|
2023-06-02 12:06:04 +09:30
|
|
|
void opt_register_version(void)
|
|
|
|
{
|
|
|
|
clnopt_noarg("--version|-V", OPT_EARLY|OPT_EXITS,
|
|
|
|
version_and_exit, NULL,
|
|
|
|
"Print version and exit");
|
|
|
|
}
|
|
|
|
|
2023-01-06 15:09:55 +01:00
|
|
|
static bool cmp_release_version(const char *version) {
|
|
|
|
if (version[0] != 'v')
|
|
|
|
return false;
|
|
|
|
return strspn(version+1, ".0123456789") == strlen(version+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Released versions are of form v[year].[month]?(.patch)* */
|
|
|
|
bool is_released_version(void)
|
|
|
|
{
|
|
|
|
return cmp_release_version(version());
|
|
|
|
}
|