1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-04 09:43:08 +02:00

Add .inc extension to C files included in other C files.

These files were never intended to be compiled on their own so the .c extension was a bit misleading. In particular Meson does not like .c files that are not intended to be compiled independently.

Leave header files as is since they are already protected against being included more than once and are never expected to be compiled.
This commit is contained in:
David Steele 2022-05-31 16:06:41 -04:00
parent cb891fa2d4
commit 2feaaeaac8
24 changed files with 48 additions and 45 deletions

3
.gitattributes vendored
View File

@ -1,2 +1,3 @@
# Classify all .h files as C # Classify all .h/c.inc files as C
*.h linguist-language=C *.h linguist-language=C
*.c.inc linguist-language=C

View File

@ -561,7 +561,7 @@ run 8/1 ------------- L2285 no current backups
## Adding an Option ## Adding an Option
Options can be added to a command or multiple commands. Options can be configuration file only, command-line only or valid for both. Once an option is successfully added, the `config.auto.h` and `parse.auto.c` files will automatically be generated by the build system. Options can be added to a command or multiple commands. Options can be configuration file only, command-line only or valid for both. Once an option is successfully added, the `config.auto.h` and `parse.auto.c.inc` files will automatically be generated by the build system.
To add an option, two files need be to be modified: To add an option, two files need be to be modified:

View File

@ -648,7 +648,7 @@ run 8/1 ------------- L2285 no current backups
<section id="option"> <section id="option">
<title>Adding an Option</title> <title>Adding an Option</title>
<p>Options can be added to a command or multiple commands. Options can be configuration file only, command-line only or valid for both. Once an option is successfully added, the <file>config.auto.h</file> and <file>parse.auto.c</file> files will automatically be generated by the build system.</p> <p>Options can be added to a command or multiple commands. Options can be configuration file only, command-line only or valid for both. Once an option is successfully added, the <file>config.auto.h</file> and <file>parse.auto.c.inc</file> files will automatically be generated by the build system.</p>
<p>To add an option, two files need be to be modified:</p> <p>To add an option, two files need be to be modified:</p>
<list> <list>

2
src/.gitignore vendored
View File

@ -1,6 +1,6 @@
/.build /.build
autom4te.cache autom4te.cache
/command/help/help.auto.c /command/help/help.auto.c.inc
/config.log /config.log
/config.status /config.status
/Makefile /Makefile

View File

@ -216,7 +216,7 @@ SRCS_BUILD_CONFIG = \
OBJS_BUILD_CONFIG = $(patsubst %.c,$(BUILDDIR)/%.o,$(SRCS_BUILD) $(SRCS_BUILD_CONFIG)) OBJS_BUILD_CONFIG = $(patsubst %.c,$(BUILDDIR)/%.o,$(SRCS_BUILD) $(SRCS_BUILD_CONFIG))
build-config: $(OBJS_BUILD_CONFIG) build/config/config.yaml config/config.auto.h config/parse.auto.c build-config: $(OBJS_BUILD_CONFIG) build/config/config.yaml config/config.auto.h config/parse.auto.c.inc
$(CC) -o build-config $(OBJS_BUILD_CONFIG) $(LDFLAGS) $(LIBS) $(LIBS_BUILD) $(CC) -o build-config $(OBJS_BUILD_CONFIG) $(LDFLAGS) $(LIBS) $(LIBS_BUILD)
./build-config $(VPATH) ./build-config $(VPATH)
@ -252,7 +252,7 @@ OBJS_BUILD_HELP = $(patsubst %.c,$(BUILDDIR)/%.o,$(SRCS_BUILD) $(SRCS_BUILD_HELP
build-help: $(OBJS_BUILD_HELP) build/config/config.yaml build/help/help.xml build-help: $(OBJS_BUILD_HELP) build/config/config.yaml build/help/help.xml
$(CC) -o build-help $(OBJS_BUILD_HELP) $(LDFLAGS) $(LIBS) $(LIBS_BUILD) $(CC) -o build-help $(OBJS_BUILD_HELP) $(LDFLAGS) $(LIBS) $(LIBS_BUILD)
command/help/help.auto.c: build-help command/help/help.auto.c.inc: build-help
./build-help $(VPATH) ./build-help $(VPATH)
#################################################################################################################################### ####################################################################################################################################
@ -276,7 +276,7 @@ uninstall:
# Clean build files and executable created by make # Clean build files and executable created by make
clean: clean:
rm -rf $(BUILDDIR) rm -rf $(BUILDDIR)
rm -f pgbackrest build-config build-error build-help command/help/help.auto.c rm -f pgbackrest build-config build-error build-help command/help/help.auto.c.inc
.PHONY = clean-all .PHONY = clean-all
@ -288,7 +288,7 @@ clean-all: clean
# Special per-object flags # Special per-object flags
#################################################################################################################################### ####################################################################################################################################
$(BUILDDIR)/postgres/interface/page.o: CFLAGS += @CFLAGS_PAGE_CHECKSUM@ $(BUILDDIR)/postgres/interface/page.o: CFLAGS += @CFLAGS_PAGE_CHECKSUM@
$(BUILDDIR)/main.o: command/help/help.auto.c $(BUILDDIR)/main.o: command/help/help.auto.c.inc
#################################################################################################################################### ####################################################################################################################################
# Compile and generate dependencies # Compile and generate dependencies

View File

@ -278,7 +278,7 @@ bldCfgRenderConfigAutoH(const Storage *const storageRepo, const BldCfg bldCfg)
} }
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Render parse.auto.c Render parse.auto.c.inc
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#define PARSE_AUTO_COMMENT "Config Parse Rules" #define PARSE_AUTO_COMMENT "Config Parse Rules"
@ -1309,7 +1309,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg, co
// Write to storage // Write to storage
// ----------------------------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------------------------
bldPut( bldPut(
storageRepo, "src/config/parse.auto.c", storageRepo, "src/config/parse.auto.c.inc",
BUFSTR(strNewFmt("%s%s%s", strZ(bldHeader(CONFIG_MODULE, PARSE_AUTO_COMMENT)), strZ(configVal), strZ(config)))); BUFSTR(strNewFmt("%s%s%s", strZ(bldHeader(CONFIG_MODULE, PARSE_AUTO_COMMENT)), strZ(configVal), strZ(config))));
} }

View File

@ -1,6 +1,6 @@
# Error Definitions # Error Definitions
# #
# Definitions for all C errors, auto-generated to src/common/error.auto.c/h. # Definitions for all C errors, auto-generated to src/common/error.auto.c.inc/.h.
# Errors in the code that it should not be possible for the user to encounter -- i.e., a likely bug # Errors in the code that it should not be possible for the user to encounter -- i.e., a likely bug
assert: assert:

View File

@ -82,7 +82,7 @@ bldErrRenderErrorAutoH(const Storage *const storageRepo, const BldErr bldErr)
} }
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Render error.auto.c Render error.auto.c.inc
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
static void static void
bldErrRenderErrorAutoC(const Storage *const storageRepo, const BldErr bldErr) bldErrRenderErrorAutoC(const Storage *const storageRepo, const BldErr bldErr)
@ -130,7 +130,7 @@ bldErrRenderErrorAutoC(const Storage *const storageRepo, const BldErr bldErr)
" NULL,\n" " NULL,\n"
"};\n"); "};\n");
bldPut(storageRepo, "src/common/error.auto.c", BUFSTR(error)); bldPut(storageRepo, "src/common/error.auto.c.inc", BUFSTR(error));
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/

View File

@ -325,7 +325,7 @@ bldHlpRenderHelpAutoC(const Storage *const storageRepo, const BldCfg bldCfg, con
strCatZ(help, "\n};\n"); strCatZ(help, "\n};\n");
// Write to storage // Write to storage
bldPut(storageRepo, "command/help/help.auto.c", BUFSTR(help)); bldPut(storageRepo, "command/help/help.auto.c.inc", BUFSTR(help));
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/

View File

@ -26,7 +26,7 @@ STRING_EXTERN(HASH_TYPE_SHA256_ZERO_STR, HASH_TYPE_SH
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Include local MD5 code Include local MD5 code
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include "common/crypto/md5.vendor.c" #include "common/crypto/md5.vendor.c.inc"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Object type Object type

View File

@ -34,7 +34,7 @@ struct ErrorType
#endif #endif
// Include error type definitions // Include error type definitions
#include "common/error.auto.c" #include "common/error.auto.c.inc"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Maximum allowed number of nested try blocks Maximum allowed number of nested try blocks

View File

@ -71,7 +71,7 @@ typedef struct ParseRuleCommand
bool parameterAllowed:1; // Command-line parameters are allowed bool parameterAllowed:1; // Command-line parameters are allowed
} ParseRuleCommand; } ParseRuleCommand;
// Macros used to define parse rules in parse.auto.c in a format that diffs well // Macros used to define parse rules in parse.auto.c.inc in a format that diffs well
#define PARSE_RULE_COMMAND(...) \ #define PARSE_RULE_COMMAND(...) \
{__VA_ARGS__} {__VA_ARGS__}
@ -110,7 +110,7 @@ typedef struct ParseRuleOptionGroup
const char *name; // All options in the group must be prefixed with this name const char *name; // All options in the group must be prefixed with this name
} ParseRuleOptionGroup; } ParseRuleOptionGroup;
// Macros used to define parse rules in parse.auto.c in a format that diffs well // Macros used to define parse rules in parse.auto.c.inc in a format that diffs well
#define PARSE_RULE_OPTION_GROUP(...) \ #define PARSE_RULE_OPTION_GROUP(...) \
{__VA_ARGS__} {__VA_ARGS__}
@ -157,7 +157,7 @@ typedef enum
parseRuleFilterTypeCommand = 1, parseRuleFilterTypeCommand = 1,
} ParseRuleFilterType; } ParseRuleFilterType;
// Macros used to define parse rules in parse.auto.c in a format that diffs well // Macros used to define parse rules in parse.auto.c.inc in a format that diffs well
#define PARSE_RULE_OPTION(...) \ #define PARSE_RULE_OPTION(...) \
{__VA_ARGS__} {__VA_ARGS__}
@ -265,7 +265,7 @@ typedef struct ParseRuleOptionDeprecate
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Include automatically generated parse data Include automatically generated parse data
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include "config/parse.auto.c" #include "config/parse.auto.c.inc"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Struct to hold options parsed from the command line Struct to hold options parsed from the command line

View File

@ -51,7 +51,7 @@ Main
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Include automatically generated help data Include automatically generated help data
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include "command/help/help.auto.c" #include "command/help/help.auto.c.inc"
int int
main(int argListSize, const char *argList[]) main(int argListSize, const char *argList[])

View File

@ -10,7 +10,7 @@ PostgreSQL Page Interface
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Include the page checksum code Include the page checksum code
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include "postgres/interface/pageChecksum.vendor.c" #include "postgres/interface/pageChecksum.vendor.c.inc"
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/
uint16_t uint16_t

View File

@ -727,7 +727,7 @@ src/common/crypto/hash.h:
class: core class: core
type: c/h type: c/h
src/common/crypto/md5.vendor.c: src/common/crypto/md5.vendor.c.inc:
class: core/vendor class: core/vendor
type: c type: c
@ -747,7 +747,7 @@ src/common/encode.h:
class: core class: core
type: c/h type: c/h
src/common/error.auto.c: src/common/error.auto.c.inc:
class: core/auto class: core/auto
type: c type: c
@ -1311,7 +1311,7 @@ src/config/load.h:
class: core class: core
type: c/h type: c/h
src/config/parse.auto.c: src/config/parse.auto.c.inc:
class: core/auto class: core/auto
type: c type: c
@ -1423,7 +1423,7 @@ src/postgres/interface/page.c:
class: core class: core
type: c type: c
src/postgres/interface/pageChecksum.vendor.c: src/postgres/interface/pageChecksum.vendor.c.inc:
class: core/vendor class: core/vendor
type: c type: c

View File

@ -94,13 +94,13 @@ sub codeCountScan
} }
# Append auto if an auto-generated file # Append auto if an auto-generated file
if ($strFile =~ '\.auto\..$' | $strFile =~ 'Auto\.pm$') if ($strFile =~ '\.auto\..$' || $strFile =~ '\.auto\..\.inc$' || $strFile =~ 'Auto\.pm$')
{ {
$strClass .= '/auto'; $strClass .= '/auto';
} }
# Append vendor if a vendorized file # Append vendor if a vendorized file
if ($strFile =~ '\.vendor\..$') if ($strFile =~ '\.vendor\..$' || $strFile =~ '\.vendor\..\.inc$')
{ {
$strClass .= '/vendor'; $strClass .= '/vendor';
} }
@ -119,7 +119,7 @@ sub codeCountScan
$strType = 'c/h'; $strType = 'c/h';
$strForceLang = 'C/C++ Header'; $strForceLang = 'C/C++ Header';
} }
elsif ($strFile =~ '\.c$') elsif ($strFile =~ '\.c$' || $strFile =~ '\.c.inc$')
{ {
$strType = 'c'; $strType = 'c';
$strForceLang = 'C'; $strForceLang = 'C';

View File

@ -140,16 +140,18 @@ sub coverageExtract
'test/src/module/' . substr(${strModuleOutName}, 5) : "src/${strModuleOutName}"); 'test/src/module/' . substr(${strModuleOutName}, 5) : "src/${strModuleOutName}");
my $strLCovFile = "${strTestResultCoveragePath}/raw/${strModuleOutName}.lcov"; my $strLCovFile = "${strTestResultCoveragePath}/raw/${strModuleOutName}.lcov";
my $strLCovTotal = "${strWorkTmpPath}/all.lcov"; my $strLCovTotal = "${strWorkTmpPath}/all.lcov";
my $bInc = $strModuleName =~ '\.vendor$' || $strModuleName =~ '\.auto$';
my $strModuleSourceFile = $strModulePath . '.c' . ($bInc ? '.inc' : '');
executeTest( executeTest(
"${strLCovExe}" . ($bTest ? ' --rc lcov_branch_coverage=0' : '') . " --extract=${strLCovOut} */${strModuleName}.c" . "${strLCovExe}" . ($bTest ? ' --rc lcov_branch_coverage=0' : '') . " --extract=${strLCovOut} */${strModuleName}.c" .
" --o=${strLCovOutTmp}"); ($bInc ? '.inc' : '') . " --o=${strLCovOutTmp}");
# Combine with prior run if there was one # Combine with prior run if there was one
if ($oStorage->exists($strLCovFile)) if ($oStorage->exists($strLCovFile))
{ {
my $strCoverage = ${$oStorage->get($strLCovOutTmp)}; my $strCoverage = ${$oStorage->get($strLCovOutTmp)};
$strCoverage =~ s/^SF\:.*$/SF:$strModulePath\.c/mg; $strCoverage =~ s/^SF\:.*$/SF:$strModuleSourceFile/mg;
$oStorage->put($strLCovOutTmp, $strCoverage); $oStorage->put($strLCovOutTmp, $strCoverage);
executeTest("${strLCovExe} --add-tracefile=${strLCovOutTmp} --add-tracefile=${strLCovFile} --o=${strLCovOutTmp}"); executeTest("${strLCovExe} --add-tracefile=${strLCovOutTmp} --add-tracefile=${strLCovFile} --o=${strLCovOutTmp}");
@ -185,7 +187,7 @@ sub coverageExtract
if (!$bTest || $iTotalLines != $iCoveredLines || $iTotalBranches != $iCoveredBranches) if (!$bTest || $iTotalLines != $iCoveredLines || $iTotalBranches != $iCoveredBranches)
{ {
# Fix source file name # Fix source file name
$strCoverage =~ s/^SF\:.*$/SF:$strModulePath\.c/mg; $strCoverage =~ s/^SF\:.*$/SF:$strModuleSourceFile/mg;
$oStorage->put($oStorage->openWrite($strLCovFile, {bPathCreate => true}), $strCoverage); $oStorage->put($oStorage->openWrite($strLCovFile, {bPathCreate => true}), $strCoverage);

View File

@ -561,11 +561,11 @@ testRun(void)
"#endif\n"); "#endif\n");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("check parse.auto.c"); TEST_TITLE("check parse.auto.c.inc");
TEST_STORAGE_GET( TEST_STORAGE_GET(
storageTest, storageTest,
"src/config/parse.auto.c", "src/config/parse.auto.c.inc",
COMMENT_BLOCK_BEGIN "\n" COMMENT_BLOCK_BEGIN "\n"
"Config Parse Rules\n" "Config Parse Rules\n"
"\n" "\n"

View File

@ -76,11 +76,11 @@ testRun(void)
"#endif\n"); "#endif\n");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("check error.auto.c"); TEST_TITLE("check error.auto.c.inc");
TEST_STORAGE_GET( TEST_STORAGE_GET(
storageTest, storageTest,
"src/common/error.auto.c", "src/common/error.auto.c.inc",
COMMENT_BLOCK_BEGIN "\n" COMMENT_BLOCK_BEGIN "\n"
"Error Type Definition\n" "Error Type Definition\n"
"\n" "\n"

View File

@ -402,7 +402,7 @@ testRun(void)
TEST_TITLE("check help file"); TEST_TITLE("check help file");
TEST_RESULT_VOID(bldHlpRender(storageTest, bldCfg, bldHlpParse(storageTest, bldCfg)), "write file"); TEST_RESULT_VOID(bldHlpRender(storageTest, bldCfg, bldHlpParse(storageTest, bldCfg)), "write file");
TEST_STORAGE_EXISTS(storageTest, "command/help/help.auto.c"); TEST_STORAGE_EXISTS(storageTest, "command/help/help.auto.c.inc");
} }
FUNCTION_HARNESS_RETURN_VOID(); FUNCTION_HARNESS_RETURN_VOID();