From 2feaaeaac803d6c0193477b56dbeb622fd991156 Mon Sep 17 00:00:00 2001 From: David Steele Date: Tue, 31 May 2022 16:06:41 -0400 Subject: [PATCH] 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. --- .gitattributes | 3 ++- CONTRIBUTING.md | 18 +++++++++--------- doc/xml/contributing.xml | 2 +- src/.gitignore | 2 +- src/Makefile.in | 8 ++++---- src/build/config/render.c | 4 ++-- src/build/error/error.yaml | 2 +- src/build/error/render.c | 4 ++-- src/build/help/render.c | 2 +- src/common/crypto/hash.c | 2 +- .../crypto/{md5.vendor.c => md5.vendor.c.inc} | 0 src/common/{error.auto.c => error.auto.c.inc} | 0 src/common/error.c | 2 +- src/config/{parse.auto.c => parse.auto.c.inc} | 0 src/config/parse.c | 8 ++++---- src/main.c | 2 +- src/postgres/interface/page.c | 2 +- ...ksum.vendor.c => pageChecksum.vendor.c.inc} | 0 test/code-count/file-type.yaml | 8 ++++---- .../lib/pgBackRestTest/Common/CodeCountTest.pm | 6 +++--- test/lib/pgBackRestTest/Common/CoverageTest.pm | 8 +++++--- test/src/module/build/configTest.c | 4 ++-- test/src/module/build/errorTest.c | 4 ++-- test/src/module/build/helpTest.c | 2 +- 24 files changed, 48 insertions(+), 45 deletions(-) rename src/common/crypto/{md5.vendor.c => md5.vendor.c.inc} (100%) rename src/common/{error.auto.c => error.auto.c.inc} (100%) rename src/config/{parse.auto.c => parse.auto.c.inc} (100%) rename src/postgres/interface/{pageChecksum.vendor.c => pageChecksum.vendor.c.inc} (100%) diff --git a/.gitattributes b/.gitattributes index f51ff42fa..0378189c3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ -# Classify all .h files as C +# Classify all .h/c.inc files as C *.h linguist-language=C +*.c.inc linguist-language=C diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5b098697c..c3997fbfd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -243,7 +243,7 @@ pgbackrest/test/test.pl --vm=none --dry-run P00 INFO: configure build P00 INFO: builds required: bin --> P00 INFO: 72 tests selected - + P00 INFO: P1-T01/72 - vm=none, module=common, test=error [filtered 69 lines of output] P00 INFO: P1-T71/72 - vm=none, module=performance, test=type @@ -265,12 +265,12 @@ pgbackrest/test/test.pl --vm=none --vm-out --module=common --test=wait P00 INFO: cleanup old data P00 INFO: builds required: none P00 INFO: 1 test selected - + P00 INFO: P1-T1/1 - vm=none, module=common, test=wait - + run 1 - waitNew(), waitMore, and waitFree() L0018 expect AssertError: assertion 'waitTime <= 999999000' failed - + run 1/1 ------------- L0021 0ms wait L0025 new wait L0026 check remaining time @@ -295,9 +295,9 @@ pgbackrest/test/test.pl --vm=none --vm-out --module=common --test=wait L0062 lower range check L0063 upper range check L0065 free wait - + TESTS COMPLETED SUCCESSFULLY - + P00 INFO: P1-T1/1 - vm=none, module=common, test=wait P00 INFO: tested modules have full coverage P00 INFO: writing C coverage report @@ -320,7 +320,7 @@ pgbackrest/test/test.pl --vm=none --module=postgres P00 INFO: cleanup old data P00 INFO: builds required: none P00 INFO: 2 tests selected - + P00 INFO: P1-T1/2 - vm=none, module=postgres, test=client P00 INFO: P1-T2/2 - vm=none, module=postgres, test=interface P00 INFO: tested modules have full coverage @@ -363,7 +363,7 @@ pgbackrest/test/test.pl --vm=u20 --module=mock --test=archive --run=2 P00 INFO: build bin for none (/home/vagrant/test/bin/none) P00 INFO: bin dependencies have changed, rebuilding P00 INFO: 1 test selected - + P00 INFO: P1-T1/1 - vm=u20, module=mock, test=archive, run=2 P00 INFO: no code modules had all tests run required for coverage P00 INFO: TESTS COMPLETED SUCCESSFULLY @@ -561,7 +561,7 @@ run 8/1 ------------- L2285 no current backups ## 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: diff --git a/doc/xml/contributing.xml b/doc/xml/contributing.xml index d7ddb17e2..a6b553481 100644 --- a/doc/xml/contributing.xml +++ b/doc/xml/contributing.xml @@ -648,7 +648,7 @@ run 8/1 ------------- L2285 no current backups
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:

diff --git a/src/.gitignore b/src/.gitignore index 734c19e09..9915273b3 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,6 +1,6 @@ /.build autom4te.cache -/command/help/help.auto.c +/command/help/help.auto.c.inc /config.log /config.status /Makefile diff --git a/src/Makefile.in b/src/Makefile.in index 3eb23e63f..378218357 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -216,7 +216,7 @@ 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) ./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 $(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) #################################################################################################################################### @@ -276,7 +276,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 + rm -f pgbackrest build-config build-error build-help command/help/help.auto.c.inc .PHONY = clean-all @@ -288,7 +288,7 @@ clean-all: clean # Special per-object flags #################################################################################################################################### $(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 diff --git a/src/build/config/render.c b/src/build/config/render.c index 3e626731f..f4613df96 100644 --- a/src/build/config/render.c +++ b/src/build/config/render.c @@ -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" @@ -1309,7 +1309,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg, co // Write to storage // ----------------------------------------------------------------------------------------------------------------------------- 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)))); } diff --git a/src/build/error/error.yaml b/src/build/error/error.yaml index 67b6cbe1c..c15ea6973 100644 --- a/src/build/error/error.yaml +++ b/src/build/error/error.yaml @@ -1,6 +1,6 @@ # 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 assert: diff --git a/src/build/error/render.c b/src/build/error/render.c index 433062049..384d86ae3 100644 --- a/src/build/error/render.c +++ b/src/build/error/render.c @@ -82,7 +82,7 @@ bldErrRenderErrorAutoH(const Storage *const storageRepo, const BldErr bldErr) } /*********************************************************************************************************************************** -Render error.auto.c +Render error.auto.c.inc ***********************************************************************************************************************************/ static void bldErrRenderErrorAutoC(const Storage *const storageRepo, const BldErr bldErr) @@ -130,7 +130,7 @@ bldErrRenderErrorAutoC(const Storage *const storageRepo, const BldErr bldErr) " NULL,\n" "};\n"); - bldPut(storageRepo, "src/common/error.auto.c", BUFSTR(error)); + bldPut(storageRepo, "src/common/error.auto.c.inc", BUFSTR(error)); } /**********************************************************************************************************************************/ diff --git a/src/build/help/render.c b/src/build/help/render.c index eb381b206..f95b12fe8 100644 --- a/src/build/help/render.c +++ b/src/build/help/render.c @@ -325,7 +325,7 @@ bldHlpRenderHelpAutoC(const Storage *const storageRepo, const BldCfg bldCfg, con strCatZ(help, "\n};\n"); // Write to storage - bldPut(storageRepo, "command/help/help.auto.c", BUFSTR(help)); + bldPut(storageRepo, "command/help/help.auto.c.inc", BUFSTR(help)); } /**********************************************************************************************************************************/ diff --git a/src/common/crypto/hash.c b/src/common/crypto/hash.c index 85b56660c..78c399062 100644 --- a/src/common/crypto/hash.c +++ b/src/common/crypto/hash.c @@ -26,7 +26,7 @@ STRING_EXTERN(HASH_TYPE_SHA256_ZERO_STR, HASH_TYPE_SH /*********************************************************************************************************************************** Include local MD5 code ***********************************************************************************************************************************/ -#include "common/crypto/md5.vendor.c" +#include "common/crypto/md5.vendor.c.inc" /*********************************************************************************************************************************** Object type diff --git a/src/common/crypto/md5.vendor.c b/src/common/crypto/md5.vendor.c.inc similarity index 100% rename from src/common/crypto/md5.vendor.c rename to src/common/crypto/md5.vendor.c.inc diff --git a/src/common/error.auto.c b/src/common/error.auto.c.inc similarity index 100% rename from src/common/error.auto.c rename to src/common/error.auto.c.inc diff --git a/src/common/error.c b/src/common/error.c index 2bb83568c..ebd6ddcc1 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -34,7 +34,7 @@ struct ErrorType #endif // Include error type definitions -#include "common/error.auto.c" +#include "common/error.auto.c.inc" /*********************************************************************************************************************************** Maximum allowed number of nested try blocks diff --git a/src/config/parse.auto.c b/src/config/parse.auto.c.inc similarity index 100% rename from src/config/parse.auto.c rename to src/config/parse.auto.c.inc diff --git a/src/config/parse.c b/src/config/parse.c index c94e02b3c..afeb382a9 100644 --- a/src/config/parse.c +++ b/src/config/parse.c @@ -71,7 +71,7 @@ typedef struct ParseRuleCommand bool parameterAllowed:1; // Command-line parameters are allowed } 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(...) \ {__VA_ARGS__} @@ -110,7 +110,7 @@ typedef struct ParseRuleOptionGroup const char *name; // All options in the group must be prefixed with this name } 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(...) \ {__VA_ARGS__} @@ -157,7 +157,7 @@ typedef enum parseRuleFilterTypeCommand = 1, } 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(...) \ {__VA_ARGS__} @@ -265,7 +265,7 @@ typedef struct ParseRuleOptionDeprecate /*********************************************************************************************************************************** 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 diff --git a/src/main.c b/src/main.c index 475723c8a..dc1cb053c 100644 --- a/src/main.c +++ b/src/main.c @@ -51,7 +51,7 @@ Main /*********************************************************************************************************************************** Include automatically generated help data ***********************************************************************************************************************************/ -#include "command/help/help.auto.c" +#include "command/help/help.auto.c.inc" int main(int argListSize, const char *argList[]) diff --git a/src/postgres/interface/page.c b/src/postgres/interface/page.c index 7c65e3415..b9dd746fc 100644 --- a/src/postgres/interface/page.c +++ b/src/postgres/interface/page.c @@ -10,7 +10,7 @@ PostgreSQL Page Interface /*********************************************************************************************************************************** Include the page checksum code ***********************************************************************************************************************************/ -#include "postgres/interface/pageChecksum.vendor.c" +#include "postgres/interface/pageChecksum.vendor.c.inc" /**********************************************************************************************************************************/ uint16_t diff --git a/src/postgres/interface/pageChecksum.vendor.c b/src/postgres/interface/pageChecksum.vendor.c.inc similarity index 100% rename from src/postgres/interface/pageChecksum.vendor.c rename to src/postgres/interface/pageChecksum.vendor.c.inc diff --git a/test/code-count/file-type.yaml b/test/code-count/file-type.yaml index 4f62bc4bf..449625cf4 100644 --- a/test/code-count/file-type.yaml +++ b/test/code-count/file-type.yaml @@ -727,7 +727,7 @@ src/common/crypto/hash.h: class: core type: c/h -src/common/crypto/md5.vendor.c: +src/common/crypto/md5.vendor.c.inc: class: core/vendor type: c @@ -747,7 +747,7 @@ src/common/encode.h: class: core type: c/h -src/common/error.auto.c: +src/common/error.auto.c.inc: class: core/auto type: c @@ -1311,7 +1311,7 @@ src/config/load.h: class: core type: c/h -src/config/parse.auto.c: +src/config/parse.auto.c.inc: class: core/auto type: c @@ -1423,7 +1423,7 @@ src/postgres/interface/page.c: class: core type: c -src/postgres/interface/pageChecksum.vendor.c: +src/postgres/interface/pageChecksum.vendor.c.inc: class: core/vendor type: c diff --git a/test/lib/pgBackRestTest/Common/CodeCountTest.pm b/test/lib/pgBackRestTest/Common/CodeCountTest.pm index ca8e72882..e7c813485 100644 --- a/test/lib/pgBackRestTest/Common/CodeCountTest.pm +++ b/test/lib/pgBackRestTest/Common/CodeCountTest.pm @@ -94,13 +94,13 @@ sub codeCountScan } # Append auto if an auto-generated file - if ($strFile =~ '\.auto\..$' | $strFile =~ 'Auto\.pm$') + if ($strFile =~ '\.auto\..$' || $strFile =~ '\.auto\..\.inc$' || $strFile =~ 'Auto\.pm$') { $strClass .= '/auto'; } # Append vendor if a vendorized file - if ($strFile =~ '\.vendor\..$') + if ($strFile =~ '\.vendor\..$' || $strFile =~ '\.vendor\..\.inc$') { $strClass .= '/vendor'; } @@ -119,7 +119,7 @@ sub codeCountScan $strType = 'c/h'; $strForceLang = 'C/C++ Header'; } - elsif ($strFile =~ '\.c$') + elsif ($strFile =~ '\.c$' || $strFile =~ '\.c.inc$') { $strType = 'c'; $strForceLang = 'C'; diff --git a/test/lib/pgBackRestTest/Common/CoverageTest.pm b/test/lib/pgBackRestTest/Common/CoverageTest.pm index dfe57fd9e..03cc2facc 100644 --- a/test/lib/pgBackRestTest/Common/CoverageTest.pm +++ b/test/lib/pgBackRestTest/Common/CoverageTest.pm @@ -140,16 +140,18 @@ sub coverageExtract 'test/src/module/' . substr(${strModuleOutName}, 5) : "src/${strModuleOutName}"); my $strLCovFile = "${strTestResultCoveragePath}/raw/${strModuleOutName}.lcov"; my $strLCovTotal = "${strWorkTmpPath}/all.lcov"; + my $bInc = $strModuleName =~ '\.vendor$' || $strModuleName =~ '\.auto$'; + my $strModuleSourceFile = $strModulePath . '.c' . ($bInc ? '.inc' : ''); executeTest( "${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 if ($oStorage->exists($strLCovFile)) { my $strCoverage = ${$oStorage->get($strLCovOutTmp)}; - $strCoverage =~ s/^SF\:.*$/SF:$strModulePath\.c/mg; + $strCoverage =~ s/^SF\:.*$/SF:$strModuleSourceFile/mg; $oStorage->put($strLCovOutTmp, $strCoverage); executeTest("${strLCovExe} --add-tracefile=${strLCovOutTmp} --add-tracefile=${strLCovFile} --o=${strLCovOutTmp}"); @@ -185,7 +187,7 @@ sub coverageExtract if (!$bTest || $iTotalLines != $iCoveredLines || $iTotalBranches != $iCoveredBranches) { # 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); diff --git a/test/src/module/build/configTest.c b/test/src/module/build/configTest.c index ed7e9ae57..2fab80eac 100644 --- a/test/src/module/build/configTest.c +++ b/test/src/module/build/configTest.c @@ -561,11 +561,11 @@ testRun(void) "#endif\n"); // ------------------------------------------------------------------------------------------------------------------------- - TEST_TITLE("check parse.auto.c"); + TEST_TITLE("check parse.auto.c.inc"); TEST_STORAGE_GET( storageTest, - "src/config/parse.auto.c", + "src/config/parse.auto.c.inc", COMMENT_BLOCK_BEGIN "\n" "Config Parse Rules\n" "\n" diff --git a/test/src/module/build/errorTest.c b/test/src/module/build/errorTest.c index 596766f8e..e6cfd4abf 100644 --- a/test/src/module/build/errorTest.c +++ b/test/src/module/build/errorTest.c @@ -76,11 +76,11 @@ testRun(void) "#endif\n"); // ------------------------------------------------------------------------------------------------------------------------- - TEST_TITLE("check error.auto.c"); + TEST_TITLE("check error.auto.c.inc"); TEST_STORAGE_GET( storageTest, - "src/common/error.auto.c", + "src/common/error.auto.c.inc", COMMENT_BLOCK_BEGIN "\n" "Error Type Definition\n" "\n" diff --git a/test/src/module/build/helpTest.c b/test/src/module/build/helpTest.c index 233b66238..c70f46091 100644 --- a/test/src/module/build/helpTest.c +++ b/test/src/module/build/helpTest.c @@ -402,7 +402,7 @@ testRun(void) TEST_TITLE("check help 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();