Skip to content

Commit 581dae4

Browse files
authored
Merge pull request #113 from paxo-phone/package-with-dll
Merge "package-with-dll"
2 parents ebb13e9 + 274c856 commit 581dae4

File tree

2 files changed

+84
-8
lines changed

2 files changed

+84
-8
lines changed

.github/workflows/platformio-ci.yml

+15-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
steps:
1616
- name: Checkout repository
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818

1919
- name: Cache dependencies
2020
uses: actions/cache@v3
@@ -54,15 +54,16 @@ jobs:
5454
uses: actions/upload-artifact@v4
5555
with:
5656
name: paxo-v5-build
57+
include-hidden-files: true
5758
path: |
58-
build
59+
build/
5960
6061
linux_build_test_upload:
6162
runs-on: ubuntu-latest
6263

6364
steps:
6465
- name: Checkout repository
65-
uses: actions/checkout@v3
66+
uses: actions/checkout@v4
6667

6768
- name: Cache dependencies
6869
uses: actions/cache@v3
@@ -111,15 +112,16 @@ jobs:
111112
uses: actions/upload-artifact@v4
112113
with:
113114
name: linux-build
115+
include-hidden-files: true
114116
path: |
115-
build
117+
build/
116118
117119
macos_build_test_upload:
118120
runs-on: macos-latest
119121

120122
steps:
121123
- name: Checkout repository
122-
uses: actions/checkout@v3
124+
uses: actions/checkout@v4
123125

124126
- name: Cache dependencies
125127
uses: actions/cache@v3
@@ -169,15 +171,16 @@ jobs:
169171
uses: actions/upload-artifact@v4
170172
with:
171173
name: macos-build
174+
include-hidden-files: true
172175
path: |
173-
build
176+
build/
174177
175178
windows_build_test_upload:
176179
runs-on: windows-latest
177180

178181
steps:
179182
- name: Checkout repository
180-
uses: actions/checkout@v3
183+
uses: actions/checkout@v4
181184

182185
- name: Cache dependencies
183186
uses: actions/cache@v3
@@ -220,9 +223,13 @@ jobs:
220223
cp -r .pio/build/windows/*.dll build
221224
cp -r storage build
222225
226+
- name: Copy required DLLs into artifact directory
227+
run: python scripts/github_actions/windows/get_dll.py build
228+
223229
- name: Upload artifact
224230
uses: actions/upload-artifact@v4
225231
with:
226232
name: windows-build
233+
include-hidden-files: true
227234
path: |
228-
build
235+
build/
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Created by Charles Mahoudeau on 19/09/2024.
2+
3+
4+
# We could also link statically
5+
# https://stackoverflow.com/questions/18138635/mingw-exe-requires-a-few-gcc-dlls-regardless-of-the-code
6+
7+
import sys
8+
import os
9+
import shutil
10+
11+
12+
REQUIRED_DLL_LIST = [
13+
"libgcc_s_seh-1.dll",
14+
"libstdc++-6.dll",
15+
"libwinpthread-1.dll"
16+
]
17+
18+
19+
def get_compiler_bin_path():
20+
for path_value in os.environ["PATH"].split(os.pathsep):
21+
if os.path.exists(path_value + os.sep + "gcc.exe") and os.path.exists(path_value + os.sep + "g++.exe"):
22+
return path_value
23+
24+
return None
25+
26+
27+
def get_dll_paths(compiler_bin_path):
28+
paths = []
29+
30+
for dll_filename in REQUIRED_DLL_LIST:
31+
path = compiler_bin_path + os.sep + dll_filename
32+
if os.path.exists(path):
33+
paths.append(path)
34+
print("Found DLL:", dll_filename)
35+
else:
36+
print("Missing DLL:", dll_filename)
37+
38+
return paths
39+
40+
def copy_files(file_paths, destination_directory):
41+
for file_path in file_paths:
42+
shutil.copy2(file_path, destination_directory)
43+
print("Copied", file_path, "to", destination_directory)
44+
45+
46+
if __name__ == "__main__":
47+
if len(sys.argv) < 2:
48+
print("Missing target directory in arguments.")
49+
sys.exit(1)
50+
51+
target_dir = sys.argv[1]
52+
53+
if not os.path.isdir(target_dir):
54+
print("Target directory is not a directory.")
55+
sys.exit(1)
56+
57+
compiler_path = get_compiler_bin_path()
58+
59+
if compiler_path is None:
60+
print("Unable to find a compiler.")
61+
sys.exit(1)
62+
63+
print("Using compiler:", compiler_path)
64+
65+
dll_paths = get_dll_paths(compiler_path)
66+
67+
copy_files(dll_paths, target_dir)
68+
69+
print("Done.")

0 commit comments

Comments
 (0)