Skip to content

Commit 315238d

Browse files
committed
Add python script to copy mingw dll dependencies
1 parent 1e5943d commit 315238d

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

.github/workflows/msys2.yml

+9-11
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,18 @@ jobs:
4949
run: |
5050
mkdir ccccc
5151
cp bin/gmake2/Release/ccccc.exe ccccc/
52-
cp /D/a/_temp/msys64/mingw64/bin/libffi-*.dll ccccc/
53-
cp /D/a/_temp/msys64/mingw64/bin/libgcc_s_seh-*.dll ccccc/
54-
cp /D/a/_temp/msys64/mingw64/bin/libiconv-*.dll ccccc/
55-
cp /D/a/_temp/msys64/mingw64/bin/libLLVM-*.dll ccccc/
56-
cp /D/a/_temp/msys64/mingw64/bin/liblzma-*.dll ccccc/
57-
cp /D/a/_temp/msys64/mingw64/bin/libstdc++-*.dll ccccc/
58-
cp /D/a/_temp/msys64/mingw64/bin/libwin*thread-*.dll ccccc/
59-
cp /D/a/_temp/msys64/mingw64/bin/libxml2-*.dll ccccc/
60-
cp /D/a/_temp/msys64/mingw64/bin/libzstd.dll ccccc/
61-
cp /D/a/_temp/msys64/mingw64/bin/zlib1.dll ccccc/
52+
python mingw_deploy.py ccccc/ccccc.exe
6253
6354
- name: Upload ccccc
6455
uses: actions/upload-artifact@v4
6556
with:
6657
name: ccccc
6758
path: |
68-
ccccc/*.*
59+
ccccc/*.exe
60+
61+
- name: Upload ccccc dependencies
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: ccccc_dll
65+
path: |
66+
ccccc/*.dll

.github/workflows/msys2_release.yml

+1-10
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,7 @@ jobs:
4747
run: |
4848
mkdir ccccc
4949
cp bin/gmake2/Release/ccccc.exe ./
50-
cp /D/a/_temp/msys64/mingw64/bin/libffi-*.dll ./
51-
cp /D/a/_temp/msys64/mingw64/bin/libgcc_s_seh-*.dll ./
52-
cp /D/a/_temp/msys64/mingw64/bin/libiconv-*.dll ./
53-
cp /D/a/_temp/msys64/mingw64/bin/libLLVM-*.dll ./
54-
cp /D/a/_temp/msys64/mingw64/bin/liblzma-*.dll ./
55-
cp /D/a/_temp/msys64/mingw64/bin/libstdc++-*.dll ./
56-
cp /D/a/_temp/msys64/mingw64/bin/libwin*thread-*.dll ./
57-
cp /D/a/_temp/msys64/mingw64/bin/libxml2-*.dll ./
58-
cp /D/a/_temp/msys64/mingw64/bin/libzstd.dll ./
59-
cp /D/a/_temp/msys64/mingw64/bin/zlib1.dll ./
50+
python mingw_deploy.py ccccc.exe
6051
6152
- name: Upload ccccc
6253
uses: actions/upload-artifact@v4

mingw_deploy.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import ntpath
2+
import os
3+
import shutil
4+
import subprocess
5+
import sys
6+
7+
def usage():
8+
print('mingw_deploy application [target-directory]')
9+
print()
10+
print('copy dependent mingw dlls needed by application in target-directory (default to near the application)')
11+
sys.exit(-1)
12+
13+
# main
14+
if __name__ == "__main__":
15+
if len(sys.argv) < 2 or len(sys.argv) > 3:
16+
print('invalid argument')
17+
usage()
18+
application = sys.argv[1]
19+
target_directory = len(sys.argv) > 2 and sys.argv[2] or os.path.dirname(application)
20+
if not os.path.exists(application):
21+
print(application, "not found")
22+
exit(-1)
23+
24+
# Retrieve dependencies from mingw
25+
# so the ones from $(InstallPath)\msys64\mingw32\bin\$(dependencies.dll)
26+
ret = subprocess.run(['cygcheck', application], capture_output=True)
27+
dlls = [
28+
line.strip() for line in ret.stdout.decode().split('\n')
29+
if line.find('clang32') != -1
30+
or line.find('clang64') != -1
31+
or line.find('mingw32') != -1
32+
or line.find('mingw64') != -1
33+
or line.find('ucrt64') != -1
34+
]
35+
# copy dlls in target-directory
36+
if len(dlls) > 0:
37+
print("copy in", target_directory)
38+
for file in dlls:
39+
shutil.copyfile(ntpath.abspath(file), target_directory + '/' + ntpath.basename(file))
40+
print(file, "copied")

0 commit comments

Comments
 (0)