]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
msvc: always call git-version.py
authorFrank Lichtenheld <frank@lichtenheld.com>
Fri, 11 Nov 2022 12:12:12 +0000 (13:12 +0100)
committerGert Doering <gert@greenie.muc.de>
Fri, 11 Nov 2022 12:44:18 +0000 (13:44 +0100)
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.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20221111121212.25167-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25508.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
build/msvc/msvc-generate/Makefile.mak
build/msvc/msvc-generate/git-version.py

index ae8b08426c02cc280347185d70f8bce22249e2f2..1c1c4bab1818c9e4e5a45bf202bd964aae428f07 100644 (file)
@@ -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)"
index b6037e1e02157ed4bb94c78d7d1dc3bb64d4f825..814dc86a87668513f7f557f45fec3ef261a1ea6e 100644 (file)
@@ -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()