mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-03 14:52:21 +02:00
Automatically create PostgreSQL version interfaces.
Maintaining the version interfaces was complicated by the fact that each interface needed to be in separate compilation unit to avoid type conflicts. This also meant that various build/test files needed to be updated to add the new interfaces. Solve these problems by auto-generating all the interfaces into a single file. This is made possible by parsing defines and types out of the header files and creating macros to rename the types. At the end of the version interface everything is undef'd. Another benefit is that the auto-generated interfaces can be static and included directly into postgres/interface.c. Since some code generation is now always required for tests, change --no-gen to --min-gen in test.pl. It would also make sense to auto-generate the version defines in postgres/version.h, but that will be left for a future commit.
This commit is contained in:
parent
b8fc20d5b8
commit
f92ce674f7
13
.cirrus.yml
13
.cirrus.yml
@ -35,10 +35,10 @@ freebsd_12_task:
|
||||
cpu: 4
|
||||
memory: 4G
|
||||
|
||||
install_script: pkg install -y bash git postgresql-libpqxx pkgconf libxml2 gmake perl5 libyaml p5-YAML-LibYAML rsync
|
||||
install_script: pkg install -y bash git postgresql-libpqxx pkgconf libxml2 gmake perl5 libyaml p5-YAML-LibYAML rsync meson
|
||||
|
||||
script:
|
||||
- cd .. && 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
|
||||
- cd .. && perl ${CIRRUS_WORKING_DIR}/test/test.pl --min-gen --make-cmd=gmake --vm=none --vm-max=2 --no-coverage --no-valgrind --module=command --test=backup
|
||||
|
||||
debug_script:
|
||||
- ls -lah ${CIRRUS_WORKING_DIR}
|
||||
@ -51,10 +51,10 @@ freebsd_13_task:
|
||||
cpu: 4
|
||||
memory: 4G
|
||||
|
||||
install_script: pkg install -y bash git postgresql-libpqxx pkgconf libxml2 gmake perl5 libyaml p5-YAML-LibYAML rsync
|
||||
install_script: pkg install -y bash git postgresql-libpqxx pkgconf libxml2 gmake perl5 libyaml p5-YAML-LibYAML rsync meson
|
||||
|
||||
script:
|
||||
- cd .. && 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
|
||||
- cd .. && perl ${CIRRUS_WORKING_DIR}/test/test.pl --min-gen --make-cmd=gmake --vm=none --vm-max=2 --no-coverage --no-valgrind --module=command --test=backup
|
||||
|
||||
debug_script:
|
||||
- ls -lah ${CIRRUS_WORKING_DIR}
|
||||
@ -69,13 +69,14 @@ macos_monterey_task:
|
||||
LDFLAGS: -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/libpq/lib -L/usr/local/opt/libxml2/lib -L/usr/local/opt/libyaml/lib
|
||||
CPPFLAGS: -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/libpq/include -I/usr/local/opt/libxml2/include/libxml2 -I/usr/local/opt/libyaml/include
|
||||
PERL5LIB: /usr/local/opt/perl5/lib/perl5
|
||||
PKG_CONFIG_PATH: /usr/local/opt/libpq/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig
|
||||
|
||||
install_script:
|
||||
- brew install -q openssl@1.1 libpq libxml2 libyaml cpanm
|
||||
- brew install -q pkg-config openssl@1.1 libpq libxml2 libyaml cpanm meson
|
||||
- cpanm --local-lib=/usr/local/opt/perl5 install YAML::XS
|
||||
|
||||
script:
|
||||
- cd .. && ${CIRRUS_WORKING_DIR}/test/test.pl --no-gen --vm=none --vm-max=2 --no-coverage --no-valgrind --module=command --test=backup
|
||||
- cd .. && ${CIRRUS_WORKING_DIR}/test/test.pl --min-gen --vm=none --vm-max=2 --no-coverage --no-valgrind --module=command --test=backup
|
||||
|
||||
debug_script:
|
||||
- ls -lah ${CIRRUS_WORKING_DIR}
|
||||
|
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -94,8 +94,8 @@ jobs:
|
||||
|
||||
run: |
|
||||
git config --global --add safe.directory ${GITHUB_WORKSPACE?}/pgbackrest
|
||||
${GITHUB_WORKSPACE?}/pgbackrest/test/test.pl --vm=none --no-gen --no-valgrind --no-coverage --no-optimize --build-max=2 --module=command --test=backup
|
||||
${GITHUB_WORKSPACE?}/pgbackrest/test/test.pl --vm=none --no-gen --no-valgrind --no-coverage --no-optimize --build-max=2 --module=postgres --test=interface
|
||||
${GITHUB_WORKSPACE?}/pgbackrest/test/test.pl --vm=none --min-gen --no-valgrind --no-coverage --no-optimize --build-max=2 --module=command --test=backup
|
||||
${GITHUB_WORKSPACE?}/pgbackrest/test/test.pl --vm=none --min-gen --no-valgrind --no-coverage --no-optimize --build-max=2 --module=postgres --test=interface
|
||||
|
||||
codeql:
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -56,6 +56,17 @@
|
||||
</release-improvement-list>
|
||||
|
||||
<release-development-list>
|
||||
<release-item>
|
||||
<github-pull-request id="1771"/>
|
||||
|
||||
<release-item-contributor-list>
|
||||
<release-item-contributor id="david.steele"/>
|
||||
<release-item-reviewer id="stephen.frost"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Automatically create <postgres/> version interfaces.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<github-pull-request id="1749"/>
|
||||
|
||||
|
1
src/.gitignore
vendored
1
src/.gitignore
vendored
@ -6,4 +6,5 @@ autom4te.cache
|
||||
/Makefile
|
||||
/build.auto.h
|
||||
/pgbackrest
|
||||
/postgres/interface.auto.c.inc
|
||||
/build-*
|
||||
|
@ -198,7 +198,6 @@ BUILDDIR=.build
|
||||
####################################################################################################################################
|
||||
# Compile and link pgbackrest
|
||||
####################################################################################################################################
|
||||
SRCS_PGBACKREST := $(wildcard postgres/interface/v*.c $(VPATH)/postgres/interface/v*.c)
|
||||
OBJS_PGBACKREST = $(patsubst %.c,$(BUILDDIR)/%.o,$(SRCS_BUILD) $(SRCS_PGBACKREST) $(SRCS) main.c)
|
||||
|
||||
pgbackrest: $(OBJS_PGBACKREST)
|
||||
@ -255,6 +254,24 @@ build-help: $(OBJS_BUILD_HELP) build/config/config.yaml build/help/help.xml
|
||||
command/help/help.auto.c.inc: build-help
|
||||
./build-help $(VPATH)
|
||||
|
||||
####################################################################################################################################
|
||||
# Compile and link postgres interface generator
|
||||
####################################################################################################################################
|
||||
SRCS_BUILD_POSTGRES = \
|
||||
build/common/render.c \
|
||||
build/common/yaml.c \
|
||||
build/postgres/parse.c \
|
||||
build/postgres/render.c \
|
||||
build/postgres/main.c
|
||||
|
||||
OBJS_BUILD_POSTGRES = $(patsubst %.c,$(BUILDDIR)/%.o,$(SRCS_BUILD) $(SRCS_BUILD_POSTGRES))
|
||||
|
||||
build-postgres: $(OBJS_BUILD_POSTGRES) build/postgres/postgres.yaml
|
||||
$(CC) -o build-postgres $(OBJS_BUILD_POSTGRES) $(LDFLAGS) $(LIBS) $(LIBS_BUILD)
|
||||
|
||||
postgres/interface.auto.c.inc: build-postgres
|
||||
./build-postgres $(VPATH)
|
||||
|
||||
####################################################################################################################################
|
||||
# Installation. DESTDIR can be used to modify the install location.
|
||||
####################################################################################################################################
|
||||
@ -276,7 +293,7 @@ uninstall:
|
||||
# Clean build files and executable created by make
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)
|
||||
rm -f pgbackrest build-config build-error build-help command/help/help.auto.c.inc
|
||||
rm -f pgbackrest build-config build-error build-help build-postgres command/help/help.auto.c.inc postgres/interface.auto.c.inc
|
||||
|
||||
.PHONY = clean-all
|
||||
|
||||
@ -288,6 +305,7 @@ clean-all: clean
|
||||
# Special per-object flags
|
||||
####################################################################################################################################
|
||||
$(BUILDDIR)/postgres/interface/page.o: CFLAGS += @CFLAGS_PAGE_CHECKSUM@
|
||||
$(BUILDDIR)/postgres/interface.o: postgres/interface.auto.c.inc
|
||||
$(BUILDDIR)/main.o: command/help/help.auto.c.inc
|
||||
|
||||
####################################################################################################################################
|
||||
|
48
src/build/postgres/main.c
Normal file
48
src/build/postgres/main.c
Normal file
@ -0,0 +1,48 @@
|
||||
/***********************************************************************************************************************************
|
||||
Auto-Generate PostgreSQL Interface
|
||||
***********************************************************************************************************************************/
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common/log.h"
|
||||
#include "storage/posix/storage.h"
|
||||
|
||||
#include "build/postgres/parse.h"
|
||||
#include "build/postgres/render.h"
|
||||
|
||||
int
|
||||
main(int argListSize, const char *argList[])
|
||||
{
|
||||
// Check parameters
|
||||
CHECK(ParamInvalidError, argListSize <= 2, "only one parameter allowed");
|
||||
|
||||
// Initialize logging
|
||||
logInit(logLevelWarn, logLevelError, logLevelOff, false, 0, 1, false);
|
||||
|
||||
// Get current working directory
|
||||
char currentWorkDir[1024];
|
||||
THROW_ON_SYS_ERROR(getcwd(currentWorkDir, sizeof(currentWorkDir)) == NULL, FormatError, "unable to get cwd");
|
||||
|
||||
// Get repo path (cwd if it was not passed)
|
||||
const String *pathRepo = strPath(STR(currentWorkDir));
|
||||
String *const pathOut = strCatZ(strNew(), currentWorkDir);
|
||||
|
||||
if (argListSize >= 2)
|
||||
{
|
||||
const String *const pathArg = STR(argList[1]);
|
||||
|
||||
if (strBeginsWith(pathArg, FSLASH_STR))
|
||||
pathRepo = strPath(pathArg);
|
||||
else
|
||||
{
|
||||
pathRepo = strPathAbsolute(pathArg, STR(currentWorkDir));
|
||||
strCatZ(pathOut, "/src");
|
||||
}
|
||||
}
|
||||
|
||||
// Render postgres
|
||||
const Storage *const storageRepo = storagePosixNewP(pathRepo);
|
||||
const Storage *const storageBuild = storagePosixNewP(pathOut, .write = true);
|
||||
bldPgRender(storageBuild, bldPgParse(storageRepo));
|
||||
|
||||
return 0;
|
||||
}
|
199
src/build/postgres/parse.c
Normal file
199
src/build/postgres/parse.c
Normal file
@ -0,0 +1,199 @@
|
||||
/***********************************************************************************************************************************
|
||||
Parse PostgreSQL Interface Yaml
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#include "storage/posix/storage.h"
|
||||
|
||||
#include "build/common/yaml.h"
|
||||
#include "build/postgres/parse.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Parse version list
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct BldPgVersionRaw
|
||||
{
|
||||
const String *version; // See BldPgVersion for comments
|
||||
bool release;
|
||||
} BldPgVersionRaw;
|
||||
|
||||
static List *
|
||||
bldPgVersionList(Yaml *const yaml)
|
||||
{
|
||||
List *const result = lstNewP(sizeof(BldPgVersion), .comparator = lstComparatorStr);
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
YamlEvent pgDef = yamlEventNextCheck(yaml, yamlEventTypeScalar);
|
||||
|
||||
// Parse version list
|
||||
if (strEqZ(pgDef.value, "version"))
|
||||
{
|
||||
yamlEventNextCheck(yaml, yamlEventTypeSeqBegin);
|
||||
|
||||
YamlEvent ver = yamlEventNext(yaml);
|
||||
|
||||
do
|
||||
{
|
||||
BldPgVersionRaw pgRaw = {.release = true};
|
||||
|
||||
if (ver.type == yamlEventTypeMapBegin)
|
||||
{
|
||||
pgRaw.version = yamlEventNextCheck(yaml, yamlEventTypeScalar).value;
|
||||
yamlEventNextCheck(yaml, yamlEventTypeMapBegin);
|
||||
|
||||
YamlEvent verDef = yamlEventNextCheck(yaml, yamlEventTypeScalar);
|
||||
YamlEvent verDefVal = yamlEventNextCheck(yaml, yamlEventTypeScalar);
|
||||
|
||||
// Get release setting
|
||||
if (strEqZ(verDef.value, "release"))
|
||||
{
|
||||
pgRaw.release = yamlBoolParse(verDefVal);
|
||||
}
|
||||
else
|
||||
THROW_FMT(FormatError, "unknown postgres definition '%s'", strZ(verDef.value));
|
||||
|
||||
yamlEventNextCheck(yaml, yamlEventTypeMapEnd);
|
||||
yamlEventNextCheck(yaml, yamlEventTypeMapEnd);
|
||||
}
|
||||
else
|
||||
pgRaw.version = ver.value;
|
||||
|
||||
// Add to list
|
||||
MEM_CONTEXT_BEGIN(lstMemContext(result))
|
||||
{
|
||||
lstAdd(
|
||||
result,
|
||||
&(BldPgVersion)
|
||||
{
|
||||
.version = strDup(pgRaw.version),
|
||||
.release = pgRaw.release,
|
||||
});
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
|
||||
ver = yamlEventNext(yaml);
|
||||
}
|
||||
while (ver.type != yamlEventTypeSeqEnd);
|
||||
}
|
||||
else
|
||||
THROW_FMT(FormatError, "unknown postgres definition '%s'", strZ(pgDef.value));
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Parse defines from header
|
||||
***********************************************************************************************************************************/
|
||||
static StringList *
|
||||
bldPgParseDefine(const String *const header)
|
||||
{
|
||||
const StringList *const lineList = strLstNewSplitZ(header, "\n");
|
||||
StringList *const result = strLstNew();
|
||||
|
||||
// Scan all lines
|
||||
for (unsigned int lineIdx = 0; lineIdx < strLstSize(lineList); lineIdx++)
|
||||
{
|
||||
const String *const line = strTrim(strLstGet(lineList, lineIdx));
|
||||
|
||||
// If define get name
|
||||
if (strBeginsWithZ(line, "#define"))
|
||||
{
|
||||
const String *const defineToken = strTrim(strLstGet(strLstNewSplitZ(line, " "), 1));
|
||||
|
||||
if (strEmpty(defineToken))
|
||||
THROW_FMT(FormatError, "unable to find define -- are there extra spaces on '%s'", strZ(line));
|
||||
|
||||
// The define might be followed by a ( or tab
|
||||
const StringList *defineList = strLstNewSplitZ(defineToken, "(");
|
||||
const String *define;
|
||||
|
||||
if (strLstSize(defineList) > 1)
|
||||
define = strTrim(strLstGet(defineList, 0));
|
||||
else
|
||||
{
|
||||
defineList = strLstNewSplitZ(defineToken, "\t");
|
||||
define = strTrim(strLstGet(defineList, 0));
|
||||
}
|
||||
|
||||
strLstAddIfMissing(result, define);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Parse types from header
|
||||
***********************************************************************************************************************************/
|
||||
static StringList *
|
||||
bldPgParseType(const String *const header)
|
||||
{
|
||||
const StringList *const lineList = strLstNewSplitZ(header, "\n");
|
||||
StringList *const result = strLstNew();
|
||||
bool scanEnum = false;
|
||||
|
||||
// Scan all lines
|
||||
for (unsigned int lineIdx = 0; lineIdx < strLstSize(lineList); lineIdx++)
|
||||
{
|
||||
const String *const line = strTrim(strLstGet(lineList, lineIdx));
|
||||
const StringList *const tokenList = strLstNewSplitZ(line, " ");
|
||||
const String *const tokenFirst = strLstGet(tokenList, 0);
|
||||
|
||||
// If typedef
|
||||
if (strEqZ(tokenFirst, "typedef"))
|
||||
{
|
||||
const String *const tokenType = strLstGet(tokenList, 1);
|
||||
|
||||
// If struct/enum continue scanning to get the name/enums
|
||||
if (strEqZ(tokenType, "struct") || strEqZ(tokenType, "enum"))
|
||||
{
|
||||
scanEnum = strEqZ(tokenType, "enum");
|
||||
}
|
||||
// Else add the type name
|
||||
else
|
||||
strLstAddIfMissing(result, strLstGet(strLstNewSplitZ(strLstGet(tokenList, strLstSize(tokenList) - 1), ";"), 0));
|
||||
}
|
||||
// End scanning of struct/enum and get name
|
||||
else if (strEqZ(tokenFirst, "}"))
|
||||
{
|
||||
strLstAddIfMissing(result, strLstGet(strLstNewSplitZ(strLstGet(tokenList, strLstSize(tokenList) - 1), ";"), 0));
|
||||
scanEnum = false;
|
||||
}
|
||||
// Add enums to type list
|
||||
else if (scanEnum && !strEqZ(tokenFirst, "{"))
|
||||
strLstAddIfMissing(result, strLstGet(strLstNewSplitZ(strLstGet(tokenList, 0), ","), 0));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
BldPg
|
||||
bldPgParse(const Storage *const storageRepo)
|
||||
{
|
||||
// Parse types from version.vendor.h
|
||||
const String *const vendorHeader = strNewBuf(
|
||||
storageGetP(storageNewReadP(storageRepo, STRDEF("src/postgres/interface/version.vendor.h"))));
|
||||
StringList *const typeList = bldPgParseType(vendorHeader);
|
||||
strLstSort(typeList, sortOrderAsc);
|
||||
|
||||
// Parse defines from version.vendor.h
|
||||
StringList *const defineList = bldPgParseDefine(vendorHeader);
|
||||
strLstAddZ(defineList, "CATALOG_VERSION_NO_MAX");
|
||||
strLstAddZ(defineList, "PG_VERSION");
|
||||
strLstSort(defineList, sortOrderAsc);
|
||||
|
||||
// Parse defines from version.intern.h
|
||||
const StringList *const functionList = bldPgParseDefine(
|
||||
strNewBuf(storageGetP(storageNewReadP(storageRepo, STRDEF("src/postgres/interface/version.intern.h")))));
|
||||
|
||||
// Initialize yaml
|
||||
Yaml *const yaml = yamlNew(storageGetP(storageNewReadP(storageRepo, STRDEF("src/build/postgres/postgres.yaml"))));
|
||||
yamlEventNextCheck(yaml, yamlEventTypeMapBegin);
|
||||
|
||||
// Parse postgres
|
||||
return (BldPg){.pgList = bldPgVersionList(yaml), .typeList = typeList, .defineList = defineList, .functionList = functionList};
|
||||
}
|
32
src/build/postgres/parse.h
Normal file
32
src/build/postgres/parse.h
Normal file
@ -0,0 +1,32 @@
|
||||
/***********************************************************************************************************************************
|
||||
Parse PostgreSQL Interface Yaml
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef BUILD_POSTRES_PARSE_H
|
||||
#define BUILD_POSTRES_PARSE_H
|
||||
|
||||
#include "common/type/string.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Types
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct BldPgVersion
|
||||
{
|
||||
const String *version; // Version
|
||||
bool release; // Is this a released version?
|
||||
} BldPgVersion;
|
||||
|
||||
typedef struct BldPg
|
||||
{
|
||||
const List *pgList; // Supported PostgreSQL versions
|
||||
const StringList *typeList; // PostgreSQL interface types
|
||||
const StringList *defineList; // PostgreSQL interface defines
|
||||
const StringList *functionList; // Functions defined by macros
|
||||
} BldPg;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
// Parse postgres.yaml
|
||||
BldPg bldPgParse(const Storage *const storageRepo);
|
||||
|
||||
#endif
|
21
src/build/postgres/postgres.yaml
Normal file
21
src/build/postgres/postgres.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
# Supported PostgreSQL Versions
|
||||
#
|
||||
# Version interfaces are auto-generated to src/postgres/interface.auto.c.inc.
|
||||
#
|
||||
# - 'version' contains a list of all supported versions
|
||||
# - For a specific version, 'release' marks it as not released (i.e. this should always be false when used)
|
||||
version:
|
||||
- 9.0
|
||||
- 9.1
|
||||
- 9.2
|
||||
- 9.3
|
||||
- 9.4
|
||||
- 9.5
|
||||
- 9.6
|
||||
- 10
|
||||
- 11
|
||||
- 12
|
||||
- 13
|
||||
- 14
|
||||
- 15:
|
||||
release: false
|
142
src/build/postgres/render.c
Normal file
142
src/build/postgres/render.c
Normal file
@ -0,0 +1,142 @@
|
||||
/***********************************************************************************************************************************
|
||||
Render PostgreSQL Interface
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#include "storage/posix/storage.h"
|
||||
|
||||
#include "build/common/render.h"
|
||||
#include "build/postgres/render.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Render interface.auto.c.inc
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_MODULE "postgres"
|
||||
#define PG_AUTO_COMMENT "PostgreSQL Interface"
|
||||
|
||||
static void
|
||||
bldPgRenderInterfaceAutoC(const Storage *const storageRepo, const BldPg bldPg)
|
||||
{
|
||||
String *pg = bldHeader(PG_MODULE, PG_AUTO_COMMENT);
|
||||
|
||||
// PostgreSQL interfaces
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
for (unsigned int pgIdx = lstSize(bldPg.pgList) - 1; pgIdx < lstSize(bldPg.pgList); pgIdx--)
|
||||
{
|
||||
const BldPgVersion *const pgVersion = lstGet(bldPg.pgList, pgIdx);
|
||||
const char *const versionNoDot = strZ(strLstJoin(strLstNewSplitZ(pgVersion->version, "."), ""));
|
||||
|
||||
strCatFmt(
|
||||
pg,
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL %s interface\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"#define PG_VERSION PG_VERSION_%s\n"
|
||||
"\n",
|
||||
strZ(pgVersion->version), versionNoDot);
|
||||
|
||||
for (unsigned int typeIdx = 0; typeIdx < strLstSize(bldPg.typeList); typeIdx++)
|
||||
{
|
||||
const String *const type = strLstGet(bldPg.typeList, typeIdx);
|
||||
|
||||
strCat(pg, bldDefineRender(type, strNewFmt("%s_%s", strZ(type), versionNoDot)));
|
||||
strCatChr(pg, '\n');
|
||||
}
|
||||
|
||||
if (!pgVersion->release)
|
||||
{
|
||||
strCatZ(
|
||||
pg,
|
||||
"\n"
|
||||
"#define CATALOG_VERSION_NO_MAX\n");
|
||||
}
|
||||
|
||||
strCatZ(
|
||||
pg,
|
||||
"\n"
|
||||
"#include \"postgres/interface/version.intern.h\"\n"
|
||||
"\n");
|
||||
|
||||
for (unsigned int functionIdx = 0; functionIdx < strLstSize(bldPg.functionList); functionIdx++)
|
||||
strCatFmt(pg, "%s(%s);\n", strZ(strLstGet(bldPg.functionList, functionIdx)), versionNoDot);
|
||||
|
||||
strCatChr(pg, '\n');
|
||||
|
||||
for (unsigned int typeIdx = 0; typeIdx < strLstSize(bldPg.typeList); typeIdx++)
|
||||
strCatFmt(pg, "#undef %s\n", strZ(strLstGet(bldPg.typeList, typeIdx)));
|
||||
|
||||
strCatChr(pg, '\n');
|
||||
|
||||
for (unsigned int defineIdx = 0; defineIdx < strLstSize(bldPg.defineList); defineIdx++)
|
||||
strCatFmt(pg, "#undef %s\n", strZ(strLstGet(bldPg.defineList, defineIdx)));
|
||||
|
||||
strCatChr(pg, '\n');
|
||||
|
||||
for (unsigned int functionIdx = 0; functionIdx < strLstSize(bldPg.functionList); functionIdx++)
|
||||
strCatFmt(pg, "#undef %s\n", strZ(strLstGet(bldPg.functionList, functionIdx)));
|
||||
}
|
||||
|
||||
// Interface struct
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
strCatFmt(
|
||||
pg,
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL interface struct\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"static const PgInterface pgInterface[] =\n"
|
||||
"{\n");
|
||||
|
||||
for (unsigned int pgIdx = lstSize(bldPg.pgList) - 1; pgIdx < lstSize(bldPg.pgList); pgIdx--)
|
||||
{
|
||||
const BldPgVersion *const pgVersion = lstGet(bldPg.pgList, pgIdx);
|
||||
const char *const versionNoDot = strZ(strLstJoin(strLstNewSplitZ(pgVersion->version, "."), ""));
|
||||
|
||||
strCatFmt(
|
||||
pg,
|
||||
" {\n"
|
||||
" .version = PG_VERSION_%s,\n"
|
||||
"\n",
|
||||
versionNoDot);
|
||||
|
||||
for (unsigned int functionIdx = 0; functionIdx < strLstSize(bldPg.functionList); functionIdx++)
|
||||
{
|
||||
// Convert define name to function name
|
||||
const StringList *const nameList = strLstNewSplitZ(strLstGet(bldPg.functionList, functionIdx), "_");
|
||||
String *const name = strNew();
|
||||
|
||||
for (unsigned int nameIdx = 0; nameIdx < strLstSize(nameList); nameIdx++)
|
||||
{
|
||||
String *const namePart = strLower(strLstGet(nameList, nameIdx));
|
||||
|
||||
if (nameIdx != 0)
|
||||
strFirstUpper(namePart);
|
||||
|
||||
strCat(name, namePart);
|
||||
}
|
||||
|
||||
strCatFmt(
|
||||
pg,
|
||||
" .%s = %s%s,\n",
|
||||
strZ(strFirstLower(strSub(name, sizeof("pgInterface") - 1))), strZ(name), versionNoDot);
|
||||
}
|
||||
|
||||
strCatZ(
|
||||
pg,
|
||||
" },\n");
|
||||
}
|
||||
|
||||
strCatFmt(
|
||||
pg,
|
||||
"};\n");
|
||||
|
||||
bldPut(storageRepo, "postgres/interface.auto.c.inc", BUFSTR(pg));
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
void
|
||||
bldPgRender(const Storage *const storageRepo, const BldPg bldPg)
|
||||
{
|
||||
bldPgRenderInterfaceAutoC(storageRepo, bldPg);
|
||||
}
|
15
src/build/postgres/render.h
Normal file
15
src/build/postgres/render.h
Normal file
@ -0,0 +1,15 @@
|
||||
/***********************************************************************************************************************************
|
||||
Render PostgreSQL Interface
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef BUILD_POSTGRES_RENDER_H
|
||||
#define BUILD_POSTGRES_RENDER_H
|
||||
|
||||
#include "build/postgres/parse.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
// Render auto-generated PostgreSQL files
|
||||
void bldPgRender(const Storage *const storageRepo, const BldPg bldPg);
|
||||
|
||||
#endif
|
@ -141,6 +141,31 @@ subdir('command/help')
|
||||
|
||||
alias_target('build-help', help_auto_c_inc)
|
||||
|
||||
####################################################################################################################################
|
||||
# Build postgres target
|
||||
####################################################################################################################################
|
||||
src_build_postgres = [
|
||||
'build/common/render.c',
|
||||
'build/common/yaml.c',
|
||||
'build/postgres/main.c',
|
||||
'build/postgres/parse.c',
|
||||
'build/postgres/render.c',
|
||||
]
|
||||
|
||||
build_postgres = executable(
|
||||
'build-postgres',
|
||||
src_common,
|
||||
src_build_postgres,
|
||||
dependencies : [
|
||||
lib_yaml
|
||||
],
|
||||
)
|
||||
|
||||
# build interface.auto.c.inc
|
||||
subdir('postgres')
|
||||
|
||||
alias_target('build-postgres', build_postgres)
|
||||
|
||||
####################################################################################################################################
|
||||
# pgBackRest target
|
||||
####################################################################################################################################
|
||||
@ -249,19 +274,6 @@ src_pgbackrest = [
|
||||
'postgres/client.c',
|
||||
'postgres/interface.c',
|
||||
'postgres/interface/page.c',
|
||||
'postgres/interface/v090.c',
|
||||
'postgres/interface/v091.c',
|
||||
'postgres/interface/v092.c',
|
||||
'postgres/interface/v093.c',
|
||||
'postgres/interface/v094.c',
|
||||
'postgres/interface/v095.c',
|
||||
'postgres/interface/v096.c',
|
||||
'postgres/interface/v100.c',
|
||||
'postgres/interface/v110.c',
|
||||
'postgres/interface/v120.c',
|
||||
'postgres/interface/v130.c',
|
||||
'postgres/interface/v140.c',
|
||||
'postgres/interface/v150.c',
|
||||
'protocol/client.c',
|
||||
'protocol/command.c',
|
||||
'protocol/helper.c',
|
||||
@ -295,6 +307,7 @@ pgbackrest = executable(
|
||||
src_common,
|
||||
src_pgbackrest,
|
||||
help_auto_c_inc,
|
||||
interface_auto_c_inc,
|
||||
dependencies : [
|
||||
lib_bz2,
|
||||
lib_openssl,
|
||||
|
@ -11,7 +11,6 @@ PostgreSQL Interface
|
||||
#include "common/regExp.h"
|
||||
#include "postgres/interface.h"
|
||||
#include "postgres/interface/static.vendor.h"
|
||||
#include "postgres/interface/version.h"
|
||||
#include "postgres/version.h"
|
||||
#include "storage/helper.h"
|
||||
|
||||
@ -52,9 +51,7 @@ sectors. This is true across all versions of PostgreSQL.
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL interface definitions
|
||||
|
||||
Each supported version of PostgreSQL must have interface files named postgres/interface/vXXX.c/h that implement the functions
|
||||
specified in the interface structure below. The functions are documented here rather than in the interface files so that a change
|
||||
in wording does not need to be propagated through N source files.
|
||||
The interface functions are documented here rather than the auto-generated file.
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct PgInterface
|
||||
{
|
||||
@ -77,139 +74,8 @@ typedef struct PgInterface
|
||||
PgWal (*wal)(const unsigned char *);
|
||||
} PgInterface;
|
||||
|
||||
static const PgInterface pgInterface[] =
|
||||
{
|
||||
{
|
||||
.version = PG_VERSION_15,
|
||||
|
||||
.controlIs = pgInterfaceControlIs150,
|
||||
.control = pgInterfaceControl150,
|
||||
.controlVersion = pgInterfaceControlVersion150,
|
||||
|
||||
.walIs = pgInterfaceWalIs150,
|
||||
.wal = pgInterfaceWal150,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_14,
|
||||
|
||||
.controlIs = pgInterfaceControlIs140,
|
||||
.control = pgInterfaceControl140,
|
||||
.controlVersion = pgInterfaceControlVersion140,
|
||||
|
||||
.walIs = pgInterfaceWalIs140,
|
||||
.wal = pgInterfaceWal140,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_13,
|
||||
|
||||
.controlIs = pgInterfaceControlIs130,
|
||||
.control = pgInterfaceControl130,
|
||||
.controlVersion = pgInterfaceControlVersion130,
|
||||
|
||||
.walIs = pgInterfaceWalIs130,
|
||||
.wal = pgInterfaceWal130,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_12,
|
||||
|
||||
.controlIs = pgInterfaceControlIs120,
|
||||
.control = pgInterfaceControl120,
|
||||
.controlVersion = pgInterfaceControlVersion120,
|
||||
|
||||
.walIs = pgInterfaceWalIs120,
|
||||
.wal = pgInterfaceWal120,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_11,
|
||||
|
||||
.controlIs = pgInterfaceControlIs110,
|
||||
.control = pgInterfaceControl110,
|
||||
.controlVersion = pgInterfaceControlVersion110,
|
||||
|
||||
.walIs = pgInterfaceWalIs110,
|
||||
.wal = pgInterfaceWal110,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_10,
|
||||
|
||||
.controlIs = pgInterfaceControlIs100,
|
||||
.control = pgInterfaceControl100,
|
||||
.controlVersion = pgInterfaceControlVersion100,
|
||||
|
||||
.walIs = pgInterfaceWalIs100,
|
||||
.wal = pgInterfaceWal100,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_96,
|
||||
|
||||
.controlIs = pgInterfaceControlIs096,
|
||||
.control = pgInterfaceControl096,
|
||||
.controlVersion = pgInterfaceControlVersion096,
|
||||
|
||||
.walIs = pgInterfaceWalIs096,
|
||||
.wal = pgInterfaceWal096,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_95,
|
||||
|
||||
.controlIs = pgInterfaceControlIs095,
|
||||
.control = pgInterfaceControl095,
|
||||
.controlVersion = pgInterfaceControlVersion095,
|
||||
|
||||
.walIs = pgInterfaceWalIs095,
|
||||
.wal = pgInterfaceWal095,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_94,
|
||||
|
||||
.controlIs = pgInterfaceControlIs094,
|
||||
.control = pgInterfaceControl094,
|
||||
.controlVersion = pgInterfaceControlVersion094,
|
||||
|
||||
.walIs = pgInterfaceWalIs094,
|
||||
.wal = pgInterfaceWal094,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_93,
|
||||
|
||||
.controlIs = pgInterfaceControlIs093,
|
||||
.control = pgInterfaceControl093,
|
||||
.controlVersion = pgInterfaceControlVersion093,
|
||||
|
||||
.walIs = pgInterfaceWalIs093,
|
||||
.wal = pgInterfaceWal093,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_92,
|
||||
|
||||
.controlIs = pgInterfaceControlIs092,
|
||||
.control = pgInterfaceControl092,
|
||||
.controlVersion = pgInterfaceControlVersion092,
|
||||
|
||||
.walIs = pgInterfaceWalIs092,
|
||||
.wal = pgInterfaceWal092,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_91,
|
||||
|
||||
.controlIs = pgInterfaceControlIs091,
|
||||
.control = pgInterfaceControl091,
|
||||
.controlVersion = pgInterfaceControlVersion091,
|
||||
|
||||
.walIs = pgInterfaceWalIs091,
|
||||
.wal = pgInterfaceWal091,
|
||||
},
|
||||
{
|
||||
.version = PG_VERSION_90,
|
||||
|
||||
.controlIs = pgInterfaceControlIs090,
|
||||
.control = pgInterfaceControl090,
|
||||
.controlVersion = pgInterfaceControlVersion090,
|
||||
|
||||
.walIs = pgInterfaceWalIs090,
|
||||
.wal = pgInterfaceWal090,
|
||||
},
|
||||
};
|
||||
// Include auto-generated interfaces
|
||||
#include "postgres/interface.auto.c.inc"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
These pg_control fields are common to all versions of PostgreSQL, so we can use them to generate error messages when the pg_control
|
||||
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.0 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_90
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(090);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.1 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_91
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(091);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.2 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_92
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(092);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.3 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_93
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(093);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.4 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_94
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(094);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.5 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_95
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(095);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.6 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_96
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(096);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 10 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_10
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(100);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 11 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_11
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(110);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 12 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_12
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(120);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 13 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_13
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(130);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 14 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_14
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(140);
|
@ -1,12 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 15 Interface
|
||||
|
||||
See postgres/interface/version.intern.h for documentation.
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#define PG_VERSION PG_VERSION_15
|
||||
|
||||
#include "postgres/interface/version.intern.h"
|
||||
|
||||
PG_INTERFACE(150);
|
@ -1,90 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL Version Interface
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef POSTGRES_INTERFACE_VERSION_H
|
||||
#define POSTGRES_INTERFACE_VERSION_H
|
||||
|
||||
#include "postgres/interface.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
bool pgInterfaceControlIs090(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl090(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion090(void);
|
||||
bool pgInterfaceWalIs090(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal090(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs091(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl091(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion091(void);
|
||||
bool pgInterfaceWalIs091(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal091(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs092(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl092(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion092(void);
|
||||
bool pgInterfaceWalIs092(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal092(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs093(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl093(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion093(void);
|
||||
bool pgInterfaceWalIs093(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal093(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs094(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl094(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion094(void);
|
||||
bool pgInterfaceWalIs094(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal094(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs095(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl095(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion095(void);
|
||||
bool pgInterfaceWalIs095(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal095(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs096(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl096(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion096(void);
|
||||
bool pgInterfaceWalIs096(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal096(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs100(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl100(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion100(void);
|
||||
bool pgInterfaceWalIs100(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal100(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs110(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl110(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion110(void);
|
||||
bool pgInterfaceWalIs110(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal110(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs120(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl120(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion120(void);
|
||||
bool pgInterfaceWalIs120(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal120(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs130(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl130(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion130(void);
|
||||
bool pgInterfaceWalIs130(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal130(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs140(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl140(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion140(void);
|
||||
bool pgInterfaceWalIs140(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal140(const unsigned char *controlFile);
|
||||
|
||||
bool pgInterfaceControlIs150(const unsigned char *controlFile);
|
||||
PgControl pgInterfaceControl150(const unsigned char *controlFile);
|
||||
uint32_t pgInterfaceControlVersion150(void);
|
||||
bool pgInterfaceWalIs150(const unsigned char *walFile);
|
||||
PgWal pgInterfaceWal150(const unsigned char *controlFile);
|
||||
|
||||
#endif
|
@ -1,24 +1,18 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL Version Interface
|
||||
|
||||
Macros for building version-specific functions that interface with the types in version.vendor.h. Due to the way PostgreSQL types
|
||||
Macros for building version-specific functions that interface with the types in version.vendor.h. Due to the way PostgreSQL types
|
||||
evolve over time, this seems to be the easiest way to extract information from them.
|
||||
|
||||
These macros should be kept as simple as possible, with most of the logic contained in postgres/interface.c.
|
||||
|
||||
Each version of PostgreSQL will need a vXXX.c file to contain the version-specific functions created by these macros.
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef POSTGRES_INTERFACE_VERSIONINTERN_H
|
||||
#define POSTGRES_INTERFACE_VERSIONINTERN_H
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "postgres/interface/version.h"
|
||||
#include "postgres/interface/version.vendor.h"
|
||||
#include "postgres/version.h"
|
||||
|
||||
#include "postgres/interface/version.vendor.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Determine if the supplied pg_control is for this version of PostgreSQL
|
||||
Determine if the supplied pg_control is for this version of PostgreSQL. When CATALOG_VERSION_NO_MAX is defined then the catalog will
|
||||
be accepted as a range that lasts until the end of the encoded year. This allows pgBackRest to work with PostgreSQL during the
|
||||
alpha/beta/rc period without needing to be updated, unless of course the actual interface changes.
|
||||
***********************************************************************************************************************************/
|
||||
#if PG_VERSION > PG_VERSION_MAX
|
||||
|
||||
@ -27,7 +21,7 @@ Determine if the supplied pg_control is for this version of PostgreSQL
|
||||
#ifdef CATALOG_VERSION_NO_MAX
|
||||
|
||||
#define PG_INTERFACE_CONTROL_IS(version) \
|
||||
bool \
|
||||
static bool \
|
||||
pgInterfaceControlIs##version(const unsigned char *controlFile) \
|
||||
{ \
|
||||
ASSERT(controlFile != NULL); \
|
||||
@ -41,7 +35,7 @@ Determine if the supplied pg_control is for this version of PostgreSQL
|
||||
#else
|
||||
|
||||
#define PG_INTERFACE_CONTROL_IS(version) \
|
||||
bool \
|
||||
static bool \
|
||||
pgInterfaceControlIs##version(const unsigned char *controlFile) \
|
||||
{ \
|
||||
ASSERT(controlFile != NULL); \
|
||||
@ -63,7 +57,7 @@ Read the version specific pg_control into a general data structure
|
||||
#elif PG_VERSION >= PG_VERSION_93
|
||||
|
||||
#define PG_INTERFACE_CONTROL(version) \
|
||||
PgControl \
|
||||
static PgControl \
|
||||
pgInterfaceControl##version(const unsigned char *controlFile) \
|
||||
{ \
|
||||
ASSERT(controlFile != NULL); \
|
||||
@ -84,7 +78,7 @@ Read the version specific pg_control into a general data structure
|
||||
#elif PG_VERSION >= PG_VERSION_90
|
||||
|
||||
#define PG_INTERFACE_CONTROL(version) \
|
||||
PgControl \
|
||||
static PgControl \
|
||||
pgInterfaceControl##version(const unsigned char *controlFile) \
|
||||
{ \
|
||||
ASSERT(controlFile != NULL); \
|
||||
@ -113,7 +107,7 @@ Get the control version
|
||||
#elif PG_VERSION >= PG_VERSION_90
|
||||
|
||||
#define PG_INTERFACE_CONTROL_VERSION(version) \
|
||||
uint32_t \
|
||||
static uint32_t \
|
||||
pgInterfaceControlVersion##version(void) \
|
||||
{ \
|
||||
return PG_CONTROL_VERSION; \
|
||||
@ -129,7 +123,7 @@ Determine if the supplied WAL is for this version of PostgreSQL
|
||||
#elif PG_VERSION >= PG_VERSION_90
|
||||
|
||||
#define PG_INTERFACE_WAL_IS(version) \
|
||||
bool \
|
||||
static bool \
|
||||
pgInterfaceWalIs##version(const unsigned char *walFile) \
|
||||
{ \
|
||||
ASSERT(walFile != NULL); \
|
||||
@ -147,7 +141,7 @@ Read the version specific WAL header into a general data structure
|
||||
#elif PG_VERSION >= PG_VERSION_90
|
||||
|
||||
#define PG_INTERFACE_WAL(version) \
|
||||
PgWal \
|
||||
static PgWal \
|
||||
pgInterfaceWal##version(const unsigned char *walFile) \
|
||||
{ \
|
||||
ASSERT(walFile != NULL); \
|
||||
@ -161,15 +155,3 @@ Read the version specific WAL header into a general data structure
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Call all macros with a single macro to make the vXXX.c files as simple as possible
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_INTERFACE(version) \
|
||||
PG_INTERFACE_CONTROL_IS(version) \
|
||||
PG_INTERFACE_CONTROL(version) \
|
||||
PG_INTERFACE_CONTROL_VERSION(version) \
|
||||
PG_INTERFACE_WAL_IS(version) \
|
||||
PG_INTERFACE_WAL(version)
|
||||
|
||||
#endif
|
||||
|
@ -177,12 +177,6 @@ Types from src/include/catalog/catversion.h
|
||||
***********************************************************************************************************************************/
|
||||
|
||||
// CATALOG_VERSION_NO define
|
||||
//
|
||||
// When PostgreSQL is in alpha/beta/rc the catalog version may change with each release. To prevent breakage during this period
|
||||
// define CATATLOG_VERSION_NO_MAX. This will allow the catalog version to "float" through the end of the year. After the PostgreSQL
|
||||
// release, remove CATALOG_VERSION_NO_MAX in the next pgBackRest release to lock down the catalog version. A side effect of this is
|
||||
// that during the period when the catalog number is allowed to float pgBackRest may misidentify development versions of PostgreSQL
|
||||
// for the next release as being an alpha/beta/rc for the current release. This seems a minor issue to prevent breakage.
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
#if PG_VERSION > PG_VERSION_MAX
|
||||
|
||||
@ -199,9 +193,6 @@ Types from src/include/catalog/catversion.h
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202204076
|
||||
|
||||
// Allow the catalog version to float during the PostgreSQL 15 beta/rc period
|
||||
#define CATALOG_VERSION_NO_MAX
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_14
|
||||
|
||||
/*
|
||||
|
14
src/postgres/meson.build
Normal file
14
src/postgres/meson.build
Normal file
@ -0,0 +1,14 @@
|
||||
####################################################################################################################################
|
||||
# Generate PostgreSQL interfaces
|
||||
####################################################################################################################################
|
||||
interface_auto_c_inc = custom_target(
|
||||
'interface.auto.c.inc',
|
||||
output : 'interface.auto.c.inc',
|
||||
depend_files: [
|
||||
'../build/postgres/postgres.yaml',
|
||||
],
|
||||
command : [
|
||||
build_postgres,
|
||||
'@CURRENT_SOURCE_DIR@/../..'
|
||||
],
|
||||
)
|
5
test/Vagrantfile
vendored
5
test/Vagrantfile
vendored
@ -152,8 +152,8 @@ Vagrant.configure(2) do |config|
|
||||
#
|
||||
# Basic environment to build/test pgBackRest using homebrew installed in the local user account.
|
||||
#-------------------------------------------------------------------------------------------------------------------------------
|
||||
# git clone --depth=1 https://github.com/Homebrew/brew homebrew
|
||||
# ~/homebrew/bin/brew install -q libpq libxml2 libyaml cpanm lcov
|
||||
# git clone --depth=1 https://github.com/Homebrew/brew ~/homebrew
|
||||
# ~/homebrew/bin/brew install -q pkg-config openssl@1.1 libpq libxml2 libyaml cpanm lcov meson
|
||||
# ~/homebrew/bin/cpanm --force --local-lib=~/homebrew/perl5 install YAML::XS XML::Checker::Parser
|
||||
#
|
||||
# export PATH="${HOME?}/homebrew/bin:$PATH"
|
||||
@ -162,6 +162,7 @@ Vagrant.configure(2) do |config|
|
||||
# export CPPFLAGS="-I${HOME?}/homebrew/opt/openssl@1.1/include -I/${HOME?}/homebrew/opt/libpq/include"
|
||||
# export CPPFLAGS="${CPPFLAGS?} -I${HOME?}/homebrew/opt/libxml2/include/libxml2 -I/${HOME?}/homebrew/opt/libyaml/include"
|
||||
# export PERL5LIB=~/homebrew/perl5/lib/perl5"${PERL5LIB:+:${PERL5LIB}}"
|
||||
# export PKG_CONFIG_PATH=~/homebrew/opt/libpq/lib/pkgconfig:~/homebrew/opt/openssl@1.1/lib/pkgconfig
|
||||
|
||||
# Don't share the default vagrant folder
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
|
@ -271,6 +271,30 @@ src/build/install-sh:
|
||||
class: build
|
||||
type: make
|
||||
|
||||
src/build/postgres/main.c:
|
||||
class: build
|
||||
type: c
|
||||
|
||||
src/build/postgres/parse.c:
|
||||
class: build
|
||||
type: c
|
||||
|
||||
src/build/postgres/parse.h:
|
||||
class: build
|
||||
type: c/h
|
||||
|
||||
src/build/postgres/postgres.yaml:
|
||||
class: build
|
||||
type: yaml
|
||||
|
||||
src/build/postgres/render.c:
|
||||
class: build
|
||||
type: c
|
||||
|
||||
src/build/postgres/render.h:
|
||||
class: build
|
||||
type: c/h
|
||||
|
||||
src/command/archive/common.c:
|
||||
class: core
|
||||
type: c
|
||||
@ -1447,62 +1471,6 @@ src/postgres/interface/static.vendor.h:
|
||||
class: core/vendor
|
||||
type: c/h
|
||||
|
||||
src/postgres/interface/v090.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v091.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v092.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v093.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v094.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v095.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v096.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v100.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v110.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v120.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v130.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v140.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/v150.c:
|
||||
class: core
|
||||
type: c
|
||||
|
||||
src/postgres/interface/version.h:
|
||||
class: core
|
||||
type: c/h
|
||||
|
||||
src/postgres/interface/version.intern.h:
|
||||
class: core
|
||||
type: c/h
|
||||
@ -1511,6 +1479,10 @@ src/postgres/interface/version.vendor.h:
|
||||
class: core/vendor
|
||||
type: c/h
|
||||
|
||||
src/postgres/meson.build:
|
||||
class: build
|
||||
type: meson
|
||||
|
||||
src/postgres/version.h:
|
||||
class: core
|
||||
type: c/h
|
||||
@ -2175,6 +2147,10 @@ test/src/module/build/helpTest.c:
|
||||
class: test/module
|
||||
type: c
|
||||
|
||||
test/src/module/build/postgresTest.c:
|
||||
class: test/module
|
||||
type: c
|
||||
|
||||
test/src/module/command/archiveCommonTest.c:
|
||||
class: test/module
|
||||
type: c
|
||||
|
@ -390,19 +390,6 @@ unit:
|
||||
- command/command
|
||||
- postgres/interface
|
||||
- postgres/interface/page
|
||||
- postgres/interface/v090
|
||||
- postgres/interface/v091
|
||||
- postgres/interface/v092
|
||||
- postgres/interface/v093
|
||||
- postgres/interface/v094
|
||||
- postgres/interface/v095
|
||||
- postgres/interface/v096
|
||||
- postgres/interface/v100
|
||||
- postgres/interface/v110
|
||||
- postgres/interface/v120
|
||||
- postgres/interface/v130
|
||||
- postgres/interface/v140
|
||||
- postgres/interface/v150
|
||||
- protocol/client
|
||||
- protocol/command
|
||||
- protocol/helper
|
||||
@ -625,6 +612,14 @@ unit:
|
||||
- build/help/parse
|
||||
- build/help/render
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------------
|
||||
- name: postgres
|
||||
total: 1
|
||||
|
||||
coverage:
|
||||
- build/postgres/parse
|
||||
- build/postgres/render
|
||||
|
||||
# ********************************************************************************************************************************
|
||||
- name: info
|
||||
|
||||
|
180
test/src/module/build/postgresTest.c
Normal file
180
test/src/module/build/postgresTest.c
Normal file
@ -0,0 +1,180 @@
|
||||
/***********************************************************************************************************************************
|
||||
Test Build PostgreSQL Interface
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/harnessStorage.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Run
|
||||
***********************************************************************************************************************************/
|
||||
static void
|
||||
testRun(void)
|
||||
{
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Create default storage object for testing
|
||||
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("bldPgParse() and bldPgRender()"))
|
||||
{
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("parse errors");
|
||||
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageTest, "src/postgres/interface/version.vendor.h",
|
||||
"#define CATALOG_VERSION_NO\t1\n"
|
||||
"#define PG_CONTROL_VERSION 2\n"
|
||||
"\n"
|
||||
"typedef int64_t int64;\n"
|
||||
"\n"
|
||||
"typedef struct struct_type\n"
|
||||
"{\n"
|
||||
" int field1;\n"
|
||||
" int field2;\n"
|
||||
"} struct_type;\n"
|
||||
"\n"
|
||||
"typedef enum\n"
|
||||
"{\n"
|
||||
" enum1 = 0,\n"
|
||||
" enum2,\n"
|
||||
"} enum_type;\n");
|
||||
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageTest, "src/postgres/interface/version.intern.h",
|
||||
"#define PG_INTERFACE_CONTROL_IS(version)\n");
|
||||
|
||||
TEST_ERROR(
|
||||
bldPgParse(storageTest), FormatError,
|
||||
"unable to find define -- are there extra spaces on '#define PG_INTERFACE_CONTROL_IS(version)'");
|
||||
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageTest, "src/postgres/interface/version.intern.h",
|
||||
"#define PG_INTERFACE_CONTROL_IS(version)\n"
|
||||
"#define PG_INTERFACE_CONTROL(version)\n");
|
||||
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageTest, "src/build/postgres/postgres.yaml",
|
||||
"bogus: value\n");
|
||||
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageTest, "src/build/postgres/postgres.yaml",
|
||||
"bogus: value\n");
|
||||
|
||||
TEST_ERROR(bldPgParse(storageTest), FormatError, "unknown postgres definition 'bogus'");
|
||||
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageTest, "src/build/postgres/postgres.yaml",
|
||||
"version:\n"
|
||||
" - 11:\n"
|
||||
" bogus: value");
|
||||
|
||||
TEST_ERROR(bldPgParse(storageTest), FormatError, "unknown postgres definition 'bogus'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("parse and render postgres");
|
||||
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageTest, "src/build/postgres/postgres.yaml",
|
||||
"version:\n"
|
||||
" - 9.0\n"
|
||||
" - 11:\n"
|
||||
" release: false\n");
|
||||
|
||||
TEST_RESULT_VOID(bldPgRender(storageTest, bldPgParse(storageTest)), "parse and render");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("check interface.auto.c.inc");
|
||||
|
||||
TEST_STORAGE_GET(
|
||||
storageTest,
|
||||
"postgres/interface.auto.c.inc",
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL Interface\n"
|
||||
"\n"
|
||||
"Automatically generated by 'make build-postgres' -- do not modify directly.\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL 11 interface\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"#define PG_VERSION PG_VERSION_11\n"
|
||||
"\n"
|
||||
"#define enum1 enum1_11\n"
|
||||
"#define enum2 enum2_11\n"
|
||||
"#define enum_type enum_type_11\n"
|
||||
"#define int64 int64_11\n"
|
||||
"#define struct_type struct_type_11\n"
|
||||
"\n"
|
||||
"#define CATALOG_VERSION_NO_MAX\n"
|
||||
"\n"
|
||||
"#include \"postgres/interface/version.intern.h\"\n"
|
||||
"\n"
|
||||
"PG_INTERFACE_CONTROL_IS(11);\n"
|
||||
"PG_INTERFACE_CONTROL(11);\n"
|
||||
"\n"
|
||||
"#undef enum1\n"
|
||||
"#undef enum2\n"
|
||||
"#undef enum_type\n"
|
||||
"#undef int64\n"
|
||||
"#undef struct_type\n"
|
||||
"\n"
|
||||
"#undef CATALOG_VERSION_NO\n"
|
||||
"#undef CATALOG_VERSION_NO_MAX\n"
|
||||
"#undef PG_CONTROL_VERSION\n"
|
||||
"#undef PG_VERSION\n"
|
||||
"\n"
|
||||
"#undef PG_INTERFACE_CONTROL_IS\n"
|
||||
"#undef PG_INTERFACE_CONTROL\n"
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL 9.0 interface\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"#define PG_VERSION PG_VERSION_90\n"
|
||||
"\n"
|
||||
"#define enum1 enum1_90\n"
|
||||
"#define enum2 enum2_90\n"
|
||||
"#define enum_type enum_type_90\n"
|
||||
"#define int64 int64_90\n"
|
||||
"#define struct_type struct_type_90\n"
|
||||
"\n"
|
||||
"#include \"postgres/interface/version.intern.h\"\n"
|
||||
"\n"
|
||||
"PG_INTERFACE_CONTROL_IS(90);\n"
|
||||
"PG_INTERFACE_CONTROL(90);\n"
|
||||
"\n"
|
||||
"#undef enum1\n"
|
||||
"#undef enum2\n"
|
||||
"#undef enum_type\n"
|
||||
"#undef int64\n"
|
||||
"#undef struct_type\n"
|
||||
"\n"
|
||||
"#undef CATALOG_VERSION_NO\n"
|
||||
"#undef CATALOG_VERSION_NO_MAX\n"
|
||||
"#undef PG_CONTROL_VERSION\n"
|
||||
"#undef PG_VERSION\n"
|
||||
"\n"
|
||||
"#undef PG_INTERFACE_CONTROL_IS\n"
|
||||
"#undef PG_INTERFACE_CONTROL\n"
|
||||
"\n"
|
||||
COMMENT_BLOCK_BEGIN "\n"
|
||||
"PostgreSQL interface struct\n"
|
||||
COMMENT_BLOCK_END "\n"
|
||||
"static const PgInterface pgInterface[] =\n"
|
||||
"{\n"
|
||||
" {\n"
|
||||
" .version = PG_VERSION_11,\n"
|
||||
"\n"
|
||||
" .controlIs = pgInterfaceControlIs11,\n"
|
||||
" .control = pgInterfaceControl11,\n"
|
||||
" },\n"
|
||||
" {\n"
|
||||
" .version = PG_VERSION_90,\n"
|
||||
"\n"
|
||||
" .controlIs = pgInterfaceControlIs90,\n"
|
||||
" .control = pgInterfaceControl90,\n"
|
||||
" },\n"
|
||||
"};\n");
|
||||
}
|
||||
|
||||
FUNCTION_HARNESS_RETURN_VOID();
|
||||
}
|
94
test/test.pl
94
test/test.pl
@ -77,7 +77,7 @@ test.pl [options]
|
||||
--container-only only run tests that must be run in a container
|
||||
--no-performance do not run performance tests
|
||||
--gen-only only run auto-generation
|
||||
--no-gen do not run code generation
|
||||
--min-gen only run required code generation
|
||||
--gen-check check that auto-generated files are correct (used in CI to detect changes)
|
||||
--code-count generate code counts
|
||||
--no-valgrind don't run valgrind on C unit tests (saves time)
|
||||
@ -156,7 +156,7 @@ my $bContainerOnly = false;
|
||||
my $bNoPerformance = false;
|
||||
my $bGenOnly = false;
|
||||
my $bGenCheck = false;
|
||||
my $bNoGen = false;
|
||||
my $bMinGen = false;
|
||||
my $bCodeCount = false;
|
||||
my $bBackTrace = false;
|
||||
my $bProfile = false;
|
||||
@ -206,7 +206,7 @@ GetOptions ('q|quiet' => \$bQuiet,
|
||||
'no-performance' => \$bNoPerformance,
|
||||
'gen-only' => \$bGenOnly,
|
||||
'gen-check' => \$bGenCheck,
|
||||
'no-gen' => \$bNoGen,
|
||||
'min-gen' => \$bMinGen,
|
||||
'code-count' => \$bCodeCount,
|
||||
'backtrace' => \$bBackTrace,
|
||||
'profile' => \$bProfile,
|
||||
@ -252,7 +252,7 @@ eval
|
||||
################################################################################################################################
|
||||
if ($bDryRun)
|
||||
{
|
||||
$bNoGen = true;
|
||||
$bMinGen = true;
|
||||
}
|
||||
|
||||
################################################################################################################################
|
||||
@ -393,9 +393,9 @@ eval
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
executeTest("make -C ${strBackRestBase}/src -f Makefile.in clean-all");
|
||||
|
||||
# Auto-generate configure files unless --no-gen specified
|
||||
# Auto-generate configure files unless --min-gen specified
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
if (!$bNoGen)
|
||||
if (!$bMinGen)
|
||||
{
|
||||
&log(INFO, "autogenerate configure");
|
||||
|
||||
@ -491,48 +491,6 @@ eval
|
||||
&log(INFO, " autogenerated configure script: " . (@stryBuilt ? join(', ', @stryBuilt) : 'no changes'));
|
||||
}
|
||||
|
||||
# Auto-generate code files unless --no-gen specified
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
if (!$bNoGen)
|
||||
{
|
||||
my $strBuildPath = "${strTestPath}/build";
|
||||
|
||||
&log(INFO, (!-e $strBuildPath ? 'clean ' : '') . 'autogenerate code');
|
||||
|
||||
# Auto-generate version for root meson.build script
|
||||
my $strMesonBuildOld = ${$oStorageTest->get("${strBackRestBase}/meson.build")};
|
||||
my $strMesonBuildNew;
|
||||
|
||||
foreach my $strLine (split("\n", $strMesonBuildOld))
|
||||
{
|
||||
if ($strLine =~ /^ version\: '/)
|
||||
{
|
||||
$strLine = " version: '" . PROJECT_VERSION . "',";
|
||||
}
|
||||
|
||||
$strMesonBuildNew .= "${strLine}\n";
|
||||
}
|
||||
|
||||
buildPutDiffers($oStorageBackRest, "${strBackRestBase}/meson.build", $strMesonBuildNew);
|
||||
|
||||
# Setup build if it does not exist
|
||||
if (!-e $strBuildPath)
|
||||
{
|
||||
executeTest("meson setup -Dwerror=true -Dfatal-errors=true -Dbuildtype=debug ${strBuildPath} ${strBackRestBase}");
|
||||
}
|
||||
|
||||
# Build code
|
||||
executeTest(
|
||||
"ninja -C ${strBuildPath} build-config build-error build-help" .
|
||||
" && ${strBuildPath}/src/build-config ${strBackRestBase}/src" .
|
||||
" && ${strBuildPath}/src/build-error ${strBackRestBase}/src");
|
||||
|
||||
if ($bGenOnly)
|
||||
{
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
# Make a copy of the repo to track which files have been changed
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
my $strRepoCachePath = "${strTestPath}/repo";
|
||||
@ -548,6 +506,46 @@ eval
|
||||
(trim(`uname`) ne 'Darwin' ? ' --ignore-missing-args' : '') .
|
||||
" ${strBackRestBase}/ ${strRepoCachePath}");
|
||||
|
||||
# Auto-generate code files (if --min-gen specified then do minimum required)
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
my $strBuildPath = "${strTestPath}/build";
|
||||
|
||||
&log(INFO, (!-e $strBuildPath ? 'clean ' : '') . 'autogenerate code');
|
||||
|
||||
# Auto-generate version for root meson.build script
|
||||
my $strMesonBuildOld = ${$oStorageTest->get("${strBackRestBase}/meson.build")};
|
||||
my $strMesonBuildNew;
|
||||
|
||||
foreach my $strLine (split("\n", $strMesonBuildOld))
|
||||
{
|
||||
if ($strLine =~ /^ version\: '/)
|
||||
{
|
||||
$strLine = " version: '" . PROJECT_VERSION . "',";
|
||||
}
|
||||
|
||||
$strMesonBuildNew .= "${strLine}\n";
|
||||
}
|
||||
|
||||
buildPutDiffers($oStorageBackRest, "${strBackRestBase}/meson.build", $strMesonBuildNew);
|
||||
|
||||
# Setup build if it does not exist
|
||||
if (!-e $strBuildPath)
|
||||
{
|
||||
executeTest("meson setup -Dwerror=true -Dfatal-errors=true -Dbuildtype=debug ${strBuildPath} ${strBackRestBase}");
|
||||
}
|
||||
|
||||
# Build code
|
||||
executeTest(
|
||||
"ninja -C ${strBuildPath}" . ($bMinGen ? '' : ' build-config build-error') . ' build-postgres' .
|
||||
($bMinGen ? '' : " && ${strBuildPath}/src/build-config ${strBackRestBase}/src") .
|
||||
($bMinGen ? '' : " && ${strBuildPath}/src/build-error ${strBackRestBase}/src") .
|
||||
" && cd $strRepoCachePath/src && ${strBuildPath}/src/build-postgres");
|
||||
|
||||
if ($bGenOnly)
|
||||
{
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# Generate code counts
|
||||
#---------------------------------------------------------------------------------------------------------------------------
|
||||
if ($bCodeCount)
|
||||
|
Loading…
x
Reference in New Issue
Block a user