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 if os.path.isfile(src):
\r
96 # Destination directory must not exist. It must be created first.
\r
97 dst_dir = os.path.normpath(os.path.join(dist_dir, 'bin', subdir))
\r
98 assert not os.path.isdir(dst_dir)
\r
99 os.makedirs(dst_dir)
\r
102 print("Copying '{}'".format(src))
\r
103 shutil.copy2(src, dst_dir)
\r
105 print("The binary '" + src + "'")
\r
106 print('was not found. It will not be present in the distribution.')
\r
109 def getBinariesZipBareName():
\r
110 ver = getDoxygenVersion()
\r
111 sha, dstamp, tstamp = gitSHA_date_time()
\r
112 fname = 'doxygenw{}_{}.zip'.format(dstamp, ver.replace('.', '_'))
\r
116 def getTranslatorReportZipBareName():
\r
117 ver = getDoxygenVersion()
\r
118 sha, dstamp, tstamp = gitSHA_date_time()
\r
119 fname = 'tr{}_{}.zip'.format(dstamp, ver.replace('.', '_'))
\r
123 def zipBinaries(distr_dir):
\r
124 # Build the zip filename. It is to be located at the same level as distr_dir.
\r
125 zip_bare_name = getBinariesZipBareName()
\r
126 dst, distr_subdir = os.path.split(distr_dir)
\r
127 zip_full_name = os.path.join(dst, zip_bare_name)
\r
129 if os.path.isfile(zip_full_name):
\r
130 print("Removing the existing '{}'".format(zip_full_name))
\r
131 os.remove(zip_full_name)
\r
133 # Change the working directory to destination directory and zip from
\r
134 # there using the bare names so that the full path is not zipped inside.
\r
137 print("Zipping new '{}'".format(zip_full_name))
\r
138 subprocess.call('zip -r {} {}'.format(zip_bare_name, distr_subdir), shell=True)
\r
139 os.chdir(wd) # back to the original working directory
\r
142 def buildAndZipTranslatorReport(distr_dir):
\r
143 # Build the translator report zip filename. It is to be located at the same
\r
144 # level as distr_dir.
\r
145 zip_bare_name = getTranslatorReportZipBareName()
\r
146 dst, subdir = os.path.split(distr_dir)
\r
147 zip_full_name = os.path.join(dst, zip_bare_name)
\r
149 if os.path.isfile(zip_full_name):
\r
150 print("Removing the existing '{}'".format(zip_full_name))
\r
151 os.remove(zip_full_name)
\r
152 print("Zipping new '{}'".format(zip_full_name))
\r
154 # Change the working directory to the doc one and generate
\r
155 # the translator report.
\r
156 sdir, fname = getThisScriptPathAndName()
\r
157 docdir = os.path.join(sdir, '..', 'doc')
\r
158 assert os.path.isdir(docdir)
\r
161 subprocess.call('python translator.py', shell=True)
\r
163 # Zip the generated translator_report.txt.
\r
164 subprocess.call('zip -r {} {}'.format(zip_full_name,
\r
165 'translator_report.txt'), shell=True)
\r
167 os.chdir(wd) # back to the original working directory
\r
172 # Information for the letter.
\r
173 ver = getDoxygenVersion()
\r
174 sha, dstamp, tstamp = gitSHA_date_time()
\r
175 doxzipname = getBinariesZipBareName()
\r
176 trzipname = getTranslatorReportZipBareName()
\r
178 subject = 'Windows binaries available for {}-{} at SourceForge'.format(ver, dstamp)
\r
179 subject = subject.replace(' ', '%20')
\r
181 body = textwrap.dedent('''\
\r
184 If interested, you can download the doxygen binaries
\r
185 compiled for MS Windows from
\r
187 http://sourceforge.net/projects/doxygen/files/snapshots/doxygen-1.8-svn/windows
\r
189 This is the place where you should find also the next
\r
190 releases. Name of the archive file is
\r
194 The related translator report can be found inside the directory
\r
196 http://sourceforge.net/projects/doxygen/files/snapshots/doxygen-1.8-svn/translator_reports/
\r
198 Name of the archive file is
\r
202 The binaries are NOT created automatically, so it may
\r
203 happen that some newer sources were not compiled
\r
204 because I am not present to do that or I forgot... ;)
\r
210 Petr Prikryl (prikryl at atlas dot cz)''').format(doxzipname, trzipname)
\r
211 body = body.replace('\n', '%0d')
\r
213 # Make the mailto URI and launch the mailer.
\r
214 to_addr = 'doxygen-users@lists.sourceforge.net'
\r
215 mailtoURI = 'mailto:%s?subject=%s&body=%s' % (to_addr, subject, body)
\r
216 os.startfile(mailtoURI)
\r
219 if __name__ == '__main__':
\r
220 # Create the empty directory for the distribution files.
\r
221 dist_dir = getEmptyDistribDir()
\r
223 # Copy the compiled binaries to the distribution directory and zip them.
\r
224 copyBinaries(dist_dir, 'Debug')
\r
225 copyBinaries(dist_dir, 'Debug64')
\r
226 copyBinaries(dist_dir, 'Release')
\r
227 copyBinaries(dist_dir, 'Release64')
\r
228 zipBinaries(dist_dir)
\r
230 # The translator report...
\r
231 buildAndZipTranslatorReport(dist_dir)
\r
233 # Launch the mailer with the generated message body.
\r