]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
setup.py: generate _version.h for use by Windows installer.
authorDaira Hopwood <daira@jacaranda.org>
Fri, 21 Nov 2014 08:12:13 +0000 (08:12 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 30 Apr 2015 14:17:27 +0000 (15:17 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
setup.py

index 5f6878539f650eea60650a4368a4134627da2f0e..ab98c6e1742176c6ffbcd88b17c76fd493e5b64c 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -38,6 +38,8 @@ def read_version_py(infname):
             return mo.group(1)
 
 VERSION_PY_FILENAME = 'src/allmydata/_version.py'
+VERSION_H_FILENAME = 'misc/build_helpers/windows/installer/installer/_version.h'
+
 version = read_version_py(VERSION_PY_FILENAME)
 
 APPNAME='allmydata-tahoe'
@@ -250,7 +252,7 @@ class MakeExecutable(Command):
                 raise
 
 
-GIT_VERSION_BODY = '''
+GIT_VERSION_PY = '''
 # This _version.py is generated from git metadata by the tahoe setup.py.
 
 __pkgname__ = %(pkgname)r
@@ -261,6 +263,12 @@ verstr = %(normalized)r
 __version__ = verstr
 '''
 
+GIT_VERSION_H = '''
+// This _version.h is generated from git metadata by the tahoe setup.py.
+
+#define PKGNAME_AND_VERSION L"%(pkgname)s-%(normalized)s"
+'''
+
 def run_command(args, cwd=None):
     use_shell = sys.platform == "win32"
     try:
@@ -366,17 +374,23 @@ Warning: no version information found. This may cause tests to fail.
         # If we change APPNAME, the release tag names should also change from then on.
         versions = versions_from_git(APPNAME + '-')
         if versions:
+            version_info = {
+                "pkgname": self.distribution.get_name(),
+                "version": versions["version"],
+                "normalized": versions["normalized"],
+                "full": versions["full"],
+                "branch": versions["branch"],
+            }
+
             f = open(VERSION_PY_FILENAME, "wb")
-            f.write(GIT_VERSION_BODY %
-                    { "pkgname": self.distribution.get_name(),
-                      "version": versions["version"],
-                      "normalized": versions["normalized"],
-                      "full": versions["full"],
-                      "branch": versions["branch"],
-                    })
+            f.write(GIT_VERSION_PY % version_info)
             f.close()
             print("Wrote normalized version %r into '%s'" % (versions["normalized"], VERSION_PY_FILENAME))
 
+            f = open(VERSION_H_FILENAME, "wb")
+            f.write(GIT_VERSION_H % version_info)
+            f.close()
+
         return versions.get("normalized", None)