3 from __future__ import print_function
\r
13 def gitSHA_date_time():
\r
14 cmd = 'git rev-parse --short HEAD'
\r
15 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
\r
16 output = p.communicate()[0]
\r
17 output = output.decode('ASCII')
\r
19 sha = output.strip()
\r
21 cmd = 'git show -s --format="%ci" ' + sha
\r
22 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
\r
23 output = p.communicate()[0]
\r
24 output = output.decode('ASCII')
\r
26 date = output.strip()
\r
27 lst = date.split() # string like '2013-06-21 09:23:47 +0200'
\r
28 dstamp = lst[0].replace('-', '') # '20130621' for the date
\r
29 tstamp = lst[1].replace(':', '') # '092347' for the time
\r
31 return sha, dstamp, tstamp
\r
34 def getDoxygenVersion():
\r
35 # ... from the VERSION file.
\r
36 sdir, fname = getThisScriptPathAndName()
\r
37 version_fname = os.path.join(sdir, '..', 'VERSION')
\r
39 with open(version_fname) as f:
\r
42 doxver = lst[0].strip()
\r
44 m = re.match(r'^(?P<ver>[0-9.]+)(-(?P<date>\d{8}))?', doxver)
\r
46 ver = m.group('ver')
\r
50 def getThisScriptPathAndName():
\r
51 script_fname = os.path.realpath(__file__)
\r
52 sdir, fname = os.path.split(script_fname)
\r
56 def getEmptyDistribDir():
\r
57 # Get this script full path, name, and the script subdir name
\r
58 # (for checking the location).
\r
59 sdir, fname = getThisScriptPathAndName()
\r
60 subdir = os.path.basename(sdir)
\r
61 assert subdir == 'winbuild'
\r
63 # The distribution directory will be a subdirectory of the "../__put"
\r
64 # (created if it does not exist, not the part of the git repo).
\r
65 target_dir = os.path.normpath(os.path.join(sdir, '..', '__put'))
\r
66 if not os.path.exists(target_dir):
\r
67 os.mkdir(target_dir)
\r
68 assert os.path.isdir(target_dir)
\r
70 # The distribution subdir is composed out of 'Doxygen-', version stamp,
\r
71 # timestamp, and commit id (partial SHA). Ignore the date from the VERSION
\r
72 # file, take the commit date.
\r
73 ver = getDoxygenVersion()
\r
74 sha, dstamp, tstamp = gitSHA_date_time()
\r
75 dist_subdir = 'Doxygen-' + ver + '-' + dstamp + tstamp
\r
76 dist_dir = os.path.join(target_dir, dist_subdir)
\r
78 if os.path.isdir(dist_dir):
\r
79 print("Removing the existing '{}'".format(dist_dir))
\r
80 shutil.rmtree(dist_dir)
\r
81 assert not os.path.exists(dist_dir)
\r
82 print("Creating the new '{}'".format(dist_dir))
\r
84 assert os.path.isdir(dist_dir)
\r
89 def copyBinaries(dist_dir, subdir):
\r
90 '''Copy the Windows binaries (doxygen.exe only) to the dist_dir directory.'''
\r
92 # Source file should exist.
\r
93 sdir, fname = getThisScriptPathAndName()
\r
94 src = os.path.normpath(os.path.join(sdir, '..', 'bin', subdir, 'doxygen.exe'))
\r
95 assert os.path.isfile(src)
\r
97 # Destination directory must not exist. It must be created first.
\r
98 dst_dir = os.path.normpath(os.path.join(dist_dir, 'bin', subdir))
\r
99 assert not os.path.isdir(dst_dir)
\r
100 os.makedirs(dst_dir)
\r
103 print("Copying '{}'".format(src))
\r
104 shutil.copy2(src, dst_dir)
\r
107 def getBinariesZipBareName():
\r
108 ver = getDoxygenVersion()
\r
109 sha, dstamp, tstamp = gitSHA_date_time()
\r
110 fname = 'doxygenw{}_{}.zip'.format(dstamp, ver.replace('.', '_'))
\r
114 def getTranslatorReportZipBareName():
\r
115 ver = getDoxygenVersion()
\r
116 sha, dstamp, tstamp = gitSHA_date_time()
\r
117 fname = 'tr{}_{}.zip'.format(dstamp, ver.replace('.', '_'))
\r
121 def zipBinaries(distr_dir):
\r
122 # Build the zip filename. It is to be located at the same level as distr_dir.
\r
123 zip_bare_name = getBinariesZipBareName()
\r
124 dst, distr_subdir = os.path.split(distr_dir)
\r
125 zip_full_name = os.path.join(dst, zip_bare_name)
\r
127 if os.path.isfile(zip_full_name):
\r
128 print("Removing the existing '{}'".format(zip_full_name))
\r
129 os.remove(zip_full_name)
\r
131 # Change the working directory to destination directory and zip from
\r
132 # there using the bare names so that the full path is not zipped inside.
\r
135 print("Zipping new '{}'".format(zip_full_name))
\r
136 subprocess.call('zip -r {} {}'.format(zip_bare_name, distr_subdir), shell=True)
\r
137 os.chdir(wd) # back to the original working directory
\r
140 def buildAndZipTranslatorReport(distr_dir):
\r
141 # Build the translator report zip filename. It is to be located at the same
\r
142 # level as distr_dir.
\r
143 zip_bare_name = getTranslatorReportZipBareName()
\r
144 dst, subdir = os.path.split(distr_dir)
\r
145 zip_full_name = os.path.join(dst, zip_bare_name)
\r
147 if os.path.isfile(zip_full_name):
\r
148 print("Removing the existing '{}'".format(zip_full_name))
\r
149 os.remove(zip_full_name)
\r
150 print("Zipping new '{}'".format(zip_full_name))
\r
152 # Change the working directory to the doc one and generate
\r
153 # the translator report.
\r
154 sdir, fname = getThisScriptPathAndName()
\r
155 docdir = os.path.join(sdir, '..', 'doc')
\r
156 assert os.path.isdir(docdir)
\r
159 subprocess.call('python translator.py', shell=True)
\r
161 # Zip the generated translator_report.txt.
\r
162 subprocess.call('zip -r {} {}'.format(zip_full_name,
\r
163 'translator_report.txt'), shell=True)
\r
165 os.chdir(wd) # back to the original working directory
\r
170 # Information for the letter.
\r
171 ver = getDoxygenVersion()
\r
172 sha, dstamp, tstamp = gitSHA_date_time()
\r
173 doxzipname = getBinariesZipBareName()
\r
174 trzipname = getTranslatorReportZipBareName()
\r
176 subject = 'Windows binaries available for {}-{} at SourceForge'.format(ver, dstamp)
\r
177 subject = subject.replace(' ', '%20')
\r
179 body = textwrap.dedent('''\
\r
182 If interested, you can download the doxygen binaries
\r
183 compiled for MS Windows from
\r
185 http://sourceforge.net/projects/doxygen/files/snapshots/doxygen-1.8-svn/windows
\r
187 This is the place where you should find also the next
\r
188 releases. Name of the archive file is
\r
192 The related translator report can be found inside the directory
\r
194 http://sourceforge.net/projects/doxygen/files/snapshots/doxygen-1.8-svn/translator_reports/
\r
196 Name of the archive file is
\r
200 The binaries are NOT created automatically, so it may
\r
201 happen that some newer sources were not compiled
\r
202 because I am not present to do that or I forgot... ;)
\r
208 Petr Prikryl (prikryl at atlas dot cz)''').format(doxzipname, trzipname)
\r
209 body = body.replace('\n', '%0d')
\r
211 # Make the mailto URI and launch the mailer.
\r
212 to_addr = 'doxygen-users@lists.sourceforge.net'
\r
213 mailtoURI = 'mailto:%s?subject=%s&body=%s' % (to_addr, subject, body)
\r
214 os.startfile(mailtoURI)
\r
217 if __name__ == '__main__':
\r
218 # Create the empty directory for the distribution files.
\r
219 dist_dir = getEmptyDistribDir()
\r
221 # Copy the compiled binaries to the distribution directory and zip them.
\r
222 copyBinaries(dist_dir, 'Debug')
\r
223 copyBinaries(dist_dir, 'Debug64')
\r
224 copyBinaries(dist_dir, 'Release')
\r
225 copyBinaries(dist_dir, 'Release64')
\r
226 zipBinaries(dist_dir)
\r
228 # The translator report...
\r
229 buildAndZipTranslatorReport(dist_dir)
\r
231 # Launch the mailer with the generated message body.
\r