annotate OrthancFramework/Resources/WindowsResources.py @ 4160:77255a09883b

back to mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 24 Aug 2020 07:28:45 +0200
parents bf7b9edf6b81
children d9473bd5ed43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/python
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1471
diff changeset
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Department, University Hospital of Liege, Belgium
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
6 # Copyright (C) 2017-2020 Osimis S.A., Belgium
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 #
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 # modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 # as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
11 # the License, or (at your option) any later version.
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 #
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful, but
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
16 # Lesser General Public License for more details.
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 #
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 # License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
20 # <http://www.gnu.org/licenses/>.
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 import os
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 import sys
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 import datetime
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 if len(sys.argv) != 5:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 sys.stderr.write('Usage: %s <Version> <ProductName> <Filename> <Description>\n\n' % sys.argv[0])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 sys.stderr.write('Example: %s 0.9.1 Orthanc Orthanc.exe "Lightweight, RESTful DICOM server for medical imaging"\n' % sys.argv[0])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 sys.exit(-1)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 SOURCE = os.path.join(os.path.dirname(__file__), 'WindowsResources.rc')
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 VERSION = sys.argv[1]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 PRODUCT = sys.argv[2]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 FILENAME = sys.argv[3]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 DESCRIPTION = sys.argv[4]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 if VERSION == 'mainline':
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 VERSION = '999.999.999'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 RELEASE = 'This is a mainline build, not an official release'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 else:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 RELEASE = 'Release %s' % VERSION
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 v = VERSION.split('.')
1470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1467
diff changeset
46 if len(v) != 2 and len(v) != 3:
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 sys.stderr.write('Bad version number: %s\n' % VERSION)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 sys.exit(-1)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
1470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1467
diff changeset
50 if len(v) == 2:
1471
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1470
diff changeset
51 v.append('0')
1470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1467
diff changeset
52
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 extension = os.path.splitext(FILENAME)[1]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 if extension.lower() == '.dll':
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 BLOCK = '040904E4'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 TYPE = 'VFT_DLL'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 elif extension.lower() == '.exe':
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 #BLOCK = '040904B0' # LANG_ENGLISH/SUBLANG_ENGLISH_US,
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 BLOCK = '040904E4' # Lang=US English, CharSet=Windows Multilingual
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 TYPE = 'VFT_APP'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 else:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 sys.stderr.write('Unsupported extension (.EXE or .DLL only): %s\n' % extension)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 sys.exit(-1)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 with open(SOURCE, 'r') as source:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 content = source.read()
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 content = content.replace('${VERSION_MAJOR}', v[0])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 content = content.replace('${VERSION_MINOR}', v[1])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 content = content.replace('${VERSION_PATCH}', v[2])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 content = content.replace('${RELEASE}', RELEASE)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 content = content.replace('${DESCRIPTION}', DESCRIPTION)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 content = content.replace('${PRODUCT}', PRODUCT)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 content = content.replace('${FILENAME}', FILENAME)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 content = content.replace('${YEAR}', str(datetime.datetime.now().year))
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 content = content.replace('${BLOCK}', BLOCK)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 content = content.replace('${TYPE}', TYPE)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 sys.stdout.write(content)