1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
####################################################################################################################################
# PROJECT INFO MODULE
#
# Contains project name, version and format.
####################################################################################################################################
package pgBackRestDoc::ProjectInfo;
use strict;
use warnings FATAL => qw(all);
use Cwd qw(abs_path);
use Exporter qw(import);
our @EXPORT = qw();
use File::Basename qw(dirname);
# Project Name
#
# Defines the official project name, exe, and config file.
#-----------------------------------------------------------------------------------------------------------------------------------
push @EXPORT, qw(PROJECT_NAME);
push @EXPORT, qw(PROJECT_EXE);
push @EXPORT, qw(PROJECT_CONF);
# Project Version Number
#
# Defines the current version of the BackRest executable. The version number is used to track features but does not affect what
# repositories or manifests can be read - that's the job of the format number.
#-----------------------------------------------------------------------------------------------------------------------------------
push @EXPORT, qw(PROJECT_VERSION_MAJOR);
push @EXPORT, qw(PROJECT_VERSION_MINOR);
push @EXPORT, qw(PROJECT_VERSION_PATCH);
push @EXPORT, qw(PROJECT_VERSION_SUFFIX);
push @EXPORT, qw(PROJECT_VERSION);
# Repository Format Number
#
# Defines format for info and manifest files as well as on-disk structure. If this number changes then the repository will be
# invalid unless migration functions are written.
#-----------------------------------------------------------------------------------------------------------------------------------
push @EXPORT, qw(REPOSITORY_FORMAT);
####################################################################################################################################
# Load project info from src/version.h
####################################################################################################################################
require pgBackRestTest::Common::Storage;
require pgBackRestTest::Common::StoragePosix;
my $strProjectInfo = ${new pgBackRestTest::Common::Storage(
dirname(dirname(abs_path($0))), new pgBackRestTest::Common::StoragePosix())->get('src/version.h')};
foreach my $strLine (split("\n", $strProjectInfo))
{
if ($strLine =~ /^#define PROJECT_NAME/)
{
eval("use constant PROJECT_NAME => " . (split(" ", $strLine))[-1]);
}
elsif ($strLine =~ /^#define PROJECT_BIN/)
{
eval("use constant PROJECT_EXE => " . (split(" ", $strLine))[-1]);
eval("use constant PROJECT_CONF => " . (split(" ", $strLine))[-1] . " . \'.conf\'");
}
elsif ($strLine =~ /^#define PROJECT_VERSION_MAJOR/)
{
eval("use constant PROJECT_VERSION_MAJOR => \"" . (split(" ", $strLine))[-1] . "\"");
}
elsif ($strLine =~ /^#define PROJECT_VERSION_MINOR/)
{
eval("use constant PROJECT_VERSION_MINOR => " . (split(" ", $strLine))[-1]);
}
elsif ($strLine =~ /^#define PROJECT_VERSION_PATCH/)
{
eval("use constant PROJECT_VERSION_PATCH => " . (split(" ", $strLine))[-1]);
}
elsif ($strLine =~ /^#define PROJECT_VERSION_SUFFIX/)
{
eval("use constant PROJECT_VERSION_SUFFIX => " . (split(" ", $strLine))[-1]);
}
elsif ($strLine =~ /^#define REPOSITORY_FORMAT/)
{
eval("use constant REPOSITORY_FORMAT => " . (split(" ", $strLine))[-1]);
}
}
eval(
'use constant PROJECT_VERSION => "' . PROJECT_VERSION_MAJOR() . '.' . PROJECT_VERSION_MINOR() . '.' . PROJECT_VERSION_PATCH() .
PROJECT_VERSION_SUFFIX() . '"');
1;
|