annotate OrthancFramework/Resources/WindowsResources.py @ 4844:55e8fb8e8028

tagging a pre-release of the Orthanc framework for WSI 1.1
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Dec 2021 14:01:17 +0100
parents 7053502fbf97
children 43e613a7756b
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
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
6 # Copyright (C) 2017-2021 Osimis S.A., Belgium
4831
7053502fbf97 added copyright UCLouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
7 # Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 #
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 # 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
10 # 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
11 # 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
12 # 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
13 #
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # 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
15 # 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
16 # 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
17 # Lesser General Public License for more details.
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 #
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
19 # 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
20 # 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
21 # <http://www.gnu.org/licenses/>.
1467
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
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 import os
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 import sys
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 import datetime
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 if len(sys.argv) != 5:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 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
30 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
31 sys.exit(-1)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 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
34
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 VERSION = sys.argv[1]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 PRODUCT = sys.argv[2]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 FILENAME = sys.argv[3]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 DESCRIPTION = sys.argv[4]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 if VERSION == 'mainline':
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 VERSION = '999.999.999'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 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
43 else:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 RELEASE = 'Release %s' % VERSION
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 v = VERSION.split('.')
1470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1467
diff changeset
47 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
48 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
49 sys.exit(-1)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
1470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1467
diff changeset
51 if len(v) == 2:
1471
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1470
diff changeset
52 v.append('0')
1470
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1467
diff changeset
53
1467
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 extension = os.path.splitext(FILENAME)[1]
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 if extension.lower() == '.dll':
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 BLOCK = '040904E4'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 TYPE = 'VFT_DLL'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 elif extension.lower() == '.exe':
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 #BLOCK = '040904B0' # LANG_ENGLISH/SUBLANG_ENGLISH_US,
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 BLOCK = '040904E4' # Lang=US English, CharSet=Windows Multilingual
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 TYPE = 'VFT_APP'
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 else:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 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
64 sys.exit(-1)
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
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 with open(SOURCE, 'r') as source:
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 content = source.read()
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 content = content.replace('${VERSION_MAJOR}', v[0])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 content = content.replace('${VERSION_MINOR}', v[1])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 content = content.replace('${VERSION_PATCH}', v[2])
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 content = content.replace('${RELEASE}', RELEASE)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 content = content.replace('${DESCRIPTION}', DESCRIPTION)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 content = content.replace('${PRODUCT}', PRODUCT)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 content = content.replace('${FILENAME}', FILENAME)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 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
77 content = content.replace('${BLOCK}', BLOCK)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 content = content.replace('${TYPE}', TYPE)
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
5068de14eef1 Inject version information into Windows binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 sys.stdout.write(content)