Skip to content

Commit 0b71450

Browse files
committed
Also copy MinGW libs on windows
1 parent 73e88ca commit 0b71450

File tree

1 file changed

+47
-12
lines changed

1 file changed

+47
-12
lines changed

test/integration/integration.go

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,8 @@ func (conf *CCppTestConf) Run(t *testing.T, envVars []string) {
247247
var testExecutable = path.Join(conf.Cmake.BuildDir, conf.Cmake.Name)
248248
if runtime.GOOS == "windows" {
249249
testExecutable = testExecutable + ".exe"
250-
// Copy (and log) objectbox.dll and any other DLL files
251-
libDir := filepath.Join(repoRoot(t), build.ObjectBoxCDir, "lib")
252-
dllFiles, err := filepath.Glob(filepath.Join(libDir, "*.dll"))
253-
assert.NoErr(t, err)
254-
for _, dllFile := range dllFiles {
255-
dllName := filepath.Base(dllFile)
256-
t.Logf("Copying DLL: %s", dllName)
257-
assert.NoErr(t, comparison.CopyFile(
258-
dllFile,
259-
filepath.Join(conf.Cmake.BuildDir, dllName),
260-
0))
261-
}
250+
conf.copyObjectBoxDll(t)
251+
conf.copyMinGwDlls(t)
262252
}
263253
var cmd = exec.Command(testExecutable)
264254
cmd.Dir = conf.Cmake.BuildDir
@@ -271,3 +261,48 @@ func (conf *CCppTestConf) Run(t *testing.T, envVars []string) {
271261
assert.NoErr(t, err)
272262
}
273263
}
264+
265+
func (conf *CCppTestConf) copyObjectBoxDll(t *testing.T) {
266+
libDir := filepath.Join(repoRoot(t), build.ObjectBoxCDir, "lib")
267+
dllFiles, err := filepath.Glob(filepath.Join(libDir, "*.dll"))
268+
assert.NoErr(t, err)
269+
for _, dllFile := range dllFiles {
270+
dllName := filepath.Base(dllFile)
271+
t.Logf("Copying DLL from lib: %s", dllName)
272+
assert.NoErr(t, comparison.CopyFile(
273+
dllFile,
274+
filepath.Join(conf.Cmake.BuildDir, dllName),
275+
0))
276+
}
277+
}
278+
279+
// Required on **some** CI runners only: copy MinGW runtime DLLs that objectbox.dll may depend on.
280+
// Finds the C++ compiler path to locate the MinGW bin directory.
281+
func (conf *CCppTestConf) copyMinGwDlls(t *testing.T) {
282+
cppPath, err := exec.LookPath("c++")
283+
if err == nil {
284+
mingwBinDir := filepath.Dir(cppPath)
285+
t.Logf("MinGW bin directory: %s", mingwBinDir)
286+
287+
// Common MinGW runtime DLLs that objectbox.dll likely depends on
288+
runtimeDlls := []string{
289+
"libwinpthread-1.dll",
290+
"libgcc_s_seh-1.dll",
291+
"libgcc_s_dw2-1.dll", // Alternative GCC DLL
292+
"libstdc++-6.dll",
293+
}
294+
295+
for _, dllName := range runtimeDlls {
296+
srcPath := filepath.Join(mingwBinDir, dllName)
297+
if _, err := os.Stat(srcPath); err == nil {
298+
t.Logf("Copying MinGW runtime DLL: %s", dllName)
299+
assert.NoErr(t, comparison.CopyFile(
300+
srcPath,
301+
filepath.Join(conf.Cmake.BuildDir, dllName),
302+
0))
303+
}
304+
}
305+
} else {
306+
t.Logf("Warning: Could not locate c++ compiler to find MinGW runtime DLLs: %v", err)
307+
}
308+
}

0 commit comments

Comments
 (0)