msvc: always regenerate config-msvc.h
PATCH 1/1 msvc: always regenerate config-msvc.h
There is no easy way to detect whether this information is outdated. One possible optimisation would be in the Python code to actually only rewrite the file if it has changed. Although VC is already pretty good in detecting whether the code has actually changed so this might not be worth the additional complexity.
While here, change some leading whitespace to tabs as expected in Makefile.
--- build/msvc/msvc-generate/Makefile.mak | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Note: this patch applies to both master and release/2.5 cleanly and should be pushed to both.
build/msvc/msvc-generate/Makefile.mak +6 -3
@@ -51,10 +51,13 @@ $(OUTPUT_PLUGIN): $(INPUT_PLUGIN) $(OUTPUT_PLUGIN_CONFIG) cscript //nologo msvc-generate.js --config="$(OUTPUT_PLUGIN_CONFIG)" --input="$(INPUT_PLUGIN)" --output="$(OUTPUT_PLUGIN)" $(OUTPUT_MAN): $(INPUT_MAN) - -FOR /F %i IN ('where rst2html.py') DO python %i "$(INPUT_MAN)" "$(OUTPUT_MAN)" + -FOR /F %i IN ('where rst2html.py') DO python %i "$(INPUT_MAN)" "$(OUTPUT_MAN)" -$(OUTPUT_MSVC_GIT_CONFIG): - python git-version.py $(SOLUTIONDIR) +# Force regeneration because we can't detect whether it is outdated +$(OUTPUT_MSVC_GIT_CONFIG): FORCE + python git-version.py $(SOLUTIONDIR) + +FORCE: clean: -del "$(OUTPUT_MSVC_VER)"
Signature · 1 line
2.34.1
PATCH v2 1/1 msvc: always call git-version.py
There is no way to detect whether this information is outdated in nmake itself. So leave it up to the Python script to decide.
While here, change some leading whitespace to tabs as expected in Makefile.
--- build/msvc/msvc-generate/Makefile.mak | 9 ++++++--- build/msvc/msvc-generate/git-version.py | 21 ++++++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-)
v2: incorporate changes to git-version.py by Lev
build/msvc/msvc-generate/Makefile.mak +6 -3
@@ -51,10 +51,13 @@ $(OUTPUT_PLUGIN): $(INPUT_PLUGIN) $(OUTPUT_PLUGIN_CONFIG) cscript //nologo msvc-generate.js --config="$(OUTPUT_PLUGIN_CONFIG)" --input="$(INPUT_PLUGIN)" --output="$(OUTPUT_PLUGIN)" $(OUTPUT_MAN): $(INPUT_MAN) - -FOR /F %i IN ('where rst2html.py') DO python %i "$(INPUT_MAN)" "$(OUTPUT_MAN)" + -FOR /F %i IN ('where rst2html.py') DO python %i "$(INPUT_MAN)" "$(OUTPUT_MAN)" -$(OUTPUT_MSVC_GIT_CONFIG): - python git-version.py $(SOLUTIONDIR) +# Force regeneration because we can't detect whether it is outdated +$(OUTPUT_MSVC_GIT_CONFIG): FORCE + python git-version.py $(SOLUTIONDIR) + +FORCE: clean: -del "$(OUTPUT_MSVC_VER)"
build/msvc/msvc-generate/git-version.py +18 -3
@@ -41,10 +41,25 @@ def main(): except: branch, commit_id = "unknown", "unknown" + prev_content = "" + name = os.path.join("%s" % (sys.argv[1] if len(sys.argv) > 1 else "."), "config-version.h") - with open(name, "w") as f: - f.write("#define CONFIGURE_GIT_REVISION \"%s/%s\"\n" % (branch, commit_id)) - f.write("#define CONFIGURE_GIT_FLAGS \"\"\n") + try: + with open(name, "r") as f: + prev_content = f.read() + except: + # file doesn't exist + pass + + content = "#define CONFIGURE_GIT_REVISION \"%s/%s\"\n" % (branch, commit_id) + content += "#define CONFIGURE_GIT_FLAGS \"\"\n" + + if prev_content != content: + print("Writing %s" % name) + with open(name, "w") as f: + f.write(content) + else: + print("Content of %s hasn't changed" % name) if __name__ == "__main__": main()
Signature · 1 line
2.38.1.windows.1
Re: [Openvpn-devel] [PATCH v2] msvc: always call git-version.py
Don't know if I can ack the patch to which I've contributed - but anyway, the makefile change looks
good and the python script doesn't regenerate version header (which would trigger recompilation of some files).
Tested locally and GHA is happy.
[Openvpn-devel] [PATCH applied] Re: msvc: always call git-version.py
In reply to Frank LichtenheldYour patch has been applied to the master and release/2.5 branch.
No code changes, and build changes look reasonable. Thanks.
Pushed to my GH instance for test building, no complaints either.
commit 3951ed8479c01e79bd8fae5c7d4b5f6b07d1f0fb (master) commit 2086517693f68a3b8fe10d79b5e193868b94adf4 (release/2.5)
Author: Frank Lichtenheld Date: Fri Nov 11 13:12:12 2022 +0100
msvc: always call git-version.py
Signed-off-by: Frank Lichtenheld <[email protected]...>
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25508.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering