1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-04-13 11:30:40 +02:00

Move configuration definition to src/build/config/config.yaml.

Moving to YAML allows the configuration data to be read by C programs.

Also go back to using YAML::XS since it is the only implementation that has proper boolean support.
This commit is contained in:
David Steele 2021-03-08 16:01:05 -05:00
parent 1dbb3bf50b
commit fe4ba455ed
13 changed files with 2067 additions and 3288 deletions

View File

@ -15,7 +15,7 @@ freebsd_12_task:
cpu: 4
memory: 4G
install_script: pkg install -y git postgresql-libpqxx pkgconf libxml2 gmake perl5 p5-YAML rsync
install_script: pkg install -y git postgresql-libpqxx pkgconf libxml2 gmake perl5 p5-YAML-LibYAML rsync
script:
- perl ${CIRRUS_WORKING_DIR}/test/test.pl --no-gen --make-cmd=gmake --vm=none --vm-max=2 --no-coverage --no-valgrind --module=command --test=backup
@ -36,7 +36,7 @@ macos_catalina_task:
install_script:
- brew install -q openssl@1.1 libpq libxml2 cpanm
- cpanm --local-lib=/usr/local/opt/perl5 install YAML
- cpanm --local-lib=/usr/local/opt/perl5 install YAML::XS
script:
- ${CIRRUS_WORKING_DIR}/test/test.pl --no-gen --vm=none --vm-max=2 --no-coverage --no-valgrind --module=command --test=backup

View File

@ -170,13 +170,13 @@ Options can be added to a command or multiple commands. Options can be configura
To add an option, two files need be to be modified:
- `build/lib/pgBackRestBuild/Config/Data.pm`
- `src/build/config/config.yaml`
- `doc/xml/reference.xml`
These files are discussed in the following sections.
### Data.pm
### `src/build/config/config.yaml`
There is a detailed comment at the top of this file on the configuration definitions which one can refer to in determining how to define the rules for the option.

View File

@ -449,9 +449,9 @@ sub buildConfigParse
my @stryOptionName = ($strOption);
if (defined($rhOption->{&CFGDEF_NAME_ALT}))
if (defined($rhOption->{&CFGDEF_DEPRECATE}))
{
foreach my $strOptionNameAlt (sort(keys(%{$rhOption->{&CFGDEF_NAME_ALT}})))
foreach my $strOptionNameAlt (sort(keys(%{$rhOption->{&CFGDEF_DEPRECATE}})))
{
push(@stryOptionName, $strOptionNameAlt);
}
@ -467,7 +467,7 @@ sub buildConfigParse
for (my $iOptionNameIdx = 0; $iOptionNameIdx < @stryOptionName; $iOptionNameIdx++)
{
my $strOptionName = $stryOptionName[$iOptionNameIdx];
my $rhNameAlt = $rhOption->{&CFGDEF_NAME_ALT}{$strOptionName};
my $rhNameAlt = $rhOption->{&CFGDEF_DEPRECATE}{$strOptionName};
# Skip alt name if it is not valid for this option index
if ($iOptionNameIdx > 0 && defined($rhNameAlt->{&CFGDEF_INDEX}) && $rhNameAlt->{&CFGDEF_INDEX} != $iOptionIdx)

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,8 @@ sub errorDefineLoad
{
my $strErrorYaml = shift;
require YAML::Any;
YAML::Any->import(qw(Load));
require YAML::XS;
YAML::XS->import(qw(Load));
$rhErrorDefine = Load($strErrorYaml);
}

View File

@ -325,11 +325,11 @@ sub process
$$oCommandOption{&CONFIG_HELP_NAME} = $oOptionDoc->paramGet('name');
# Generate a list of alternate names
if (defined($rhConfigDefine->{$strOption}{&CFGDEF_NAME_ALT}))
if (defined($rhConfigDefine->{$strOption}{&CFGDEF_DEPRECATE}))
{
my $rhNameAlt = {};
foreach my $strNameAlt (sort(keys(%{$rhConfigDefine->{$strOption}{&CFGDEF_NAME_ALT}})))
foreach my $strNameAlt (sort(keys(%{$rhConfigDefine->{$strOption}{&CFGDEF_DEPRECATE}})))
{
$strNameAlt =~ s/\?//g;

View File

@ -193,14 +193,14 @@
<p> To add an option, two files need be to be modified:</p>
<list>
<list-item><file>build/lib/pgBackRestBuild/Config/Data.pm</file></list-item>
<list-item><file>src/build/config/config.yaml</file></list-item>
<list-item><file>doc/xml/reference.xml</file></list-item>
</list>
<p>These files are discussed in the following sections.</p>
<section id="data-file">
<title>Data.pm</title>
<title><file>src/build/config/config.yaml</file></title>
<p>There is a detailed comment at the top of this file on the configuration definitions which one can refer to in determining how to define the rules for the option.</p>

1981
src/build/config/config.yaml Normal file

File diff suppressed because it is too large Load Diff

4
test/Vagrantfile vendored
View File

@ -136,7 +136,7 @@ Vagrant.configure(2) do |config|
#-----------------------------------------------------------------------------------------------------------------------
echo 'Install Build Tools' && date
pkg install -y git postgresql-libpqxx pkgconf libxml2 gmake perl5 p5-YAML rsync
pkg install -y git postgresql-libpqxx pkgconf libxml2 gmake perl5 p5-YAML-LibYAML rsync
#-----------------------------------------------------------------------------------------------------------------------
echo 'Build End' && date
@ -149,7 +149,7 @@ Vagrant.configure(2) do |config|
#-------------------------------------------------------------------------------------------------------------------------------
# mkdir ~/homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C ~/homebrew
# ~/homebrew/bin/brew install -q libpq libxml2 cpanm
# ~/homebrew/bin/cpanm --force --local-lib=~/homebrew/perl5 install YAML XML::Checker::Parser
# ~/homebrew/bin/cpanm --force --local-lib=~/homebrew/perl5 install YAML::XS XML::Checker::Parser
#
# export LDFLAGS="-L${HOME?}/homebrew/opt/openssl@1.1/lib -L${HOME?}/homebrew/opt/libpq/lib -L${HOME?}/homebrew/opt/libxml2/lib"
# export CPPFLAGS="-I${HOME?}/homebrew/opt/openssl@1.1/include -I/${HOME?}/homebrew/opt/libpq/include"

View File

@ -27,8 +27,8 @@ sub codeCountScan
my $strBasePath = shift;
# Load YAML
require YAML::Any;
YAML::Any->import(qw(Load Dump));
require YAML::XS;
YAML::XS->import(qw(Load Dump));
my $hCodeCount = {};

View File

@ -301,8 +301,8 @@ sub containerBuild
$oStorageDocker->pathCreate($strTempPath, {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
# Load container definitions from yaml
require YAML::Any;
YAML::Any->import(qw(Load));
require YAML::XS;
YAML::XS->import(qw(Load));
$hContainerCache = Load(${$oStorageDocker->get($oStorageDocker->pathGet('test/container.yaml'))});

View File

@ -92,8 +92,8 @@ sub testDefLoad
my $strDefineYaml = shift;
# Load test definitions from yaml
require YAML::Any;
YAML::Any->import(qw(Load));
require YAML::XS;
YAML::XS->import(qw(Load));
my $hTestDef = Load($strDefineYaml);

View File

@ -572,7 +572,8 @@ eval
# Auto-generate C files
#-----------------------------------------------------------------------------------------------------------------------
if (!$bSmart || grep(/^build\//, @stryModifiedList) || grep(/^doc\/xml\/reference\.xml/, @stryModifiedList))
if (!$bSmart || grep(/^build\//, @stryModifiedList) || grep(/^doc\/xml\/reference\.xml/, @stryModifiedList) ||
grep(/^src\/build\/config\/config\.yaml/, @stryModifiedList))
{
errorDefineLoad(${$oStorageBackRest->get("build/error.yaml")});