Mercurial > hg > orthanc
comparison Resources/WindowsResources.py @ 1467:5068de14eef1
Inject version information into Windows binaries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 Jul 2015 09:46:28 +0200 |
parents | |
children | b6a80a5ac500 |
comparison
equal
deleted
inserted
replaced
1466:0cd0f2ad3599 | 1467:5068de14eef1 |
---|---|
1 #!/usr/bin/python | |
2 | |
3 # Orthanc - A Lightweight, RESTful DICOM Store | |
4 # Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics | |
5 # Department, University Hospital of Liege, Belgium | |
6 # | |
7 # This program is free software: you can redistribute it and/or | |
8 # modify it under the terms of the GNU General Public License as | |
9 # published by the Free Software Foundation, either version 3 of the | |
10 # License, or (at your option) any later version. | |
11 # | |
12 # In addition, as a special exception, the copyright holders of this | |
13 # program give permission to link the code of its release with the | |
14 # OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 # that use the same license as the "OpenSSL" library), and distribute | |
16 # the linked executables. You must obey the GNU General Public License | |
17 # in all respects for all of the code used other than "OpenSSL". If you | |
18 # modify file(s) with this exception, you may extend this exception to | |
19 # your version of the file(s), but you are not obligated to do so. If | |
20 # you do not wish to do so, delete this exception statement from your | |
21 # version. If you delete this exception statement from all source files | |
22 # in the program, then also delete it here. | |
23 # | |
24 # This program is distributed in the hope that it will be useful, but | |
25 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 # General Public License for more details. | |
28 # | |
29 # You should have received a copy of the GNU General Public License | |
30 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 | |
32 | |
33 import os | |
34 import sys | |
35 import datetime | |
36 | |
37 if len(sys.argv) != 5: | |
38 sys.stderr.write('Usage: %s <Version> <ProductName> <Filename> <Description>\n\n' % sys.argv[0]) | |
39 sys.stderr.write('Example: %s 0.9.1 Orthanc Orthanc.exe "Lightweight, RESTful DICOM server for medical imaging"\n' % sys.argv[0]) | |
40 sys.exit(-1) | |
41 | |
42 SOURCE = os.path.join(os.path.dirname(__file__), 'WindowsResources.rc') | |
43 | |
44 VERSION = sys.argv[1] | |
45 PRODUCT = sys.argv[2] | |
46 FILENAME = sys.argv[3] | |
47 DESCRIPTION = sys.argv[4] | |
48 | |
49 if VERSION == 'mainline': | |
50 VERSION = '999.999.999' | |
51 RELEASE = 'This is a mainline build, not an official release' | |
52 else: | |
53 RELEASE = 'Release %s' % VERSION | |
54 | |
55 v = VERSION.split('.') | |
56 if len(v) != 3: | |
57 sys.stderr.write('Bad version number: %s\n' % VERSION) | |
58 sys.exit(-1) | |
59 | |
60 extension = os.path.splitext(FILENAME)[1] | |
61 if extension.lower() == '.dll': | |
62 BLOCK = '040904E4' | |
63 TYPE = 'VFT_DLL' | |
64 elif extension.lower() == '.exe': | |
65 #BLOCK = '040904B0' # LANG_ENGLISH/SUBLANG_ENGLISH_US, | |
66 BLOCK = '040904E4' # Lang=US English, CharSet=Windows Multilingual | |
67 TYPE = 'VFT_APP' | |
68 else: | |
69 sys.stderr.write('Unsupported extension (.EXE or .DLL only): %s\n' % extension) | |
70 sys.exit(-1) | |
71 | |
72 | |
73 with open(SOURCE, 'r') as source: | |
74 content = source.read() | |
75 content = content.replace('${VERSION_MAJOR}', v[0]) | |
76 content = content.replace('${VERSION_MINOR}', v[1]) | |
77 content = content.replace('${VERSION_PATCH}', v[2]) | |
78 content = content.replace('${RELEASE}', RELEASE) | |
79 content = content.replace('${DESCRIPTION}', DESCRIPTION) | |
80 content = content.replace('${PRODUCT}', PRODUCT) | |
81 content = content.replace('${FILENAME}', FILENAME) | |
82 content = content.replace('${YEAR}', str(datetime.datetime.now().year)) | |
83 content = content.replace('${BLOCK}', BLOCK) | |
84 content = content.replace('${TYPE}', TYPE) | |
85 | |
86 sys.stdout.write(content) |