comparison Resources/Orthanc/CMake/WindowsResources.py @ 0:3ecef5782f2c

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