Mercurial > hg > orthanc-python
annotate Resources/SyncOrthancFolder.py @ 22:04b8a44b2717
adding patch.exe command-line tool for MSVC
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 03 Apr 2020 10:47:01 +0200 |
parents | 777b677cc9fc |
children | fd58eb5749ed |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 | |
3 # | |
4 # This maintenance script updates the content of the "Orthanc" folder | |
5 # to match the latest version of the Orthanc source code. | |
6 # | |
7 | |
8 import multiprocessing | |
9 import os | |
10 import stat | |
11 import urllib2 | |
12 import subprocess | |
13 | |
14 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') | |
15 PLUGIN_SDK_VERSION = '1.5.7' | |
16 REPOSITORY = 'https://hg.orthanc-server.com/orthanc/raw-file' | |
17 | |
18 FILES = [ | |
19 'Core/Compatibility.h', | |
20 'Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', | |
21 'Plugins/Samples/Common/OrthancPluginCppWrapper.h', | |
22 'Plugins/Samples/Common/OrthancPluginException.h', | |
23 'Plugins/Samples/Common/VersionScript.map', | |
24 'Resources/CMake/BoostConfiguration.cmake', | |
25 'Resources/CMake/Compiler.cmake', | |
26 'Resources/CMake/DownloadPackage.cmake', | |
27 'Resources/CMake/JsonCppConfiguration.cmake', | |
28 'Resources/LinuxStandardBaseToolchain.cmake', | |
29 'Resources/MinGW-W64-Toolchain32.cmake', | |
30 'Resources/MinGW-W64-Toolchain64.cmake', | |
31 'Resources/MinGWToolchain.cmake', | |
32 'Resources/Patches/boost-1.69.0-linux-standard-base.patch', | |
22
04b8a44b2717
adding patch.exe command-line tool for MSVC
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
33 'Resources/ThirdParty/patch/NOTES.txt', |
04b8a44b2717
adding patch.exe command-line tool for MSVC
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
34 'Resources/ThirdParty/patch/msys-1.0.dll', |
04b8a44b2717
adding patch.exe command-line tool for MSVC
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
35 'Resources/ThirdParty/patch/patch.exe', |
04b8a44b2717
adding patch.exe command-line tool for MSVC
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
36 'Resources/ThirdParty/patch/patch.exe.manifest', |
16
777b677cc9fc
generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
37 'Resources/WindowsResources.py', |
777b677cc9fc
generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
38 'Resources/WindowsResources.rc', |
0 | 39 ] |
40 | |
41 SDK = [ | |
42 'orthanc/OrthancCPlugin.h', | |
43 ] | |
44 | |
45 | |
46 def Download(x): | |
47 branch = x[0] | |
48 source = x[1] | |
49 target = os.path.join(TARGET, x[2]) | |
50 print target | |
51 | |
52 try: | |
53 os.makedirs(os.path.dirname(target)) | |
54 except: | |
55 pass | |
56 | |
57 url = '%s/%s/%s' % (REPOSITORY, branch, source) | |
58 print('Downloading %s' % url) | |
59 | |
60 with open(target, 'w') as f: | |
61 f.write(urllib2.urlopen(url).read()) | |
62 | |
63 print('Done %s' % url) | |
64 | |
65 | |
66 | |
67 commands = [] | |
68 | |
69 for f in FILES: | |
70 commands.append([ 'default', f, f ]) | |
71 | |
72 for f in SDK: | |
73 commands.append([ | |
74 'Orthanc-%s' % PLUGIN_SDK_VERSION, | |
75 'Plugins/Include/%s' % f, | |
76 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f) | |
77 ]) | |
78 | |
79 | |
80 pool = multiprocessing.Pool(10) # simultaneous downloads | |
81 pool.map(Download, commands) | |
82 | |
83 | |
84 # Patch the SDK | |
85 subprocess.check_call([ 'patch', '-p0', '-i', os.path.join | |
86 (os.path.abspath(os.path.dirname(__file__)), | |
87 'OrthancCPlugin-%s.patch' % PLUGIN_SDK_VERSION) ], | |
88 cwd = os.path.join(os.path.dirname(__file__), | |
89 'Orthanc', | |
90 'Sdk-%s' % PLUGIN_SDK_VERSION, 'orthanc')) |